akhauriyash/Code-Regression huggingface dataset:
import sys

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

N, *A = map(int, read().split())

if N == 0:
    x = A[0]
    if x == 1:
        print(1)
    else:
        print(-1)
    exit()

INF = 10 ** 13 + 100

bound = [0] * (N + 1)
bound[0] = 1
ok = True
for n in range(1, N + 1):
    bound[n] = min(INF, (bound[n - 1] - A[n - 1]) * 2)
    if bound[n] < A[n]:
        ok = False

if not ok:
    print(-1)
    exit()

B = [0] * (N + 2)
for n in range(N, -1, -1):
    x = min(bound[n], B[n + 1] + A[n])
    B[n] = x

print(sum(B))



Measured memory_bytes: 645512
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
//template< typename T >
//T mod_pow(T x, T n, const T &p) {
//  T ret = 1;
//  while(n > 0) {
//    if(n & 1) (ret *= x) %= p;
//    (x *= x) %= p;
//    n >>= 1;
//  }
//  return ret;
//}
/////////////////// 
//

#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
#define mp make_pair
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  string s;
  cin >> s;
  if(s.length()>=4 && s[0]=='Y' && s[1]=='A' && s[2] =='K' && s[3]=='I')
    pri("Yes");
  else 
    pri("No");
  return 0;
}







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

int main()
{
  int n;
  cin >> n;

  int h = n / 3600;
  int m = n % 3600 / 60;
  int s = n % 3600 % 60;

  printf("%d:%d:%d\n",h, m, s);

  return 0;
}


Measured memory_bytes: 3200
using static System.Math;using static System.Console;using System.Collections.Generic;using System.Linq;using System;
using System.Reflection;

class Program
{
    #region Reader
    static string ReadStr => Console.ReadLine();
    static string[] ReadStrs => Console.ReadLine().Split(' ');
    static int ReadInt => Convert.ToInt32(Console.ReadLine());
    static int[] ReadInts => Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
    static long ReadLong => Convert.ToInt64(Console.ReadLine());
    static long[] ReadLongs => Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
    #endregion

    static int mod = (int)Pow(10, 9) + 7;

    static void Main()
    {
        int[] NW = ReadInts;
        int N = NW[0];
        int W = NW[1];

        int[][] items = new int[N][];
        for (int i = 0; i < N; i++)
        {
            items[i] = ReadInts;
        }

        int[,] dp = new int[N + 1, W + 1];

        int ans = 0;
        for (int n = 1; n <= N; n++)
        {
            Item item = new Item(items[n - 1][0], items[n - 1][1]);
            for (int w = 0; w <= W; w++)
            {
                dp[n, w] = Max(dp[n - 1, w], dp[n, w]);

                if (w + item.w <= W)
                {
                    dp[n, w + item.w] = Max(dp[n, w + item.w], dp[n, w] + item.v);

                    ans = Max(ans, dp[n, w + item.w ]);


                }




            }
        }
        WriteLine(ans);
    }


    public class Item
    {
        public Item(int v,int w)
        {
            this.v = v;
            this.w = w;
        }
        public int v;
        public int w;
    }


}



Measured memory_bytes: 21932
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x;
  cin >> n >> m >> x;
  int minv=INT_MAX;
  int a[n][m];
  vector<int> c(n);
  for(int i=0;i<n;i++){
    cin >> c[i];
    for(int j=0;j<m;j++)
      cin >> a[i][j];
  }
  for(int i=0;i<(1<<n);i++){
    vector<int> b(m);
    int v=0;
    for(int j=0;j<n;j++){
      if((i>>j)&1){
        v+=c[j];
        for(int k=0;k<m;k++){
          b[k]+=a[j][k];
        }
      }
    }
    int check=1;
    for(int j=0;j<m;j++){
      if(b[j]<x) check=0;
    }
    if(check)minv=min(minv,v);
  }
  if(minv==INT_MAX) cout << -1 << endl;
  else cout << minv << endl;
}

Measured memory_bytes: 3632
#include <cstring>
#include <iostream>

using namespace std;

