akhauriyash/Code-Regression huggingface dataset:
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {

	int a, b;
	cin >> a >> b;
	a = a == 1 ? 14 : a;
	b = b == 1 ? 14 : b;
	if (a < b)cout << "Bob";
	else if (a > b)cout << "Alice";
	else cout << "Draw";

	return 0;
}





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


template<typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
    static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string ret;
    static numeric_limits<TypeInt> t;
    TypeInt n = v;
    if (t.is_signed) {
        if (v < 0) n *= -1;
    }

    while (n >= base) {
        ret += table[n%base];
        n /= base;
    }
    ret += table[n];
    if (t.is_signed) {
        if (v < 0 && base == 10) ret += '-';
    }
    // 文字列の順番を逆にする
    std::reverse(ret.begin(), ret.end());

    return ret;
}
int main(void)
{
    int n;
    int K;
    cin >> n >> K;
    string s = Itoa(n, K);
    
    cout << s.size() << endl;
    
}



Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    N = int(input())
    queries = [input().split() for _ in range(N)]

    class Node():
        def __init__(self, val):
            self.val = val
            self.left = None
            self.right = None

    class BinaryTree():
        def __init__(self):
            self.root = None

        def insert(self, val):
            if self.root == None:
                self.root = Node(val)
                # print('insert to root', val)
            else:
                # print('insert', val)
                node = self.root
                is_search = True
                while is_search:
                    # print('try insert to ', node.val)
                    if val <= node.val:
                        if node.left:
                            node = node.left
                        else:
                            node.left = Node(val)
                            is_search = False
                    else:
                        if node.right:
                            node = node.right
                        else:
                            node.right = Node(val)
                            is_search = False


        def show_inorder(self, node):
            if node == None:
                return

            self.show_inorder(node.left)
            print('', node.val, end='')
            self.show_inorder(node.right)


        def show_preorder(self, node):
            if node == None:
                return

            print('', node.val, end='')
            self.show_preorder(node.left)
            self.show_preorder(node.right)

    bt = BinaryTree()

    for query, *val in queries:
        if query == 'insert':
            value = int(val[0])
            bt.insert(value)
        else:
            bt.show_inorder(bt.root)
            print('')
            bt.show_preorder(bt.root)
            print('')



if __name__ == "__main__":
    resolve()



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

  ll N = 0, M = 0,T = 0;
  cin >> N >> M >> T;
  ll ans = 0;
  while(N > 0){
    ans += T;
    N -= M;
  }
  cout << ans;
}

