akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		long K = sc.nextLong();
		
		
		int length = S.length();
		
		String one = "1";
		
		int flag = 0;
		int F = 0;
		int B = 1;
		long locate = 1;
		String Ma = "1";
		
		for (int count = 1; flag == 0 && count <= length; count++){
			String compareX = S.substring(F,B);
			if(one.equals(compareX)){
				F++;
				B++;
			}else {
				Ma = S.substring(F,B);
				locate = B;
				flag = 1;
			}
		}
		int ans = Integer.parseInt(Ma);
		
		
		if(K < locate){
			System.out.println(1);
		}
		else{
			System.out.println(ans);
		}
		
		
	}
}

Measured memory_bytes: 21972
def main():
    N = int(input())
    csf = []
    for _ in range(N - 1):
        C, S, F = map(int, input().split())
        csf.append((C, S, F))
    
    ans = []
    for i in range(N - 1):
        c, s, _  = csf[i]
        t = c + s
        for ii in range(i + 1, N - 1):
            nc, ns, nf = csf[ii]
            if t > ns:
                ns += ((t - ns) // nf) * nf
                if (t - ns) % nf != 0:
                    ns += nf
            t += nc + ns - t
        ans.append(t)
    ans.append(0)
    
    for t in ans:
        print(t)
    

main()


Measured memory_bytes: 3188
A, B = map(int, input().split())
S = input()

if len(S) != A+B+1:
    print('No')
    exit()

try:
    int(S[:A])
except ValueError:
    print('No')
    exit()

if S[A]!='-':
    print('No')
    exit()

try:
    int(S[A+1:])
except ValueError:
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 3064
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
# import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
# from collections import deque
# from collections import defaultdict
# from collections import Counter
# from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	s=input().rstrip().decode('utf-8')
	n=len(s)
	
	dp=[[0]*13 for _ in range(n+1)]
	dp[0][0]=1
	
	for i in range(1,n+1):
		now=s[i-1]
		if now=="?":
			for j in range(13):
				for k in range(10):
					dp[i][(10*j+k)%13]+=dp[i-1][j]
		else:
			k=int(now)
			for j in range(13):
				dp[i][(10*j+k)%13]+=dp[i-1][j]
		
		for j in range(13):
			dp[i][j]%=MOD
	
	print(dp[n][5])
	
	
	
	
if __name__ == '__main__':
	main()


Measured memory_bytes: 61788
#include<cstdio>
int main(){
	long long n, a, b;
	scanf("%lld %lld %lld",&a, &b, &n);
	long long answer;
	if(b>n) {
		answer = a*n/b;
	}else{
		answer = a*(b-1)/b;
	}
	printf("%lld",answer);
	
	return 0;
}

Measured memory_bytes: 1732
import itertools as it

import copy

n, m = map(int, input().split())
sp = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

seq = [0, 1]

sw = list(it.product(seq, repeat=n))
sw_new = copy.copy(sw)

for sp_ele,p_ele in zip(sp, p):
    s = sp_ele[1:]
    for sw_ele in sw:
        cnt = 0
        for s_ele in s:
            cnt = cnt+sw_ele[s_ele-1]
        if cnt % 2 != p_ele and sw_ele in sw_new:
            sw_new.remove(sw_ele)

print(len(sw_new))

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;

   typedef long long ll;
   typedef pair<ll, ll> P;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   int gcd(int a,int b){return b?gcd(b,a%b):a;};

   int dx[4]={1,0,-1,0};
   int dy[4]={0,1,0,-1};

const ll MAX_N = 1e6, MAX_Q = 75;
ll N, Q;
string S;
ll K[MAX_Q];

ll a[MAX_N * 2] = {};
ll b[MAX_N * 2] = {};
ll c[MAX_N * 2] = {};
ll A[MAX_N * 2 + 1], B[MAX_N * 2 + 1], C[MAX_N * 2 + 1];

ll DMC(ll k){
   ll F[MAX_N + 1] = {};
   REP(i, N){
      F[i + 1] = F[i] + a[i] * C[i + k];
   }
   ll ans = 0;
   REP(y, N){
      ans += b[y] * (F[y] - F[max(0ll, y - k + 2)] - C[y + 1] * (A[y] - A[max(0ll, y - k + 2)]));
   }
   return ans;
}

int main(){
   cin >> N >> S >> Q;
   REP(i, Q){
      cin >> K[i];
   }
   REP(i, N){
      a[i] = (S[i] == 'D');
      b[i] = (S[i] == 'M');
      c[i] = (S[i] == 'C');
   }
   A[0] = 0;
   B[0] = 0;
   C[0] = 0;
   REP(i, 2 * N){
      A[i + 1] = A[i] + a[i];
      B[i + 1] = B[i] + b[i];
      C[i + 1] = C[i] + c[i];
   }
   REP(i, Q){
      cout << DMC(K[i]) << endl;
   }
}

Measured memory_bytes: 82948
import java.util.Scanner;

public class Main {

    public Main() {
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
   int     N = scan.nextInt();
 if(N==0){System.out.println("1");}
 else{System.out.println("0");}



    }
}


Measured memory_bytes: 27076
import java.math.BigInteger;
    import java.util.*;
    import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    TreeSet<Integer> l = new TreeSet<>();
    ArrayList<Integer> lList = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      int tmp = sc.nextInt();
      l.add(tmp);
      lList.add(tmp);
    }
    lList.sort(Comparator.naturalOrder());

    Map<Integer, Integer> indexMap = new HashMap<>();
    int pre = -1;
    for (int i = 0; i < n; i++) {
      if (pre != lList.get(i)) {
        indexMap.put(pre, i - 1);
        pre = lList.get(i);
      }
    }
    indexMap.put(lList.get(lList.size() - 1), lList.size() - 1);

    long result = 0;
    for (int i = 0; i < n; i++) {
      int a = lList.get(i);
      for (int j = i + 1; j < n; j++) {
        int b = lList.get(j);
        int sum = a + b;
        int max = l.headSet(sum).last();
        int maxIndex = indexMap.get(max);
        result += Math.max(maxIndex - j, 0);
      }
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 67400
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        
       List<Mgawa> list = new ArrayList<>();
       int x,y;
       
       while((x = sc.nextInt()) != 0 && (y =sc.nextInt()) != 0) list.add(new Mgawa(x,y));    
      
       for(Mgawa m : list){   // for(int i=0; i<list.size(); i++) ??
           m.pie();
           System.out.println();
       }
      
       
    }
    
    
}

