akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD				1000000007
#define MOD1			998244353
#define EPS				1e-9
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)

using namespace std;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const int tam = 10000010;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("asd.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	ll n, x;
	cin>>n>>x;
	ll can[n+2], pe[n+2];
	can[0] = pe[0] = 1;
	fore(i, 1, n+2) can[i] = can[i-1] * 2 + 3, pe[i] = pe[i-1] * 2 + 1;
	ll res = 0;
	while(x > 0)
	{
		while(x < can[n] && x > 0)
		{
			x--, n--;
		}
		if(x == 0) break;
		x -= can[n];
		res += pe[n];
		if(x > 0)
			x--, res++;
	}
	cout<<res<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int f[N][N];
string s,p;
vector <int> res;
string ans;
int dp(int x,int y)
{
	if(x == 0 || y == 0) return 0;
	if(f[x][y] != -1) return f[x][y];
	
	int best = -1;
	if(s[x] == p[y]) 
		best = dp(x-1,y-1) + 1;
		
	else 
		best = max(dp(x-1,y) , dp(x,y-1));
	
	f[x][y] = best;
	return f[x][y];  
}

void trace(int x,int y)
{
	if(x == 0 || y == 0) return;
	
	if(s[x] == p[y]) 
	{
		res.push_back(s[x]-'a');
		trace(x-1,y-1);
	}
	
	else
	{
		if(dp(x,y-1) > dp(x-1,y)) 
			trace(x,y-1);
			
		else
			trace(x-1,y);
	}
}

int main()
{
	res.clear();
	cin>>s>>p;
	s = "8" + s;
	p = "9" + p;
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<N;j++)
		{
			f[i][j] = -1;
		}
	}
	
	f[0][0] = 0;
	trace(s.length()-1,p.length()-1);
	
	for(int i=res.size()-1;i>=0;i--)
	{
		cout<<char(res[i] + 97);
	}
	
}

Measured memory_bytes: 35840
N, K = map(int, input().split())
mod = 10 ** 9 + 7
mi = 0
ma = 0
count = 0

for i in range(K):
    mi += i
for i in range(N, N-K, -1):
    ma += i
#print(mi, ma)
N2 = K
N3 = N-K
#print(count, mi, ma, N2, N3)
for i in range(1, N-K+2):
    count += ma - mi +1
    count %= mod
    mi +=N2
    N2+=1
    ma +=N3
    N3-=1
    #print(count, mi, ma, N2, N3)
count += 1
print(count%mod)


Measured memory_bytes: 64696
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
typedef long long ll;

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define MAX_INT 100000
#define MOD 1000000007
#define forf(i,a,b) for(int i=a;i<b;i++)


// vector<int> adj[1000002];
// int vis[1000002],dep[1000002],siz[1000002];


// void dfs(ll cur,ll par)
// {
//     vis[cur]=1;
//     siz[cur]=1;
//     for(auto x:adj[cur])
//     {
//         if(vis[x]!=1)
//         {
//             dep[x]=dep[cur]+1;
//             dfs(x,cur);
//             siz[cur]+=siz[x];
//         }    
//     }
// }

ll func(ll n,ll m)
{
    return (((n*(n+1))/2)-(m*(m+1))/2)%MOD;
}

void solve()
{
    ll n;cin>>n;
    ll m;cin>>m;
    // ll k;cin>>k;
    // string s="",s1="",s2="";
    ll tmp=0,cnt=0,ans=0,tmp1=0,fg=0,fg1=0;
    // ll a[n];
    for(ll i=m;i<=n+1;i++)
    {
        ans=(ans+func(n,n-i)%MOD-func(i-1,0)%MOD+1+MOD)%MOD;
    }
    cout<<ans%MOD<<endl;
    
    
}
    
int main()
{
    IOS;
    
    // ll t;cin>>t;while(t--)
        solve();
 
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()

using namespace std;

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

  // e+e=e
  // e+o=o !
  // o+e=o !
  // o+o=e
  int ans = 0;
  for (int i = 1; i <= k - 1; ++i)
    for (int j = i + 1; j <= k; ++j)
      if ((i + j) & 1) ans++;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N, M, R = gets.split.map(&:to_i)
r = gets.split.map(&:to_i).map(&:pred)
edges = Array.new(N){[9e9]*N}
$<.each{|s|
  a, b, c = s.split.map(&:to_i)
  edges[a-1][b-1] = edges[b-1][a-1] = c
}
 
N.times{|i|
  N.times{|j|
    N.times{|k|
      if edges[j][k] > x = edges[j][i] + edges[i][k]
        edges[j][k] = x
      end
    }
  }
}
 
p r.permutation.map{|perm|
  perm.each_cons(2).map{|a,b|edges[a][b]}.inject:+
}.min

Measured memory_bytes: 2556
n, m = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n)]
CD = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    a, b = AB[i]
    res = float("inf")
    for j in range(m):
        c, d = CD[j]
        dist = abs(a - c) + abs(b - d)
        if res > dist:
            res = dist
            ans = j + 1
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