int main()
{
	int tc; cin>>tc;
	while(tc--){
		int gx,gy; cin>>gx>>gy;
		static int m[16][16][16][16];
		memset(m,0,sizeof m);
		int p; cin>>p;
		while(p--){
			int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
			m[x1][y1][x2][y2]=m[x2][y2][x1][y1]=1;
		}
		
		int dp[16][16]={};
		dp[0][0]=1;
		for(int i=0;i<=gx;i++)
			for(int j=0;j<=gy;j++){
				if(i && !m[i-1][j][i][j]) dp[i][j]+=dp[i-1][j];
				if(j && !m[i][j-1][i][j]) dp[i][j]+=dp[i][j-1];
			}
		
		if(!dp[gx][gy])
			cout<<"Miserable Hokusai!"<<endl;
		else
			cout<<dp[gx][gy]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1424
#include <cstdio>
#include <cmath>

#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main() {
	int a, b, t;
	cin >> a >> b >> t;
	cout << t / a * b;	
}


Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n = II()
    m = 1
    for i in range(1,n+1):
        m *= i
        m %= 10**9+7
    print(m%(10**9+7))
if __name__ == '__main__':
    main()

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

int main(){
	while(1){
		int n;
		cin >> n;
		if( !n ) break;

		vector<string> v(n+1);
		for(int i = 0 ; i < n ; i++ ){
			cin >> v[i];
		}
		v[n] = "";
		
		if( n == 1 )
			cout << v[0] << endl;
		else{
			stack<bool> st;
			stack<long> stN;
			st.push(0);
			stN.push(0);
			int len = 1;
			rep(i,0,n){
				string s = v[i];
				char c = s[s.size()-1];
				//cout << "stN:" << stN.top() << " st:" << st.top() << " s:" << s << " len:" << len << "size" << st.size() << endl;
				if( s.size() < len ){
					rep(i,0,len-s.size()){
						int num = stN.top();
						stN.pop();
						st.pop();
						if(st.top()) num *= stN.top();
						else num += stN.top();
						stN.pop();
						stN.push(num);
					}
					len = s.size();
				}
				if( c == '+' ){
					stN.push(0);
					st.push(0);
					len++;
				}
				else if( c == '*'){
					stN.push(1);
					st.push(1);
					len++;
				}
				else{
					int num = stN.top();
					stN.pop();
					if( st.top() ) num *= c - '0';
					else num += c - '0';
					stN.push(num);
				}
			}

			while( st.size() > 1 ){
				int num = stN.top();
				stN.pop();
				st.pop();
				if(st.top()) num *= stN.top();
				else num += stN.top();
				stN.pop();
				stN.push(num);
			}

			cout << stN.top() << endl;
		}	







	}	
	return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n, t;
    cin >> n >> t;

    map<int, int> cnt;
    vs32 a(n);
    for (auto& x : a)
    {
        cin >> x;
        ++cnt[x];
    }

    vs32 back_max(n);
    back_max.back() = a.back();
    for (int i = n - 2; i >= 0; --i)
    {
        back_max[i] = max(back_max[i + 1], a[i]);
    }

    int m = 0;
    int small = 0, large = 0;
    rep (i, n - 1)
    {
        int temp = back_max[i + 1] - a[i];
        if (m < temp)
        {
            m = temp;
            small = 1;
            large = cnt[back_max[i + 1]];
        }
        else if (m == temp)
        {
            ++small;
            large += cnt[back_max[i + 1]];
        }
    }

    cout << min(small, large) << "\n";

    return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

void bfs(int s, vvi &v, vi &resenje, int n)
{
    queue<int> q;
    q.push(s);
    vector<bool> visited(n+1,false);
    vi odstojanje(n+1,0);
    visited[s]=true;

    while(!q.empty())
    {
        int trenutni = q.front();
        q.pop();
        for(auto e : v[trenutni])
        {
            if(!visited[e])
            {
                q.push(e);
                odstojanje[e]=odstojanje[trenutni]+1;
                resenje[odstojanje[e]]++;
                visited[e]=true;
            }
        }
    }
}

int main()
{
    int n,x,y;

    cin >> n >> x >> y;

    vvi v(n+1);

    v[x].pb(y);
    v[y].pb(x);

    for(int i = 1; i < n; i++)
    {
        v[i].pb(i+1);
        v[i+1].pb(i);
    }

    vi resenje(n,0);

    for(int i = 1; i <= n; i++)
    {
        bfs(i,v,resenje,n);
    }

    for(int i = 1; i < n; i++)
    {
        cout << resenje[i] / 2 << '\n';
    }

    return 0;
}


Measured memory_bytes: 384
'use strict'
function otoshidama(stdin) {
  const inputs = stdin.split(' ')
  const n = inputs[0]
  const y = inputs[1]
  for (let i = 0;i <= n;i++) {
    const remain = y - 10000 * i
    if (remain === 0 && n === i) {
      return console.log(n, 0, 0)
    } else if (remain <= 0 && i === n) {
      break
    }
    for (let j = 0;j <= n - i;j++) {
      const sen = n - i - j
      const result = remain - 5000 * j - 1000 * sen
      if (result === 0) {
        return console.log(i, j, sen)
      } else if (result < 1000) {
        break
      }
    }
  }
  return console.log(-1, -1, -1)
}
otoshidama(require('fs').readFileSync(0, 'utf8'))


Measured memory_bytes: 7884
s=input()
n=len(s)
if s[0] != "A":
  print("WA")  
  exit()
if s[2:n-1].count("C") != 1:
  print("WA")
  exit()
s=s.replace("A", "")
s=s.replace("C", "")
if not s.islower():
  print("WA")
  exit()
print("AC")



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

using namespace std;
int n;

int main() {
    scanf("%d", &n);
    vector<vector<int>> h(n, vector<int>(3, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            scanf("%d", &h[i][j]);
        }
    }

    vector<int> dp(3);
    for (int j = 0; j < 3; ++j) {
        dp[j] = h[0][j];
    }

    // dp[i][j] := maximum possible happiness until day i, with the last activity j
    for (int i = 1; i < n; ++i) {
        vector<int> cur(3, 0);
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j != k) cur[j] = max(cur[j], dp[k] + h[i][j]);
            }
        }
        dp = cur;
    }

    int ans = max(max(dp[0], dp[1]), dp[2]);
    printf("%d\n", ans);
    return 0;
}

