Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def meu_map(l):
    for i in range(len(l)):
        l[i] = int(l[i])


n = int(raw_input())
array = raw_input().split()

meu_map(array)

fatores = 0
for e in array:
    while e != 1:
        if e % 2 == 0:
            e /= 2
            fatores += 1
        else:
            break

print(fatores)

Fixed submission:
n = int(input())
a = map(int, input().split())
 
cont = 0
 
for e in a:
    x = e
    while x % 2 == 0:
        x /= 2
        cont += 1
 
print(cont)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums = list(map(int, input().split()))

ods = 0
ans = 0
first = True
while ods != n:
    ods = 0
    div = 0
    for i in range(len(nums)):
        e = nums[i]
        if e % 2 == 0 and div < 1:
            nums[i] = e // 2
            first = False
            div += 1
        else:
            nums[i] *= 3
            ods += 1
    ans += 1
ans -= 1
print(ans)

Fixed submission:
n = int(input())
a = map(int, input().split())
 
cont = 0
 
for e in a:
    x = e
    while x % 2 == 0:
        x /= 2
        cont += 1
 
print(cont)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
m = [int(x) for x in raw_input().split()]
a = 0
possible = True
while possible:
    dividiu = False
    for i in range(n):
        if not dividiu and m[i] % 2 == 0:
            m[i] /= 2
            dividiu = True
        else:
            m[i] *= 3
    if not dividiu:
        possible = False
    else:
        a += 1

print a

Fixed submission:
n = int(input())
a = map(int, input().split())
 
cont = 0
 
for e in a:
    x = e
    while x % 2 == 0:
        x /= 2
        cont += 1
 
print(cont)
Buggy python submission (verdict: Runtime Error):
n = int(input())


x = n - 2
y = n - x

if n < 10:
    print(n)
if n = 10:
    print(1)
else:
    resulty, resultx = 0, 0

    while(x > 0):
        resultx += x % 10
        x = x // 10

    while(y > 0):
        resulty += y % 10
        y = y // 10

    #print(resulty+resultx)
    z = n//2

    result = 0
    while(z > 0):
        result += z % 10
        z = z // 10

    if result*2 < resulty+resultx:
        print(result*2)
    else:
        print(resulty+resultx)



Fixed submission:
def sum_value(n):
    n = str(n)
    sum = 0
    for i in range(len(n)):
        sum+=int(n[i])
    return sum

N = int(input())
A = int(N/2)
B = int(N/2) if N%2 == 0 else int(N/2)+1
menor = -1
for i in range(int(N/2)):
    menor = sum_value(A+i)+sum_value(B-i) if menor < 0 else min(sum_value(A+i)+sum_value(B-i), menor) 
print(menor)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, sys.stdin.readline().strip)
sys.stdout.write(max(a+b, a-b, a*b) + '\n')

Fixed submission:
a,b = map(int,input().split())
print(max(a+b, a-b, a*b))

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

c = a + b
d = a - b
e = a * b
ary = [c, d, e]
f = max(ary)
print ("Max:", f)

Fixed submission:
a,b = map(int,input().split())
print(max(a+b, a-b, a*b))
Buggy python submission (verdict: Runtime Error):
line = input()
A, B, X = [int(u) for u in line.split()]
u=[A,B,C]
j = max(u)
u.remove(j)
u.append(j*2**K)
print(sum(u))

Fixed submission:
a, b, c = map(int, input().split())
k = int(input())
if a >= b and a >= c:
	print(a * 2 ** k + b + c)
elif b >= a and b >= c:
	print(b * 2 ** k + a + c)
else:
	print(c * 2 ** k + b + a)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
lst = [int(i) for i in input().split()]
lst.insert(0, 0)
res = [0]
for i in range(1, N+1):
    t = lst[:]
    del(t[i])
    # if max(t) < 0:
    #     res.append(2 * abs(min(t)))
    # elif min(t) > 0:
    #     res.append(2 * maxt)
    # else:
    #     res.append(2 * (max(t) - min(t)))
    k = 0
    for i in range(1, len(t)):
        k += abs(t[i] - t[i-1])
    res.append(k + abs(t[-1]))

for i in range(1, N+1):
    print(res[i])