vector<int> to[200005];

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  vector<int> dist(n, INF);
  vector<int> prev(n);
  queue<int> q;
  q.push(0);

  while(!q.empty()) {
    int v = q.front(); q.pop();
    for(int u : to[v]) {
      if(dist[u] != INF) {
        continue;
      }
      prev[u] = v;
      dist[u] = dist[v] + 1;
      q.push(u);
    }
  }
  cout << "Yes" << endl;
  rep(i, n) {
    if(i==0) continue;
    int ans = prev[i];
    ans++;
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
    //
    int num;
    int l = 0;
    int r = 0;
    int Min = 99999;

    cin >> num;

    vector<int> vec(num);
    for (int i = 0; i < num; i++) {
        cin >> vec.at(i);
        r += vec.at(i);
    }

    Min = r;
    for (int i = 0; i < num; i++) {
        l += vec.at(i);
        r -= vec.at(i);

        Min = min(Min, abs(l - r));
    }

    cout << Min;
    //
}


Measured memory_bytes: 3648
from sys import setrecursionlimit
setrecursionlimit(10**6)
n,k=map(int,input().split())
paths=[[] for i in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    paths[a-1].append(b-1)
    paths[b-1].append(a-1)
inf=100000000000000
nums=[-inf]*n
nums[0]=k
from collections import deque
now=deque()
now.append(0)
def bfs(d):
    global n,k,paths,nums,now
    l=len(now)
    if d==1:
        for i in range(l):
            p=now.popleft()
            ln=len(paths[p])
            next_num=k-1
            for j in range(ln):
                if nums[paths[p][j]]==-inf:
                    nums[paths[p][j]]=next_num
                    now.append(paths[p][j])
                    next_num-=1
    else:
        for i in range(l):
            p=now.popleft()
            ln=len(paths[p])
            next_num=k-2
            for j in range(ln):
                if nums[paths[p][j]]==-inf:
                    nums[paths[p][j]]=next_num
                    now.append(paths[p][j])
                    next_num-=1
    if len(now):bfs(d+1)
bfs(1)
ans=1
for i in range(n):
    if nums[i]<=0:
        print(0)
        exit()
    ans*=nums[i]
    ans%=(10**9+7)
print(ans)

Measured memory_bytes: 91980
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
using namespace std;

const int A = 0;
const int B = 1;
const int C = 2;

int D, N;
int T[200];
int F[200][3];  //Fuku

int DP[200][200];

int main(void) {
  cin >> D >> N;
  for (int i=0; i<D; i++) {
    cin >> T[i];
  }
  for (int j=0; j<N; j++) {
    cin >> F[j][A] >> F[j][B] >> F[j][C];
  }
  for (int i=0; i<D; i++) {
    for (int j=0; j<N; j++) {
      DP[i][j] = -1;
    }
  }
  for (int j=0; j<N; j++) {
    if (F[j][A]<=T[0] && F[j][B]>=T[0]) {
      DP[0][j] = 0;
    }
  }
  for (int i=0; i<D-1; i++) {
    for (int j=0; j<N; j++) {
      if (DP[i][j] != -1) {
	for (int k=0; k<N; k++) {
	  if (F[k][A]<=T[i+1] && F[k][B]>=T[i+1]) {
	    DP[i+1][k] = max(DP[i+1][k], abs(F[j][C]-F[k][C])+DP[i][j]);
	  }
	}
      }
    }
  }
  int ans = 0;
  for (int j=0; j<N; j++) {
    ans = max(ans, DP[D-1][j]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1320
/**
     *      ABC 109 B
     *      author  : kyomukyomupurin
     *      created : 2018-09-08 21:02:26
    **/
     
    #include <bits/stdc++.h>
    using namespace std;
     
    int main(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        
        int N; cin >> N;
     
        string W[N] = {};
        for (int i = 0; i < N; ++i) {
            cin >> W[i];
        }
     
        for (int i = 0; i < N - 1; ++i) {
            for (int j = i + 1; j < N; ++j) {
                if (W[i] == W[j]){
                    cout << "No" << endl; return 0;
                }            
            }        
        }
     
        for (int i = 0; i < N - 1; ++i) {
            int size = W[i].size();
            if (W[i][size - 1] != W[i + 1][0]){
                cout << "No" << endl; return 0;
            }        
        }
     
        cout << "Yes" << endl;
     
        return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>

using namespace std;

void dfs( int W, int H, int w_index, int h_index, vector< vector<char> > &V, int &ans );

int main(int argc, char const *argv[]) {
    vector< vector<char> > vec;

    int w, h, w_index, h_index, ans;
    vector<int> sums;

    while (1) {
        ans = 1;
        cin >> w >> h;

        if( w==0 || h==0 ) break;

        vec.resize(h);
        for (int i = 0; i < h; i++) {
            vec[i].resize(w);
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cin >> vec[i][j];
            }
        }

        for (auto it = vec.begin(); it != vec.end(); it++ ) {
            auto iter = find(it->begin(), it->end(), '@');

            if(iter!=it->end()){
                h_index = distance( vec.begin(), it );
                w_index = distance( it->begin(), iter );
            }
        }

        dfs( w, h, w_index, h_index, vec, ans );

        sums.push_back( ans );
    }

    for( auto it = sums.begin(); it != sums.end(); it++ ){
        cout << *it << endl;
    }

    return 0;
}

void dfs( int W, int H, int w_index, int h_index, vector< vector<char> > &v , int &ans ){
    int dx[4] = { 1, 0, -1, 0 };
    int dy[4] = { 0, 1, 0, -1 };
    v[h_index][w_index] = '#';

    for( int i = 0; i < 4; i++ ){
        int nx = w_index + dx[i];
        int ny = h_index + dy[i];

        if( 0 <= nx && nx < W && 0 <= ny && ny < H && v[ny][nx] != '#' ){
            ans++;
            dfs( W, H, nx, ny, v, ans );
        }
    }
    return;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define ll long long int


using namespace std;

int main()
{
    ll t,n,item,temp,a,b,c,x,y,z,sum,flag,k;
    string s,s1,s2;
    vector<ll>v;
    vector<string>vs;
    map<ll,ll>mp;
    map<ll,ll>check;

    cin>>a>>b>>c>>x>>y;
    if(!a)
        cout<<1<<endl;
    else if(!b)
        cout<<2<<endl;
    else if(!c)
        cout<<3<<endl;
    else  if(!x)
        cout<<4<<endl;
    else  if(!y)
        cout<<5<<endl;

    return 0;
}


Measured memory_bytes: 3572
// D.

#include <iostream>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <vector>

using namespace std;

string solve(int n, string s) {
	for (int a = 0; a <= 1; ++a) {
		for (int b = 0; b <= 1; ++b) {
			bool ok = true;
			vector<int> t(n, -1);
			t[0] = a;
			t[n - 1] = b;
			for (int j = 0; j < n; ++j) {
				bool same = s[j] == 'o';
				int prev = t[(j - 1 + n) % n];
				int& next = t[(j + 1) % n];
				if (next == -1) {
					next = t[j] ^ !same ^ prev;
				} else if ((same ^ t[j]) != (next == prev)) {
					ok = false;
				}
			}
			if (ok) {
				string ans;
				for (int i = 0; i < n; ++i) {
					ans += t[i] ? 'W' : 'S';
				}
				return ans;
			}
		}
	}
	return "-1";
}

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	string s;
	cin >> s;
	cout << solve(n, s) << endl;
	return 0;
}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mp(v1, v2)       make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  string s;
  cin >> s;

  bool prev[4][1001];
  bool now[4][1001];
  map<int, bool> mp;

  rep(i,4){
    rep(j,1001){
      prev[i][j]=false;
      now[i][j]=false;
    }
  }
  prev[0][0]=true;
  rep(i,n){
    rep(j,3){
      rep(k,1000){
        if(!prev[j][k]) continue;
        int tmp = s[i]-'0';
        now[j][k] = true;
        if(j<3) now[j+1][k*10+tmp]=true;
        if(j==2 && mp.find(k*10+tmp)==mp.end()){
          mp.emplace(k*10+tmp, true);
        }
      }
    }
    rep(j,3){
      rep(k,1000){
        prev[j][k]=now[j][k];
      }
    }
  }

  prt(mp.size());
}


Measured memory_bytes: 384
import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

# available on Google, not available on Codeforces
# import numpy as np
# import scipy


def solve(grid):  # fix inputs here
    console("----- solving ------")

    for a,b,c in zip(grid, grid[1:], grid[2:]):
        if a[0] == a[1] and b[0] == b[1] and c[0] == c[1]:
            return "Yes"
    return "No"


def console(*args):  # the judge will not read these print statement
    print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return

# fast read all
# sys.stdin.readlines()

for case_num in [1]:
    # read line as a string
    # strr = input()

    # read line as an integer
    nrows = int(input())
    
    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer
    # lst = list(map(int,input().split()))

    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
    grid = []
    for _ in range(nrows):
        grid.append(list(map(int,input().split())))

    res = solve(grid)  # please change
    
    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
    print(res)


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

using namespace std;
typedef long long ll;
const int MAXN = 1e5 * 2 + 5;

ll adds[MAXN];
ll ans[MAXN];

vector<int> G[MAXN];

void dfs(int cur, int p, ll count) {
  count += adds[cur];
  ans[cur] = count;
  for (int i = 0; i < (int)G[cur].size(); ++i) {
    if (G[cur][i] != p) {
      dfs(G[cur][i], cur, count);
    }
  }
}

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

  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    // cerr << "a, b: " << a << " " << b << endl;
    a--; b--;    
    G[a].push_back(b);
    G[b].push_back(a);
  }

  for (int i = 0; i < q; ++i) {
    int p; ll x;
    cin >> p;
    cin >> x;
    p--;
    adds[p] += x;
  }

  dfs(0, -1, 0);
  for (int i = 0; i < n; ++i) {
    cout << ans[i];
    if (i == n - 1) cout << endl;
    else cout << " ";
  }
  return 0;
}



Measured memory_bytes: 31872
import re
import copy

def accept_input():
    N = int(input())
    A = {}
    for i in range(1,N+1):
        A[i] = int(input())
    return N,A

def process(s):
    if s == "#":
        return 1
    else:
        return 0
N,A = accept_input()
cur = 1
kaisu = 0
for _ in range(N):
    cur = A[cur]
    kaisu += 1
    if cur == 2:
        break
if cur == 2:
    print(kaisu)
else:
    print(-1)


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

using db = double;
const db eps = 1e-9;
int sgn(db a, db b = 0) {
	a -= b;
	return (a > eps) - (a < -eps);
}

struct poi {
	db x, y;
	poi operator -(poi p) {
		return {x - p.x, y - p.y};
	}
	poi operator *(db d) {
		return {x * d, y * d};
	}
	poi operator /(db d) {
		return {x / d, y / d};
	}
	db cross(poi p) {
		return x * p.y - y * p.x;
	}
};
db xmul(poi a, poi b, poi c) {
	return (b - a).cross(c - a);
}
poi li(poi a, poi b, poi c, poi d) {
	db u = xmul(c, d, a), v = xmul(c, d, b);
	return (a * v - b * u) / (v - u);
}

using vp = vector <poi>;

vp cp_cut(vp cp, poi p, poi q) {
	vp ret; int n = cp.size();
	for(int i = 0; i < n; ++i) {
		poi s = cp[i], t = cp[(i + 1) % n];
		int d1 = sgn(xmul(p, q, s)), d2 = sgn(xmul(p, q, t));
		if(d1 >= 0) ret.push_back(s);
		if(d1 * d2 < 0) ret.push_back(li(s, t, p, q));
	}
	return ret;
}

int main() {
	cout << fixed << setprecision(9);
	ios :: sync_with_stdio(false);
	int n; cin >> n; vp v;
	for(int i = 0; i < n; i ++) {
		db x, y; cin >> x >> y;
		v.push_back({x, y});
	}
	int T; cin >> T;
	while(T --) {
		poi p, q;
		cin >> p.x >> p.y;
		cin >> q.x >> q.y;
		vp u = cp_cut(v, p, q);
		db ans = 0;
		for(int i = 0; i < u.size(); i ++)
			ans += u[i].cross(u[(i + 1) % u.size()]) / 2;
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    vector<int> n(3);
    rep(i,3) cin >> n[i];
    sort(all(n));
    cout << 10*n[2]+n[1]+n[0] << endl;
}

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

bool match(vector<string> b, vector<string> q){
    auto np = string::npos;
    if(q[0] != "*" && b[0].find(q[0]) == np) return false;
    if(q[1] != "*" && b[1].find(q[1]) == np) return false;
    if(q[2] != "*" && q[2] > b[2]) return false;
    if(q[3] != "*" && q[3] < b[2]) return false;
    return true;
}

int main(){
    int n;
    cin >> n;
    vector<vector<string>> bs(n,{"","","",""});
    rep(i,n)rep(j,3) cin >> bs[i][j];
    int q;
    cin >> q;
    rep(i,q){
        vector<string> qq(4);
        rep(j,4) cin >> qq[j];
        rep(j,n){
            if(match(bs[j],qq)){
                cout << bs[j][0] << endl;
            }
        }
        if(i!=q-1) cout << endl;
    }
}

Measured memory_bytes: 1244
n = int(input())
l = list(map(int, input().split()))
for i in range(n):
    if l[i]%2 == 0:
        if l[i]%3 == 0 or l[i]%5 == 0:
            continue
        else:
            print('DENIED')
            exit()
else:
    print('APPROVED')

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
constexpr int MOD = 1e9 + 7;
//} END

constexpr int MAX_N = 2 * 10e3 + 10;
int n, x, y;
Graph graph;
int min_cost[MAX_N];

void Dijkstra(int s) {
  //昇順でfirstを小さい方から取る
  min_heap<P> que;
  fill(min_cost, min_cost + n + 2, INF);
  min_cost[s] = 0;
  que.emplace(0, s);

  while (!que.empty()) {
    int now_cost, now_node;
    tie(now_cost, now_node) = que.top();
    que.pop();

    if (min_cost[now_node] <
        now_cost)  // queの値より新しいcostの方が小さいとき見ない
    {
      continue;
    }

    rep(i, 0, graph[now_node].size()) {
      int next_node, next_cost;
      tie(next_node, next_cost) = graph[now_node][i];

      if (chmin(min_cost[next_node],
                min_cost[now_node] + next_cost))  //最短経路の更新
      {                                           //最短経路更新
        que.emplace(min_cost[next_node], next_node);
      }
    }
  }
}

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  cin >> n >> x >> y;

  graph.resize(n + 1);

  rep(i, 1, n) {
    graph[i].emplace_back(i + 1, 1);  //グラフの構築
    graph[i + 1].emplace_back(i, 1);
  }
  graph[x].emplace_back(y, 1);
  graph[y].emplace_back(x, 1);

  vector<int> ans(n + 5);

  rep(i, 1, n) {
    Dijkstra(i);
    rep(j, i + 1, n + 1)++ ans[min_cost[j]];
  }

  rep(i, 1, n) cout << ans[i] << '\n';

  return 0;
}

Measured memory_bytes: 3772
N = int(input())
edge = [[] for _ in range(N+1)]
d = [0] * (N+1)
f = [0] * (N+1)
for i in range(N):
    t = list(map(int, input().split()))
    for j in range(t[1]):
        edge[t[0]].append(t[j+2])

#print(1)
def dfs(v, t):
    if d[v] == 0:
        d[v] = t
        t += 1
    else:
        return t
    for nv in edge[v]:
        t = dfs(nv, t)
    if f[v] == 0:
        f[v] = t
        t += 1
    return t

t = 1
for i in range(1,1+N):
    if d[i] == 0:
        t = dfs(i, t)
for i in range(1,1+N):
    print(i, d[i], f[i])



Measured memory_bytes: 5716
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val X = sc.next().toInt()
        pw.println(if (X >= 30) "Yes" else "No")
    }
}