class Mgawa{
    int x,y;
    Mgawa(int x, int y){
        this.x = x;
        this.y = y;
    }
            

public void pie() {
    
    for(int i=0; i<this.x; i++){
        for(int j=0; j<this.y; j++){
            
        if(i == 0 || i == this.x-1 || j == this.y-1 || j == 0){
            System.out.print("#");
        }else{
            System.out.print(".");
        }
        }
        
        System.out.println();
    }
    
    
}   
    
    
}   
        
    

       

   


        
    

       

   




Measured memory_bytes: 34920
unittest
{
	assert( [ "2 1" ].parse.expand.solve == 1 );
	assert( [ "4 3" ].parse.expand.solve == 9 );
	assert( [ "1 1" ].parse.expand.solve == 0 );
	assert( [ "13 3" ].parse.expand.solve == 81 );
	assert( [ "0 3" ].parse.expand.solve == 3 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	return tuple( nm[ 0 ], nm[ 1 ] );
}

auto solve( long n, long m )
{
	return n * ( n - 1 ) / 2 + m * ( m - 1 ) / 2;
}


Measured memory_bytes: 256
A,B,C,X,Y = map(int, open(0).read().split())

if (C * 2) < (A + B):
    n = min(X, Y)
    ans = (C * n * 2)
    x = X - n
    y = Y - n
    if x > 0:
        if A < C * 2:
            ans += x * A
        else:
            ans += x * C * 2
            y -= x
    if y > 0:
        if B < C * 2:
            ans += y * B
        else:
            ans += y * C * 2
else:
    ans = A * X + B * Y

print(ans)

Measured memory_bytes: 9152
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
S = [1] + [0] * (N-1)
sc = sorted(sc, key=lambda x: x[0])


def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]


if N != 1 and [1, 0] in sc:
    print(-1)
elif len(list(set([i[0] for i in sc]))) != len(list(get_unique_list(sc))):
    print(-1)
elif N == 1 and M == 0:
    print(0)
else:
    for i in sc:
        S[i[0]-1] = "{}".format(i[1])

    print(*S, sep="")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;
void chmax(int& a, int b) { a = max(a, b);}
void chmin(int& a,int b) {a = min(a,b);}

int main(){
    int h,w;cin >> h >> w;
    map<int,int> mp;
    multiset<int> m;
    rep(i,w) mp[i] = i;
    rep(i,w) m.insert(0);
    rep(i,h){
        int l,r;cin >> l >> r;
        --l;
        map<int,int>::iterator it = mp.lower_bound(l);
        int mr = -1;
        while(it != mp.end() && it->first <= r){
            mr = it->second;
            m.erase(m.find(it->first - it->second));
            mp.erase(it++);
        }
        if(mr != -1 && r < w) {
            mp[r] = mr;
            m.insert(r-mr);
        }
        int  ans = -1;
        if(m.size()>0) {
            ans = *m.begin() + (i+1);
        }
        cout << ans << endl;

    }
}

Measured memory_bytes: 22384
import sys

sys.setrecursionlimit(10000)

ERROR_INPUT = 'input is invalid'
OPECODE = ['+', '-', '*']
BUF = []


def main():
    stack = get_input()
    ans = calc_stack(stack=stack)
    print(ans)