Measured memory_bytes: 3616
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def main():
    n, k = list(map(int, input().split()))
    h = list(map(int, input().split()))
    h.sort(reverse=True)
    print(sum(h[k:]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 28432
#include <iostream>
using namespace std;
int main(){
    string s;
    cin>>s;

    int divisor = 2019;
    int rem_count[2019] = {1};
    int num = 0;
    int pow10 = 1;
    int total = 0;

    int charac[s.length()];
    for(int i=0;i<s.length();i++){
        charac[i]=s[i]-48;
    }
    for(int i=s.length()-1;i>=0;i--){
        int dig = charac[i];
        num += dig*pow10;
        int rem = num%divisor;
        total += rem_count[rem];
        pow10 *=10;
        rem_count[rem] +=1;

        num=rem;
        pow10%=divisor;

    }

    cout<<total;
}

Measured memory_bytes: 3940
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
ll k;
queue<ll>st;

void solve(){
    cin >> k;
    for(int i=1;i<10LL;++i)
        st.push(i);
    for(int i=0;i<k;++i) {
        ll f = st.front();
        st.pop();
        if(i == k-1) 
            cout << f << "\n";
        if(f%10LL!=0)
            st.push(10LL*f + (f%10LL) - 1);
        st.push(10LL*f + (f%10LL));
        if(f%10LL!=9)
            st.push(10LL*f + (f%10LL) + 1);
    }
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    while(t--)
        solve();
    return  0;
}


Measured memory_bytes: 4712
#include <bits/stdc++.h>
 using namespace std;
 
int main() {
 int P = -1, Q, count = 0;
 int A[21];
 int B[21];
 int C[21];
  int N;
  cin >> N;
  for(int i=1;i<=N;i++){
    cin >> A[i];
  }
  for(int i=1;i<=N;i++){
    cin >> B[i];
  }
  for(int i=1;i<N;i++){
    cin >> C[i];
  }
  
  for(int i=1;i<=N;i++){
    Q = A[i];
    count += B[Q];
    if(P == Q - 1){
      count += C[P];
    }
    P=Q;
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 3596
import sys
from collections import deque


input = sys.stdin.readline
h, w = map(int, input().split())
a = [input() for i in range(h)]

visited = [[False]*w for i in range(h)]
q = deque([])
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            q.append((i, j, 0))
            visited[i][j] = True
ans = 0
while q:
    i, j, times = q.popleft()
    ans = max(times, ans)
    for next_i, next_j in [(i+1, j), (i-1, j), (i, j+1), (i, j-1)]:
        if 0 <= next_i < h and 0 <= next_j < w and not visited[next_i][next_j]:
            visited[next_i][next_j] = True
            q.append((next_i, next_j, times + 1))
print(ans)

Measured memory_bytes: 134876
#include<iostream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

struct Maya{
  vector<int> v;
  Maya():v(5,0){
  }
  void fix(){
    v[3]+=v[4]/20;
    v[4]%=20;
    v[2]+=v[3]/18;
    v[3]%=18;
    v[1]+=v[2]/20;
    v[2]%=20;
    v[0]+=v[1]/20;
    v[1]%=20;
    v[0]%=13;
  }
  void inc(){
    v[4]++;
    fix();
  }
};

struct AD{
  vector<int> v;
  AD():v{2012,12,21}{
  }
  void inc(){
    const static int dom[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    v[2]++;
    if(v[2]>dom[v[1]]+(v[1]==2&&(v[0]%400==0||v[0]%100!=0&&v[0]%4==0))){
      v[2]=1;
      v[1]++;
      if(v[1]>12){
	v[1]=1;
	v[0]++;
      }
    }
  }
};
    
       
int main(){
  for(string s;getline(cin,s),s[0]!='#';){
    replace(begin(s),end(s),'.',' ');
    stringstream ss(s);
    vector<int> v;
    for(int i;ss>>i;){
      v.push_back(i);
    }
    vector<int> ans;
    if(v.size()==5){
      Maya m;
      AD a;
      while(m.v!=v){
	m.inc();
	a.inc();
      }
      ans=a.v;
    }else{
      Maya m;
      AD a;
      while(v[0]-a.v[0]>400){
	a.v[0]+=400;
	m.v[4]+=400*365+97;
	m.fix();
      }
      while(a.v!=v){
	a.inc();
	m.inc();
      }
      ans=m.v;
    }
    for(int i=0;i<ans.size();i++){
      cout<<ans[i]<<((i+1==ans.size())?'\n':'.');
    }
  }
}

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

int main() {
  int N;
  cin>>N;
  int H[N];
  for(int k=0;k<N;k++) cin>>H[k];
  long long ans=0;
  int reg;
  for(int i=0;i<N;i+=reg){
    reg=0;
    for(int j=i;j<N-1;j++){
      if(H[j]>=H[j+1]){
        reg++;
        if(j==N-2){
          if(ans<reg) ans=reg;
        }
      }
      else{
        if(ans<reg) ans=reg;
        break;
      }
    }
    reg++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 200;
const int M = 100;

main(){
  int d, n, t[N], a[N], b[N], c[N], dp[N][M+1], ans = 0;
  cin >> d >> n;
  for(int i=0;i<d;i++) cin >> t[i];
  for(int i=0;i<n;i++) cin >> a[i] >> b[i] >> c[i];
  fill(dp[0], dp[N], -1);
  for(int i=0;i<n;i++) if(a[i] <= t[0] && t[0] <= b[i]) dp[0][c[i]] = 0;
  for(int i=1;i<d;i++){
    for(int j=0;j<=M;j++){
      if(dp[i-1][j] == -1) continue;
      for(int k=0;k<n;k++){
        if(a[k] <= t[i] && t[i] <= b[k]){
          int tmp = dp[i-1][j] + abs(c[k] - j);
          if(dp[i][c[k]] < tmp) dp[i][c[k]] = tmp;
        }
      }
    }
  }
  for(int i=0;i<=M;i++) ans = max(ans, dp[d-1][i]);
  cout << ans << endl;
}

Measured memory_bytes: 1240
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N=in();
	auto A=vecin(N);
	int M=in();
	auto B=vecin(M);
	vector<int> C;
	set_difference(ALL(A),ALL(B),back_inserter(C));
	
	for(auto& x:C){
		out(x);
	}
	return 0;
}


Measured memory_bytes: 5392
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++) 
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
const int MAX = 1e6 + 100;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=998244353;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n<0)return 0;if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
#define all(x) x.begin(),x.end()
#define Return(x) {cout << x << endl; return 0;}

int__ main() {
    fast;
    int n; cin >> n;
    vi a(n);

    for(int i=0;i<n;i++) cin >> a[i];

    vi p = a;

    for(int i=1;i<n;i++) p[i] += p[i-1];

    vvi dp(n, vi (n,1e16));

    for(int i=n-1;i>=0;i--) {
        for(int j=i;j<n;j++) {
            if(i == j) {
                dp[i][j] = 0;
            }
            else {
                for(int k=i;k<j;k++) {
                    dp[i][j] = min(dp[i][k] + dp[k+1][j],dp[i][j]);
                }
                dp[i][j] += p[j];
                if(i > 0) dp[i][j] -= p[i-1];
            }
        }
    }   

    cout << dp[0][n-1] << endl; 

}

Measured memory_bytes: 1536
#include <stdio.h>

int main(void)
{
	int n, ac, wa, tle, re, i;
	char buf[16];

	scanf("%d", &n);

	ac = wa = tle = re = 0;

	for (i = 0; i < n; i++)
	{
		scanf("%s", buf);
		if (buf[0] == 'A') ac++;
		else if (buf[0] == 'W') wa++;
		else if (buf[0] == 'T') tle++;
		else if (buf[0] == 'R') re++;
	}

	printf("AC x %d\n", ac);
	printf("WA x %d\n", wa);
	printf("TLE x %d\n", tle);
	printf("RE x %d\n", re);

	return 0;
}


Measured memory_bytes: 1700
H,N =map(int, input().split())
a = [] 
M = 0 
for i in range(N):
	t = list(map(int, input().split()))
	a.append(t)
	M = max(M,t[0])
dp = [100000000]*(H+1+M)
dp[0] = 0
for i in range(H):
	for j,k in a:
		dp[i+j] = min(dp[i+j],dp[i]+k)

print(min(dp[H:]))

Measured memory_bytes: 41836
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int H, W;
int N;
VI Xs[200011];

void MAIN() {
    scanf("%d%d%d", &H, &W, &N);
    REP (i, N) {
	int x, y;
	scanf("%d%d", &x, &y);
	Xs[y].push_back(x);
    }
    REP (i, W+1) sort(Xs[i].begin(), Xs[i].end());


    int ans = 1<<29;
    int step = 0;
    int curX = 1, curY = 1;
    while (1) {

	int k = upper_bound(Xs[curY].begin(), Xs[curY].end(), curX) - Xs[curY].begin();
	int nxtX;
	if (k == (int)Xs[curY].size()) {
	    nxtX = H+1;
	} else {
	    nxtX = Xs[curY][k];
	}

	amin(ans, step + nxtX - curX);

	if (curX+1 == nxtX) break;
	step++;
	curX++;

	if (curY == W) break;

	k = lower_bound(Xs[curY+1].begin(), Xs[curY+1].end(), curX) - Xs[curY+1].begin();
	if (k == (int)Xs[curY+1].size() || curX < Xs[curY+1][k]) {
	    curY++;
	}
    }

    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 8704
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

const int INF = (int)1e9;

int main(){
  int q,c,a,n;

  scanf("%d",&q);
  
  for(int i=0;i<q;i++){
    int ans = 0;
    scanf("%d%d%d",&c,&a,&n);

    while(1){
      if(c>0 && a>0 && n>0){
	ans ++;
	c-=1;
	a-=1;
	n-=1;
      }else{
	break;
      }
    }

    while(1){
      if(c>1 && a>0){
	ans ++;
	c-=2;
	a-=1;
      }else{
	break;
      }
    }

    while(1){
      if(c>2){
	ans ++;
	c-=3;
      }else{
	break;
      }
    }

    cout << ans << endl;
  }
  
  return 0;
}

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

const ll mo = pow(10,9) + 7;

ll fac(ll a,ll b){
    if (b == 0) return 1;
    ll ret = 1;
    ll mul = a+b;
    for(ll i=0; i<b; i++){
        ret *= mul;
        ret %= mo;
        mul--;
    }
    return ret;
}

ll mod(ll a,ll m){
    ll b = m,u = 1, v = 0;
    while(b){
        ll t = a/b;
        a -= t * b; swap(a,b);
        u -= t * v; swap(u,v);
    }
    u %= m;
    if(u < 0) u+= m;
    return u;
}


int main() {
    ll x,y;
    cin >> x >> y;
    if((x+y)%3 != 0){
        cout << 0 << endl;
        return 0;
    }
    ll move = (x+y)/3;
    x -= move; y -= move;
    if(x < 0 || y < 0){
        cout << 0 << endl;
        return 0;
    }
    ll ans;
    if(x < y) swap(x,y);
    ans = fac(x,y);
    for(ll i=1; i<=y; i++){
        ans *= mod(i,mo);
        ans %= mo;
    }
    cout << ans << endl;
}

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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
// #define int long long

typedef pair<int,int> pii;
const int N = 80+5;
const int INF = 1e9;
const int MOD = 1e9+7;
const int MAX_VALUE = (N+N)*N;

int n, m, a[N][N], b[N][N];
bool f[N][N][MAX_VALUE];
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> m;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			cin >> a[i][j];
		}
	}
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			cin >> b[i][j];
		}
	}
	f[0][1][0] = 1;
	f[1][0][0] = 1;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			for(int k=0; k<MAX_VALUE; k++){
				f[i][j][k] = f[i-1][j][abs(k-abs(a[i][j]-b[i][j]))];
				f[i][j][k] |= f[i-1][j][k+abs(a[i][j]-b[i][j])];
				f[i][j][k] |= f[i][j-1][abs(k-abs(a[i][j]-b[i][j]))];
				f[i][j][k] |= f[i][j-1][k+abs(a[i][j]-b[i][j])];
			}
		}
	}
	for(int k=0; k<MAX_VALUE; k++){
		if (f[n][m][k]) {
			cout << k << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 97408
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	string S;
	cin >> S;

	int result = 0;
	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] == '1') result++;
	}

	cout << result;

	return 0;
}