Measured memory_bytes: 36436
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Control.Monad.State (State, evalState, runState, put, gets, modify)
import Data.Map.Strict (Map, lookup, insert, empty)
import Data.Foldable

main :: IO ()
main = readLn >>= print . solve

solve :: Int -> Int
solve n = evalMemo calc ("XXX", n)
    where
        calc _ (_, 0) = return 1
        calc f (_ : "AG", i) = adds f [("AGA", i - 1), ("AGG", i - 1), ("AGT", i - 1)]
        calc f (_ : "GA", i) = adds f [("GAA", i - 1), ("GAG", i - 1), ("GAT", i - 1)]
        calc f (_ : "AC", i) = adds f [("ACA", i - 1), ("ACC", i - 1), ("ACT", i - 1)]
        calc f ('A' : x : "G", i) = adds f [(x : "GA", i - 1), (x : "GG", i - 1), (x : "GT", i - 1)]
        calc f ('A' : 'G' : [x], i) = adds f [('G' : x : "A", i - 1), ('G' : x : "G", i - 1), ('G' : x : "T", i - 1)]
        calc f (_ : xs, i) = adds f [(xs ++ "A", i - 1), (xs ++ "C", i - 1), (xs ++ "G", i - 1), (xs ++ "T", i - 1)]

        adds f xs = mapM f xs >>= foldlM ff 0 
            where
                ff acc x = return $ acc `add` x

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