def calc_stack(stack):
    if stack[-1] in OPECODE:
        BUF.append(stack[-1])
        stack.pop()
        return calc_stack(stack=stack)
    else:
        right_num = int(stack[-1])
        stack.pop()
        if stack[-1] in OPECODE:
            BUF.append(right_num)
            BUF.append(stack[-1])
            stack.pop()
            return calc_stack(stack=stack)
        else:
            left_num = int(stack[-1])
            stack.pop()
            stack.append(calc(left_num, right_num, BUF[-1]))
            BUF.pop()
            stack.extend(reversed(BUF))
            BUF.clear()

        if len(stack) == 1:
            return stack[0]
        else:
            return calc_stack(stack=stack)


def calc(left, right, ope):
    if ope == '+':
        return left + right
    elif ope == '-':
        return left - right
    elif ope == '*':
        return left * right


def get_input():
    inp = input().split(' ')
    opecode_count = 0
    OPECODE_count = 0

    for i in inp:
        if i in OPECODE:
            opecode_count += 1
        elif int(i) < 0 or int(i) > 10**6:
            print(ERROR_INPUT)
            sys.exit(1)
        else:
            OPECODE_count += 1

    if opecode_count < 1 or opecode_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    if OPECODE_count < 2 or OPECODE_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    return inp


main()

Measured memory_bytes: 11536
import collections as c
ip = lambda : map(int, input().split())

#################
s = input()
c0 = [0,0]
for n,i in enumerate(s):
    if n%2==0 and i=='0':
        c0[0] += 1
    elif n%2==1 and i=='1':
        c0[1] += 1
    
length = len(s)
print(min([sum(c0),length-sum(c0)]))

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;

int change(int n, int t, int f, int h, int fh){
    int sum = 10*t + 50*f + 100 * h + 500 * fh;
    if(sum < n)return -1;
    int c = sum - n, rt = 0, rf = 0, rh = 0, rfh = 0;
    if(c >= 500){
        rfh += c / 500;
        if(rfh > 0 && fh > 0)return -1;
        c -= rfh * 500;
    }
    if(c >= 100){
        rh += c / 100;
        if(rh > 0 && h > 0)return -1;
        c -= rh * 100;
    }
    if(c >= 50){
        rf += c / 50;
        if(rf > 0 && f > 0)return -1;
        c -= rf * 50;
    }
    if(c >= 10){
        rt += c / 10;
        if(rt > 0 && t > 0)return -1;
        c -= rt * 10;
    }
    assert(c == 0);
    assert(10*rt + 50*rf + 100*rh + 500*rfh == sum - n);
    return rt + rf + rh + rfh;
}

int main(){
    int n;
    bool flag = false;
    while(cin >> n, n != 0){
        if(flag)cout << endl;
        flag = true;
        int ten, fifty, hundred, five_hundred;
        cin >> ten >> fifty >> hundred >> five_hundred;
        int at = 0, af = 0, ah = 0, afh = 0, sum = INT_MAX;
        for(int t=0;t<=ten;++t){
            for(int f=0;f<=fifty;++f){
                for(int h=0;h<=hundred;++h){
                    for(int fh=0;fh<=five_hundred;++fh){
                        int res = change(n, t, f, h, fh);
                        if(res == -1)continue;
                        res += (ten-t+fifty-f+hundred-h+five_hundred-fh);
                        if(res < sum){
                            at = t;
                            af = f;
                            ah = h;
                            afh = fh;
                            sum = res;
                        }
                    }
                }
            }
        }
        if(at > 0)cout << "10 " << at << endl;
        if(af > 0)cout << "50 " << af << endl;
        if(ah > 0)cout << "100 " << ah << endl;
        if(afh > 0)cout << "500 " << afh << endl;
    }

    return 0;
}



Measured memory_bytes: 3028
#include <bits/stdc++.h>

using namespace std;

long x[3][1111];
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 3; j++)
			cin >> x[j][i];
	long r = 0;
	for (int i = 0; i < 8; i++) {
		long y[1111];
		for (int j = 0; j < n; j++)
			y[j] = x[0][j] * (1 - (i & 4) / 2) + x[1][j] * (1 - (i & 2)) + x[2][j] * (1 - (i & 1) * 2);
		nth_element(y, y + (n - m), y + n);
		long s = 0;
		for (int j = n - m; j < n; j++)
			s += y[j];
		r = max(r, s);
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
    uint64_t N, K;
    cin >> N >> K;

    uint64_t modK = 0;
    uint64_t modK2 = 0;
    if(K%2 == 1) {
        rep(i, N) {
            if( (i+1) % K == 0 )
                modK++;
        }
        cout << modK * modK * modK << endl;
    } else {
        uint64_t modK  = 0;
        rep(i, N) {
            if((i+1) % K == 0 )
                modK++;
            if((i+1) % K == (K/2))
                modK2++;
        }
        cout << modK * modK * modK + modK2 * modK2 * modK2 << endl;
    }

    return 0;
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define ll long long 

double r;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>r;
    cout<<2*3.14159265359*r;
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
	int x;
	cin >> x;
	int l = x / 500;
	int s = (x % 500) / 5;
	cout << l * 1000 + s * 5 << endl;

}

Measured memory_bytes: 256
# coding: utf-8