/*Space O(n) solution *//*

#include <iostream>
#include <vector>

using namespace std;
int n;

int main() {
    scanf("%d", &n);
    vector<vector<int>> h(n, vector<int>(3, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            scanf("%d", &h[i][j]);
        }
    }

    vector<vector<int>> dp(n, vector<int>(3, 0));
    for (int j = 0; j < 3; ++j) {
        dp[0][j] = h[0][j];
    }

    // dp[i][j] := maximum possible happiness until day i, with the last activity j
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + h[i][j]);
            }
        }
    }

    int ans = max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]);
    printf("%d\n", ans);
    return 0;
}
*/


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int H, W; cin >> H >> W;
    char field[H + 10][W + 10] = {};


    vector<string> S;
    for (int i = 0; i < H; ++i) {
        string x; cin >> x;
        S.push_back(x);
    }

    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
             field[i][j] = S[i - 1][j - 1]; 
        }
    }
    /*
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
             cout << field[i][j];
        }
        cout << endl;
    }
    */
    char answer[H + 10][W + 10] = {};
    
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            if (field[i][j] == '#') answer[i - 1][j - 1] = '#';
            else {
                int count = 0;
                for (int k = i - 1; k <= i + 1; ++k){
                    for (int l = j - 1; l <= j + 1; ++l){
                        if (field[k][l] == '#'){
                            ++count;
                        }
                    }
                }
                string str = to_string(count);
                char const *pchar = str.c_str();
                answer[i - 1][j - 1] = *pchar;
            }
        }
        
    }
    
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cout << answer[i][j];
        }
        cout << endl;
    }
    
    return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N;
ll a[200005],b[200005];
ll a_mod[35][200005],b_mod[35][200005];
ll bit[35];

ll pw(ll x,ll y){
    ll ret=1;
    for(ll i=0; i<y; i++){
       ret*=x;
    }
    return ret;
}
int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N;

rep(i,N) cin>>a[i];
rep(i,N) cin>>b[i];
rep(k,30){
	rep(i,N){
		a_mod[k][i]=a[i]%pw(2,k+1);
		b_mod[k][i]=b[i]%pw(2,k+1);
	}
}

rep(k,30){
	sort(b_mod[k],b_mod[k]+N);
	ll T=pw(2,k);
	rep(i,N){
		ll i1=lower_bound(b_mod[k],b_mod[k]+N,T-a_mod[k][i])-b_mod[k];
		ll i2=lower_bound(b_mod[k],b_mod[k]+N,2*T-a_mod[k][i])-b_mod[k];
		ll i3=lower_bound(b_mod[k],b_mod[k]+N,3*T-a_mod[k][i])-b_mod[k];
		bit[k]+=(N-i1+i2-i3);
	}
	bit[k]%=2;
}

ll ans=0;
rep(k,30){
	ll mul=pw(2,k);
	if(bit[k]){
		ans+=mul;
	}
}
cout<<ans<<endl;

}
	


Measured memory_bytes: 100480
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll N;
    cin >> N;
    vector<ll> d(N);
    for(int i=0;i<N;i++) cin >> d[i];

    sort(d.begin(),d.end());
    cout << d[N/2]-d[N/2-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
char b[4];
  int a=0;
  scanf("%s",&b);
  if(b[0]=='o'){a++;}
    if(b[1]=='o'){a++;}
    if(b[2]=='o'){a++;}
  printf("%d",700+a*100);
return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// i番目までで、j個選んだ時、合計がkになる組み合わせの数
ll dp[55][55][2505];

// ====================================================================

int main() {
  int n, a;
  cin >> n >> a;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];

  dp[0][0][0] = 1;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= 2500; k++) {
        if (dp[i][j][k])
          dp[i + 1][j + 1][k + v[i]] += dp[i][j][k];  // 選んだ
        dp[i + 1][j][k] += dp[i][j][k];               // 選ばない
      }
    }
  }

  // for (int i = 0; i < n; i++) {
  //   for (int j = i + 1; j < n; j++) {
  //     // for (int k = j + 1; k < n; k++) {
  //     if (v[i] + v[j] == 13) {
  //       cout << v[i] << " " << v[j] << endl;
  //     }
  //     // }
  //   }
  // }

  // DPテーブル表示
  // for (int i = 0; i <= n; i++) {
  //   cout << v[i - 1] << endl;
  //   for (int j = 1; j <= n; j++) {
  //     for (int k = 0; k <= 47; k++) {
  //       if (k == j * a) cout << '[';
  //       cout << (dp[i][j][k] ? (char)(dp[i][j][k] + '0') : '*');
  //       if (k == j * a) cout << ']';
  //       cout << " ";
  //     }
  //     cout << endl;
  //   }
  //   cout << endl;
  // }

  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += dp[n][i][i * a];
  }
  cout << ans << endl;
}