Fixed submission:
import sys
for line in sys.stdin:
    if line == None or line == '\n':
        break
    line = line.rstrip()
    line = line.split(" ")
    if len(line) == 1:
        N = int(line[0])
        continue
    else:
        coordinates = line

        coordinates.insert(0, 0)
        coordinates.append(0)

        prev_coord = int(coordinates[0])
        total_cost = 0
        for i in range(1, len(coordinates)):
            total_cost += abs(int(coordinates[i]) - int(coordinates[i-1]))

        for i in range(1, len(coordinates) - 1):
            print(total_cost - abs(int(coordinates[i]) - int(coordinates[i - 1])) - abs(int(coordinates[i]) - int(coordinates[i + 1])) + abs(int(coordinates[i + 1]) - int(coordinates[i - 1])))
Buggy python submission (verdict: Runtime Error):
import math
x, y = map(int, input().split())
def lcm(x,y):
    return (x * y)//math.gcd(x, y)

def thingo(x,y):
    if (x == 0 and y == 0):
        return -1
    if (x != 0 and y == 0):
        return x
    test = lcm(x,y)
    if (test-x >= x):
        return test-x
    else:
        return -1
print(thingo(x,y))


Fixed submission:
b=[]
b = input().strip().split()
b[0]=int(b[0])
b[1]=int(b[1])
if b[0]%b[1]==0:
	print("-1")
else:
	print(b[0])

Buggy python submission (verdict: Time Limit Exceeded):
import math

input = str(input()).split(" ")
for index in range(len(input)):
    input[index] = int(input[index])
x = input[0]
y = input[1]


def test(x, y):
    for index in range(1, min(abs(y), math.floor((10**18)/x))):
        if (x * index % y != 0 and abs(x * index) <= 10**(18)):
            return x * index
    return -1
print(test(x,y))


Fixed submission:
b=[]
b = input().strip().split()
b[0]=int(b[0])
b[1]=int(b[1])
if b[0]%b[1]==0:
	print("-1")
else:
	print(b[0])

Buggy python submission (verdict: Time Limit Exceeded):
import math

input = str(input()).split(" ")
for index in range(len(input)):
    input[index] = int(input[index])
x = input[0]
y = input[1]


def test(x, y):
    for index in range(1, abs(y) + 1):
        if (x * index % y != 0 and abs(x * index) <= 10**(18)):
            return x * index
    return -1
print(test(x,y))

Fixed submission:
b=[]
b = input().strip().split()
b[0]=int(b[0])
b[1]=int(b[1])
if b[0]%b[1]==0:
	print("-1")
else:
	print(b[0])
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
#CODE
u=a-b
v=u//c
w=v*c
left=u-w
print(left)
.

Fixed submission:
X = int(input())
A = int(input())
B = int(input())

P = X-A
PT = P % B
print(PT)

Buggy python submission (verdict: Runtime Error):
// code 
x=int(input())
y=int(input())
z=int(input())
left=x-y
print(left%z)


Fixed submission:
X = int(input())
A = int(input())
B = int(input())

P = X-A
PT = P % B
print(PT)

Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
c=input()
left=a-b
result=left%c
print(result)

Fixed submission:
X = int(input())
A = int(input())
B = int(input())

P = X-A
PT = P % B
print(PT)

Buggy python submission (verdict: Runtime Error):
y=int(input())
y1=int(input())
y2=int(input())