Measured memory_bytes: 3652
from collections import Counter

N, M = map(int, input().split())
L = []
R = []

for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

maxL = max(L)
minR = min(R)

ans = max(0, minR - maxL + 1)
print(ans)

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache

import heapq


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

K = inputI()
A,B = inputIL()

for i in range(A,B+1):
  if i%K == 0:
    print("OK")
    exit()
    
print("NG")

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;  cin >> n >> k;
    int t = 1;
    rep(i, n) {
      if (t * 2 >= t + k) {
        t += k;
      } else {
        t *= 2;
      }
    }
    cout << t << '\n';

    return 0;
}


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

using namespace std;
#define PI              3.1415926536

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define REP(i,n) for(i=0;i<n;i++)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

bool f(int x, int y)
{
	return x > y;
}
void c_p_c()
{
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int n, m;
int a[100][100];
int vis[100][100];
int x;
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
bool safe(int x, int y)
{
	return (x >= 0 && y >= 0 && x < n && y < m && vis[x][y] == 0 && a[x][y] == 1);
}
void dfs(int i, int j)
{
	x++;

	vis[i][j] = 1;
	int k;
	for (k = 0; k < 8; k++)
	{
		int p = i + dx[k];
		int q = j + dy[k];
		if (safe(p, q) )
			dfs(p, q);
	}


}

int32_t main()
{
	
	int n;
	cin >> n;
	int i, j, k;

	int a[n];

	for (i = 0; i < n; i++)
		cin >> a[i];

	int c = 0;
	for (i = 0; i < n; i++)
	{
		for (j = i + 1; j < n; j++)
		{
			for (k = j + 1; k < n; k++)
			{
				if (a[i] == a[j] || a[i] == a[k] || a[j] == a[k]) {
					continue;
				}
				else {
					if (
					    a[i] + a[j] > a[k]
					    && a[i] + a[k] > a[j]
					    && a[k] + a[j] > a[i]) {

						c++;
					}

				}
			}
		}
	}
	cout << c;

}





Measured memory_bytes: 3620
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val N = rd.readInt()
    val S = rd.readString()
    val c = S.toCharArray()
    
    var l = 0; var r = N-1
    var swap = 0
    while (l < r) {
        while (l<N-1 && c[l] == 'R') l++
        while (0<r && c[r] == 'W') r--
        if (l>=r) break
        c[l] = 'R'
        c[r] = 'W'
        swap++
    }

    val ans = swap
    println(ans)
}