infixl 6 `add`
infixl 7 `mul`

add :: Int -> Int -> Int
add x y = val $ x + y

mul :: Int -> Int -> Int
mul x y = val $ x * y

inv :: Int -> Int
inv x = pow x $ modVal - 2

pow :: Int -> Int -> Int
pow b e
    | e == 0 = 1
    | odd e = mul b . pow b $ e - 1
    | otherwise = mul v v
    where
        v = pow b $ e `div` 2

val :: Int -> Int
val = (`mod` modVal)

modVal :: Int
modVal = 10 ^ 9 + 7

primes :: [Int]
primes = build [2..]
    where
        build (x : xs) = x : build (filter (\n -> n `mod` x /= 0) xs)
        
isPrime :: Int -> Bool
isPrime n = check primes
    where
        check (x : xs)
            | x == n = True
            | x > n = False
            | otherwise = check xs


type Memoizer a b = a -> State (Map a b) b

evalMemo :: (Ord a) => (Memoizer a b -> Memoizer a b) -> a -> b
evalMemo f = flip evalState empty . memoizeFix f

runMemo :: (Ord a) => (Memoizer a b -> Memoizer a b) -> a -> (b, Map a b)
runMemo f = flip runState empty . memoizeFix f

memoizeFix :: (Ord a) => (Memoizer a b -> Memoizer a b) -> Memoizer a b
memoizeFix f x = gets (Data.Map.Strict.lookup x) >>= maybe (f (memoizeFix f) x >>= ((<$) <*> (modify . Data.Map.Strict.insert x))) return