while True:
	try:
		data = map(int, raw_input().split())
		if data[0] > data[1]:
			a = data[0]
			b = data[1]
		else:
			a = data[1]
			b = data[0]
		
		r = 1
		while r > 0:
			q = a / b
			r = a - b * q
			a = b
			b = r
		gcd = a
		lcm = data[0] * data[1] / gcd

		print("{:} {:}".format(gcd, lcm))

	except EOFError:
		break

Measured memory_bytes: 4656
#include <iostream>
using namespace std;

int main(){
  int n, m, A[100][100], b[100], c[100];
    cin>>n>>m;
    for(int i=0; i<n; i++)
      for(int j=0; j<m; j++)cin>>A[i][j];
    for(int i=0; i<m; i++)cin>>b[i];

    for(int i=0; i<n; i++){
      c[i]=0;
      for(int j=0; j<m; j++){
        c[i] += A[i][j]*b[j];
      }
    }
    for(int i=0; i<n; i++)cout<<c[i] <<endl;
    return 0;
  }


Measured memory_bytes: 3124
def main():
    N, M = map(int, input().split())
    cnt = 0
    answer_list = [[] for _ in range(N)]
    for i in range(M):
        p, S = input().split()
        p = int(p) - 1
        answer_list[p].append(S)

    ac = 0
    wa = 0
    for answers in answer_list:
        tmp_wa = 0
        for a in answers:
            if a == 'AC':
                ac += 1
                wa += tmp_wa
                break
            else:
                tmp_wa += 1
    
    print(ac, wa)

    

if __name__ == "__main__":
    main()

Measured memory_bytes: 59168
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 998244353;
#define SIZE 1000010
vector<int>yak[1010101];
ll d[1010101];
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
int main()
{
	for (int i = 1; i <= 1000000; i++)for (int j = i; j <= 1000000; j += i)yak[j].push_back(i);
	int num;
	scanf("%d", &num);
	invinit();
	ll ans = 0;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		for (int j = 0; j < yak[z].size(); j++)d[yak[z][j]] += z;
		ans += mod - z;
	}
	for (int i = 1; i <= 1000000; i++)
	{
		d[i] %= mod;
		d[i] = d[i] * d[i] % mod;
	}
	for (int i = 2; i <= 1000000; i++)
	{
		if (yak[i].size() != 2)continue;
		for (int j = 1; j*i <= 1000000; j++)d[j] = (d[j] + mod - d[j*i]) % mod;
	}
	ans %= mod;
	for (int i = 1; i <= 1000000; i++)
	{
		//if (i <= 10)printf("%d %lld\n", i, d[i]);
		ans = (ans + d[i] * inv[i]) % mod;
	}
	printf("%lld\n", ans*(mod + 1) / 2 % mod);
}

Measured memory_bytes: 146936
# -*- coding: utf-8 -*-
 
import sys
 
primes = [2]
for i in range(3, 50022):
    flag = True
    for p in primes:
        if i % p == 0:
            flag = False
            break
    if flag:
        primes.append(i)
 
for line in sys.stdin:
    n = int(line)
    i = 0
    while primes[i] < n and i < len(primes):
        i += 1
    if primes[i] == n:
        s = primes[i-1]
        m = primes[i+1]
    else:
        s = primes[i-1]
        m = primes[i]
    print s, m

Measured memory_bytes: 7784
#include<iostream>
using namespace std;
int main(){
  string str;
  cin >> str;
  bool flag = 0;
  int i=0;
  while(1){
    if(str[i] == 'e'){
      if(str[i+1]== 'r' && str[i+2] == 'a' && str[i+3] == 's' && str[i+4] == 'e'){
        if(str[i+5] == 'r'){
          i += 6;
        }else if(str[i+5] == 'd'){
          i+= 5;
        }else if(str[i+5] == '\0'){
          break;
        }else{
          i+= 5;
        }
      }else{
        flag = true;
        break;
      }
    }else if(str[i] == 'd'){
      if(str[i+1]== 'r' && str[i+2] == 'e' && str[i+3] == 'a' && str[i+4] == 'm'){
        if(str[i+5] == 'e' && str [i+6] == 'r'){
          if(str[i+7] == 'a'){
            i+= 5;
          }else{
            i+=7;
          }
        }else{
          i+=5;
        }
      }else{
        flag = true;
        break;
      }
    }else if(str[i] == '\0'){
      break;
    }else{
      flag = true;
      break;
    }
  }
  if(flag == 0){
    cout << "YES";
  }else{
    cout << "NO";
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll N,Q;
  cin>>N>>Q;
  fenwick_tree<ll> fw(N);
  rep(i,N){
    ll a;
    cin>>a;
    fw.add(i,a);
  }
  rep(i,Q){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a==0) fw.add(b,c);
    else {
      cout<<fw.sum(b,c)<<endl;
    }
  }
}

Measured memory_bytes: 8212
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::min;