Measured memory_bytes: 56448
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
}

Measured memory_bytes: 256
// This is the start of shubhams template//
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long int
void input(){
#ifndef ONLINE_JUDGE 
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout); 
#endif
}
#define vll vector<int>
#define pb push_back
#define pll pair<int,int>
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define INF LONG_LONG_MAX
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define cases int t; cin>>t; while(t--)
#define array(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define sortall(a) sort(a.begin(),a.end())
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;
//this is the end of shubhams template //

int32_t main() 
{ 
	input();
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
   	int curr=0,k;
   	cin>>k;
   	
   	for(int i=1;i<1000001;++i)
   	{
   		curr*=10;
   		curr+=7;
   		curr=curr%k;
   		if(curr==0)
   		{
   			cout<<i<<endl;
   			return 0;
   		}
   	}
   	cout<<-1<<endl;
    return 0; 
} 

Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.*;
/**
 * Created by Aksenov239 on 24.09.2016.
 */
public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;

    public String nextToken() throws IOException{
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    public int nextInt() throws IOException{
        return Integer.parseInt(nextToken());
    }

    public void solve() throws IOException {
        char[] c = nextToken().toCharArray();
        int k = nextInt();
        int d = 'z' + 1;
        for (int i = 0; i < c.length; i++) {
            if (c[i] == 'a')
                continue;
            if (d - c[i] <= k) {
                k -= (d - c[i]);
                c[i] = 'a';
            }
        }
        if (k > 0) {
            c[c.length - 1] = (char)('a' + (c[c.length - 1] - 'a' + k) % 26);
        }
        out.println(new String(c));
    }

    public void run() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);

            solve();

            out.close();
        }catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 11476
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

long long roundup(long long a,long long b){
    return (a+b-1)/b;
}