Measured memory_bytes: 3452
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define F(i, j, k) for(int i = j; i <= k; ++i)
#define pp pair<int, int>
#define mp make_pair
const int maxn = 2e5+5;
int n, m, x;
int read() {
    char ch = getchar();
    int x = 0,f = 1;
    while(!isdigit(ch)) {
	if(ch == '-') f = -1;
	ch = getchar();
    }
    while(isdigit(ch)) {
	x = x * 10 + ch - '0';
	ch = getchar();
    }
    return x * f;
}
int main() {
#ifdef orz
    freopen("input", "r", stdin);
#endif
    n = read();
    int a[maxn];
    F(i, 1, n) cin >> a[i];
    int pos = 1, ans = 0;
    while(pos <= n) {
	if(a[pos] != pos) {
	    pos++;
	    continue;
	}
	if(a[pos+1] == pos+1 || a[pos+1] != pos) pos += 2;
	else pos++;
	ans++;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int array[10];
  int N;
  int sum=0;
  cin>>N;
  for(int i=0;i<N;i++)
    cin>>array[i];
  sort(array,array+N);
  for(int i=0;i<N-1;i++)
    sum+=array[i];
  sum+=(array[N-1]/2);
  cout<<sum<<endl;
}


Measured memory_bytes: 256
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

bool app[256];

int32_t main() {
    fastIO();
    
    string s;
    cin >> s;
    
    for (auto ch : s) app[ch] = 1;
    
    if ((app['N'] ^ app['S']) or (app['E'] ^ app['W'])) cout << "No\n";
    else cout << "Yes\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)


int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m, 0);
    rep1(i, m) cin >> a[i];
    ll sum = accumulate(a.begin(), a.end(), 0);
    ll ans = 0;
    if (sum > n) ans = -1;
    else ans = n - sum;
    cout << ans << endl;
}

Measured memory_bytes: 3700
A=gets.to_i
B=gets.to_i
C=gets.to_i
X=gets.to_i

ans = 0
0.upto(X/500) do |i|
  break if i > A
  0.upto((X-i*500)/100) do |j|
    break if j > B
    0.upto((X-500*i-100*j)/50) do |k|
      break if k > C
      ans += 1 if 500*i+100*j+50*k == X
    end
  end
end
puts ans

Measured memory_bytes: 1788
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Edge{
	int src,dst;
	Edge(){}
	Edge(int s,int d):src(s),dst(d){}
};
typedef vector<vector<Edge> > Graph;

bool BFS(const Graph& g,const vi& side,const vi& match,vi& level)
{
	int n=g.size();
	level.assign(n,n);
	queue<pii> q;
	rep(i,n) if(side[i]==0 && match[i]==-1)
		q.push(mp(i,0));
	bool res=false;
	while(!q.empty()){
		pii cur=q.front(); q.pop();
		int u=cur.first,l=cur.second;
		if(level[u]<=l) continue;
		level[u]=l;
		rep(i,g[u].size()){
			int v=g[u][i].dst;
			if(match[v]==-1)
				res=true;
			else
				q.push(mp(match[v],l+2));
		}
	}
	return res;
}