//val rd = debug.Reader("abc", "174", "d", "sample-3")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!!
    } catch (e: Exception) { throw e }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)
data class To(val idx: Int, val cost: Long)
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 38488
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  rep (i, n) cin >> a[i];
  int maxi = 0, maxi2, cnt;
  rep (i, n) {
    if (a[i] > maxi) {
      maxi2 = maxi;
      maxi  = a[i];
      cnt   = 1;
    } else if (a[i] > maxi2) {
      maxi2 = a[i];
    } else if (a[i] == maxi) ++cnt;
  }
  rep (i, n) cout << (cnt > 1 || a[i] != maxi ? maxi : maxi2) << endl;
  return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int main() {
	string w;
	map<char, int> memo;

	cin >> w;

	for (char x : w) {
		memo[x]++;
	}

	bool ans = true;
	for (auto x : memo) {
		if (x.second % 2 != 0) {
			ans = false;
		}
	}

	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
    fast;
    lli h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    lli temp=(h2-h1)*60;
    temp+=(m2-m1);
    cout<<temp-k;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int n;

	cin >> n;

	if (n <= 999) Out("ABC");
	else Out("ABD");
	
	return 0;
}


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

using namespace std;

const int N = 2005;

vector<int> g[N];

int h[N], d[N], c[N];
string s;