print((y-y1)%y2

Fixed submission:
X = int(input())
A = int(input())
B = int(input())

P = X-A
PT = P % B
print(PT)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
 
 result= 0
 
for ai in range(a+1):
    for bi in range(b+1):
        for ci in range(c+1):
            amount = 500 * ai + 100 * bi + 50 * ci
            if amount == x:
                result += 1
 
print(result)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
x=int(input())
x=int(x/50)
p=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 10*i + 2*j + k == x:
                p=p+1


print(p)
Buggy python submission (verdict: Runtime Error):
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h>
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 2000000;
const int inf = 1000000007;
const ll mod = 1000000007;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
 
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
 
 
 
int n, ans;
int a[2][100005];
 
int main() {
 
cin >> n;
 
rep(i, 2) {
rrep(j, n) {
int tmp;
cin >> tmp;
a[i][j] = a[i][j - 1] + tmp;
}
}
 
rrep(i, n) {
ans = max(ans, a[0][i] + (a[1][n] - a[1][i - 1]));
}
 
cout << ans << endl;
 int heath=4;
return 0;
}

Fixed submission:
#input template
from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
mp = lambda: list(map(int, cin().split()))

def chars(): #function for taking string input as character array since string in python is immutable
    s = cin()
    return(list(s[:len(s) - 1]))

#print list	
def pl(a):	
	for val in a:
		cout(str(val) + ' ')
	cout('\n')
		
#main

n, = mp()
a = mp()
b = mp()

x = sum(b)
ans = a[0] + x
temp = ans
for i in range(1, n):
	temp += a[i] - b[i-1]
	ans = max(ans, temp)
cout(str(ans))
Buggy python submission (verdict: Runtime Error):
X,Y = map(int,input())
ans = 0
while X <= Y:
	ans += 1
	X * = 2
print(ans)

Fixed submission:
from math import log
a,b = input().split()
a = eval(a)
b = eval(b)
cnt = 0
while a <= b:
	cnt += 1
	a *= 2
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
c=0
for i in set(a):
  n=a.count(i)
  c+=n if n<i else n-i
print(c)


Fixed submission:
from collections import Counter
a = int(input())
l = list(map(int, input().split()))
#i = 1

c=Counter(l)
d = dict(c)
kv = []
for k,v in d.items():
    if k>v:
        kv.append(v)
    elif k<v:
        t = v-k
        kv.append(t)
s = sum(kv)
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
import math

line1 = int(input())
line2 = str(input()).split(" ")
for index in range(len(line2)):
    line2[index] = int(line2[index])

keepTrack = dict()
keys = []
keys = list(set(line2))
for element in keys:
    keepTrack[element] = line2.count(element)

sum = 0
for key in keys:
    ##sum += abs()
    if (key < keepTrack[key]):
        sum += -key + keepTrack[key]
    elif (key > keepTrack[key]):
        sum += keepTrack[key]
print(sum)


Fixed submission:
from collections import Counter
a = int(input())
l = list(map(int, input().split()))
#i = 1

c=Counter(l)
d = dict(c)
kv = []
for k,v in d.items():
    if k>v:
        kv.append(v)
    elif k<v:
        t = v-k
        kv.append(t)
s = sum(kv)
print(s)

Buggy python submission (verdict: Runtime Error):
import math
import random

line1 = int(input())
line2 = str(input()).split(" ")
keepTrack = dict()
keys = []
keys = list(set(line2))
for element in keys:
    keepTrack[element] = line2.count(element)

sum = 0
for key in keys:
    ##sum += abs()
    if (key < keepTrack[key]):
        sum += -key + keepTrack[key]
    elif (key > keepTrack[key]):
        sum += keepTrack[key]
print(sum)


Fixed submission:
from collections import Counter
a = int(input())
l = list(map(int, input().split()))
#i = 1

c=Counter(l)
d = dict(c)
kv = []
for k,v in d.items():
    if k>v:
        kv.append(v)
    elif k<v:
        t = v-k
        kv.append(t)
s = sum(kv)
print(s)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
a = int(input())
l = []
i = 1
for i in range(a):
    b = [int(i) for i in input(i).split(" ")]
    l.append(b)
c=Counter(l)
d = dict(c)
kv = []
for k,v in d.items():
    if k>v:
        kv.append(v)
    elif k<v:
        t = v-k
        kv.append(t)
s = sum(kv)
print(s)




Fixed submission:
from collections import Counter
a = int(input())
l = list(map(int, input().split()))
#i = 1

c=Counter(l)
d = dict(c)
kv = []
for k,v in d.items():
    if k>v:
        kv.append(v)
    elif k<v:
        t = v-k
        kv.append(t)
s = sum(kv)
print(s)
Buggy python submission (verdict: Runtime Error):
x=int(input(""))
y=int(input(""))
z=int(input(""))
answer= (x-z)//(z+y)
print(answer)
exit()

Fixed submission:
x,y,z=map(int,input().split())
print((x-z)//(y+z))
Buggy python submission (verdict: Runtime Error):
a= (input()) 
b=(input()) 
if(a[0]==b[2] &&a[1] ==b[1] && a[2] ==b[0] ):
       print("Yes")
else:
        print ("No" ) 



Fixed submission:
s = input()
r = input()
s = s + r
r = ''.join(reversed(s))
if s == r:
    print("YES")
else: print("NO")
Buggy python submission (verdict: Runtime Error):
a=int(input())
for i in range(1,a+1):
    if(i*i)>a:
        j=i-1
        break;
        
print(j*j);

Fixed submission:
import math
n = int(input())
s = int(math.sqrt(n))
print(s**2)
Buggy python submission (verdict: Runtime Error):
a=int(input("enter a"))
b=int(input("enter b"))
c=int(input("enter c"))
if a<=100 and a>=-100 and b<=100 and b>=-100 and c<=100 and c>=-100:
    if a==b:
        print(c)
    elif a==c:
        print(b)
    elif c==b:
        print(a)

Fixed submission:
x,y,z=input().split()
x,y,z=int(x),int(y),int(z)
if x==y:
        print(z)
elif x==z:
        print(y)
elif y==z:
        print(x)
Buggy python submission (verdict: Runtime Error):
print(2/0)

#  random shit  random shit  random shit  random shit  random shit  random shit 

Fixed submission:
inp = input().split(" ")
h = int(inp[0])
w = int(inp[1])

grid = []

for i in range(h):
	grid.append(list(input()))

for i in range(h):
	for j in range(w):
		c = grid[i][j]
		if c == ".":
			total = 0
			adj = []
			if i > 0:
				adj.append(grid[i-1][j])
			if j > 0:
				adj.append(grid[i][j-1])
			if i < h-1:
				adj.append(grid[i+1][j])
			if j < w-1:
				adj.append(grid[i][j+1])
			if i > 0 and j > 0:
				adj.append(grid[i-1][j-1])
			if i > 0 and j < w-1:
				adj.append(grid[i-1][j+1])
			if i < h-1 and j > 0:
				adj.append(grid[i+1][j-1])
			if i < h-1 and j < w-1:
				adj.append(grid[i+1][j+1])
			for k in adj:
				if k == "#":
					total += 1
			grid[i][j] = str(total)

for i in grid:
	print("".join(i))
Buggy python submission (verdict: Runtime Error):
lst = []
N = int(input("Enter number of elements : "))
for i in range(0,N):
    lst.append(int(input()))
temp = [x for x in lst if lst.count(x)>1]
list_set = set(temp)
# convert the set to the list
dups = (list(list_set))
n=len(dups)
if (n<2):
   print('0\nNo rectangle can be formed')
else:
    a = dups[0]
    b = dups[1]
    for i in range(0, n):
      for j in range(i + 1, n):
        if (dups[i]*dups[j]>a*b):
             a = dups[i]
             b = dups[j]
    print(a*b)
    print(a,' times ',b,' rectangle can be formed')

Fixed submission:
n = int(input())
vals = list(map(int, input().split()))
d= {}
a = [0, 0]

for i in range(n):
    if(vals[i] in d.keys()):
        d[vals[i]] += 1
    else:
        d[vals[i]] = 1


for i in d.keys():
    if(d[i] >= 4):
        a.append(i)
        a.append(i)
    elif(d[i] >= 2):
        a.append(i)
a.sort()

print(a[-1]*a[-2])
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int(),input().split())
print(max(0,min(a,c)-max(b,d))

Fixed submission:
a,b,c,d=map(int,input().split())
print(max(0,min(b,d)-max(a,c)))
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
n = (input())
res = (input())
while n > 1:
	x = (input())
	res = (res * x) // gcd(res, x);
	n -= 1
print(res)

Fixed submission:
import fractions
import functools

def lcm(a,b):
	return a*b//fractions.gcd(a,b)

n=int(input())
t=[]
for i in range(n):
	t.append(int(input()))
ans=functools.reduce(lcm,t)
print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin, stdout


def main():
    line = stdin.readline()
    parts = line.split()
    n = int(parts[1])
    m = int(parts[2])
    stdout.write(str((n-1)*(m-1)))


main()


Fixed submission:




a,b=map(int,input().split())
print((a-1)*(b-1))
Buggy python submission (verdict: Runtime Error):
mod = 10 ** 9 + 7

f = [0 for _ in range(100000)]
f[0] = 1
for i in range(1, 100000):
    f[i] = f[i - 1] * i % mod
inv = [pow(f[i], mod - 2, mod) for i in range(100000)]


def C(n, m):
    if n < m: return 0
    return f[n] * inv[m] * inv[n - m]

n = int(input())
a = [*map(lambda x: int(x) - 1, input().split())]
pos = [[] for _ in range(n)]

for idx, x in enumerate(a):
    pos[x].append(idx)

for _ in pos:
    if len(_) == 2:
        l, r = _

for i in range(1, n + 2):
    print(((C(n + 1, i) - C(n + l - r, i - 1)) % mod + mod) % mod)


Fixed submission:
mod = 10 ** 9 + 7

f = [0 for _ in range(200000)]
f[0] = 1
for i in range(1, 200000):
    f[i] = f[i - 1] * i % mod
inv = [pow(f[i], mod - 2, mod) for i in range(200000)]


def C(n, m):
    if n < m or m < 0: return 0
    return f[n] * inv[m] * inv[n - m] % mod

n = int(input())
a = list(map(lambda x: int(x) - 1, input().split()))
pos = [[] for _ in range(n)]

for idx, x in enumerate(a):
    pos[x].append(idx)

for _ in pos:
    if len(_) == 2:
        l, r = _

for i in range(1, n + 2):
    print(((C(n + 1, i) - C(n + l - r, i - 1)) % mod + mod) % mod)

Buggy python submission (verdict: Runtime Error):
mod = 10 ** 9 + 7

f = [0 for _ in range(100000)]
f[0] = 1
for i in range(1, 100000):
    f[i] = f[i - 1] * i % mod
inv = [pow(f[i], mod - 2, mod) for i in range(100000)]


def C(n, m):
    if n < m: return 0
    return f[n] * inv[m] * inv[n - m]

n = int(input())
a = [*map(lambda x: int(x) - 1, input().split())]
pos = [[] for _ in range(n)]

for idx, x in enumerate(a):
    pos[x].append(idx)

for _ in pos:
    if len(_) == 2:
        l, r = _

for i in range(1, n + 2):
    print(((C(n + 1, i) - C(n + l - r, i - 1)) % mod + mod) % mod)



Fixed submission:
mod = 10 ** 9 + 7

f = [0 for _ in range(200000)]
f[0] = 1
for i in range(1, 200000):
    f[i] = f[i - 1] * i % mod
inv = [pow(f[i], mod - 2, mod) for i in range(200000)]


def C(n, m):
    if n < m or m < 0: return 0
    return f[n] * inv[m] * inv[n - m] % mod

n = int(input())
a = list(map(lambda x: int(x) - 1, input().split()))
pos = [[] for _ in range(n)]

for idx, x in enumerate(a):
    pos[x].append(idx)

for _ in pos:
    if len(_) == 2:
        l, r = _

for i in range(1, n + 2):
    print(((C(n + 1, i) - C(n + l - r, i - 1)) % mod + mod) % mod)
Buggy python submission (verdict: Runtime Error):
line = input().split()
N = line[0]
A = line[1]
B = line[2]

if A > B:
    cnt = 0
elif N == 1:
    cnt = 0
elif A == B:
    cnt = 1
else:
    cnt=(2-N)*A+(N-2)*B+1

print(cnt)

Fixed submission:
a,b,c = map(int,input().split())
if a<=1:
    if b==c:
        print(1)
    else:
        print(0)
elif b>c:
    print(0)
else:
    print((a-2)*(c-b)+1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())
if n == 1 and a == b:
    print(1)
elif n<2 or a>b:
    print(0)
else:
    print((n-2)*(b-a)+1)


Fixed submission:
a,b,c = map(int,input().split())
if a<=1:
    if b==c:
        print(1)
    else:
        print(0)
elif b>c:
    print(0)
else:
    print((a-2)*(c-b)+1)
Buggy python submission (verdict: Runtime Error):
x = int(input())
y = int(input())
s1 = [1,3,5,7,8,10,12]
s2 = [4,6,9,11]
if x in s1 and y in s1:
    print("Yes")
elif x in s2 and y in s2:
    print("Yes")
elif x == 2 and y == 2:
    print("Yes")
else:
    print("No")

Fixed submission:
a = [1,2,1,0,1,0,1,1,0,1,0,1]    
x,y=map(int, input().split())
if(x==2 or y == 2):
  print("No")
  exit()
if(a[x-1] == a[y-1]):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):

n,m=map(int,input().split())
# print
v=[]
for i in range(n+2):
    s=""
    if i==0 or i==n+1:
        s="#"*(m+2)
        
    else:
        a=input()
        s="#"+a+"#"
    v.append(s)
    
    
for i in v:
    print(i)
    

Fixed submission:

n,m=map(int,input().split())
# print
# v=[]
for i in range(n+2):
    s=""
    if i==0 or i==n+1:
        s="#"*(m+2)
        
    else:
        a=input()
        s="#"+a+"#"
    print(s)
    # v.append(s)
    
    
# for i in v:
#     print(i)
Buggy python submission (verdict: Runtime Error):
n = int(input())
k = int(input())
x = 0
y =0
sum = 0
for i in range(n):
    x=int(input())
    y = int(input())
    sum+=y
    if(k <= sum):
        print(x)
        break

Fixed submission:
x = raw_input().split(" ")
num_operations = int(x[0])
kth_integer = int(x[1])
field = {}
for p in range(0, num_operations):
 line = raw_input().split(" ")
 a = int(line[0])
 b = int(line[1])
 if a in field:
  field[a] += b
 else:
  field[a] = b
ks = field.keys()
ks.sort()
out = field.keys()[-1]
for k in ks:
 kth_integer -= field[k]
 if (kth_integer <= 0):
  out = k
  break
print (out)

Buggy python submission (verdict: Runtime Error):
args = raw_input().split()
sarr = []
for i in range(int(args[0])):
        sarr.append(raw_input().split())

counter = 0
lim = int(args[1])

for i in sarr:
    counter += int(i[1])
    if(counter >= lim):
        print(int(i[0]))
        exit()


Fixed submission:
x = raw_input().split(" ")
num_operations = int(x[0])
kth_integer = int(x[1])
field = {}
for p in range(0, num_operations):
 line = raw_input().split(" ")
 a = int(line[0])
 b = int(line[1])
 if a in field:
  field[a] += b
 else:
  field[a] = b
ks = field.keys()
ks.sort()
out = field.keys()[-1]
for k in ks:
 kth_integer -= field[k]
 if (kth_integer <= 0):
  out = k
  break
print (out)

Buggy python submission (verdict: Time Limit Exceeded):
inp = input().split(" ")
N = int(inp[0])
K = int(inp[1])

arr = []
indicies = [0]

for i in range(N):
	inp = input().split(" ")
	a = int(inp[0])
	b = int(inp[1])
	if len(arr) == 0 or a >= arr[-1]:
		arr += [a] * b
		indicies.append(len(arr))
	elif a <= arr[0]:
		arr = ([a] * b) + arr
		for i in range(len(indicies)):
			indicies[i] += b
		indicies.append(0)
	else:
		index = 0
		for i in range(len(indicies)):
			i = indicies[i]
			if a >= arr[i-1] and a <= arr[i]:
				index = i
				
				arr = arr[0:i] + ([a] * b) + arr[i:]
				break
		for i in range(len(indicies)):
			if indicies[i] > index:
				indicies[i] += b
		indicies.append(index+b)

print(arr[K-1])


Fixed submission:
x = raw_input().split(" ")
num_operations = int(x[0])
kth_integer = int(x[1])
field = {}
for p in range(0, num_operations):
 line = raw_input().split(" ")
 a = int(line[0])
 b = int(line[1])
 if a in field:
  field[a] += b
 else:
  field[a] = b
ks = field.keys()
ks.sort()
out = field.keys()[-1]
for k in ks:
 kth_integer -= field[k]
 if (kth_integer <= 0):
  out = k
  break
print (out)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))+[0]
a=[a[i] for i in range(n) if a[i]!=a[i+1]]
s=0
while a:
  n=len(a)
  if n==1:
    a=[]
  else:
    d=a[0]-a[1]>0
    for i in range(n-1):
      if d==(a[i]-a[i+1]<0):
        a=a[i+1:]
        break
    else:
      a=[]
  s+=1
print(s)


Fixed submission:
n = int(input())
ans = 1
a, b = False, False
x = list(map(int, input().split()))
for i in range(1, n):
    if x[i] > x[i - 1]:
        a = True
    if x[i] < x[i - 1]:
        b = True
    if a and b:
        a, b = False, False
        ans += 1
print(ans)