bool DFS(const Graph& g,const vi& side,int u,vi& match,vi& level)
{
	rep(i,g[u].size()){
		int v=g[u][i].dst;
		if(match[v]==-1 || level[match[v]]>level[u] && DFS(g,side,match[v],match,level)){
			match[u]=v;
			match[v]=u;
			return true;
		}
	}
	level[u]=-1;
	return false;
}

int HopcroftKarp(const Graph& g,const vi& side,vi& match)
{
	int n=g.size();
	match.assign(n,-1);
	int res=0;
	for(vi level;BFS(g,side,match,level);)
		rep(i,n) if(side[i]==0 && match[i]==-1)
			res+=DFS(g,side,i,match,level);
	return res;
}

typedef complex<double> Point;

int main()
{
	for(int n,m;scanf("%d%d",&n,&m),n|m;){
		vector<Point> ts(n),bs(m);
		vi vs(n);
		rep(i,n){
			int x,y; scanf("%d%d%d",&x,&y,&vs[i]);
			ts[i]=Point(x,y);
		}
		rep(i,m){
			int x,y; scanf("%d%d",&x,&y);
			bs[i]=Point(x,y);
		}
		
		vvd t(n,vd(m));
		rep(i,n) rep(j,m)
			t[i][j]=abs(bs[j]-ts[i])/vs[i];
		
		double lo=0,hi=20000;
		rep(_,50){
			double mi=(lo+hi)/2;
			Graph g(n+m);
			rep(i,n) rep(j,m) if(t[i][j]<mi){
				g[i].emplace_back(i,n+j);
				g[n+j].emplace_back(n+j,i);
			}
			vi side(n+m),match;
			fill(n+all(side),1);
			if(HopcroftKarp(g,side,match)==m)
				hi=mi;
			else
				lo=mi;
		}
		printf("%.8f\n",lo);
	}
	
	return 0;
}

Measured memory_bytes: 1612
#include<iostream>

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

int main(){
	int n;
	char str[500][73];
	std::cin >> n;
	int strsize;
	int moji;
	int ans;
	rep(h,n){
		std::cin >> str[0];
		strsize = 0;
		rep(i,73){
			if(str[0][i] == '\0'){
				strsize = i;
				break;
			}
		}
		rep(i,strsize-1){
			rep(j,7){
				switch(j){
				case 0:rep(k,strsize) {
						if (k <= i) str[1 + j + 7 * i][k] = str[0][k];
						else str[1 + j + 7 * i][k] = str[0][strsize + i - k];
					}
					break;
				case 1:rep(k,strsize) {
						if (k <= i) str[1 + j + 7 * i][k] = str[0][i - k];
						else str[1 + j + 7 * i][k] = str[0][k];
					}
					break;
				case 2:rep(k,strsize) {
						if (k <= i) str[1 + j + 7 * i][k] = str[0][i - k];
						else str[1 + j + 7 * i][k] = str[0][strsize+i-k];
					}
					break;
				case 3:rep(k,strsize) {
						if (k <= i) str[1 + j + 7 * i][strsize-1-i+k] = str[0][k];
						else str[1 + j + 7 * i][k-i-1] = str[0][k];
					}
					break;
				case 4:rep(k,strsize) {
						if (k <= i) str[1 + j + 7 * i][strsize - 1 - i + k] = str[0][k];
						else str[1 + j + 7 * i][strsize-k-1] = str[0][k];
					}
					break;
				case 5:rep(k,strsize) {
						if (k <= i) str[1 + j + 7 * i][strsize-k-1] = str[0][k];
						else str[1 + j + 7 * i][k-i-1] = str[0][k];
					}
					break;
				case 6:rep(k,strsize) {
						if (k <= i) str[1 + j + 7 * i][strsize - k - 1] = str[0][k];
						else str[1 + j + 7 * i][strsize-k-1] = str[0][k];
					}
					break;
				}
			}
		}
		rep(k,7*(strsize-1)+1) {
			if(str[k][0] == '0')continue;
			rep(i,7*(strsize-1)+1) {
				if(i == k || str[i][0] == '0')continue;
				moji = 0;
				rep(j,strsize) {
					if (str[i][j] != str[k][j])
						break;
					else
						moji++;
				}
				if (moji == strsize)
					str[i][0] = '0';
			}
		}
		ans=0;
		rep(i,(strsize-1)*7+1){
			if(str[i][0] != '0')ans++;
		}
		std::cout << ans << std::endl;
	}
	return 0;
}

Measured memory_bytes: 0
use proconio::input;