void dfs(int u, int p = -1) {
  c[u] = s[u] == '1';
  d[u] = 0;
  for (int v : g[u]) {
    if (v != p) {
      h[v] = h[u] + 1;
      dfs(v, u);
      c[u] += c[v];
      d[u] += d[v] + c[v];
    }
  }
}

int dp[N];

void calc(int u, int p = -1) {
  int M = -1;
  for (int v : g[u]) {
    if (v != p) {
      calc(v, u);
      if (M == -1) M = v;
      else if (d[M] + c[M] < d[v] + c[v]) M = v;
    }
  }
  if (M == -1) {
    dp[u] = 0;
    return;
  }
  int other = d[u] - d[M] - c[M];
  if (other < dp[M] + c[M]) {
    dp[u] = dp[M] + c[M] - other;
  } else {
    dp[u] = d[u] & 1;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cin >> s;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int Min = -1;
  for (int i = 0; i < n; i++) {
    h[i] = 0;
    dfs(i);
    calc(i);
    if (dp[i] == 0 && d[i] % 2 == 0) {
      if (Min == -1) Min = d[i] / 2;
      else Min = min(Min, d[i] / 2);
    }
  }
  cout << Min << '\n';
  return 0;
}



Measured memory_bytes: 3820
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
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*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
  ll N,K,T=-1,sum=0,A,B;cin>>N>>K;
  vector<pair<ll,ll>> AB;
  rep(i,N){
      cin >> A >> B;
      AB.push_back(make_pair(A,B));
  }
  sort(ALL(AB));
  rep(i,N){
      sum+=AB[i].second;
      if(sum>=K){
          cout << AB[i].first << endl;
          return 0;
      }
  }
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b > c+d) cout << "Left" << endl;
  else if(a+b < c+d) cout << "Right" << endl;
  else cout << "Balanced" << endl;