fn main() {
    input! {
        n: i64,
    }

    let mut ans = i64::max_value();

    for i in 1..(n as f64).sqrt() as i64 + 1 {
        if n % i == 0 {
            ans = min(ans, i + n / i - 2);
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
n = int(input())
ls = []
for i in xrange(0, n):
    ls.append(int(input()))
sls = sorted(ls)
st = {j for i, j in enumerate(ls) if i % 2 == 1}
sst = {j for i, j in enumerate(sls) if i % 2 == 1}
print(len(st.difference(sst)))

Measured memory_bytes: 13436
#include <bits/stdc++.h> 
    //#define M_PI 3.14159265358979323846



using namespace std;
#define M 1000000007
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repb(i,a,b) for(int i=a;i>=b;--i)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();++it)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define vc vector<char>
#define sz(a) (int)a.size()
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define ssortB(arr)   stable_sort(arr.begin(),arr.end(),greater<ll >());
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define fi first
#define se second
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define mp make_pair
#define endl "\n" 
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
 
 int main(){
     string s;
     cin>>s;
     int sum=0;
     rep(i,0,sz(s)){
         sum+=s[i]-'0';
     }
     if(sum%9==0)cout<<"Yes"<<endl;
     else cout<<"No"<<endl;
 }

Measured memory_bytes: 3744
#include<stdio.h>
#include<math.h>
main()
{
	long long int n,i,d;
	int t=0;
	scanf("%lld%lld",&n,&d);
	for(i=1;i<=n;i++)
	{
		long long int a,b;
		scanf("%lld%lld",&a,&b);
		double c=sqrt(a*a + b*b);
		if(c<=d)
		{
			t=t+1;
		}
	}
	printf("%d\n",t);
}


Measured memory_bytes: 2152
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  cin >> n;
  for(int i = 1; i <= 9; i++)
  {
    for(int j = 1; j <= 9; j++)
    {
		if(n == i * j)
        {
          cout << "Yes" << endl;
          return 0;
        }	
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//Hang in there!

using namespace std;


int main() {
	int N, X;
	cin >> N >> X;
	vector<int>data(N);
	int ans = N;
	for (int i = 0; i < N; i++) {
		cin >> data[i];
		X -= data[i];
	}
	sort(data.begin(), data.end());
	ans += X / data[0];
	cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;


clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
  fastio
  ll n,i,j,k;
  string s;

  ll a,b;
  cin >> n >> a >> b;
  cout << min(n *a, b) << '\n';

  ktj();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

typedef pair<int, int> P;
int main(){
    long long n,m;
    cin>>n>>m;
    vector<long long> ans;
    long long a[m];
    rep(i,m){
        cin>>a[i];
    }
    ans.push_back(1);
    long long p=0;
    if(a[0]==1){
       p++; 
       ans.push_back(0);
    }
    else{
        ans.push_back(1);
    }
    
    for(int i=2; i<=n; i++){
        if (a[p]==i){
            p++;
            ans.push_back(0);
        }
        else{
            long long c1=ans[i-1];
            long long c2=ans[i-2];
            ans.push_back((c1+c2)%1000000007);
            }
    }
    cout<<ans[ans.size()-1]<<endl;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int n, k;
    cin >> n >> k;

    vi h(n);
    
    rep(i, n) {
        cin >> h[i];
       
    }
    GSORT(h);

    int sum = 0;
    FOR(i, k, n) {
        sum += h[i];
    }

    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
  
 int main(){
    int a[4],b[4],hit,blow,i,j;
    while(std::cin>>a[0]){
    for(i=1;i<4;i++){
    std::cin>>a[i];
    }for(i=0;i<4;i++){
    std::cin>>b[i];
    }
    hit=0;
    blow=0;
    for(i=0;i<4;i++){
        for(j=0;j<4;j++){
            if(i==j&&a[i]==b[j]){
            hit++;
            }if(i!=j&&a[i]==b[j]){
            blow++;
            }
        }
    }
    std::cout<<hit<<" "<<blow<<std::endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import sys
sys.setrecursionlimit(1000000)
def main():
    N, X = (int(_) for _ in input().split())

    ex2 = []
    num = 1
    for i in range(51):
        ex2.append(num)
        num *= 2

    def Height(L):
        return 4 * ex2[L] - 3

    def TotalPatty(L):
        return 2 * ex2[L] - 1

    def NumPatty(L, x):
        M = Height(L)
        m = (M+1)//2
        if x == 1:
            if L == 0: return 1
            else: return 0
        elif x == m: return TotalPatty(L-1) + 1
        elif x == M: return 2*TotalPatty(L-1) + 1
        elif 1 < x < m: return NumPatty(L-1, x-1)
        else: return TotalPatty(L-1) + 1 + NumPatty(L-1, x-(Height(L-1)+2))

    print(NumPatty(N, X))
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
from math import gcd

def threegcd(a, b, c):
    return gcd(gcd(a,b), c)

k = int(input())

ans = 0

for i in range(1, k+1):
    for j in range(1, k+1):
        for k in range(1, k+1):
            ans += threegcd(i, j, k)

print(ans)

Measured memory_bytes: 68172
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define ull unsigned long long
using namespace std;
void io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

const int MAXN = 1e5 + 5;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9 + 7;

int N, K;
ll fact[MAXN];
ll infact[MAXN];
ll dp[MAXN];
vector<int> g[MAXN];

ll ppow(ll base, int t) {
    ll ans = 1;
    while (t) {
        if (t & 1) {
            ans = (ans * base) % MOD;
        }
        base = (base * base) % MOD;
        t >>= 1;
    }
    return ans;
}

void init_inv() {
    fact[0] = 1;
    for (int i = 1; i < MAXN; i++) {
        fact[i] = (fact[i - 1] * i) % MOD;
    }
    infact[MAXN - 1] = ppow(fact[MAXN - 1], MOD - 2);
    for (int i = MAXN - 2; i >= 0; i--) {
        infact[i] = (infact[i + 1] * (i + 1)) % MOD;
    }
}

ll C(int n, int m) {
    if (n < m) {
        return 0;
    }
    return fact[n] * infact[m] % MOD * infact[n - m] % MOD;
}

void dfs(int fa, int u, int dep) {
    ll A = 1;
    int cnt = 0;
    for (int v : g[u]) {
        if (v != fa) {
            dfs(u, v, dep + 1);
            A = (A * dp[v]) % MOD;
            cnt++;
        }
    }
    int n = dep ? K - 2 : K - 1;
    dp[u] = C(n, cnt) * fact[cnt] % MOD * A % MOD;
}

int main() {
    io();
    cin >> N >> K;
    init_inv();
    for (int i = 0; i < N - 1; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(0, 1, 0);
    cout << (dp[1] * K) % MOD;
}


Measured memory_bytes: 18476
#include <iostream>

using namespace std;

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << ((i < b && j < a) != (b <= i && a <= j) ? "0" : "1");
        }
        cout << endl;
    }
}


Measured memory_bytes: 1280
#include <stdio.h>
int main (void)
{
    char a[150][150]={0};
    int H;
    int W;
    int i,j;

    scanf("%d",&H);
    scanf("%d",&W);

    for(i=0;i<H;i++){
       a[i][j] = 0;
    }
    for(i=0;i<H;i++){
       scanf("%s",&a[i]);
    }
    
   for(i=0;i<H;i++){
        printf("%s\n",&a[i]);
        printf("%s\n",&a[i]);
   }

    return 0;
}

  

Measured memory_bytes: 256
s = input()
l = list(s)
sum_ = 0
for i in range(1 << len(l) -1):
    ll = []
    for j in range(len(l)):
#         print(i,j)
        ll +=[l[j]]
        if i & (1 << j):
            ll +=['+']
#     print(''.join(ll))    
    sum_ += eval(''.join(ll))
print(sum_)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

signed compare(const void *a, const void *b){
	return *(int *)a - *(int *)b;
}

int main(){
	int N, M, i;
	scanf("%d%d", &N, &M);
	int *X = (int *)malloc(sizeof(int) * M);
	for(i = 0; i < M; i++){
		scanf("%d", &X[i]);
	}
	if(N >= M){
		printf("0\n");
		return 0;
	}
	qsort(X, M, sizeof(int), compare);
/*	for(i = 0; i < N; i++){
		printf("X[%d] = %d\n", i, X[i]);
	}
*/	int *sub = (int *)malloc(sizeof(int) * (M - 1));
	for(i = 1; i < M; i++){
		sub[i - 1] = X[i] - X[i - 1];
//		printf("sub[%d] = %d\n", i - 1, sub[i - 1]);
	}
	qsort(sub, M - 1, sizeof(int), compare);
	int ans = 0;
	for(i = 0; i < M - N; i++){
		ans += sub[i];
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1396
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;
using ll  = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(i, ini));
    return move(vec);
}
template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}


int main() {
    int N = In<int>();
    vector<int> p(N), q(N);
    for(int i = 0; i < N; i++){
        q[i] = p[i] = In<int>();
    }
    sort(p.begin(), p.end());
    int cntP = 0, cntQ = 0;
    for(int i = 0; i < N; i++) {
        if(q[i] < p[i])
            cntP++;
        else if(q[i] > p[i])
            cntQ++;
    }
    if((cntP==0 && cntQ==0)||(cntP==1)&(cntQ==1)){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{
	int N, sum = 0;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	if (sum % (N * (N + 1) / 2) == 0) {
		bool flag = true;
		int d = sum / (N * (N + 1) / 2), cnt = 0;
		for (int i = 1; i <= N; i++) {
			if ((A[i - 1] - A[i % N] + d + N * 1000000000) % N != 0 || (A[i - 1] - A[i % N] + d) / N < 0) {
				flag = false;
				break;
			}
			else {
				cnt += (A[i - 1] - A[i % N] + d) / N;
			}
		}
		cout << (flag && cnt == d ? "YES" : "NO") << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 1152
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
K = int(input())
 
 
ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
           
 
                ans += gcd(i+1,j+1,k+1)
            #1-Kまで
print(ans)
 

Measured memory_bytes: 69592
N = int(input())

a = [0] * 4

for i in range(N):
  result = input()
  if (result == 'AC'):
    a[0] += 1
  elif (result == 'WA'):
    a[1] += 1
  elif (result == 'TLE'):
    a[2] += 1
  else:
    a[3] += 1

print('AC x {0}\nWA x {1}\nTLE x {2}\nRE x {3}'.format(a[0], a[1], a[2], a[3]))

Measured memory_bytes: 9204
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int x=scan.nextInt();
        String mOperator=scan.next();
        int y=scan.nextInt();
        
        while(!(mOperator.equals("?"))){
            switch(mOperator){
                case "+":
                    System.out.println(x+y);
                break;
                case "-":
                    System.out.println(x-y);
                break;
                case "*":
                    System.out.println(x*y);
                break;
                case "/":
                    System.out.println(x/y);
                break;
            }
        x=scan.nextInt();
        mOperator=scan.next();
        y=scan.nextInt();
        }
    }
}


Measured memory_bytes: 26144
#include <bits/stdc++.h>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int , int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18 

int main() {
    ll a, b ;
    cin >> a >> b ;
    ll k = a + b;
    if(k % 2 == 1){
        cout << "IMPOSSIBLE" << endl ;
    }
    else {
        cout << k / 2 << endl ;
    }
}


Measured memory_bytes: 3560
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int a, b, c;
	
	while(cin >> a >> b){
		a += b;
		c = 1;
		for(int i = 10; i <= a;i *= 10, c++);
		cout  << c << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  char a,b;
  cin>>a>>b;
  if(a=='H' && b=='H')cout<<'H';
  else if(a=='D'&& b=='D')cout<<'H';
  else if(a=='D' && b=='H')cout<<'D';
  else cout<<'D';
}


Measured memory_bytes: 256
n,m = map(int,input().split())
k = []
s = []
for _ in range(m):
    tmp = list(map(int,input().split()))
    k.append(tmp[0])
    s.append(tmp[1:])
p = list(map(int,input().split()))
ans = 0
for i in range(2**n):
    b = format(i, '0'+str(n)+'b')
    for j in range(m):
        cnt = 0
        for l in range(k[j]):
            cnt += int(b[s[j][l]-1])
        if cnt%2 != p[j]:
            break
    else:
        ans += 1
print(ans)



Measured memory_bytes: 3064
l,r = map(int, input().split())
if r - l > 2018:
  print(0)
else:
  a = []
  min_a = 10**9
  for i in range(r-l+1):
    a.append((l+i)%2019)
  for i in range(len(a)):
    for j in range(1,len(a)-i):
      min_a = min(min_a,(a[i]*a[i+j])%2019)
#      print(i,j,(a[i]*a[i+j])%2019)
  print(min_a)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int max,min;
	if(a>b)max=a,min=b;else max=b,min=a;
	if(max<c)cout<<min<<" "<<max<<" "<<c<<endl;
	else if(min>c)cout<<c<<" "<<min<<" "<<max<<endl;
	else cout<<min<<" "<<c<<" "<<max<<endl;
	return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;

bool f(int a, int b, int c) {
  return ( a == b && a != c ?
          true : false);
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (f(a, b, c) || f(c, a, b) || f(b, c, a) ?
    "Yes" : "No");
}


Measured memory_bytes: 3632
main = do
  [n,_,x] <- map read . words <$> getLine
  as <- map read . words <$> getLine
  let s1 = length (filter (\y -> x<y&&y<=n) as)
      s2 = length (filter (\y -> 0<y&&y<x) as)
    in putStrLn $ show $ min s1 s2


Measured memory_bytes: 1020
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll dp[1003][1003];

int main() {
  ll h, w, ans = 0;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  dp[0][0] = 1;

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (i - 1 >= 0 && s[i][j] == '.')
        dp[i][j] += dp[i - 1][j], dp[i][j] %= mod;
      if (j - 1 >= 0 && s[i][j] == '.')
        dp[i][j] += dp[i][j - 1], dp[i][j] %= mod;
    }
  }

  cout << dp[h - 1][w - 1] << endl;
  return 0;
}


Measured memory_bytes: 9088
A, V = list(map(int, input().strip().split()))
B, W = list(map(int, input().strip().split()))
T = int(input().strip())
ans = None

speed = V-W
if speed<=0:
  ans = 'NO'
else:
  distance = abs(A-B)
  if distance <= speed*T:
    ans = 'YES'
  else:
    ans = 'NO'

print(ans)

Measured memory_bytes: 9148
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
int x , t;
cin >> x >> t;
int k = x - t;
if(k >= 0)cout << k << endl;
else cout << 0 << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t; cin>>t;
    rep(_,t){
        ll n,m,a,b; cin>>n>>m>>a>>b;
        printf("%lld\n",floor_sum(n,m,a,b));
    }
}

Measured memory_bytes: 3780
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int[] a = new int[n];


		for(int i=0;i<n;i++) {
			a[i] = sc.nextInt();
		}

		int x = 0;

		for(int i=0;i<a.length;i++) {

			while(a[i]%2==0) {
				if(a[i] % 2 ==0) {
					a[i] /= 2;
					x++;
				}
			}
		}

		System.out.println(x);
	}
}


Measured memory_bytes: 35028
# -*- coding: utf-8 -*-

N,K=map(int,input().split())
A=input().split()
A=[int(a) for a in A]

P=0
L=[0]*int(N+1)
D=[0]*int(N+1)
c=0
R=0
while(1):
    c+=1
    P=A[P]-1
    L[c]=P
    if D[P]>0: 
        R=D[P]
        break
    D[P]=c
    if P==0: break
    

if K < R:
    ans=L[K]+1
else:
    K-=R
    K%=(c-R)
    ans=L[R+K]+1

print(ans)

Measured memory_bytes: 32488
#include <bits/stdc++.h>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;

    for (int i = M / N + 1; i >= 1; --i) {
        if (M % i == 0) {
            int k = M / i;
            if (k >= N) {
                cout << M / k << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int n;
string s;
bool solve(int p, int q) {
	vector<int> a(n);
	a[0] = p, a[1] = q;
	repl(i, 1, n - 1) {
		if (a[i] == 1) {
			if (s[i] == 'o')
				a[i + 1] = 1 - a[i - 1];
			else
				a[i + 1] = a[i - 1];
		} else {
			if (s[i] == 'o')
				a[i + 1] = a[i - 1];
			else
				a[i + 1] = 1 - a[i - 1];
		}
	}
	if (a[n - 1] == 1) {
		if (s[n - 1] == 'o' and a[n - 2] == a[0]) return false;
		if (s[n - 1] == 'x' and a[n - 2] != a[0]) return false;
	} else {
		if (s[n - 1] == 'o' and a[n - 2] != a[0]) return false;
		if (s[n - 1] == 'x' and a[n - 2] == a[0]) return false;
	}
	if (a[0] == 1) {
		if (s[0] == 'o' and a[n - 1] == a[1]) return false;
		if (s[0] == 'x' and a[n - 1] != a[1]) return false;
	} else {
		if (s[0] == 'o' and a[n - 1] != a[1]) return false;
		if (s[0] == 'x' and a[n - 1] == a[1]) return false;
	}
	rep(i, n) {
		if (a[i] == 0)
			cout << 'S';
		else
			cout << 'W';
	}
	cout << endl;
	return true;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	cin >> n >> s;
	rep(i, 2) rep(j, 2) {
		if (solve(i, j)) return 0;
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 4208
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<cstdint>
using namespace std;

const uint64_t kMax = UINT64_MAX;

int main()
{
  uint64_t l, r;

  cin >> l >> r;
  if (r - l >= 2019) {
    cout << "0";
    return 0;
  }
  uint64_t m = kMax;
  for (uint64_t i = l; i < r; ++i) {
    for (uint64_t j = i + 1; j <= r; ++j) {
      m = min(m, (i * j) % 2019);
    }
  }
  cout << m;

  return 0;
}





Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)

q = [0] * N
start = 0
end = 0
for i in range(N):
    q[i] = A[i] * F[i]
    end = max(end, q[i])

def check(now, K):
    cnt = 0
    for i in range(N):
        if q[i] - now > 0:
            cnt += (q[i] - now + F[i] - 1) // F[i]
            if cnt > K:
                return False
    return True

now = end // 2
while end > start + 1:
    if check(now, K):
        end = now
    else:
        start = now
    now = (start + end) // 2

if check(start, K):
    print(start)
else:
    print(end)


Measured memory_bytes: 119500
#include <iostream>
#include <vector>

using namespace std;

char alp[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int getIndex(char x) {
	for (int i = 0; i < 26; i++) {
		if (x == alp[i]) return i;
	}
}
int getConvIndex(int i) {
	if (i < 0)
		return 26 + i;
	else
		return i;
}

int main()
{
	char orgStr[1000];
	vector<char> covStr;

	cin >> orgStr;

	for (int i = 0; orgStr[i] != '\0'; i++) {
		covStr.push_back(alp[getConvIndex(getIndex(orgStr[i]) - 3)]);
	}
	
	for (int i = 0; i < covStr.size(); i++) {
		cout << covStr[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using  namespace std;
typedef long long ll;

int main()
{
  int n;
  ll x;
  cin >> n >> x;
  ll p[n+1], b[n+1], l[n+1];
  p[0] = 1;
  b[0] = 0;
  rep(i, n) p[i+1] = 2 * p[i] + 1;
  rep(i, n) b[i+1] = 2 * b[i] + 2;
  rep(i, n+1) l[i] = p[i] + b[i];

  ll ans = 0;
  while (n > 0 && x > 0) {
    ll mid = l[n-1] + 2;
    if (x < mid) {
      --x;
    }
    else {
      ans += p[n-1] + 1;
      x -= mid;
    }
    --n;
  }

  if (x > 0) ++ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256