problem_id
stringlengths 6
6
| buggy_code
stringlengths 8
526k
| fixed_code
stringlengths 12
526k
| labels
listlengths 0
15
⌀ | buggy_submission_id
int64 1
1.54M
| fixed_submission_id
int64 2
1.54M
| user_id
stringlengths 10
10
| language
stringclasses 8
values |
|---|---|---|---|---|---|---|---|
p02753
|
p gets.chomp.bytes.inject(:+)%3>0?"Yes":"No"
|
puts gets.chomp.bytes.inject(:+)%3>0?"Yes":"No"
|
[
"call.function.change",
"io.output.change"
] | 530,650
| 530,651
|
u713019978
|
ruby
|
p02753
|
a = gets.chars
puts a.uniq.size != 1 ? "Yes" : "No"
|
a = gets.chomp.chars
puts a.uniq.size != 1 ? "Yes" : "No"
|
[
"call.add"
] | 530,771
| 530,772
|
u868276730
|
ruby
|
p02753
|
L = gets
if L=="AAA" || L=="BBB"
print "No"
else
print "Yes"
end
|
L = gets.chomp
if L == "AAA" || L == "BBB"
print "No"
else
print "Yes"
end
|
[
"call.add"
] | 530,789
| 530,790
|
u262765247
|
ruby
|
p02753
|
L = gets
if L=="AAA" || L=="BBB"
puts "No"
else
puts "Yes"
end
|
L = gets.chomp
if L == "AAA" || L == "BBB"
print "No"
else
print "Yes"
end
|
[
"call.add",
"identifier.change"
] | 530,791
| 530,790
|
u262765247
|
ruby
|
p02753
|
L = gets
if L=="AAA" || L=="BBB"
puts "NO"
else
puts "Yes"
end
|
L = gets.chomp
if L == "AAA" || L == "BBB"
print "No"
else
print "Yes"
end
|
[
"call.add",
"identifier.change",
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 530,793
| 530,790
|
u262765247
|
ruby
|
p02753
|
print gets.chars.uniq.size > 1 ? "Yes" : "No"
|
print gets.chomp.chars.uniq.size > 1 ? "Yes" : "No"
|
[
"control_flow.branch.if.condition.change",
"call.add"
] | 531,223
| 531,224
|
u771131483
|
ruby
|
p02753
|
puts gets.chomp.squeeze.size == 1 ? "No" : "YES"
|
puts gets.chomp.squeeze.size == 1 ? "No" : "Yes"
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 531,358
| 531,359
|
u716826907
|
ruby
|
p02753
|
s = gets.split("")
if s.uniq.size!=1
puts "Yes"
else
puts "No"
end
|
s = gets.chomp.split("")
if s.uniq.size!=1
puts "Yes"
else
puts "No"
end
|
[
"call.add"
] | 531,376
| 531,377
|
u397763977
|
ruby
|
p02753
|
puts gets.split('').uniq.size == 1 ? 'No' : 'Yes'
|
puts gets.chomp.split('').uniq.size == 1 ? 'No' : 'Yes'
|
[
"control_flow.branch.if.condition.change",
"call.add"
] | 531,392
| 531,393
|
u104886851
|
ruby
|
p02753
|
str = gets.chomp
puts str
if str == "AAA" or str == "BBB"
puts "No"
else
puts "Yes"
end
|
str = gets.chomp
if str == "AAA" or str == "BBB"
puts "No"
else
puts "Yes"
end
|
[
"call.remove"
] | 531,444
| 531,445
|
u033272694
|
ruby
|
p02753
|
str = gets.chomp
if str == "AAA" or "BBB"
puts "No"
else
puts "Yes"
end
|
str = gets.chomp
if str == "AAA" or str == "BBB"
puts "No"
else
puts "Yes"
end
|
[
"control_flow.branch.if.condition.change"
] | 531,446
| 531,445
|
u033272694
|
ruby
|
p02753
|
str = gets.chomp
if str = "AAA" or "BBB"
puts "No"
else
puts "Yes"
end
|
str = gets.chomp
if str == "AAA" or str == "BBB"
puts "No"
else
puts "Yes"
end
|
[
"expression.operation.compare.replace.add",
"assignment.replace.remove",
"misc.typo",
"control_flow.branch.if.condition.change"
] | 531,447
| 531,445
|
u033272694
|
ruby
|
p02754
|
n,a,b = gets.chomp.split(' ').map(&:to_i)
sum = a + b
remai = n % sum
set = (n - remai) / sum
blue = [a,remai].min
puts = a * remai + blue
|
n,a,b = gets.chomp.split(" ").map(&:to_i)
sum = a + b
remai = n % sum
set = (n - remai) / sum
blue = [a,remai].min
puts a * set + blue
|
[
"literal.string.change",
"assignment.value.change",
"call.arguments.change",
"identifier.change",
"expression.operation.binary.change"
] | 531,937
| 531,938
|
u844000954
|
ruby
|
p02754
|
require 'set'
class Hash
def push(key, value)
self[key] = [] if self[key] == nil
self[key].push(value)
end
end
class Array
def lower_bound(value)
left = -1;
right = self.length;
while left + 1 < right
mid = left + (right - left) / 2;
if self[mid] >= value
right = mid
else
left = mid
end
end
right
end
def unique
res = [self.first]
each_cons(2) do |a, b|
if a != b
res.push(b)
end
end
res
end
end
def get_ints
gets.split.map(&:to_i)
end
def get_ints_minus_one
get_ints.map { |x| x - 1 }
end
def get_int
gets.chomp.to_i
end
N, A, B = get_ints
X = A + B
a = (N / X) * A
b = (N % X > B) ? B : N % X
puts a + b
|
require 'set'
class Hash
def push(key, value)
self[key] = [] if self[key] == nil
self[key].push(value)
end
end
class Array
def lower_bound(value)
left = -1;
right = self.length;
while left + 1 < right
mid = left + (right - left) / 2;
if self[mid] >= value
right = mid
else
left = mid
end
end
right
end
def unique
res = [self.first]
each_cons(2) do |a, b|
if a != b
res.push(b)
end
end
res
end
end
def get_ints
gets.split.map(&:to_i)
end
def get_ints_minus_one
get_ints.map { |x| x - 1 }
end
def get_int
gets.chomp.to_i
end
N, A, B = get_ints
X = A + B
a = (N / X) * A
b = (N % X > A) ? A : N % X
puts a + b
|
[
"assignment.value.change",
"control_flow.branch.if.condition.change"
] | 532,101
| 532,102
|
u305883349
|
ruby
|
p02754
|
n,a,b = gets.chomp.split.map(&:to_i)
puts (a * n / (a + b)) + [n % (a + b), a].min
|
n,a,b = gets.chomp.split.map(&:to_i)
puts (n / (a + b)) * a + [n % (a + b), a].min
|
[
"expression.operation.binary.remove"
] | 532,396
| 532,397
|
u191196346
|
ruby
|
p02754
|
n,a,b=gets.split.map(&:to_i)
group = n / (a+b)
noMatch = n % (a+b)
puts group * a + (noMatch <= a ? noMatch : 0)
|
n,a,b=gets.split.map(&:to_i)
group = n / (a+b)
noMatch = n % (a+b)
puts group * a + (noMatch < a ? noMatch : a)
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"identifier.replace.add",
"literal.replace.remove",
"call.arguments.change",
"expression.operation.binary.change"
] | 532,517
| 532,518
|
u802371628
|
ruby
|
p02754
|
N, A, B = gets.split.map(&:to_i)
p A+B>N ? [A, N].min : N/(A+B)*A + N%(A+B)
|
N, A, B = gets.split.map(&:to_i)
p A+B>N ? [A, N].min : N/(A+B)*A + [N%(A+B), A].min
|
[
"call.arguments.change",
"call.add"
] | 532,540
| 532,541
|
u091810847
|
ruby
|
p02754
|
n,a,b = gets.split.map &:to_i
if a != 0
split = (n / (a+b))
ret = split*a
modulo = n % (a+b)
if modulo <= a
ret += modulo
else
ret += modulo - a
end
puts ret
else
puts 0
end
|
n,a,b = gets.split.map &:to_i
if a != 0
split = (n / (a+b))
ret = split*a
modulo = n % (a+b)
if modulo <= a
ret += modulo
else
ret += a
end
puts ret
else
puts 0
end
|
[
"expression.operation.binary.remove"
] | 532,648
| 532,649
|
u246139109
|
ruby
|
p02754
|
n,a,b=gets.split.map(&:to_i)
c=a+b
if c<n
set=(n/c)*a
one=[n%c,a].min
puts set+one
else
puts a
end
|
n,a,b=gets.split.map(&:to_i)
c=a+b
if c<n
set=(n/c)*a
one=[n%c,a].min
puts set+one
else
puts [a,n].min
end
|
[
"call.arguments.change",
"call.add"
] | 533,228
| 533,229
|
u602591412
|
ruby
|
p02754
|
n, a, b = gets.split.map(&:to_i)
ans = a * n / (a + b)
frac = n % (a + b) >= a ? a : n % (a + b)
puts ans + frac
|
n, a, b = gets.split.map(&:to_i)
ans = a * (n / (a + b))
frac = n % (a + b) >= a ? a : n % (a + b)
puts ans + frac
|
[] | 533,902
| 533,903
|
u889326464
|
ruby
|
p02754
|
n, a, b = gets.split.map(&:to_i)
ans = a * n / (a + b)
frac = [n % (a + b), a].min
puts ans + frac
|
n, a, b = gets.split.map(&:to_i)
ans = a * (n / (a + b))
frac = [n % (a + b), a].min
puts ans + frac
|
[] | 533,904
| 533,905
|
u889326464
|
ruby
|
p02754
|
n, a, b = gets.split.map(&:to_i)
tries = (n / (a + b))
ans = tries * a
puts ans + n % (a + b)
|
n, a, b = gets.split.map(&:to_i)
tries = (n / (a + b))
ans = tries * a
puts ans + [n % (a + b), a].min
|
[
"call.arguments.change",
"call.add"
] | 533,906
| 533,907
|
u889326464
|
ruby
|
p02754
|
n, a, b = gets.rstrip.split(" ").map { |str| str.to_i }
puts (n.div(a+b)*a) + (n%(a+b)*a)
|
n, a, b = gets.rstrip.split(" ").map { |str| str.to_i }
puts (n.div(a+b)*a) + [n%(a+b), a].min
|
[
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change",
"call.add"
] | 534,033
| 534,034
|
u644533034
|
ruby
|
p02754
|
n, b, r = gets.chomp.split(' ').map(&:to_i)
ans = n / (b + r) * b
rem = n / (b + r)
ans += [rem, b].min
puts ans
|
n, b, r = gets.chomp.split(' ').map(&:to_i)
ans = n / (b + r) * b
rem = n % (b + r)
ans += [rem, b].min
puts ans
|
[
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 534,091
| 534,092
|
u808711621
|
ruby
|
p02754
|
n,a,b = gets.split("\s").map(&:to_i)
ret = (n/a+b) * a
if n%(a+b) <= a then
ret += n%(a+b)
else
ret += a
end
puts ret
|
n,a,b = gets.split("\s").map(&:to_i)
ret = (n/(a+b)) * a
if n%(a+b) <= a then
ret += n%(a+b)
else
ret += a
end
puts ret
|
[] | 534,278
| 534,279
|
u500441504
|
ruby
|
p02754
|
n,a,b = gets.split("\s").map(&:to_i)
ret = (n/a+b) * a
if n%(a+b) <= a then
ret += n%(a+b)
else
ret += a
end
|
n,a,b = gets.split("\s").map(&:to_i)
ret = (n/(a+b)) * a
if n%(a+b) <= a then
ret += n%(a+b)
else
ret += a
end
puts ret
|
[
"call.add"
] | 534,280
| 534,279
|
u500441504
|
ruby
|
p02754
|
a=gets.chomp.split.map(&:to_i)
b=a[1]+a[2]
c=a[0]/b
d=a[0]%b
cons=c*a[1]
if d<=a[1]
cons+=d
else cons+=a[1]
end
|
a=gets.chomp.split.map(&:to_i)
b=a[1]+a[2]
c=a[0]/b
d=a[0]%b
cons=0
cons+=c*a[1]
if d<=a[1]
cons+=d
else cons+=a[1]
end
puts cons
|
[
"call.add"
] | 534,709
| 534,710
|
u175113369
|
ruby
|
p02754
|
n,a,b=gets.split.map(&:to_i)
c=a+b
if c==0
p 0
exit
end
ans=n/c*a+n%c
p ans
|
n,a,b=gets.split.map(&:to_i)
c=a+b
if c==0
p 0
exit
end
ans=n/c*a+[n%c,a].min
p ans
|
[
"call.add"
] | 534,711
| 534,712
|
u693378622
|
ruby
|
p02754
|
n, a, b = gets.split.map{|e| e.to_i}
c = a + b
puts a * (n/c) + n%c
|
n, a, b = gets.split.map{|e| e.to_i}
c = a + b
puts a * (n/c) + [n%c, a].min
|
[
"call.arguments.change",
"call.add"
] | 535,330
| 535,331
|
u547363461
|
ruby
|
p02754
|
N, A, B = gets.chomp.split.map(&:to_i)
# if A == 0 then
# puts 0.to_s
# else
c = N / (A+B)
rem = N % (A+B)
if rem > A then
puts (A * c + A).to_s
else
puts (A * C + rem).to_s
end
# end
|
N, A, B = gets.chomp.split.map(&:to_i)
c = N / (A+B)
rem = N % (A+B)
if rem > A then
puts (A * c + A).to_s
else
puts (A * c + rem).to_s
end
|
[
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 535,727
| 535,728
|
u394640249
|
ruby
|
p02754
|
n, a, b = gets.split(' ').map(&:to_i)
count = 0
x = n / (a + b)
count += a * x
y = n % (a + b)
if (y - a) < a
count += y
else
count += a
end
puts count
|
n, a, b = gets.split(' ').map(&:to_i)
count = 0
x = n / (a + b)
count += a * x
y = n % (a + b)
if (y - a) < 0
count += y
else
count += a
end
puts count
|
[
"identifier.replace.remove",
"literal.replace.add",
"control_flow.branch.if.condition.change"
] | 536,397
| 536,398
|
u598150937
|
ruby
|
p02755
|
eval"p (1..1e5).find{_1*2/25==%d&&_2/10==%d}||-1"%gets.split
|
eval"p (1..1e5).find{_1*2/25==%d&&_1/10==%d}||-1"%gets.split
|
[
"literal.string.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 536,824
| 536,825
|
u657913472
|
ruby
|
p02755
|
require 'set'
class Hash
def push(key, value)
self[key] = [] if self[key] == nil
self[key].push(value)
end
end
class Array
def lower_bound(value)
left = -1;
right = self.length;
while left + 1 < right
mid = left + (right - left) / 2;
if self[mid] >= value
right = mid
else
left = mid
end
end
right
end
def unique
res = [self.first]
each_cons(2) do |a, b|
if a != b
res.push(b)
end
end
res
end
end
def get_ints
gets.split.map(&:to_i)
end
def get_ints_minus_one
get_ints.map { |x| x - 1 }
end
def get_int
gets.chomp.to_i
end
A, B = get_ints
a = (A / 0.08).to_i
a_min = a
loop do
break if ((a_min - 1) * 0.08).to_i != A
a_min -= 1
end
a_max = a
loop do
break if ((a_max + 1) * 0.08).to_i != A
a_max += 1
end
b_min = 10 * B
b_max = 10 * B + 9
ans = ([*a_min..a_max] & [*b_min..b_max]).first
if ans.nil?
puts '-1'
else
puts ans
end
|
require 'set'
class Hash
def push(key, value)
self[key] = [] if self[key] == nil
self[key].push(value)
end
end
class Array
def lower_bound(value)
left = -1;
right = self.length;
while left + 1 < right
mid = left + (right - left) / 2;
if self[mid] >= value
right = mid
else
left = mid
end
end
right
end
def unique
res = [self.first]
each_cons(2) do |a, b|
if a != b
res.push(b)
end
end
res
end
end
def get_ints
gets.split.map(&:to_i)
end
def get_ints_minus_one
get_ints.map { |x| x - 1 }
end
def get_int
gets.chomp.to_i
end
A, B = get_ints
a = (A * 12.5).ceil
a_min = a
loop do
break if ((a_min - 1) * 0.08).to_i != A
a_min -= 1
end
a_max = a
loop do
break if ((a_max + 1) * 0.08).to_i != A
a_max += 1
end
b_min = 10 * B
b_max = 10 * B + 9
ans = ([*a_min..a_max] & [*b_min..b_max]).first
if ans.nil?
puts '-1'
else
puts ans
end
|
[
"assignment.value.change",
"identifier.change"
] | 536,974
| 536,975
|
u305883349
|
ruby
|
p02755
|
a, b = gets.split.map(&:to_i)
"想定解"
# MAX = 1300
# 0.upto MAX do |i|
# pa = (i*0.08).floor
# pb = (i*0.1).floor
# if pa==a and pb==b
# puts i
# exit
# end
# end
# puts -1
"O(1)解法"
sa, ta = 0
sb, tb = 0
sa = (a/0.08).ceil
ta = ((a+1)/0.08).floor
sb = (b/0.1).ceil
tb = ((b+1)/0.1).floor
if sa <= sb
if sb <= ta
puts sb
else
puts -1
end
else
if sa <= tb
puts sa
else
puts -1
end
end
|
a, b = gets.split.map(&:to_i)
"想定解"
# MAX = 1300
# 0.upto MAX do |i|
# pa = (i*0.08).floor
# pb = (i*0.1).floor
# if pa==a and pb==b
# puts i
# exit
# end
# end
# puts -1
"O(1)解法"
sa, ta = 0
sb, tb = 0
sa = (a/0.08).ceil
ta = ((a+1)/0.08).floor - 1
sb = (b/0.1).ceil
tb = ((b+1)/0.1).floor - 1
# puts "#{sa} #{ta} #{sb} #{tb}"
if sa <= sb
if sb <= ta
puts sb
else
puts -1
end
else
if sa <= tb
puts sa
else
puts -1
end
end
|
[
"assignment.change"
] | 537,021
| 537,022
|
u326288614
|
ruby
|
p02755
|
# https://atcoder.jp/contests/abc158/tasks/abc158_c
A, B = gets.split.map(&:to_i)
ai = (A / 0.08).ceil
ax = ((A + 1) / 0.08).floor
bi = (B / 0.1).ceil
bx = ((B + 1) / 0.1).floor
ans = ([*ai..ax] & [*bi..bx]).sort.first || -1
puts ans
|
# https://atcoder.jp/contests/abc158/tasks/abc158_c
A, B = gets.split.map(&:to_i)
ai = (A / 0.08).ceil
ax = ((A + 1) / 0.08 - 1).ceil
bi = (B / 0.1).ceil
bx = ((B + 1) / 0.1 - 1).ceil
ans = ([*ai..ax] & [*bi..bx]).sort.first || -1
puts ans
|
[
"misc.opposites",
"assignment.value.change",
"identifier.change"
] | 537,060
| 537,061
|
u091367113
|
ruby
|
p02755
|
x,y=gets.split.map!(&:to_i)
max=1000
for i in 1..1000
if (i*0.08).to_i==x && (i*0.1).to_i==y
if max>i
max=i
end
end
end
if max==1000
puts -1
else
puts max
end
|
x,y=gets.split.map!(&:to_i)
max=1009
for i in 1..1009
if (i*0.08).to_i==x && (i*0.1).to_i==y
if max>i
max=i
end
end
end
if max==1009
puts -1
else
puts max
end
|
[
"literal.number.integer.change",
"assignment.value.change",
"control_flow.branch.if.condition.change"
] | 537,214
| 537,215
|
u977506075
|
ruby
|
p02755
|
a, b = gets.split.map(&:to_i)
a1 = (a * 12.5).to_i
a2 = ((a + 1) * 12.5).to_i
b1 = b * 10
b2 = (b + 1) * 10
r = -1
(a1...a2).each do |i|
if (b1...b2).include?(i)
r = i
break
end
end
puts r
|
a, b = gets.split.map(&:to_i)
a1 = (a * 12.5).ceil.to_i
a2 = ((a + 1) * 12.5).to_i
b1 = b * 10
b2 = (b + 1) * 10
r = -1
(a1...a2).each do |i|
if (b1...b2).include?(i)
r = i
break
end
end
puts r
|
[
"call.add"
] | 537,550
| 537,551
|
u489339677
|
ruby
|
p02755
|
a, b = gets.split.map(&:to_i)
a1 = (a * 12.5).to_i
a2 = ((a + 1) * 12.5).to_i
b1 = b * 10
b2 = (b + 1) * 10
r = -1
(a1..a2).each do |i|
if (b1..b2).include?(i)
r = i
break
end
end
puts r
|
a, b = gets.split.map(&:to_i)
a1 = (a * 12.5).ceil.to_i
a2 = ((a + 1) * 12.5).to_i
b1 = b * 10
b2 = (b + 1) * 10
r = -1
(a1...a2).each do |i|
if (b1...b2).include?(i)
r = i
break
end
end
puts r
|
[
"call.add",
"control_flow.branch.if.condition.change"
] | 537,552
| 537,551
|
u489339677
|
ruby
|
p02755
|
a,b = gets.chomp.split.map(&:to_i)
left = [(12.5 * a),10 * b].max.ceil
right = [10 * (b+1),12.5 * (a+1)].min.floor
if left > right
puts -1
else
puts left
end
|
a,b = gets.chomp.split.map(&:to_i)
left = [(12.5 * a),10 * b].max.ceil
right = [10 * (b+1),12.5 * (a+1)].min
if left >= right
puts -1
else
puts left
end
|
[
"call.remove",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 537,610
| 537,611
|
u191196346
|
ruby
|
p02755
|
a,b = gets.chomp.split.map(&:to_i)
left = [(12.5 * a),10 * b].max
right = [10 * (b+1),12.5 * (a+1)].min
if left > right
puts -1
else
puts left.ceil
end
|
a,b = gets.chomp.split.map(&:to_i)
left = [(12.5 * a),10 * b].max.ceil
right = [10 * (b+1),12.5 * (a+1)].min
if left >= right
puts -1
else
puts left
end
|
[
"call.add",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"call.remove"
] | 537,612
| 537,611
|
u191196346
|
ruby
|
p02755
|
a,b = gets.chomp.split.map(&:to_i)
left = [(12.5 * a).ceil,10 * b].max
right = [10 * (b+1),12.5 * (a+1)].min
if left > right
puts -1
else
puts left
end
|
a,b = gets.chomp.split.map(&:to_i)
left = [(12.5 * a),10 * b].max.ceil
right = [10 * (b+1),12.5 * (a+1)].min
if left >= right
puts -1
else
puts left
end
|
[
"call.remove",
"call.add",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 537,613
| 537,611
|
u191196346
|
ruby
|
p02755
|
a, b = gets.chomp.split(" ").map(&:to_f)
ans = -1
(1..100).each do |i|
if (i * 0.08).floor == a && (i * 0.1).floor == b then
ans = i
break
end
end
puts ans
|
a, b = gets.chomp.split(" ").map(&:to_i)
ans = -1
(1..1010).each do |i|
if (i * 0.08).floor == a && (i * 0.1).floor == b then
ans = i
break
end
end
puts ans
|
[
"assignment.value.change",
"call.arguments.change",
"literal.number.integer.change"
] | 537,629
| 537,630
|
u466332671
|
ruby
|
p02755
|
a, b = gets.chomp.split(" ").map(&:to_f)
ans = -1
(1..100).each do |i|
if (i * 0.08).floor == a && (i * 0.1).floor == b then
ans = i
break
end
end
puts ans
|
a, b = gets.chomp.split(" ").map(&:to_f)
ans = -1
2000.times do |i|
if (i * 0.08).floor == a && (i * 0.1).floor == b then
ans = i
break
end
end
puts ans
|
[
"identifier.change"
] | 537,629
| 537,631
|
u466332671
|
ruby
|
p02754
|
N, A, B = STDIN.gets.split(' ').map{|s| s.to_i}
if A == 0
puts 0
else
ab = A + B
n = N / ab
m = N % ab
mb = (m < B) ? m : B
# puts "ab:#{ab} n:#{n} m:#{m} mb:#{mb}"
puts n * A + mb
end
|
N, A, B = STDIN.gets.split(' ').map{|s| s.to_i}
if A == 0
puts 0
else
ab = A + B
n = N / ab
m = N % ab
mb = (m <= A) ? m : A
# puts "ab:#{ab} n:#{n} m:#{m} mb:#{mb}"
puts n * A + mb
end
|
[
"assignment.value.change"
] | 537,764
| 537,765
|
u902774407
|
ruby
|
p02755
|
a, b = gets.chomp.split.map(&:to_i)
n = (1..100).bsearch {|x| (x * 0.08).to_i >= a && (x * 0.10).to_i >= b }
puts (n.nil? || (0.08 * n).to_i != a || (0.10 * n).to_i != b)? "-1" : n
|
a, b = gets.chomp.split.map(&:to_i)
n = (1..1000).bsearch {|x| (x * 0.08).to_i >= a && (x * 0.10).to_i >= b }
puts (n.nil? || (0.08 * n).to_i != a || (0.10 * n).to_i != b)? "-1" : n
|
[
"literal.number.integer.change",
"assignment.value.change"
] | 538,075
| 538,076
|
u482840940
|
ruby
|
p02755
|
a, b = gets.chomp.split.map(&:to_i)
res = -1
(1..100).each do |i|
a_lb = (0.08 * i).to_i
b_lb = (0.10 * i).to_i
break if a_lb > a || b_lb > b
if a_lb == a && b_lb == b
res = i
break
end
end
puts res
|
a, b = gets.chomp.split.map(&:to_i)
res = -1
(1..1000).each do |i|
a_lb = (0.08 * i).to_i
b_lb = (0.10 * i).to_i
break if a_lb > a || b_lb > b
if a_lb == a && b_lb == b
res = i
break
end
end
puts res
|
[
"literal.number.integer.change"
] | 538,077
| 538,078
|
u482840940
|
ruby
|
p02755
|
a, b = gets.split(" ").map(&:to_i)
20000.times do |i|
if (0.08 * i).floor == a && (0.1 * i).floor == b
puts i
break
end
puts -1 if i == 199
end
|
a, b = gets.split(" ").map(&:to_i)
20000.times do |i|
if (0.08 * i).floor == a && (0.1 * i).floor == b
puts i
break
end
puts -1 if i == 19999
end
|
[
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 538,167
| 538,168
|
u016444909
|
ruby
|
p02755
|
def solve
a, b = gets.split.map!(&:to_i)
(1..100).each do |i|
return i if (i * 0.08).to_i == a && (i * 0.1).to_i == b
end
return -1
end
print(solve)
|
def solve
a, b = gets.split.map!(&:to_i)
(1..80000).each do |i|
return i if (i * 0.08).to_i == a && (i * 0.1).to_i == b
end
-1
end
print solve
|
[
"literal.number.integer.change",
"control_flow.return.remove",
"call.arguments.change"
] | 538,386
| 538,387
|
u595657182
|
ruby
|
p02755
|
A,B=$<.read.split.map(&:to_i)
n = B*10
(n..n+9).each do |i|
if (i*0.08) == A
p i
exit 0
end
end
p (-1)
|
A,B=$<.read.split.map(&:to_i)
n = B*10
(n..n+9).each do |i|
if (i*0.08).floor == A
p i
exit 0
end
end
p(-1)
|
[
"control_flow.branch.if.condition.change",
"call.add"
] | 538,494
| 538,495
|
u852974293
|
ruby
|
p02755
|
A,B=$<.read.split.map(&:to_i)
n = B*10
(n..n+9).each do |i|
if (i*0.08) == A
p i
exit 0
end
end
p -1
|
A,B=$<.read.split.map(&:to_i)
n = B*10
(n..n+9).each do |i|
if (i*0.08).floor == A
p i
exit 0
end
end
p(-1)
|
[
"control_flow.branch.if.condition.change",
"call.add",
"call.arguments.change"
] | 538,496
| 538,495
|
u852974293
|
ruby
|
p02755
|
A,B=$<.read.split.map(&:to_i)
n = B*10
(n..n+10).each do |i|
if (i*0.08) == A
p i
exit 0
end
end
p -1
|
A,B=$<.read.split.map(&:to_i)
n = B*10
(n..n+9).each do |i|
if (i*0.08).floor == A
p i
exit 0
end
end
p(-1)
|
[
"literal.number.integer.change",
"expression.operation.binary.change",
"control_flow.branch.if.condition.change",
"call.add",
"call.arguments.change"
] | 538,497
| 538,495
|
u852974293
|
ruby
|
p02755
|
a, b = gets.chop.split.map(&:to_i)
ans = -1
1010.times do |i|
if (i.to_f * 0.08).floor == a && (i.to_f * 0.10).floor == b
ans = i
break
end
end
puts $ans
|
a, b = gets.chop.split.map(&:to_i)
ans = -1
1010.times do |i|
if (i.to_f * 0.08).floor == a && (i.to_f * 0.10).floor == b
ans = i
break
end
end
puts ans
|
[
"call.arguments.change"
] | 538,628
| 538,629
|
u450617345
|
ruby
|
p02755
|
def f1(a)
[a / (8/100r), (a + 1) / (8/100r)]
end
def f2(b)
[b / (10/100r), (b + 1) / (10/100r)]
end
def find(a1, a2)
bgn = [a1[0], a2[0]].max.ceil
ed = [a1[1], a2[1]].min
f = if ed == ed.floor
bgn < ed
else
bgnl <= ed.floor
end
f ? bgn : -1
end
a, b = gets.split.map(&:to_i)
puts find(f1(a), f2(b))
|
def f1(a)
[a / (8/100r), (a + 1) / (8/100r)]
end
def f2(b)
[b / (10/100r), (b + 1) / (10/100r)]
end
def find(a1, a2)
bgn = [a1[0], a2[0]].max.ceil
ed = [a1[1], a2[1]].min
f = if ed == ed.floor
bgn < ed
else
bgn <= ed.floor
end
f ? bgn : -1
end
a, b = gets.split.map(&:to_i)
puts find(f1(a), f2(b))
|
[
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change"
] | 538,814
| 538,815
|
u297507288
|
ruby
|
p02755
|
a,b = gets.split.map(&:to_i)
p1 = 12.5 * a
p2 = 12.5 * (a+1)
q1 = 10.0 * b
q2 = 10.0 * (b+1)
if p1 >= q1
x = p1
else
x = q1
end
if p2 <= q2
y = p2
else
y = q2
end
if x.ceil <= y
puts x.ceil
else
puts -1
end
|
a,b = gets.split.map(&:to_i)
p1 = 12.5 * a
p2 = 12.5 * (a+1)
q1 = 10.0 * b
q2 = 10.0 * (b+1)
if p1 >= q1
x = p1
else
x = q1
end
if p2 <= q2
y = p2
else
y = q2
end
if x.ceil < y
puts x.ceil
else
puts -1
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 538,822
| 538,823
|
u911373146
|
ruby
|
p02755
|
A, B = gets.split(' ').map(&:to_i)
yen = '-1'
(1..100).each do |i|
if (i * 0.08).floor == A && (i * 0.1).floor == B
yen = i
break
end
end
puts yen
|
A, B = gets.split(' ').map(&:to_i)
yen = '-1'
(1..10000).each do |i|
if (i * 0.08).floor == A && (i * 0.1).floor == B
yen = i
break
end
end
puts yen
|
[
"literal.number.integer.change"
] | 538,876
| 538,877
|
u857555436
|
ruby
|
p02755
|
#!/usr/bin/env ruby
A,B=gets.split.map &:to_i
X = [25*A, 20*B].max
p (A != X/25 || B != X/20) ? -1 : X/2
|
#!/usr/bin/env ruby
A,B=gets.split.map &:to_i
X = [25*A, 20*B].max
p (A != X/25 || B != X/20) ? -1 : (X+1)/2
# 提出者の回答参考
|
[
"call.arguments.change"
] | 539,115
| 539,116
|
u958542160
|
ruby
|
p02755
|
A,B=gets.split.map &:to_i
X=[25*A,20*B].max
p A!=X/25||b!=X/20? -1: (X+1)/2
|
A,B=gets.split.map &:to_i
X=[25*A,20*B].max
p A!=X/25||B!=X/20? -1: (X+1)/2
|
[
"assignment.variable.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 539,388
| 539,389
|
u720281401
|
ruby
|
p02755
|
a, b = gets.split.map(&:to_i)
(1..1010).eaach do |i|
if (i * 0.08).floor == a && (i * 0.1).floor == b
puts i
exit
end
end
puts '-1'
|
a, b = gets.split.map(&:to_i)
(1..1100).each do |i|
if (i * 0.08).floor == a && (i * 0.1).floor == b
puts i
exit
end
end
puts '-1'
|
[
"literal.number.integer.change",
"identifier.change"
] | 539,539
| 539,540
|
u866325115
|
ruby
|
p02755
|
a, b = *gets.split.map(&:to_i)
ans = -1
(1..(b * 10)).each do |i|
if (i * 0.08).floor == a && (i * 0.1).floor == b
ans = i
break
end
end
puts ans
|
a, b = *gets.split.map(&:to_i)
ans = -1
(1..(b * 20)).each do |i|
if (i * 0.08).floor == a && (i * 0.1).floor == b
ans = i
break
end
end
puts ans
|
[
"literal.number.integer.change",
"expression.operation.binary.change"
] | 539,771
| 539,772
|
u868276730
|
ruby
|
p02755
|
A, B = gets.chomp.split(" ").map(&:to_i)
x = A / 0.08
y = B / 0.1
i = 1
if x <= y
z = y.floor
if (z * 0.08).floor == A
puts z
elsif
while i < 13 do
if ((z + i)* 0.08).floor == A && ((z + i)* 0.1).floor == B
puts (z + i)
end
i += 1
end
else
puts -1
end
else
z = x.floor
if (z * 0.1).floor == B
puts z
elsif
while i < 10 do
if ((z + i)* 0.1).floor == B && ((z + i)* 0.08).floor == A
puts (z + i)
end
i += 1
end
else
puts -1
end
end
|
A, B = gets.chomp.split(" ").map(&:to_i)
x = A / 0.08
y = B / 0.1
i = 1
if x <= y
z = y.ceil
if (z * 0.08).floor == A
puts z
elsif
while i < 13 do
if ((z + i)* 0.08).floor == A && ((z + i)* 0.1).floor == B
puts (z + i)
end
i += 1
end
else
puts -1
end
else
z = x.ceil
if (z * 0.1).floor == B
puts z
elsif
while i < 10 do
if ((z + i)* 0.1).floor == B && ((z + i)* 0.08).floor == A
puts (z + i)
end
i += 1
end
else
puts -1
end
end
|
[
"misc.opposites",
"assignment.value.change",
"identifier.change"
] | 540,166
| 540,167
|
u729911058
|
ruby
|
p02755
|
A, B = gets.split.map(&:to_i)
1.upto(100) do |i|
if (i * 0.08).floor == A && (i * 0.1).floor == B
puts i
exit
end
end
puts -1
|
A, B = gets.split.map(&:to_i)
1.upto(1250) do |i|
if (i * 0.08).floor == A && (i * 0.1).floor == B
puts i
exit
end
end
puts -1
|
[
"literal.number.integer.change",
"call.arguments.change"
] | 540,354
| 540,355
|
u875730451
|
ruby
|
p02755
|
eval"A,B="+gets.split*?,;p (1..$$).select{|i|i*2/25==A&&i/10==B}[0]||-1
|
eval"A,B="+gets.split*?,;p (1..2e3).select{|i|i*2/25==A&&i/10==B}[0]||-1
|
[
"call.arguments.change",
"expression.operation.binary.change"
] | 540,426
| 540,427
|
u049095189
|
ruby
|
p02755
|
A, B = gets.split.map(&:to_i)
A_lowerBound = (A.to_f/0.08).ceil
A_upperLimit = ((A.to_f + 1.0)/0.08).floor
B_lowerBound = (B.to_f/0.1).ceil
B_upperLimit = ((B.to_f + 1.0)/0.1).floor
if A_lowerBound > B_upperLimit || A_upperLimit < B_lowerBound then
p -1
else
p [A_lowerBound, B_lowerBound].max
end
|
A, B = gets.split.map(&:to_i)
A_lowerBound = (A.to_f/0.08).ceil
A_upperLimit = ((A.to_f + 1.0)/0.08).floor
B_lowerBound = (B.to_f/0.1).ceil
B_upperLimit = ((B.to_f + 1.0)/0.1).floor
if A_lowerBound >= B_upperLimit || A_upperLimit <= B_lowerBound then
p -1
else
p [A_lowerBound, B_lowerBound].max
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 540,528
| 540,529
|
u716826907
|
ruby
|
p02755
|
a, b = gets.split(' ').map!(&:to_i)
ans = -1
1000.times do |i|
if (i * 0.08).floor == a && (i * 0.1).floor == b
ans = i
break
end
end
puts ans
|
a, b = gets.split(' ').map!(&:to_i)
ans = -1
10000.times do |i|
if (i * 0.08).floor == a && (i * 0.1).floor == b
ans = i
break
end
end
puts ans
|
[
"literal.number.integer.change"
] | 540,788
| 540,789
|
u315984289
|
ruby
|
p02755
|
line = gets.split(' ').map(&:to_f)
a=line[0]
b=line[1]
c=0
d=0
while c==0 do
if (d*0.08).floor==a.to_i && (d*0.10).floor==b.to_i then
c=1
puts d
end
d=d+1
if d>1000 then
c=1
puts -1
end
end
|
line = gets.split(' ').map(&:to_f)
a=line[0]
b=line[1]
c=0
d=0
while c==0 do
if (d*0.08).floor==a.to_i && (d*0.10).floor==b.to_i then
c=1
puts d
end
d=d+1
if d>=1010 then
c=1
puts -1
end
end
|
[] | 540,895
| 540,896
|
u413184068
|
ruby
|
p02755
|
A, B = gets.chomp.split(" ").map(&:to_i)
ans = 0
(1..100).each{|i|
(ans = i; break) if (i * 0.08).floor == A && (i * 0.1).floor == B
}
puts ans == 0 ? -1 : ans
|
A, B = gets.chomp.split(" ").map(&:to_i)
ans = 0
(1..1000).each{|i|
(ans = i; break) if (i * 0.08).floor == A && (i * 0.1).floor == B
}
puts ans == 0 ? -1 : ans
|
[
"literal.number.integer.change"
] | 540,933
| 540,934
|
u276517671
|
ruby
|
p02755
|
a, b = gets.split(" ").map(&:to_i)
n = 10**4 + 1
n.times.with_index(1) do |i|
puts i
if (i * 0.08).to_i == a && (i * 0.1).to_i == b
puts i
exit
end
end
puts -1
|
a, b = gets.split(" ").map(&:to_i)
n = 10**4 + 1
n.times.with_index(1) do |i|
if (i * 0.08).to_i == a && (i * 0.1).to_i == b
puts i
exit
end
end
puts -1
|
[
"call.remove"
] | 540,946
| 540,947
|
u928941036
|
ruby
|
p02755
|
a, b = gets.chomp.split(' ').map(&:to_i)
eight_tax_price = (a / 0.08).floor
ten_tax_price = (b / 0.1).floor
eight_is_true = false
ten_is_true = false
eight_is_true = true if (eight_tax_price * 0.1).floor == b
ten_is_true = true if (ten_tax_price * 0.08).floor == a
if eight_tax_price === ten_tax_price
puts eight_tax_price
elsif eight_is_true && ten_is_true
puts eight_is_true <= ten_is_true ? eight_is_true : ten_is_true
elsif eight_is_true
puts eight_tax_price
elsif ten_is_true
puts ten_tax_price
else
puts -1
end
|
a, b = gets.chomp.split(' ').map(&:to_i)
eight_tax_price = (a / 0.08).round
ten_tax_price = (b / 0.1).round
eight_is_true = false
ten_is_true = false
eight_is_true = true if (eight_tax_price * 0.1).floor == b
ten_is_true = true if (ten_tax_price * 0.08).floor == a
if eight_tax_price === ten_tax_price
puts eight_tax_price
elsif eight_is_true && ten_is_true
puts eight_is_true <= ten_is_true ? eight_is_true : ten_is_true
elsif eight_is_true
puts eight_tax_price
elsif ten_is_true
puts ten_tax_price
else
puts -1
end
|
[
"assignment.value.change",
"identifier.change"
] | 541,232
| 541,233
|
u721508245
|
ruby
|
p02755
|
A, B = gets.chomp.split(" ").map(&:to_i)
1.upto(100) do |i|
if (i * 0.08).floor == A && (i * 0.1).floor == B
puts i
exit
end
end
puts -1
|
A, B = gets.chomp.split(" ").map(&:to_i)
1.upto(1250) do |i|
if (i * 0.08).floor == A && (i * 0.1).floor == B
puts i
exit
end
end
puts -1
|
[
"literal.number.integer.change",
"call.arguments.change"
] | 541,538
| 541,539
|
u443924743
|
ruby
|
p02755
|
def doit(a,b)
1.upto(100%0.08) do |n|
n8 = (n*0.08).to_i
n10 = (n*0.1).to_i
if n8==a && n10==b then
return n
end
end
return -1
end
a, b= gets.chomp.split(" ").map{|e|e.to_i}
print(doit(a,b))
|
def doit(a,b)
1.upto(1251) do |n|
n8 = (n*0.08).to_i
n10 = (n*0.1).to_i
if n8==a && n10==b then
return n
end
end
return -1
end
a, b= gets.chomp.split(" ").map{|e|e.to_i}
print(doit(a,b))
|
[
"literal.number.integer.change",
"call.arguments.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 541,591
| 541,592
|
u849186626
|
ruby
|
p02756
|
s = gets.chomp.split.to_a
Q = gets.chomp.to_i
Query = Q.times.map do
gets.chomp.split(" ")
end
flag = true
(0..Q-1).each do |i|
if Query[i][0] == "1"
flag = !flag
else
if flag
if Query[i][1] == "1"
s = s.unshift(Query[i][2])
else
s = s.push(Query[i][2])
end
else
if Query[i][1] == "1"
s = s.push(Query[i][2])
else
s = s.unshift(Query[i][2])
end
end
end
end
if flag
puts s.join.to_s
else
puts s.reverse.join.to_s
end
|
s = gets.chomp.split("").to_a
Q = gets.chomp.to_i
Query = Q.times.map do
gets.chomp.split(" ")
end
flag = true
(0..Q-1).each do |i|
if Query[i][0] == "1"
flag = !flag
else
if flag
if Query[i][1] == "1"
s = s.unshift(Query[i][2])
else
s = s.push(Query[i][2])
end
else
if Query[i][1] == "1"
s = s.push(Query[i][2])
else
s = s.unshift(Query[i][2])
end
end
end
end
if flag
puts s.join.to_s
else
puts s.reverse.join.to_s
end
|
[
"call.arguments.add"
] | 541,950
| 541,951
|
u088211391
|
ruby
|
p02756
|
S = gets.chomp
Q = gets.to_i
s1 = []
s2 = []
flag = 1
Q.times do |i|
Query = gets.split(" ")
if Query[0] == "1"
flag *= -1
elsif Query[0] == "2"
if Query[1] == "1"
if flag == 1
s1 << Query[2]
else
s2 << Query[2]
end
elsif Query[1] == "2"
if flag == 1
s2 << Query[2]
else
s1 << Query[2]
end
end
end
end
if flag == 1
puts s1.reverse.join + S + s2.join
else
puts s2.reverse.join + S + s1.join
end
|
S = gets.chomp
Q = gets.to_i
s1 = []
s2 = []
flag = 1
Q.times do
Query = gets.split(" ")
if Query[0] == "1"
flag *= -1
elsif Query[0] == "2"
if Query[1] == "1"
if flag == 1
s1 << Query[2]
else
s2 << Query[2]
end
elsif Query[1] == "2"
if flag == 1
s2 << Query[2]
else
s1 << Query[2]
end
end
end
end
if flag == 1
puts s1.reverse.join + S + s2.join
else
puts s2.reverse.join + S.reverse + s1.join
end
|
[
"call.add"
] | 542,066
| 542,067
|
u729911058
|
ruby
|
p02756
|
S=gets.chomp
Q=gets.to_i
left = ''
right = ''
rev = false
Q.times do
a,b,c = gets.split
if a == '1'
rev = !rev
elsif (b == '1' && !rev) || (b == '2' && rev)
left << c
else
right << c
end
end
s = left.reverse.join + S + right.join
s = s.reverse if rev
puts s
|
S=gets.chomp
Q=gets.to_i
left = []
right = []
rev = false
Q.times do
a,b,c = gets.split
if a == '1'
rev = !rev
elsif (b == '1' && !rev) || (b == '2' && rev)
left << c
else
right << c
end
end
s = left.reverse.join + S + right.join
s = s.reverse if rev
puts s
|
[] | 542,176
| 542,177
|
u852974293
|
ruby
|
p02756
|
S = gets.chomp.chars
Q = gets.to_i
QList = []
Q.times{ QList << gets.chomp }
reverse = false
QList.each do |query|
ch = query.split
if ch[0].to_i == 1
reverse = !reverse
elsif ch[1].to_i == 1 and reverse or ch[1].to_i == 2 and !reverse
S << ch[2]
else
S.unshift(ch[2])
end
end
if reverse
S.reverse!
end
puts S.join
|
S = gets.chomp.chars
Q = gets.to_i
QList = []
Q.times{ QList << gets.chomp }
reverse = false
QList.each do |query|
ch = query.split
if ch[0].to_i == 1
reverse = !reverse
elsif ch[1].to_i == 1 && reverse || ch[1].to_i == 2 && !reverse
S << ch[2]
else
S.unshift(ch[2])
end
end
if reverse
S.reverse!
end
puts S.join
|
[
"control_flow.branch.if.condition.change"
] | 542,230
| 542,231
|
u487252913
|
ruby
|
p02756
|
s = gets.chomp.split.map(&:to_s)
a = gets.to_i.times.map{gets.split.map(&:to_s)}
reverse = false
a.each do |_a|
if _a[0] == '1'
reverse = !reverse
next
elsif _a[1] == '1'
if reverse
s.push(_a[2])
else
s.unshift(_a[2])
end
next
else _a[1] == '2'
if reverse
s.unshift(_a[2])
else
s.push(_a[2])
end
end
end
puts reverse ? s.reverse.join : s.join
|
s = gets.chomp.split.map(&:to_s)
a = gets.to_i.times.map{gets.split.map(&:to_s)}
reverse = false
a.each do |_a|
if _a[0] == '1'
reverse = !reverse
next
elsif _a[1] == '1'
if reverse
s.push(_a[2])
else
s.unshift(_a[2])
end
next
else _a[1] == '2'
if reverse
s.unshift(_a[2])
else
s.push(_a[2])
end
end
end
puts reverse ? s.join.reverse : s.join
|
[
"call.remove",
"call.add"
] | 542,303
| 542,304
|
u542197477
|
ruby
|
p02756
|
a = gets.chomp.to_s
q = gets.to_i
queries = q.times.map { gets.chomp.split(" ").map(&:to_s) }
ans = [a]
rev = false
queries.each do |query|
if query[0] == "1"
rev = !rev
else
(query[1] == "1") ^ rev ? ans.unshift(query[2]) : ans << query[2]
end
end
puts rev ? ans.reverse.join : ans.join
|
a = gets.chomp.to_s
q = gets.to_i
queries = q.times.map { gets.chomp.split(" ").map(&:to_s) }
ans = [a]
# ans = a
rev = false
queries.each do |query|
if query[0] == "1"
rev = !rev
else
(query[1] == "1") ^ rev ? ans.unshift(query[2]) : ans << query[2]
# (query[1] == "1") ^ rev ? ans = query[2] + ans : ans += query[2]
end
end
puts rev ? ans.join.reverse : ans.join
# puts rev ? ans.reverse : ans
|
[
"call.remove",
"call.add"
] | 542,365
| 542,366
|
u390727364
|
ruby
|
p02756
|
s = gets.chomp
q = gets.chomp.to_i
right = ''
left = ''
is_reverse = false
q.times do |i|
t, f, c = gets.chomp.split(' ')
if t == '1'
is_reverse = !is_reverse
else
if f == '1'
is_reverse ? right << c : left << s
else
is_reverse ? left << s : right << c
end
end
end
ans = left + s + right
ans.reverse! if is_reverse
puts ans
|
s = gets.chomp
q = gets.chomp.to_i
right = ''
left = ''
is_reverse = false
q.times do |i|
t, f, c = gets.chomp.split(' ')
if t == '1'
is_reverse = !is_reverse
else
if f == '1'
is_reverse ? right << c : left << c
else
is_reverse ? left << c : right << c
end
end
end
ans = left.reverse + s + right
# binding.pry
ans.reverse! if is_reverse
puts ans
|
[
"identifier.change",
"expression.operation.binary.change",
"call.add"
] | 542,472
| 542,473
|
u608949838
|
ruby
|
p02756
|
# frozen_string_literal: true
# ENV[Z = 'RUBY_THREAD_VM_STACK_SIZE'] || exec( { Z => '50000000' },'ruby',$0)
s = gets.chomp!
q = gets.to_i
array = readlines.map(&:chomp!).map(&:split)
count = 0
sentou = []
matubi = []
array.each do |command|
case command.first
when '1'
count += 1
when '2'
if count.even?
if command[1] == '1'
sentou.push command[2]
else
matubi.push command[2]
end
else
if command[1] == '1'
matubi.push command[2]
else
sentou.push command[2]
end
end
end
end
if count.odd?
s.reverse!
puts matubi.join + s + sentou.join
else
puts sentou.join.reverse! + s + matubi.join.reverse!
end
|
# frozen_string_literal: true
# ENV[Z = 'RUBY_THREAD_VM_STACK_SIZE'] || exec( { Z => '50000000' },'ruby',$0)
s = gets.chomp!
q = gets.to_i
array = readlines.map(&:chomp!).map(&:split)
count = 0
sentou = []
matubi = []
array.each do |command|
case command.first
when '1'
count += 1
when '2'
if count.even?
if command[1] == '1'
sentou.push command[2]
else
matubi.push command[2]
end
else
if command[1] == '1'
matubi.push command[2]
else
sentou.push command[2]
end
end
end
end
if count.odd?
s.reverse!
puts matubi.join.reverse! + s + sentou.join
else
puts sentou.join.reverse! + s + matubi.join
end
|
[
"call.add",
"call.remove"
] | 542,752
| 542,753
|
u393913844
|
ruby
|
p02756
|
# frozen_string_literal: true
# ENV[Z = 'RUBY_THREAD_VM_STACK_SIZE'] || exec( { Z => '50000000' },'ruby',$0)
s = gets.chomp!
q = gets.to_i
array = readlines.map(&:chomp!).map(&:split)
count = 0
sentou = []
matubi = []
array.each do |command|
case command.first
when '1'
count += 1
when '2'
if count.even?
if command[1] == '1'
sentou.push command[2]
else
matubi.push command[2]
end
else
if command[1] == '1'
matubi.push command[2]
else
sentou.push command[2]
end
end
end
end
if count.odd?
s.reverse!
puts matubi.join + s + sentou.join
else
puts sentou.join.reverse! + s + matubi.join.reverse!
end
|
# frozen_string_literal: true
# ENV[Z = 'RUBY_THREAD_VM_STACK_SIZE'] || exec( { Z => '50000000' },'ruby',$0)
s = gets.chomp!
q = gets.to_i
array = readlines.map(&:chomp!).map(&:split)
count = 0
sentou = []
matubi = []
array.each do |command|
case command.first
when '1'
count += 1
when '2'
if count.even?
if command[1] == '1'
sentou.push command[2]
else
matubi.push command[2]
end
else
if command[1] == '1'
matubi.push command[2]
else
sentou.push command[2]
end
end
end
end
if count.odd?
s.reverse!
puts matubi.join.reverse! + s + sentou.join
else
puts sentou.join.reverse! + s + matubi.join
end
|
[
"call.add",
"call.remove"
] | 542,754
| 542,753
|
u393913844
|
ruby
|
p02756
|
s=gets.chomp
s0=""
s1=""
fl=false
q=gets.to_i
q.times do
qu=gets.chomp
if qu=="1"
fl=!fl
else
if fl&&qu[2]=="1"||!fl&&qu[2]=="0"
s1+=qu[4]
else
s0+=qu[4]
end
end
end
if !fl
puts s0.reverse+s+s1
else
puts s1.reverse+s.reverse+s0
end
|
s=gets.chomp
s0=""
s1=""
fl=false
q=gets.to_i
q.times do
qu=gets.chomp
if qu=="1"
fl=!fl
else
if fl&&qu[2]=="1"||!fl&&qu[2]=="2"
s1 << qu[4]
else
s0 << qu[4]
end
end
end
if !fl
puts s0.reverse+s+s1
else
puts s1.reverse+s.reverse+s0
end
|
[
"literal.string.change",
"control_flow.branch.if.condition.change"
] | 542,773
| 542,772
|
u744908753
|
ruby
|
p02756
|
s = gets.chomp
q=gets.to_i
front=Array.new()
behind=Array.new()
front2=Array.new(10)
front2[0]="a"
count=0
for i in 1..q
query2=gets.to_s
query=query2.split(' ').map(&:to_s)
#query2=gets.delete(' ')
#query=query2.split('')
#puts query[0]
#puts query[1]
#puts "改行"
if query[0].to_i==1
count+=1
#puts "通過"
else
if (count+query[1].to_i-1)%2==0
front.push(query[2])
else
behind.push(query[2])
end
end
end
s=front.reverse!.join+s+behind.reverse!.join
#puts s
if count%2==1
s.reverse!
end
#p front
#p behind
puts s
|
s = gets.chomp
q=gets.to_i
front=Array.new()
behind=Array.new()
front2=Array.new(10)
front2[0]="a"
count=0
for i in 1..q
query2=gets.to_s
query=query2.split(' ').map(&:to_s)
#query2=gets.delete(' ')
#query=query2.split('')
#puts query[0]
#puts query[1]
#puts "改行"
if query[0].to_i==1
count+=1
#puts "通過"
else
if (count+query[1].to_i-1)%2==0
front.push(query[2])
else
behind.push(query[2])
end
end
end
s=front.reverse!.join+s+behind.join
#puts s
if count%2==1
s.reverse!
end
#p front
#p behind
puts s
|
[
"call.remove"
] | 542,880
| 542,881
|
u387173453
|
ruby
|
p02757
|
N, P = gets.chomp.split(" ").map(&:to_i)
S = gets.chomp
if P == 2 || P == 5
count = 0
(N - 1).downto(0) do |i|
count += i + 1 if S[i].to_i % P == 0
end
puts count
else
mods = Array.new(P, 0)
sum = 0
bit = 1
(N - 1).downto(0) do |i|
sum += S[i].to_i * bit
sum %= P
mods[sum] += 1
bit = bit * 10 % P
end
count += mods[0]
for i in (0..P-1)
count += mods[i] * (mods[i] - 1) / 2
end
puts count
end
|
N, P = gets.chomp.split(" ").map(&:to_i)
S = gets.chomp
if P == 2 || P == 5
count = 0
(N - 1).downto(0) do |i|
count += i + 1 if S[i].to_i % P == 0
end
puts count
else
mods = Array.new(P, 0)
sum = 0
bit = 1
(N - 1).downto(0) do |i|
sum += S[i].to_i * bit
sum %= P
mods[sum] += 1
bit = bit * 10 % P
end
count = mods[0]
for i in (0..P-1)
count += mods[i] * (mods[i] - 1) / 2
end
puts count
end
|
[
"assignment.value.change"
] | 543,918
| 543,919
|
u729911058
|
ruby
|
p02757
|
# 解説参照
N, P = gets.split.map(&:to_i)
s = gets.chomp
if 10 % P == 0
ans = 0
N.times do |i|
if s[i].to_i % P == 0
ans += i + 1
end
end
puts ans
end
d = Array.new(N + 1, 0)
ten = 1
(N-1).downto(0) do |i|
a = s[i].to_i * ten % P
d[i] = (d[i+1] + a) % P
ten *= 10
ten %= P
end
cnt = Array.new(P, 0)
ans = 0
N.downto(0) do |i|
ans += cnt[d[i]]
cnt[d[i]] += 1
end
puts ans
|
# 解説参照
N, P = gets.split.map(&:to_i)
s = gets.chomp
if 10 % P == 0
ans = 0
N.times do |i|
if s[i].to_i % P == 0
ans += i + 1
end
end
puts ans
exit
end
d = Array.new(N + 1, 0)
ten = 1
(N-1).downto(0) do |i|
a = s[i].to_i * ten % P
d[i] = (d[i+1] + a) % P
ten *= 10
ten %= P
end
cnt = Array.new(P, 0)
ans = 0
N.downto(0) do |i|
ans += cnt[d[i]]
cnt[d[i]] += 1
end
puts ans
|
[
"control_flow.exit.add"
] | 543,950
| 543,951
|
u875730451
|
ruby
|
p02759
|
puts (gets.to-f / 2).round
|
puts (gets.to_f / 2).round
|
[
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 545,089
| 545,090
|
u016323272
|
ruby
|
p02759
|
puts (gets.to-f/2).round
|
puts (gets.to_f / 2).round
|
[
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 545,091
| 545,090
|
u016323272
|
ruby
|
p02759
|
## 値の半分を小数点以下切り上げ表示させる計算
N = gets.to_i
ans = N/2
if ans % 2 == 1
ans = ans + 1
end
puts ans
|
## 値の半分を小数点以下切り上げ表示させる計算
N = gets.to_i
ans = N/2
if N % 2 == 1
ans = ans + 1
end
puts ans
|
[
"control_flow.branch.if.condition.change"
] | 545,219
| 545,220
|
u552761221
|
ruby
|
p02759
|
## 値の半分を小数点以下切り上げ表示させる計算
N = gets.to_i
ans = N/2
if ans % 2 == 1
ans = ans + 1
return
end
puts ans
|
## 値の半分を小数点以下切り上げ表示させる計算
N = gets.to_i
ans = N/2
if N % 2 == 1
ans = ans + 1
end
puts ans
|
[
"control_flow.branch.if.condition.change",
"control_flow.return.remove"
] | 545,221
| 545,220
|
u552761221
|
ruby
|
p02759
|
p = gets.to_i
a = p / 2
puts a.ceil
|
p = gets.to_i
a = p / 2.0
puts a.ceil
|
[
"assignment.value.change",
"expression.operation.binary.change"
] | 545,655
| 545,656
|
u036108511
|
ruby
|
p02759
|
data = gets.to_i
puts(data + data%2)
|
n = gets.to_i
puts n/2 + n%2
|
[
"assignment.variable.change",
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 545,729
| 545,730
|
u924399788
|
ruby
|
p02759
|
num = gets.to_i
if num % 2 == 0
puts num % 2
else
puts (num % 2) + 1
end
|
num = gets.to_i
if num % 2 == 0
puts num / 2
else
puts (num / 2) + 1
end
|
[
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 545,803
| 545,804
|
u750375267
|
ruby
|
p02759
|
n = gets.chomp.to_i
if a.even? then
print n/2
else
print (n/2+1)
end
|
n = gets.chomp.to_i
if n.even? then
print n/2
else
print (n/2+1)
end
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 545,915
| 545,916
|
u394640249
|
ruby
|
p02759
|
puts (get.to_i / 2.0).ceil
|
puts (gets.to_i / 2.0).ceil
|
[
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 546,002
| 546,003
|
u039293076
|
ruby
|
p02760
|
#!/usr/bin/env ruby
a = Array.new(3, gets.split(" ").map(&:to_i))
n = gets.to_i
n.times do
b = gets.to_i
3.times do |i|
a[i].map! do |k|
k == b ? 0 : k
end
end
end
flag = false
a.each do |l|
if l.inject(&:+) == 0
flag = true
break
end
end
a.transpose.each do |l|
if l.inject(&:+) == 0
flag = true
break
end
end
flag = true if (a[2][0] == 0 && a[1][1] == 0 && a[0][2] == 0) || (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)
puts flag ? "Yes" : "No"
|
a = Array.new(3){gets.split(" ").map(&:to_i)}
n = gets.to_i
n.times do
b = gets.to_i
3.times do |i|
a[i].map! do |k|
k == b ? 0 : k
end
end
end
flag = false
a.each do |l|
if l.inject(&:+) == 0
flag = true
break
end
end
a.transpose.each do |l|
if l.inject(&:+) == 0
flag = true
break
end
end
flag = true if (a[2][0] == 0 && a[1][1] == 0 && a[0][2] == 0) || (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)
puts flag ? "Yes" : "No"
|
[
"assignment.value.change",
"call.arguments.change"
] | 547,017
| 547,018
|
u016444909
|
ruby
|
p02760
|
a = []
3.times do |i|
ai = gets.rstrip.split(" ").map { |c| c.to_i }
a.push(ai)
end
n = gets.rstrip.to_i
hole = Array.new(3, Array.new(3, false))
n.times do |temp|
bi = gets.rstrip.to_i
3.times do |i|
3.times do |j|
if a[i][j] == bi
hole[i][j] = true
end
end
end
end
if hole[0].all? \
or hole[1].all? \
or hole[2].all? \
or 3.times.map{|i| hole[i][0]}.all? \
or 3.times.map{|i| hole[i][1]}.all? \
or 3.times.map{|i| hole[i][2]}.all? \
or 3.times.map{|i| hole[i][i]}.all? \
or 3.times.map{|i| hole[i][2-i]}.all?
puts "Yes"
else
puts "No"
end
|
a = []
3.times do |temp|
ai = gets.rstrip.split(" ").map { |c| c.to_i }
a.push(ai)
end
n = gets.rstrip.to_i
hole = Array.new(3){Array.new(3, false)}
n.times do |temp|
bi = gets.rstrip.to_i
3.times do |i|
3.times do |j|
if a[i][j] == bi
hole[i][j] = true
end
end
end
end
if hole[0].all? \
or hole[1].all? \
or hole[2].all? \
or 3.times.map{|i| hole[i][0]}.all? \
or 3.times.map{|i| hole[i][1]}.all? \
or 3.times.map{|i| hole[i][2]}.all? \
or 3.times.map{|i| hole[i][i]}.all? \
or 3.times.map{|i| hole[i][2-i]}.all?
puts "Yes"
else
puts "No"
end
|
[
"identifier.change",
"assignment.value.change",
"call.arguments.change"
] | 547,088
| 547,089
|
u644533034
|
ruby
|
p02760
|
bingo = []
ans = false
flag = Array.new(3).map{Array.new(3, false)}
3.times do
bingo << gets.chomp.split(" ").map(&:to_i)
end
n = gets.chomp.to_i
n.times do
b = gets.chomp.to_i
bingo.each_with_index do |arr, i|
arr.each_with_index do |e, j|
if b == e
flag[i][j] = true
end
end
end
end
if flag[0][0] == true && flag[1][1] == true && flag[2][2] == true
ans = true
end
if flag[0][2] == true && flag[1][1] == true && flag[2][0] == true
ans = true
end
print flag
flag.each do |i|
if i.all?{|v| v == true}
ans = true
end
end
flag = flag.transpose
flag.each do |i|
if i.all?{|v| v == true}
ans = true
end
end
puts ans ? "Yes" : "No"
|
bingo = []
ans = false
flag = Array.new(3).map{Array.new(3, false)}
3.times do
bingo << gets.chomp.split(" ").map(&:to_i)
end
n = gets.chomp.to_i
n.times do
b = gets.chomp.to_i
bingo.each_with_index do |arr, i|
arr.each_with_index do |e, j|
if b == e
flag[i][j] = true
end
end
end
end
if flag[0][0] == true && flag[1][1] == true && flag[2][2] == true
ans = true
end
if flag[0][2] == true && flag[1][1] == true && flag[2][0] == true
ans = true
end
flag.each do |i|
if i.all?{|v| v == true}
ans = true
end
end
flag = flag.transpose
flag.each do |i|
if i.all?{|v| v == true}
ans = true
end
end
puts ans ? "Yes" : "No"
|
[
"call.remove"
] | 547,278
| 547,279
|
u466332671
|
ruby
|
p02760
|
card = []
3.times { |i| card[i] = gets.chomp.split(" ").map(&:to_i)}
n = gets.to_i
selectedNums = []
n.times { |i| selectedNums[i] = gets.to_i}
# 行でそろう場合
card.each do |row|
if (row & selectedNums).length == 3
print 'Yes'
exit
end
end
# 列でそろう場合
card.transpose.each do |row|
if (row & selectedNums).length == 3
print 'Yes'
exit
end
end
# ななめでそろう場合
if ([card[0][0], card[1][1], card[2][2]] & selectedNums).length > 3 || ([card[0][2], card[1][1], card[2][0]] & selectedNums).length > 3
print 'Yes'
exit
end
print 'No'
|
card = []
3.times { |i| card[i] = gets.chomp.split(" ").map(&:to_i)}
n = gets.to_i
selectedNums = []
n.times { |i| selectedNums[i] = gets.to_i}
# 行でそろう場合
card.each do |row|
if (row & selectedNums).length == 3
print 'Yes'
exit
end
end
# 列でそろう場合
card.transpose.each do |row|
if (row & selectedNums).length == 3
print 'Yes'
exit
end
end
# ななめでそろう場合
if ([card[0][0], card[1][1], card[2][2]] & selectedNums).length == 3 || ([card[0][2], card[1][1], card[2][0]] & selectedNums).length == 3
print 'Yes'
exit
end
print 'No'
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 547,397
| 547,398
|
u994502918
|
ruby
|
p02760
|
a = 3.times.map{gets.split.map(&:to_i)}
n = gets.to_i
b = n.times.map{gets.to_i}
f = 3.times.map{[false]*3}
b.each{|x|
3.times{|i|
3.times{|j|
if a[i][j]==x
f[i][j] = true
end
}
}
}
ans = false
2.times{
3.times{|i|
ans = true if f[i].all?
}
ans = true if 3.times.map{|i|f[i][i]}.all?
f = f.transpose
}
puts ans ? "Yes" : "No"
|
a = 3.times.map{gets.split.map(&:to_i)}
n = gets.to_i
b = n.times.map{gets.to_i}
f = 3.times.map{[false]*3}
b.each{|x|
3.times{|i|
3.times{|j|
if a[i][j]==x
f[i][j] = true
end
}
}
}
ans = false
2.times{
3.times{|i|
ans = true if f[i].all?
}
ans = true if 3.times.map{|i|f[i][i]}.all?
f = f.transpose.reverse
}
puts ans ? "Yes" : "No"
|
[
"call.add"
] | 547,608
| 547,609
|
u397763977
|
ruby
|
p02760
|
a = 3.times.map { gets.chomp.split(' ').map(&:to_i) }
n = gets.chomp.to_i
b = n.times.map { gets.chomp.to_i }
marked = [[false, false, false], [false, false, false], [false, false, false]]
b.each do |num|
(0..2).each do |i|
(0..2).each do |j|
marked[i][j] = true if a[i][j] == num
end
end
end
ans = 'No'
(0..2).each do |i|
ans = 'Yes' if marked[i][0] && marked[i][1] && marked[i][2]
end
(0..2).each do |j|
ans = 'Yes' if marked[0][j] && marked[1][j] && marked[2][j]
end
ans = 'Yes' if marked[0][0] && marked[1][1] && marked[2][2]
ans = 'Yes' if marked[0][2] && marked[1][1] && marked[2][0]
put ans
|
a = 3.times.map { gets.chomp.split(' ').map(&:to_i) }
n = gets.chomp.to_i
b = n.times.map { gets.chomp.to_i }
marked = [[false, false, false], [false, false, false], [false, false, false]]
b.each do |num|
(0..2).each do |i|
(0..2).each do |j|
marked[i][j] = true if a[i][j] == num
end
end
end
ans = 'No'
(0..2).each do |i|
ans = 'Yes' if marked[i][0] && marked[i][1] && marked[i][2]
end
(0..2).each do |j|
ans = 'Yes' if marked[0][j] && marked[1][j] && marked[2][j]
end
ans = 'Yes' if marked[0][0] && marked[1][1] && marked[2][2]
ans = 'Yes' if marked[0][2] && marked[1][1] && marked[2][0]
puts ans
|
[
"misc.typo",
"identifier.change"
] | 547,852
| 547,853
|
u768135881
|
ruby
|
p02760
|
bingo = (0..2).map do
gets.split(' ').map { |v| { value: v.to_i, open: false } }
end
N = gets.to_i
(1..N).each do
v = gets.to_i
bingo = bingo.map do |row|
row.map do |cell|
if cell[:value] == v
cell[:open] = true
end
cell
end
end
(0..2).each do |i|
if bingo[i].all? { |cell| cell[:open] }
puts 'Yes'
exit
end
if bingo.all? { |col| col[i][:open] }
puts 'Yes'
exit
end
if bingo[0][0][:open] && bingo[1][1][:open] && bingo[2][2][:open]
puts 'Yes'
exit
end
if bingo[2][0][:open] && bingo[1][1][:open] && bingo[0][2][:open]
puts 'Yes'
exit
end
end
end
|
bingo = (0..2).map do
gets.split(' ').map { |v| { value: v.to_i, open: false } }
end
N = gets.to_i
(1..N).each do
v = gets.to_i
bingo = bingo.map do |row|
row.map do |cell|
if cell[:value] == v
cell[:open] = true
end
cell
end
end
(0..2).each do |i|
if bingo[i].all? { |cell| cell[:open] }
puts 'Yes'
exit
end
if bingo.all? { |col| col[i][:open] }
puts 'Yes'
exit
end
if bingo[0][0][:open] && bingo[1][1][:open] && bingo[2][2][:open]
puts 'Yes'
exit
end
if bingo[2][0][:open] && bingo[1][1][:open] && bingo[0][2][:open]
puts 'Yes'
exit
end
end
end
puts 'No'
|
[
"call.add"
] | 548,166
| 548,167
|
u043059662
|
ruby
|
p02760
|
bingo = 3.times.map{gets.split.map(&:to_i)}
_b = gets.to_i.times.map{gets.to_i}
(0..2).each do |i|
(0..2).each do |j|
bingo[i][j] = 0 if _b.include?(bingo[i][j])
end
end
result = false
(0..2).each do |i|
result ||= (0..2).all? { |j| bingo[i][j] == 0 }
end
(0..2).each do |i|
result ||= (0..2).all? { |j| bingo[j][i] == 0 }
end
result ||= (0..2).all? { |i| bingo[i][i] == 0 }
result ||= (0..2).all? { |i| bingo[2 - i][i] == 0 }
p result ? 'Yes' : 'No'
|
bingo = 3.times.map{gets.split.map(&:to_i)}
_b = gets.to_i.times.map{gets.to_i}
(0..2).each do |i|
(0..2).each do |j|
bingo[i][j] = 0 if _b.include?(bingo[i][j])
end
end
result = false
(0..2).each do |i|
result ||= (0..2).all? { |j| bingo[i][j] == 0 }
end
(0..2).each do |i|
result ||= (0..2).all? { |j| bingo[j][i] == 0 }
end
result ||= (0..2).all? { |i| bingo[i][i] == 0 }
result ||= (0..2).all? { |i| bingo[2 - i][i] == 0 }
puts result ? 'Yes' : 'No'
|
[
"call.function.change",
"io.output.change"
] | 548,217
| 548,218
|
u542197477
|
ruby
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.