return 0;
}

Measured memory_bytes: 3584
#!/usr/bin/env python3
import sys, math, fractions, itertools

MOD = 1000000007  # type: int
memo = []

def ok(last4: str):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i-1], t[i] = t[i], t[i-1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True

def dfs(N: int, cur: int, last3: str):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret  = 0
    for c in 'ACGT':
        if ok(last3 + c):
            ret = (ret + dfs(N, cur+1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret

def solve(N: int):
    print(dfs(N, 0, 'TTT'))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    global memo
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    memo = [{} for i in range(N+1)]
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5840
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>

#define ll long long
#define pll pair<ll, ll>

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

const int INF = 1111111111;

using namespace std;

const int H = 111;
const int W = 111;

int h, w;
char b[H][W];

void init()
{
	cin >> h >> w;
	reps(i, 1, h + 1)
	{
		reps(j, 1, w + 1)
		{
			cin >> b[i][j];
		}
	}

	rep(i, H)
	{
		b[i][0] = b[0][i] = '*';
	}
}

int v[H][W];

void solve()
{
	rep(i, H) rep(j, W) v[i][j] = INF;
	v[1][1] = 0;

	reps(i, 1, h + 1)
	{
		reps(j, 1, w + 1)
		{
			v[i][j] = min(v[i][j], v[i - 1][j] + 1);
			v[i][j] = min(v[i][j], v[i][j - 1] + 1);

			if (b[i][j] != b[i - 1][j])
			{
				if (b[i - 1][j] == '#')
				{
					v[i][j] = min(v[i][j], v[i - 1][j]);
				}
			}
			if (b[i][j] != b[i][j - 1])
			{
				if (b[i][j - 1] == '#')
				{
					v[i][j] = min(v[i][j], v[i][j - 1]);
				}
			}
			if (b[i][j] == b[i - 1][j])
			{
				v[i][j] = min(v[i][j], v[i - 1][j]);
			}
			if (b[i][j] == b[i][j - 1])
			{
				v[i][j] = min(v[i][j], v[i][j - 1]);
			}
		}
	}

	int add = b[1][1] == '#' ? 1 : 0;
	cout << v[h][w] + add << endl;
}

int main()
{
	init();
	solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
using namespace std;

bool  check(string a,string b){
  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++){
      if(a[i]=='*')continue;
      if(a[i]!=b[i])return false;
    }
  }
  return true;
}

int main()
{
  int n,m;
  string b[1000];
  pair<string,int> a[100];
  while(1){
    cin>>n>>m;
    if(n+m==0)break;
    for(int i=0;i<n;i++)cin>>a[i].f>>a[i].s;
    for(int i=0;i<m;i++)cin>>b[i];

    long long ans=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	if(check(a[i].f,b[j]))ans+=a[i].s;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1264
#include "bits/stdc++.h"

using namespace std;

void Main() {
    long long N;
    cin >> N;
    map<char, long long> initial;
    initial.insert(make_pair('M', 0));
    initial.insert(make_pair('A', 0));
    initial.insert(make_pair('R', 0));
    initial.insert(make_pair('C', 0));
    initial.insert(make_pair('H', 0));
    for (long long i = 0; i < N; ++i) {
        string s;
        cin >> s;
        if (s[0] == 'M') {
            initial['M'] += 1;
        }
        else if (s[0] == 'A') {
            initial['A'] += 1;
        }
        else if (s[0] == 'R') {
            initial['R'] += 1;
        }
        else if (s[0] == 'C') {
            initial['C'] += 1;
        }
        else if (s[0] == 'H') {
            initial['H'] += 1;
        }
    }

    long long ans = 0;
    ans += initial['M'] * initial['A'] * initial['R'];
    ans += initial['M'] * initial['A'] * initial['C'];
    ans += initial['M'] * initial['A'] * initial['H'];
    ans += initial['M'] * initial['R'] * initial['C'];
    ans += initial['M'] * initial['R'] * initial['H'];
    ans += initial['M'] * initial['C'] * initial['H'];
    ans += initial['A'] * initial['R'] * initial['C'];
    ans += initial['A'] * initial['R'] * initial['H'];
    ans += initial['A'] * initial['C'] * initial['H'];
    ans += initial['R'] * initial['C'] * initial['H'];
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	cout<<((int)(log(n)/log(k)))+1<<endl;
}


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

int main() {
    int n;

    cin >> n;
    int *R = (int *)malloc(sizeof(int) * n);
    for (int i = 0; i < n; i++) cin >> R[i];

    int maxv = R[1] - R[0];
    int minv = R[0];

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;
    return 0;
}



Measured memory_bytes: 3880
import sys
def main():
    input = sys.stdin.readline
    N = int(input())
    iS = input().rstrip()

    S = []
    for i in range(N-1):
        S.append(abs(int(iS[i])-int(iS[i+1])))
    N -= 1

    f = FactorialUtils(N)
    n1 = n2 = 0
    for i in range(N):
        t = f.choose(N-1,i)
        #print(t,S[i])
        if S[i] == 1: n1 += t
        elif S[i] == 2: n2 += t
    if n1&1 and n2&1: print(1)
    elif n1&1: print(1)
    elif n2&1 and n1==0: print(2)
    else: print(0)
    #print(n1,n2)

class FactorialUtils:
    def __init__(self, n):
        self.fac = [1] * (n+1)
        for i in range(2, n+1): self.fac[i] = self.fac[i-1] + (i&(-i)).bit_length()

    def choose(self, n, r):
        if r < 0 or r > n: return 0
        return 2 if (self.fac[n] - self.fac[n-r] - self.fac[r]) > 0 else 1

if __name__ == '__main__':
    main()


Measured memory_bytes: 118920
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
const int N = 3000300;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const int mod =    1e9+7;
int n,cnt0,cnt1,cnt2;
int arr[100005];
int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


int m1,m2,d1,d2;
cin>>m1>>d1>>m2>>d2;
if(m2-m1==1&&d2==1)
cout<<1;
else
cout<<0;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e+13;
int main(){
    int n, m, l;
    cin >> n >> m >> l;
    ll dist[300][300]{};
    for(int x = 0; x < n; x++)
        for(int y = 0; y < n; y++)
            dist[x][y] = INF;
    for(int i  = 0; i < m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        --a;--b;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    for(int k = 0; k < n; k ++)
        for(int i = 0; i < n; i ++)
            for(int j = 0; j < n; j++)
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); 
    for(int x = 0; x < n; x++)
        for(int y = 0; y < n; y++)
            dist[x][y] = (dist[x][y] <= l?1LL:INF);
    for(int k = 0; k < n; k ++)
        for(int i = 0; i < n; i ++)
            for(int j = 0; j < n; j++)
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); 
    int q;
    cin >> q;
    for(int i  = 0; i < q; i++){
        int s, t;
        cin >> s >> t;
        cout << dist[--s][--t]%INF - 1 << endl;
    }

}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
#define Endl endl
const int INF=100000000;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<((b-a==c-b)?"YES":"NO")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define f first
#define s second

signed main()
{
    int k;
    string s;
    cin>>k>>s;
    if(s.size()<=k)
        cout<<s<<endl;
    else
        cout<<s.substr(0,k)+"..."<<endl;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

const int MaxN = 500;
const int MaxM = 500;

int n, m;
char map[MaxN + 2][MaxM + 2];

inline bool is_red(int x, int y)
{
	return map[x][y] == '#' || y == 1 || (y != m && (x & 1));
}
inline bool is_blue(int x, int y)
{
	return map[x][y] == '#' || y == m || (y != 1 && (~x & 1));
}

int main()
{
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; ++i)
		scanf("%s", map[i] + 1);

	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
			putchar(is_red(i, j) ? '#' : '.');
		putchar('\n');
	}

	putchar('\n');

	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
			putchar(is_blue(i, j) ? '#': '.');
		putchar('\n');
	}

	return 0;
}

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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

const string YES = "YES";
const string NO = "NO";

void func(long long N, std::vector<long long> A){
    set<int> C;
    rep(i,N) C.insert(A[i]);
    printf("%s\n", (C.size() == A.size())? YES.c_str() : NO.c_str());
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    func(N, std::move(A));
    return 0;
}


Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        scan.close();
        String[] array = str.split(" ");
      String a = array[0];
      String b = array[1];
      Integer ai = Integer.parseInt(a);
      Integer bi = Integer.parseInt(b);
      if( ai*bi%2==0){
        System.out.println("Even")    ;
      }
      else{
        System.out.println("Odd")    ;
      }
    }
}