fn main() {
    input! {
        x: f64,
    }

    let mut s = 100.0_f64;
    let mut r = 0;

    while s < x {
        s = (s * 1.01).trunc();
        r += 1;
    }

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


Measured memory_bytes: 2628
#include<stdio.h>
int map[20][20],n,N,center,num;
void next(int y,int x){
	if(num>N)return;
	if(n<=y)next(0,x);
	else if(n<=x)next(y,0);
	else if(x<0)next(y,n-1);
	else if(map[y][x]==-1){
		map[y][x]=num;
		num++;
		next(y+1,x+1);
	}
	else if(map[y][x]>0)next(y+1,x-1);
}
int main(){
	int i,j;
	for(;scanf("%d",&n)&&n;){
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				map[i][j]=-1;
			}
		}
		N=n*n;
		center=(n+1)/2-1;
		num=1;
		next(center+1,center);
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				printf("%4d",map[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}

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

if A == B:
    print(A)
elif B - A == 1:
    print(A^B)
else:
    ans = 0
    if A % 2 != 0:
        ans ^= A
        A += 1
    if B % 2 == 0:
        ans ^= B
        B -= 1
    ans ^= ((B-A+1)//2)%2

    print(ans)  

Measured memory_bytes: 3064
N, K =map(int,input().split())
p = list(map(int,input().split()))

for i in range(N):
    for n in range(N-1):
        if p[n]>p[n+1]:
            tmp = p[n]
            p[n] = p[n+1]
            p[n+1] = tmp

ans =0
for i in range(K):
    ans += p[i]

print(ans)

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

#define fastIO ios::sync_with_stdio(false);cout.tie(0);cin.tie(0);
#define endl '\n'
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MP make_pair
#define inf INT_MAX
#define minf INT_MIN

typedef long long int lli;

ofstream outfile;
ifstream infile;

int main()
{
	lli n, m, temp, t;
	lli sum1 = 0, sum2 = 0, prod;

	cin >> n >> m;
	lli i, j;
	temp = -(n-1);
	for(i = 0; i < n; ++i)
	{
		
		cin >> t;
		sum1 = (sum1+ t * temp)%(1000000007);
		temp += 2;
	}
	//cout << "\n"<<temp << " "<< sum1 << "\n";
	temp = -(m-1);

	for(i = 0; i < m; ++i)
	{
		cin >> t;
		sum2 = (sum2+ t* temp)%(1000000007);
		temp += 2;
	}
	//cout << temp <<" "<< sum2<<  "\n";

	prod = (sum1%(1000000007) *sum2%(1000000007))%(1000000007);

	cout << prod << "\n";
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n: usize,
      m: usize,
      q: usize,
      lr: [(Usize1, Usize1); m],
      pq: [(Usize1, Usize1); q],
   }

   let mut a = vec![vec![0; n]; n];
   for &(l, r) in lr.iter() {
      a[l][r] += 1;
   }
   for i in 0..n {
      for j in i + 1..n {
         a[i][j] += a[i][j - 1];
      }
   }
   for i in (0..n - 1).rev() {
      for j in i + 1..n {
         a[i][j] += a[i + 1][j];
      }
   }
   for (p, q) in pq {
      println!("{}", a[p][q]);
   }
}


Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> pll;
typedef pair<int, int> pii;
#define ff first
#define ss second
#define mod 1000000007

lli n,w;
lli dp[101][100005];
lli wg[101],val[101];

lli func(lli in,lli lt){
    if(in==n) return 0;
    if(lt==0) return 0;
    if(dp[in][lt]!=-1) return dp[in][lt];

    lli j;
    if(lt>=wg[in]) j=val[in] + func(in+1,lt-wg[in]);
    else j=0;
    return dp[in][lt] = max(j , func(in+1,lt));
}

int main(){
    cin>>n>>w;
    lli i,j,l;
    memset(dp,-1,sizeof(dp));
    for(i=0;i<n;i++){
        cin>>wg[i]>>val[i];
    }
    lli ans=func(0,w);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 79104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;



public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n=sc.nextInt();
		int a[]=sc.readArray(n);
		
		long ans=0;
		for(int i=1;i<n;i++) {
			if(a[i]<a[i-1]) {
				ans+=a[i-1]-a[i];
				a[i]=a[i-1];
			}
		}
		out.println(ans);
		out.close();
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}

Measured memory_bytes: 55028
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
#define MAXX 200010
 
#define PI   3.14159265358979323846264338327950
 
#define PB push_back 
#define F first
#define S second
 
#define fixx(n) fixed << setprecision(n)
 
#define ll 	  long long 
 
#define mod  1000000007
 
 
 
int main()
{
	FAST;
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0; i < s.size(); i ++){
		ans += s[i]-48;
	}
	if(ans % 9){
		cout << "No";
		return 0;
	}
	cout << "Yes";
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vz;
typedef vector<vz> vvz;
typedef pair<ll, ll> pll;
#define sz(x) ll((x).size())
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(ll i=(a); i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define F first
#define S second
#define os(x) cout<<x<<' '
#define on(x) cout<<x<<"\n"
#define nl cout<<"\n"
#define maxe(x) max_element(all(x))-(x).begin()
#define mine(x) min_element(all(x))-(x).begin()
const ll P=1e9+7;
const ll N=1e6+10;

ll gcd(ll a, ll b)
{
	ll m=min(a, b), M=max(a, b);
	if(m==0) return M;
	return gcd(m, M%m);
}

vector<ll> spf(N+1, 1);

void sieve(){
	for(ll i=2; i<N+1; i+=2) spf[i]=2;
	for(ll i=3; i<N+1; i+=2){
		spf[i]=i;
	}
	for(ll i=3; i*i<N+1; i+=2){
		if(spf[i]!=i) continue;
		for(ll j=i*i; j<N+1; j+=i){
			if(spf[j]==j) spf[j]=i;
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\input1.txt", "r", stdin);
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\output1.txt", "w", stdout);
#endif

	int n;
	cin>>n;
	if(n) on(0);
	else on(1);
	cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
	return 0;
}

Measured memory_bytes: 10968
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;
string s,st;
void digui(int w){
    if(s[w]=='e'){
        st="";
        for(int i=w;i<=w+4;i++)st+=s[i];
        if(st=="erase"){
            if(w+4==s.size()-1){
                cout<<"YES"<<endl;
                exit(0);
            }
            if(s[w+5]=='r'){
                if(w+5==s.size()-1){
                    cout<<"YES"<<endl;
                    exit(0);
                }
                digui(w+5+1);
            }
            else digui(w+4+1);
        }
        else return ;
    }
    if(s[w]=='d'){
        st="";
        for(int i=w;i<=w+4;i++)st+=s[i];
        if(st=="dream"){
            if(w+4==s.size()-1){
                cout<<"YES"<<endl;
                exit(0);
            }
            if(s[w+5]=='e'&&s[w+6]=='r'){
                if(w+6==s.size()-1){
                    cout<<"YES"<<endl;
                    exit(0);
                }
                digui(w+6+1);
                digui(w+4+1);
            }
            else digui(w+4+1);
        }
        else return ;
    }
}
int main(){
    cin>>s;
    if(s[0]!='d'&&s[0]!='e'){
        cout<<"NO"<<endl;
        return 0;
    }
    digui(0);
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}



main(){
  int n,t;
  cin>>n>>t;
  int res=inf,ans=inf;

  rep(i,n){
    int a,b;
    cin>>a>>b;
    if(b<=t&&res>a){
      ans=i+1;
      res=a;
    }
  }

  if(res==inf){
    cout<<"TLE"<<endl;
  }else{
    cout<<res<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dbl double
#define forn(i,n,k) for(int i=0;i<n;i=i+k)
#define forpn(p,n,k) for(int i=p;i<n;i+=k)
#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
using namespace std;
int a[500000],b[500000];
int no_of_bits(long long n)
{
    int count=0;
    while(n>0)
    {
        n=n>>1;
        count++;
    }
    return count;
}
long long gcd(int a,int b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
void primeFactors(int n,int p)  
{  
    
   if(n%2==0){ a[p]=2;}
    while (n % 2 == 0)  
    {  
        // cout << 2 << " ";
        
        // a[p]=2;
        n = n/2;  
    }  
  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
     if(n%i==0){ if(a[p]>0) b[p]=i;
         else a[p]=i;
     }
        while (n % i == 0)  
        {  
            // cout << i << " ";  
            n = n/i;  
        }  
    }  
   
}
void solve(){
   int a,b;
   cin>>a>>b;
   if(b>=2*a&&b<=4*a&&b%2==0) cout<<"Yes";
   else cout<<"No";
}
int main()
{   ios::sync_with_stdio(0);
    int t;
    // cin>>t;
    t=1;
    cin.tie(0);
    cout.tie(0);
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3688
N = int(input())
S = list(map(int, input().split()))
ans = int(sum(S) /N)
def HP(x):
    A = 0
    for i in S:
        A += (i - x) **2
    return A

mi = False
UP = False
DO = False
while(mi == False):
    if HP(ans) > HP(ans+1):
        ans = ans+1
        UP = False
        DO = False
    elif HP(ans) > HP(ans-1):
        ans = ans -1
        UP = False
        DO = False
    elif HP(ans) == HP(ans+1):
        if DO :
            break
        else:
            UP = True
            ans = ans +1
    elif HP(ans) == HP(ans-1):
        if UP:
            break
        else:
            Do = True
            ans = ans -1  
    else:
        mi = True

print(HP(ans)) 

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

#define f first
#define s second
#define int long long
int32_t main()
{
    string s,t;
    cin>>s>>t;
    
    int n=s.length();
    int m=t.length();
    
    int lcs[n+1][m+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i==0 || j==0)
                lcs[i][j]=0;
            else if(s[i-1]==t[j-1])
                lcs[i][j]=lcs[i-1][j-1]+1;
            else
                lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
        }
    }
    string ans;
    int len=lcs[n][m];
   // cout<<len;
    int i=n;
    int j=m;
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans.push_back(s[i-1]);
            i--;
            j--;
        }
            else if(lcs[i-1][j]>lcs[i][j-1])
            i--;
        else
            j--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
}

Measured memory_bytes: 70656
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
// 1. dpを書く
// 2. nを書く
ll N;
ll A[100001];
ll B[100001];
ll C[100001];
// 7. calcを書く
ll calcA(ll lb,ll ub,ll k){
	if(A[lb]>=k)return -1;
	ll mid=(lb+ub)/2;
	if(ub-lb<2){
		if(A[ub]<k)return ub;
		return lb;
	}
	if(A[mid]<k){
		lb=mid;
	}else{
		ub=mid;
	}

	return calcA(lb,ub,k);
}
ll calcC(ll lb,ll ub,ll k){
	if(C[lb]<=k)return -1;
	ll mid=(lb+ub)/2;
	if(ub-lb<2){
		if(C[ub]>k)return ub;
		return lb;
	}
	if(C[mid]>k){
		lb=mid;
	}else{
		ub=mid;
	}

	return calcC(lb,ub,k);

}


int main() {
	cin>>N;

	//3.初期化

	//4.入力
	for(ll i=0;i<N;i++){
		cin>>A[i];
	}
	for(ll i=0;i<N;i++){
		cin>>B[i];
	}
	for(ll i=0;i<N;i++){
		cin>>C[i];
	}

	//5.並び替え
	sort(A,A+N);
	sort(C,C+N, greater<ll>() );

	//6.出力

	ll total=0;
	for(ll i=0;i<N;i++){
		total+=(calcA(0,N-1,B[i])+1)*(calcC(0,N-1,B[i])+1);
	}

	cout<<total<<endl;

	return 0;
}


Measured memory_bytes: 2560