signed main(void){
    int N;
    int C[514],S[514],F[514];
    cin >> N;
    REP(i,N-1){
        cin >> C[i] >> S[i] >> F[i];
    }
    REP(j,N){
        int Ans=0;
        for(int i=j;i<N-1;i++){
            int nex=F[i]*roundup(Ans,F[i]);
            Ans=C[i]+max(S[i],nex);
        }
        cout << Ans << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
bool isincluded(char x, string str) {
	bool f = 0;
	for (size_t i = 0; i < str.size(); i++) {
		if (str.at(i) == x)f = 1;
	}
	return f;
}
int ctoi(char c) {
	if ('0' <= c && c <= '9') {
		return c - '0';
	}
	return 0;
}

char a[100][100], b[100][100];



int main(void) {
	int n, m; cin >> n >> m;
	rep(i, n)rep(j, n)cin >> a[i][j];
	rep(i, m)rep(j, m)cin >> b[i][j];
	for (int i = 0; i < n - m + 1; i++) {
		for (int j = 0; j < n - m + 1; j++) {
			bool x = 0;
			for (int hi = 0; hi < m; hi++) {
				for (int wi = 0; wi < m; wi++) {
					if (a[hi + i][wi + j] != b[hi][wi]) {
						x = 1;
						goto xx;
					}
				}
			}
		xx:
			if (x) {
				x = 0;
			}
			else {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    rep(i, H)
    {
        rep(j, W)
        {
            if (((i >= B) && (j >= A)) || ((i < B) && (j < A)))
            {
                cout << "0";
            }
            else
            {
                cout << "1";
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 1280
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String s = in.next();
            out.println(s.lastIndexOf('Z') - s.indexOf('A') + 1);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isPrintableChar(int c) {
            return c >= 33 && c <= 126;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define ll  long long  
#define pb push_back
#define fi first
#define se second
using namespace std;
ll mo=1e9+7;
ll i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p)%mo;
p=(p*p)%mo;
k>>=1;
}
return a;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	 ll k,a,b;
	 cin>>k>>a>>b;
	if((b/k-(a-1)/k)>=1)
	cout<<"OK";
	else
	cout<<"NG";
	cout<<"\n"; 
 } 
}


Measured memory_bytes: 3652
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = []
for _ in range(N):
    data.append([int(x) for x in stdin.readline().rstrip().split()])

ans = 0
for i in sorted(data):
    if K <= 0:
        break
    ans = i[0]
    K -= i[1]
    
    
print(ans)

Measured memory_bytes: 22420
#include <bits/stdc++.h>
#define int 	long long
using namespace std;
 
struct point 
{
	int x, y;
	int id;
};
 
int n, r, c;
 
bool av(point x)    {
    return  (x.x == 0 || x.y == 0 || x.x == r || x.y == c);
}
 
point center;
 
bool les(point a, point b)
{
    if (a.x - center.x >= 0 && b.x - center.x < 0)
        return true;
    if (a.x - center.x < 0 && b.x - center.x >= 0)
        return false;
    if (a.x - center.x == 0 && b.x - center.x == 0) {
        if (a.y - center.y >= 0 || b.y - center.y >= 0)
            return a.y > b.y;
        return b.y > a.y;
    }
    int det = (a.x - center.x) * (b.y - center.y) - (b.x - center.x) * (a.y - center.y);
    if (det < 0)
        return true;
    if (det > 0)
        return false;
    int d1 = (a.x - center.x) * (a.x - center.x) + (a.y - center.y) * (a.y - center.y);
    int d2 = (b.x - center.x) * (b.x - center.x) + (b.y - center.y) * (b.y - center.y);
    return d1 > d2;
}
 
 
vector<point> chec;
 
signed main()
{
	scanf("%lld%lld%lld", &r, &c, &n);
	for (int i = 1; i <= n; i++)
	{
		point temp1, temp2;
		scanf("%lld%lld%lld%lld", &temp1.x, &temp1.y, &temp2.x, &temp2.y);
		temp1.id = i;
		temp2.id = i;
		if (av(temp1) && av(temp2))
		{
			chec.push_back(temp1);
			chec.push_back(temp2);
		}
	}
	center.x = (1+r)/2;
	center.y = (1+c)/2;
	sort(chec.begin(), chec.end(), les);
	stack<int> s;
	for (int i = 0; i < chec.size(); i++)
	{
		if (s.empty())
		{
			s.push(chec[i].id);
		}
		else
		{
			if (s.top() == chec[i].id)
			{
				s.pop();
			}
			else
			{
				s.push(chec[i].id);
			}
		}
	}
	if (!s.empty()) 
	{
		printf("NO");
	}
	else
	{
		printf("YES");
	}
}

Measured memory_bytes: 8304
#include <algorithm>
#include <iostream>
#include <string>

int main() {
    std::string s1, s2;
    std::cin >> s1 >> s2;
    
    std::sort(s1.begin(), s1.end());
    std::sort(s2.begin(), s2.end(), std::greater<char>());
    const auto ret = (s1 < s2) ? "Yes" : "No";

    std::cout << ret << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define TOP 1
#define NORTH 2
#define EAST 3
#define WEST 4
#define SOUTH 5
#define BOTTOM 6

struct dice {
  int num[6 + 1];
  int top, n, e, w, s, bottom;
  int tmp;
};

void dice_init(struct dice *d);
void dice_move(struct dice *d, char move);
void dice_move_str(struct dice *d, const char *str);
int dice_label(struct dice *d, int n);
int dice_location(struct dice *d, int label);
int dice_judge(struct dice *d1, struct dice *d2);

int main(int argc, char *argv[])
{
  struct dice *d;
  int n, i, j, k, l;
  char *set[] = {"S", "", "WS", "ES", "SS", "N"};
  int res = 0;

  scanf ("%d", &n);

  d = (struct dice *)malloc(sizeof(struct dice) * n);
  for (i = 0; i < n; i++) {
    dice_init(&d[i]);
    for (j = 1; j <= 6; j++) scanf("%d", &(d[i].num[j]));
  }

  for (i = 0; i < n - 1; i++) {
    dice_init(&d[i]);
    for (j = i + 1; j < n; j++) {
      for (k = 0; k < 6; k++) {
        dice_init(&d[j]);
        dice_move_str(&d[j], set[k]);
        
        for (l = 0; l < 4; l++) {
          dice_move(&d[j], 'W');
          if ((res = dice_judge(&d[i], &d[j])) == 1) break;
        }
        if (res == 1) break;
      }
      if (res == 1) break;
    }
    if (res == 1) break;
  }

  if (res == 1) printf("No\n");
  else printf("Yes\n");

  free(d);

  return 0;
}

void dice_init(struct dice *d)
{
  d->top = 1;
  d->n = 5;
  d->e = 3;
  d->w = 4;
  d->s = 2;
  d->bottom = 6;
}

void dice_move(struct dice *d, char move)
{
  switch (move) {
  case 'N':
    d->tmp = d->top;
    d->top = d->s;
    d->s = d->bottom;
    d->bottom = d->n;
    d->n = d->tmp;
    break;

  case 'E':
    d->tmp = d->top;
    d->top = d->w;
    d->w = d->bottom;
    d->bottom = d->e;
    d->e = d->tmp;
    break;

  case 'W':
    d->tmp = d->top;
    d->top = d->e;
    d->e = d->bottom;
    d->bottom = d->w;
    d->w = d->tmp;
    break;

  case 'S':
    d->tmp = d->top;
    d->top = d->n;
    d->n = d->bottom;
    d->bottom = d->s;
    d->s = d->tmp;
    break;

  default:
    break;
  }
}

void dice_move_str(struct dice *d, const char *str)
{
  int i;

  for (i = 0; i < strlen(str); i++) dice_move(d, str[i]);
}

int dice_label(struct dice *d, int n)
{
  int i;

  for (i = 6; i > 0; i--) {
    if (d->num[i] == n) return i;
  }
  return i;
}

int dice_location(struct dice *d, int label)
{
  if (d->top == label) return TOP;
  else if (d->n == label) return NORTH;
  else if (d->e == label) return EAST;
  else if (d->w == label) return WEST;
  else if (d->s == label) return SOUTH;
  else if (d->bottom == label) return BOTTOM;
  else return 0;
}

int dice_judge(struct dice *d1, struct dice *d2)
{
  int correspond = 0;

  if (d1->num[d1->top] == d2->num[d2->top]) correspond++;
  if (d1->num[d1->n] == d2->num[d2->n]) correspond++;
  if (d1->num[d1->e] == d2->num[d2->e]) correspond++;
  if (d1->num[d1->w] == d2->num[d2->w]) correspond++;
  if (d1->num[d1->s] == d2->num[d2->s]) correspond++;
  if (d1->num[d1->bottom] == d2->num[d2->bottom]) correspond++;

  if (correspond == 6) return 1;
  else return 0;
}

Measured memory_bytes: 588
#![allow(unused_imports, non_snake_case, dead_code)]
use proconio::{
    input, fastout,
    marker::{Chars, Bytes, Usize1}
};

struct Graph {
    size: usize,
    G: Vec<Vec<usize>>,
    bic: Vec<usize>,
}

impl Graph {
    fn new(size:usize, G:Vec<Vec<usize>>) -> Self {
        let bic = vec![0; size];
        Graph {
            size, G, bic
        }
    }

    fn dfs(&mut self, v:usize, p:usize) {
        let mut chi = Vec::new();
        for &x in &self.G[v] {
            if x == p { continue };
            self.bic[x] = 1 ^ self.bic[v];
            chi.push(x);
        }
        for &x in &chi {
            self.dfs(x, v);
        }
    }
}

#[fastout]
fn main() {
    input! {
        N: usize,
        edges: [(Usize1, Usize1); N-1]
    }
    let mut G = vec![vec![]; N];
    for &(u, v) in &edges {
        G[u].push(v);
        G[v].push(u)
    }
    let mut graph = Graph::new(N, G);
    graph.dfs(0, 0);
    if graph.bic.iter().sum::<usize>() * 2 > N {
        for i in 0..N {
            graph.bic[i] ^= 1;
        }
    }
    let mut one = 1;
    let mut two = 2;
    let mut three = 3;
    let mut ans = vec![0; N];
    if graph.bic.iter().sum::<usize>() * 3 > N {
        for i in 0..N {
            if graph.bic[i] > 0 && one <= N {
                ans[i] = one;
                one += 3;
            } else if graph.bic[i] == 0 && two <= N {
                ans[i] = two;
                two += 3;
            } else {
                ans[i] = three;
                three += 3;
            }
        }
    } else {
        for i in 0..N {
            if graph.bic[i] == 0 && one <= N {
                ans[i] = one;
                one += 3;
            } else if graph.bic[i] == 0 && two <= N {
                ans[i] = two;
                two += 3;
            } else {
                ans[i] = three;
                three += 3;
            }
        }
    }
    println!("{}", ans.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(" "));

}

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

int main(){
        long N,P;
        long ans;
        cin >> N >> P;
        ans = (long)pow(P,1/(long double)N);
        while((long)P % (long)pow(ans,N) != 0){
          ans--;
        }
        cout << ans << endl;
        return 0;
}


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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) {
        cin >> a[i];
    }

    int ans = INT32_MAX;
    for(int n=-100; n<=100; n++) {
        int tmp = 0;
        for(int i=0; i<N; i++) {
            tmp += (n-a[i])*(n-a[i]);
        }
        ans = min(ans, tmp);
    }

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


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

int main() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> ac(n);
    for(int i = 0;i < n;i++){
        if(i != 0) ac[i] = ac[i-1];
        if(s[i] == 'A' && s[i+1] == 'C'){
            ac[i]++;
        }
    }
    for(int i = 0;i < q;i++){
        int l, r, res = 0;
        cin >> l >> r;
        res = ac[r-2] - ac[l-2];
        cout << res << endl;
    } 
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> sum(1, 0);
    rep(i, n) { sum.push_back(sum[i] + a[i]); }

    ll mi = INF;
    for(size_t i = 1; i < n; i++) {
        mi = min(mi, abs(sum[i] - (sum[n] - sum[i])));
    }
    cout << mi << endl;
}


Measured memory_bytes: 3956
// luogu-judger-enable-o2
#include <cstdio>
#include <cstring>

#include <algorithm>
#include <queue>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

struct E {
  int v;
  E* next;
};

const int N = 200010;

int n, good;
char col[N];
int deg[N], dp1[N], dp2[N];
bool vis[N], ct[N], f[N];

E epool[N * 2], *etop;
E* g[N];

void adde(int u, int v) {
  E* p = etop++;
  p->v = v;
  p->next = g[u];
  g[u] = p;
  ++deg[u];
}

void dfs1(int u) {
  vis[u] = true;
  for (E* p = g[u]; p; p = p->next)
    if (!vis[p->v] && !ct[p->v]) {
      dfs1(p->v);
      int upd1 = dp1[p->v] + -1 + (f[u] ? 1 : -1), upd2 = dp2[p->v] + -1 + (f[p->v] ? 1 : -1);
      good = min({good, dp1[u] + upd2, dp2[u] + upd1});
      dp1[u] = min(dp1[u], upd1);
      dp2[u] = min(dp2[u], upd2);
    }
}

int main() {
  int tc = 1;
  while (tc--) {
    memset(g, 0, sizeof(g));
    memset(ct, 0, sizeof(ct));
    memset(deg, 0, sizeof(deg));
    etop = epool;
    scanf("%d", &n);
    for (int rep = 1; rep < n; ++rep) {
      int u, v;
      scanf("%d%d", &u, &v);
      adde(u, v);
      adde(v, u);
    }
    scanf("%s", col + 1);
    for (int i = 1; i <= n; ++i)
      col[i] = col[i] == 'B';
    if (count(col + 1, col + n + 1, 1) == n) {
      puts("0");
      continue;
    }
    queue<int> q;
    for (int i = 1; i <= n; ++i) {
      if (deg[i] == 1 && col[i])
        q.push(i);
    }
    int cnt = n;
    while (!q.empty()) {
      --cnt;
      int u = q.front();
      ct[u] = true;
      q.pop();
      for (E* p = g[u]; p; p = p->next)
        if (--deg[p->v] == 1 && col[p->v])
          q.push(p->v);
    }
    for (int i = 1; i <= n; ++i)
      f[i] = col[i] ^ (deg[i] & 1);
    int rt = find(col + 1, col + n + 1, 0) - col;
    int ans = 2 * (cnt - 1);
    for (int i = 1; i <= n; ++i)
      if (!ct[i])
        ans += !f[i];
    memset(vis, 0, sizeof(vis));
    memset(dp1, 0, sizeof(dp1));
    memset(dp2, 0, sizeof(dp2));
    good = 0;
    dfs1(rt);
    printf("%d\n", good + ans);
  }
  return 0;
}


Measured memory_bytes: 14208
n, t = map(int, input().split())
ct = [0] * n
for i in range(n):
    ct[i] = list(map(int, input().split()))

stt = []
for i in ct:
    if i[1] <= t:
        stt.append(i[0])
if len(stt) == 0:
    print("TLE")
else:
    ans = min(stt)
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
string str = "1974";
int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	vector<char> a(4);
	for(auto &x : a)cin>>x;
	for(auto x : a){
        if(str.find(x) != -1){
            str.erase(str.find(x), 1);
        }
	}
	if(str == "")cout<<"YES\n";
	else cout<<"NO\n";
}


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

int main() {
    int x;
    cin >> x;
    if(x >= 400 && x < 600) cout << 8 << endl;
    else if(x >= 600 && x < 800) cout  << 7 << endl;
    else if(x >= 800 && x < 1000) cout  << 6 << endl;
    else if(x >= 1000 && x < 1200) cout  << 5 << endl;
    else if(x >= 1200 && x < 1400) cout  << 4 << endl;
    else if(x >= 1400 && x < 1600) cout  << 3 << endl;
    else if(x >= 1600 && x < 1800) cout  << 2 << endl;
    else if(x >= 1800 && x < 2000) cout  << 1 << endl;
    return 0;
}

Measured memory_bytes: 3632
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pll >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 

const ll inf=1e18+1e17;
const ll mod =1e9+7;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}

const ll N =3e5+6;
ll arr[N];
ll brr[N][65];
void solve(){
	ll n,k;
	cin>>n>>k;
	for ( ll i=0;i<n;i++){
		cin>>arr[i];
		arr[i]--;
	}
	for ( ll i=0;i<n;i++)
		brr[i][0]=arr[i];
	for ( ll i=0;i<64;i++){
		for ( ll j=0;j<n;j++ )
			brr[j][i+1]=brr[brr[j][i]][i];
	}
	ll pos=0;
	ll j=0;
	while ( k){
		if ( k&1){
			pos=brr[pos][j];
		}
		k>>=1;
		j++;
	}
	cout<<pos+1<<'\n';

}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
//	#ifndef ONLINE_JUDGE
//		cin.tie(NULL);
//		freopen ("INPUT.txt" , "r" , stdin);
//		freopen ("OUTPUT.txt", "w" , stdout);
//	#endif	
    ll t=1;
   // cin>>t;
    for (ll i=1;i<=t;i++){
    //	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}

Measured memory_bytes: 106756
#include <stdio.h>
#include <limits.h>

int comparisons = 0;

void merge(int A[], int left, int mid, int right) {
  int n1, n2, i, j, k;
  n1 = mid - left;
  n2 = right - mid;
  int L[n1+1], R[n2+1];

  for (i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }

  L[n1] = R[n2] = INT_MAX;
  i = 0, j = 0;

  for (k = left; k < right; k++) {
    comparisons++;
    if (L[i] <= R[j])
      A[k] = L[i++];
    else
      A[k] = R[j++];
  }
}

void mergeSort(int A[], int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main() {
  int n, i;

  scanf("%d", &n);

  int arr[n+5];
  
  for (i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }

  mergeSort(arr, 0, n);

  for (i = 0; i < n; i++) {
    if (i == n - 1)
      printf("%d\n", arr[i]);
    else
      printf("%d ", arr[i]);
  }
  printf("%d\n", comparisons);
}




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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 300300;
const long long mod = 1e9 + 7;

using namespace std;

long long n;
long long m;
long long x[N];
long long y[N];

void solve()
{
        cin >> n >> m;
        long long S1 = 0, S2 = 0, s1 = 0, s2 = 0;
        for(int i = 0; i < n; i++) cin >> x[i];
        for(int i = 0; i < m; i++) cin >> y[i];
        for(int i = 0; i < n; i++){
                S1 = (S1 + x[i] * i) % mod;
                S1 = (S1 - s1 + mod) % mod;
                s1 = (s1 + x[i]) % mod;
        }
        for(int i = 0; i < m; i++){
                S2 = (S2 + y[i] * i) % mod;
                S2 = (S2 - s2 + mod) % mod;
                s2 = (s2 + y[i]) % mod;
        }
        cout << (1ll * S1 * S2) % mod << "\n";
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("landscape.in");
        //fout("landscape.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;

int A, B;
int M;
int a[MAX_N], b[MAX_N];
int x[MAX_N], y[MAX_N], c[MAX_N];

signed main()
{
  cin >> A >> B >> M;
  REP(i,A) {
    cin >> a[i];
  }
  REP(i,B) {
    cin >> b[i];
  }

  int ans = INF_LL;
  REP(i,M) {
    cin >> x[i] >> y[i] >> c[i];
    x[i]--; y[i]--;
    ans = min(ans, a[x[i]] + b[y[i]] - c[i]);
  }

  sort(a,a+A);
  sort(b,b+B);

  cout << min(ans, a[0] + b[0]) << endl;

  return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <utility>
#include <tuple>
#include <string>
#include <cstdint>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <cassert>
using namespace std;
using i64 = int64_t;
i64 n;
vector<i64> s;
int main() {
    cin >> n;
    s.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    i64 ans = 0;
    for (int c = 1; c < n; ++c) {
        vector<bool> vis(n);
        i64 scr = 0;
        for (int i = 0; i < n; i += c) {
            int j = n - i - 1;
            i64 a = j, b = a - c;
            if (b <= 0) break;
            if (vis[i]) break;
            vis[i] = true;
            if (vis[j]) break;
            vis[j] = true;
            scr += s[i] + s[j];

       
            ans = max(ans, scr);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>

#define rep(i,n) for(int (i)=0;i < (n);(i)++)
#define ll long long
#define INF 9223372036854775807

using namespace std;

// input
string s;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;

  if (s[2] == s[3] && s[4] == s[5] ){
	cout << "Yes" <<endl;
  } else {
	cout << "No" << endl;
  }
}



Measured memory_bytes: 256
#include<cstdio>

int main() {
    int N;
    scanf("%d",&N);
    int d[N];
    for(int i = 0; i < N; i++) {
        scanf("%d",&d[i]);
    }

    int n[110] = {0};
    for(int i = 0; i < N; i++) {
        n[d[i]]++;
    }

    int result = 0;
    for(int i = 1; i <= 100; i++) {
        if(n[i]) {
            result++;
        }
    }

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


Measured memory_bytes: 128