Measured memory_bytes: 23764
#include<stdio.h>

int main()
{
	int k,x,sum;
	scanf("%d %d",&k,&x);
	if (500*k>x)
	{
		printf("Yes\n");
	}
	if (500*k<x)
	{
		printf("No\n");
	}
	else if (500*k == x)
	{
		printf("Yes\n");
	}
	
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, vector<pair<long long, long long>> t, std::vector<long long> x, std::vector<long long> y){
  sort(t.begin(), t.end());
  long long currentx = 0;
  long long currenty = 0;
  long long currentt = 0;

  for(auto i: t) {
    long long dist = (i.first - currentt) - (abs(currentx - x[i.second]) + abs(currenty - y[i.second]));

    if(dist >= 0 && (dist % 2) == 0) {
      currentx = x[i.second];
      currenty = y[i.second];
      currentt = i.first;
      continue;
    }
    else {
      cout << NO << endl;
      return;
    }
  }

  cout << YES << endl;
  return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  long long myt;
  std::vector<pair<long long, long long>> t(N);
  std::vector<long long> x(N);
  std::vector<long long> y(N);
  for(int i = 0 ; i < N ; i++){
    cin >> myt;
    t[i] = make_pair(myt, i);
    scanf("%lld",&x[i]);
    scanf("%lld",&y[i]);
  }
    solve(N, std::move(t), std::move(x), std::move(y));
    return 0;
}


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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("op.txt","w",stdout);
#endif
	int a[5],i;
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
	for(i=0;i<5;i++)
	{
		if(a[i] == 0)
		{
			break;
		}
	}
	cout<<i+1;
	return 0;
}

Measured memory_bytes: 3044
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int N; cin>>N;
    N--;
    int C[N],S[N],F[N]; REP(i,N) cin>>C[i]>>S[i]>>F[i];
    REP(i,N) {
        int t = 0;
        FOR(j,i,N) {
            t = max(S[j],t);
            if (t%F[j]!=0) t += F[j]-t%F[j];
            t += C[j];
        }
        cout<<t<<endl;
    }
    cout<<0<<endl;
}



Measured memory_bytes: 256