akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/



int main(){
  ll n,ma,mb;
  cin>>n>>ma>>mb;
  vec(a,n);
  vec(b,n);
  vec(c,n);
  rep(i,n){
    cin>>a[i]>>b[i]>>c[i];
  }
  //mat(dp,510,510);
  vector<vector<vector<ll>>> DP(411,vector<vector<ll>>(411,vector<ll>(41,-1)));
  /*
  rep(i,dp.size()){
    rep(j,dp[i].size()){
      dp[i][j]=-1;
    }
  }*/
  rep(i,n){
  DP[0][0][0]=0;
  }
  rep(k,n){
  rep(i,401){
    rep(j,401){
      
        if(DP[i][j][k]!=-1){
          if(DP[i+a[k]][j+b[k]][k+1]>0) DP[i+a[k]][j+b[k]][k+1]=min(DP[i+a[k]][j+b[k]][k+1],c[k]+DP[i][j][k]);
          else DP[i+a[k]][j+b[k]][k+1]=c[k]+DP[i][j][k];
          if(DP[i][j][k+1]>=0) DP[i][j][k+1]=min(DP[i][j][k],DP[i][j][k+1]);
          else DP[i][j][k+1]=DP[i][j][k];
        }
      }
    }
  }
  ll ans=LLONG_MAX;
  for(int i=1;;i++){
    if(i*ma>401||i*mb>401)break;
    if(DP[i*ma][i*mb][n]!=-1){
      ans=min(ans,DP[i*ma][i*mb][n]);
    }
  }
  /*
  rep(i,n){
    rep(j,10){
      rep(k,10){
        cout<<DP[j][k][i]<<" ";
      }cout<<endl;
    }cout<<endl;
  }
  */

  if(ans==LLONG_MAX)ans=-1;
  op(ans); 
  return 0;
}

Measured memory_bytes: 59776
#include<bits/stdc++.h>
using namespace std;
int main (){
    int a , b;
    cin >> a >> b;
   int sum = 1;
   for(int i=0; i < a; i++){
      if(sum <= b){
          sum *= 2;
      }
       else{
           sum += b;
       }
   } 
  cout << sum << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<pair<long,long>> xy,res;
  long dx1=-INF*2,dx2=-INF*2,dy1=INF*2,dy2=INF*2;
  //set<pair<long,long>> res;
  rep(i,n){
    long a,b;
    cin >> a >> b;
    xy.push_back({a,b});
    res.push_back({a-b,a+b});
    dx1 = max(dx1,a-b);
    dx2 = max(dx2,a+b);
    dy1 = min(dy1,a-b);
    dy2 = min(dy2,a+b);
  }
  cout << max(dx1-dy1,dx2-dy2) << endl;
  return 0;
}

Measured memory_bytes: 9748
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
    n,a=MI()
    lis=LI()
    for i in range(n):
        lis[i]-=a
    #print(lis)
    dp=[[0]*5001 for i in range(n+1)]
    dp[0][2500]=1
    for i in range(n):
        num=lis[i]
        for j in range(5001):
            dp[i+1][j]+=dp[i][j]
            if 0<=j+num<5001:
                dp[i+1][j+num]+=dp[i][j]
    #print(dp)
    print(dp[-1][2500]-1)
if __name__=="__main__":
    main()

Measured memory_bytes: 68376
//
//  -b.cpp
//  ABC119
//
//  Created by hiroaki on 2019/02/25.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<float> x(n);
    vector<string> u(n);
    
    for (int i=0; i<n; i++) {
        cin >> x.at(i) >> u.at(i);
    }
    
    float sum = 0;
    for (int i=0; i<n; i++) {
        if (u[i]=="JPY") {
            sum=sum+x[i];
        }else{
            sum=sum+380000.0*x[i];
        }
    }
    cout << sum <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 128
#define ll long long
#define dmp make_pair
#define dpb push_back
#define P pair<int,int>
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);
const int INF = 1e9;

int n, t, dat[MAX+1], a[100000];
void add(int k, int x){
	if(!k)t++;
	else{
		while(k <= n){
			dat[k] += x;
			k  += k&-k;
		}
	}
}

int sum(int k){
	int ans = 0;
	while(k > 0){
		ans += dat[k];
		k -= k&-k;
	}
	return ans+t;
}

int main(){
	int m, x, ans = 0;
	scanf("%d", &m);
	n = MAX;t = 0;
	rep(i,m)scanf("%d", &a[i]);
	for(int i = 0;i < m;i++){
		ans += i-sum(a[i]);
		add(a[i], 1);
	}
	sort(a, a+m);
	rep(i,m-1)printf("%d ", a[i]);
	printf("%d\n", a[m-1]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3276
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n) {
        cin >> v[i];
    }
    int pre=v[0];

    for(int i=1;i<n;i++){
        if(v[i]>v[i-1]){
            pre=v[i];
        }else if(v[i]+1==v[i-1]){
            //pre=v[i]+1;
            v[i]++;
        }else if(v[i-1]==v[i]){
            
        } else{
            cout<<"No"<<endl;
            return 0;
        }

    }
    cout<<"Yes"<<endl;



    return 0;
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;


int main() {
  int n, m; cin >> n >> m;
  int a;
  for (int i = 0; i < m; i++){
    cin >> a;
    n -= a;
  }
  if(n >= 0){
    cout << n << endl;
  }else{
    cout << "-1" << endl;
  }
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,a,b; cin>>n>>a>>b;
    if (n+a+b >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

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

int main(int argc, const char * argv[]) {
    
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    if(x >= r &&
       y >= r &&
       W - r >= x &&
       H - r >= y){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
//@author yash
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define x first
#define y second
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
	fast();
	int k;
	cin>>k;
	int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cout<<arr[k-1]<<endl;	
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a[ohara],b[ohara],c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>h;
    rep(i,n)cin>>a[i]>>b[i];
    ll furu=*max_element(a,a+n);
    sort(b,b+n);
    reverse(b,b+n);
    rep(i,n){
        if(furu>b[i]||h<=0)break;
        h-=b[i];
        ans++;
    }
    if(h<=0)Cout(ans);
    else{
        tmp=h/furu;
        if(h%furu!=0)tmp++;
        ans+=tmp;
        Cout(ans);
    }
    return 0;
}


Measured memory_bytes: 5120
// round robin


#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
// [name,time]
pair<string,int> process[100010];
queue<pair< string,int> > Q;
queue<pair< string,int> > Ans;
pair<string,int> temp;
int time0;
int main(){
  int n,q,b;
  string a;
  cin >> n >> q;
  for (int i=0; i<n; i++){
    cin >> a >> b;
    process[i] = make_pair(a,b);
    Q.push(process[i]);
  }
  while(!Q.empty()){
    temp = Q.front();
    Q.pop();
    if (temp.second <= q){
      time0 += temp.second;
      temp.second = time0;
      Ans.push(temp);
    }else{
      time0 += q;
      temp.second -= q;
      Q.push(temp);
    }
  }
  for (int i=0; i<n; i++){
    cout << Ans.front().first << " " << Ans.front().second << endl;
    Ans.pop();
  }
}

Measured memory_bytes: 6012
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n,mini;
  cin >> n;
  vector <string> data1(n),data2(n);
  for(int i=0;i<n;i++){
    cin >> data1[i];
    data2[i] = data1[i];
  }
  for(int i=0;i<n-1;i++){
    for(int j=n-1;j>i;j--){
      if(data1[j][1]<data1[j-1][1]) swap(data1[j],data1[j-1]);
    }
  }
  for(int i=0;i<n;i++){
    mini = i;
    for(int j=i;j<n;j++){
      if(data2[j][1]<data2[mini][1]) mini = j;
    }
    if(mini != i) swap(data2[i],data2[mini]);
  }
  for(int i=0;i<n;i++) cout << (i!=0?" ":"") << data1[i];
  cout << endl << "Stable" << endl;
  for(int i=0;i<n;i++) cout << (i!=0?" ":"") << data2[i];
  if(data1==data2) cout << endl << "Stable" << endl;
  else cout << endl << "Not stable" << endl;
}



Measured memory_bytes: 3144
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
T = LIST()
M = INT()
PX = [LIST() for _ in range(M)]

total = sum(T)

for i in range(M):
	P_i = PX[i][0]
	X_i = PX[i][1]
	diff = T[P_i-1] - X_i
	print(total - diff)

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

using namespace std;

int main(){
    
    vector<int> array;
    int n,c;
    cin >>n;
    for(int i=0;i<n;i++){
        cin >> c;
        array.push_back(c);
    }
    
    // Insertion sort
    for(int i=1;i<array.size(); i++){
        //print
        for(int i=0; i<array.size(); i++){
            cout << array[i] << " \n"[i==array.size()-1];
        }
        int key = array[i];
        int j = i-1;
        while(j >=0 && array[j]>key){
            array[j+1] = array[j];
            j--;
        }
        array[j+1] = key;
        
        

    }//print
        for(int i=0; i<array.size(); i++){
            cout << array[i] << " \n"[i==array.size()-1];
        }
    
    return 0;
}


Measured memory_bytes: 3104
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 18 00:26:07 2020

@author: liang
"""

"""
コーナーケース１:
    重複があるとき　not coprime(※これが誤り)
    ただし、1の重複は除く

コーナーケース:
    重複があるとき　pairwise coprime ではない
    setwise coprimeの可能性はある
    ただし、１の重複は
"""
import math
C = 10**6
#T = int(math.sqrt(C)*10**3)+1
N = int(input())
judge = [0]+[False]*C
A =list()
f = True
for a in input().split():
    if judge[int(a)] == True and int(a) != 1:
        f = False
    judge[int(a)]=True
    A.append(int(a))
d = [False]+[True]*C

#print(judge[:10])
def solve(f):
    flag = True
    #エラトステネスの篩 O(N log N)
    for i in range(2,C+1):
        count = 0
        if d[i] == True:
            for j in range(i,C+1,i):
                if judge[j] == True:
                    count += 1
                if count == 2:
                    flag = False
                    break
                d[j] = False
        if not flag:
            break
    
    if flag == True and f == True:
        return "pairwise coprime"
    ans = A[0]
    #線形探索 O(N)
    for i in range(N):
        ans = math.gcd(ans,A[i])
    #print("ans",a)
    if ans == 1:
        return "setwise coprime"
    return "not coprime"

print(solve(f))
#print(len(A))

Measured memory_bytes: 141912
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;
	string s,p;
	cin >> s;
	cin >> p;

	string tmp="";
	for(i=0;i<sz(p);i++)
		tmp+=s[i];

	x=0;
	for(j=0;j<sz(tmp);j++)
		if(tmp[j]!=p[j])x++;

	for(i=sz(p);i<sz(s);i++)
	{
		tmp=tmp.substr(1,sz(tmp)-1);
		tmp+=s[i];
		y=0;
		for(j=0;j<sz(tmp);j++)
			if(tmp[j]!=p[j])y++;
		x=min(x,y);			
	}
	cout<<x<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N, K;
  cin >> N >> K;
  
  vector<int> count(N,0);
  
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int tmp;
      cin >> tmp;
      count.at(tmp - 1)++;
    }
  }
  
  int treat = 0;
  
  for (int i = 0; i < N; i++) {
    if (count.at(i) == 0) {
      treat++;
    }
  }
  
  cout << treat << endl;
  
  
  return 0;
  
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

LL mod(LL x, LL md) {
	return ((x % md) + md) % md;
}

class Mint {
public:
	static LL md;
	LL x;
	Mint(LL _x) {
		x = mod(_x, md);
	}
	Mint(const Mint &y) {
		x = mod(y.x, md);
	}
};

void MintMyExgcd(LL a, LL b, LL &x, LL &y) {
	// solve equation ax + by = 1 (mod m)
	LL md = Mint::md;
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	}
	MintMyExgcd(b, a % b, x, y);
	LL t = y;
	y = mod(x - (a / b) * y, md);
	x = t;
}

LL MintNY(LL x) {
	if (x == 0) {
		return 1;
	}
	LL md = Mint::md;
	LL a, b;
	MintMyExgcd(x, md, a, b);
	while (a < 0) {
		a += md;
	}
	return a;
}

/* LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
} */

Mint operator+(Mint a, Mint b) {
	return Mint(mod(a.x + b.x, Mint::md));
}
Mint operator-(Mint a, Mint b) {
	return Mint(mod(a.x - b.x, Mint::md));
}
Mint operator*(Mint a, Mint b) {
	return Mint(mod(a.x * b.x, Mint::md));
}
Mint operator/(Mint a, Mint b) {
	Mint c = Mint(MintNY(b.x));
	return Mint(mod(a.x * c.x, Mint::md));
}

Mint operator-(Mint a) {
	return Mint(-a.x);
}
bool operator==(Mint a, Mint b) {
	return a.x == b.x;
}
bool operator!=(Mint a, Mint b) {
	return a.x != b.x;
}
bool operator>(Mint a, Mint b) {
	return a.x > b.x;
}
bool operator<(Mint a, Mint b) {
	return a.x < b.x;
}
bool operator>=(Mint a, Mint b) {
	return a.x >= b.x;
}
bool operator<=(Mint a, Mint b) {
	return a.x <= b.x;
}

void operator+=(Mint &a, Mint b) {
	a = a + b;
}
void operator-=(Mint &a, Mint b) {
	a = a - b;
}
void operator*=(Mint &a, Mint b) {
	a = a * b;
}
void operator/=(Mint &a, Mint b) {
	a = a / b;
}

ostream& operator<<(ostream &out, Mint a) {
	out << a.x;
	return out;
}

istream& operator>>(istream &in, Mint &a) {
	in >> a.x;
	return in;
}

Mint factorial(LL n) {
	if (n == 0) {
		return Mint(1);
	}
	Mint res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
	}
	return res;
}
Mint multiRange(LL s, LL t) {
	Mint res = 1;
	for (LL i = s; i <= t; ++i) {
		res *= i;
	}
	return res;
}

Mint getC(LL n, LL k) {
	if (n - k < k) {
		return getC(n, n - k);
	}
	return multiRange(n - k + 1, n) / factorial(k);
}

Mint getA(LL n, LL k) {
	return multiRange(n - k + 1, n);
}

Mint countNonNegativeDivision(LL n, LL k) {
	return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(LL n, LL k) {
	if (n < k) {
		return 0;
	}
	if (k <= 0) {
		return 0;
	}
	return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, LL b) {
	Mint res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
		}
		a *= a;
		b /= 2;
	}
	return res;
}

LL Mint::md = 1000000007;

int a, b, c, k;
int res;
int main() {
	cin >> a >> b >> c >> k;
	res = 0;
	if (k > a) {
		k -= a;
		res += a;
	} else {
		res += k;
		cout << res << endl;
		return 0;
	}
	if (k > b) {
		k -= b;
	} else {
		cout << res << endl;
		return 0;
	}
	res -= k;
	cout << res << endl;
	return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {

    int n, a;
    cin >> n >> a;

    n %= 500;
    cout << (n <= a ? "Yes" : "No") << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repab(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define  printarr(v) for(auto x:v){cout<<x<<" "; }
#define debug1(a) cout<<#a<<" "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" "<<(a)<<" "<<#b<<" "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" "<<(a)<<" "<<#b<<" "<<(b)<<" "#c<<" "<<(c)<<endl;
typedef long double ld;
ll mod = 1e9 + 7;
ll dp[2005];
ll ok(ll val)
{
	if (val == 0)
	{
		return 1LL;
	}

	if (dp[val] != -1)
	{
		return dp[val];
	}
	ll ans = 0;
	for (ll i = 3; i <= val; i++)
	{
		if (val - i >= 0)
		{
			ans = (ans + ok(val - i)) % mod;
			ans = ans % mod;
		}
	}
	return dp[val] = ans;
}
void solve()
{
	ll n;
	cin >> n;
	memset(dp, -1, sizeof(dp));
	dp[0] = 1;
	cout << ok(n) << endl;

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

	}
}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;

/* prime */
int isPrime(int x) {
    if (x < 2) return 0; // 0, 1 is not prime
    else if (x == 2) return 1;  // 2 is prime
    if (x % 2 == 0) return 0;  // x is even
    for (int i = 3; i * i <= x; i+=2) {
        if (x % i == 0)
            return 0;
    }
    return 1;
}


int main() {
    int n, x;
    cin >> n;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cin >> x;
        if (isPrime(x)) cnt++;
    }
    cout << cnt << '\n';
}



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

typedef long long ll;
typedef vector<long long> vecll;
typedef vector<string> vecstr;

#define rep0(i, n) for(ll i=0; i<(ll)(n); i++)
#define rep1(i, n) for(ll i=1; i<=(ll)(n); i++)
#define rep(i, a, b) for(ll i=(ll)a; i<=(ll)(b); i++)
#define rep0r(i, n) for(ll i=(ll)(n)-1; i>=0; i--)
#define rep1r(i, n) for(ll i=(ll)(n); i>0; i--)
#define repr(i, a, b) for(ll i=(ll)b; i>=(ll)(a); i--)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) a * b / __gcd(a, b)
#define len(x) x.size()
#define Sort(x) sort(x.begin(), x.end())
#define rSort(x) sort(x.begin(), x.end(), greater<ll>())

const ll mod_const = 1000000007;

ll modpow(ll a, ll n, ll m) {
    ll result = 1;
    while(n > 0) {
        if(n&1) {
            result = result * a % m;
        }

    a = a * a % m;
    n >>= 1;
    }

    return result;
}

ll modinv(ll a, ll n) {
    if(a <= 1) {
        return 1;
    } else {
        return  n - modinv(n%a, n) * (n/a) % n;
    }
}

ll comb(ll n, ll r, ll m = mod_const) {
    vecll fac = {1, 1};
    vecll inv ={1, 1};
    vecll facinv = {1 , 1};

    rep(i, 2, n) {
        fac.push_back(fac[i-1] * i % m);
        inv.push_back(modinv(i, m));
        facinv.push_back(facinv[i-1] * inv[i] % m);
    }

    if (n<r || n<0 || r<0) {
        return 0;
    } else {
        return fac[n] * (facinv[r] * facinv[n-r] % m) % m;
    }
}
void solve() {
    ll s, w;

    cin >> s >> w;

    if(w >= s) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }

}

signed main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}

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

using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a < b){
		if (a < c){
			if (c < b) cout << a << " " << c << " " << b << endl;
			else  cout << a << " " << b << " " << c << endl;
		}
		else  cout << c << " " << a << " " << b << endl;
	}
	else {
		if (a < c) cout << b << " " << a << " " << c << endl;
		else  {
			if (c < b) cout << c << " " << b << " " << a << endl;
			else cout << b << " " << c << " " << a << endl;
		}
	}
}

Measured memory_bytes: 3076
N = int(input())
P = list(map(int, input().split()))

ans = 0
for i in range(N - 1):
    if i + 1 == P[i]:
        P[i], P[i + 1] = P[i + 1], P[i] 
        ans += 1
if P[N-1] == N:
    ans += 1
print(ans)


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

int N;

void solve(){
	int a = N / 100;
	int b = N % 10;
	if(a == b) printf("Yes\n");
	else printf("No\n");
}

int main(){
	scanf("%d", &N);
	solve();
	return 0;
}


Measured memory_bytes: 256
def main():
    # import sys
    # readline = sys.stdin.readline
    # readlines = sys.stdin.readlines
    H, W = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]
    B = [list(map(int, input().split())) for _ in range(H)]
    M = 0
    grid = [[0] * W for _ in range(H)]
    for i in range(H):
        for j in range(W):
            m = abs(A[i][j] - B[i][j])
            grid[i][j] = m
            M = max(M, m)

    dp = [[0] * W for _ in range(H)]
    dp[0][0] = (1 << 0)

    for i in range(H):
        for j in range(W):
            here = dp[i][j]
            k = grid[i][j]

            dp[i][j] = (here << k) | (here >> k)
            for l in range(1, k + 1):
                if (here >> l) & 1:
                    dp[i][j] |= (1 << (k - l))

            if i < H - 1:
                dp[i + 1][j] |= dp[i][j]
            if j < W - 1:
                dp[i][j + 1] |= dp[i][j]

    V = dp[-1][-1]
    ans = 0
    while V > 0:
        if V & 1:
            print(ans)
            break
        V >>= 1
        ans += 1


if __name__ == "__main__":
    main()


Measured memory_bytes: 53052
a,b = map(int,input().split())
m = 0
c = list(map(int,input().split()))
for i in range(len(c)-b+1):
    if c[i] * c[i+b-1] < 0:
        if i == 0:
            m = abs(c[i]) + c[i+b-1] +abs(min(abs(c[i]),c[i+b-1]))
        else:
            m = min(m,abs(c[i]) + c[i+b-1] +abs(min(abs(c[i]),c[i+b-1])))
    else:
        if i == 0:
            m = max(abs(c[i]),abs(c[i+b-1]))
        else:
            m = min(m,max(abs(c[i]),abs(c[i+b-1])))

print(m)


Measured memory_bytes: 62576
N, M = map(int, input().split())		# 5 7

P=[0]
Y=[0]
A=[]

for i in range(M):
	p, y = map(int, input().split())		# 5 7
	P.append(p)
	Y.append(y)
	A.append([i,p,y,p*100000000000 + y])

#print(N,M)
#print(*P)
#print(*Y)
#print(*A)

A = sorted(A, key=lambda x: x[3])

#print(*A)

p0=0
no=0
for i in range(len(A)):
	a=A[i]
	p=a[1]
	y=a[2]
#	print(i,a,p,y)
	
	if(p!=p0):no=0
	no+=1
	A[i].append(no)
	
	p0=p

#print(*A)

A = sorted(A, key=lambda x: x[0])
#print(*A)

for a in A:
	p = "000000" + str(a[1])
	i = "000000" + str(a[4])
	print(p[-6:]+i[-6:])

Measured memory_bytes: 39816
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
const int maxn = 3050;
using namespace std;
typedef long long ll;
ll a[maxn];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	ll ans=1000;
	ll cnt=0;
	for(int i=1;i<=n;i++){
		if(a[i]<a[i+1]&&!cnt){
			cnt=ans/a[i];
			ans=ans%a[i];	
		}
		else if(cnt&&a[i+1]<a[i]){
			ans+=cnt*a[i];
			cnt=0;
		}
	}
	cout<<ans;
	return 0; 
} 

Measured memory_bytes: 3596
N,W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())
w=[0]+w
v=[0]+v
dp=[[0 for i in range(N+1)] for j in range(W+1)]

for i in range(1,N+1):
    for j in range(1,W+1):
        if j-w[i]>=0:
            dp[j][i]=max(dp[j-w[i]][i-1]+v[i],dp[j][i-1])
        else:
            dp[j][i]=dp[j][i-1]
print(dp[-1][-1]) 

Measured memory_bytes: 169060
import java.util.*;

public class Main{ // Main
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i ++) {
			a[i] = scanner.nextInt();
		}
		Arrays.sort(a);
		System.out.println(a[n-1] - a[0]);
		
		scanner.close();
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	char s[20];
	scanf("%s",s);

	s[5] = ' ';
	s[13] = ' ';

	printf("%s\n",s);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000007
//S.size()

using namespace std;


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;



int main(void){
  bool p = false,w = false,g = false,y = false;
  int N;cin>>N;
  int cnt = 0;
  char s[N];rep(i ,N)cin>>s[i];
  for(int t = 0;t < N;t++){
    if(s[t]  == 'P')p = true;
    else if(s[t] == 'W')w = true;
    else if(s[t] == 'G')g = true;
    else if(s[t] == 'Y')y = true;
  }
  if(p)cnt++;
  if(w)cnt++;
  if(g)cnt++;
  if(y)cnt++;
  cout<<(cnt == 4?"Four":"Three");
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	
	int slen = s.size();
	bool k=true,g=true;
	for(int i=0;i<slen;i+=2){
		if(s[i]=='L') k=false;
	}
	for(int i=1;i<slen;i+=2){
		if(s[i]=='R') g=false;
	}
	if(k&&g)cout<<"Yes";
	else cout<<"No";
}

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

#define rep(i, n)     for(auto i = 0; i != n; ++i)
#define REP(i, k, n)  for(auto i = k; i != n; ++i)
#define rrep(i, n)    for(auto i = n; i != 0; --i)
#define RREP(i, n, k) for(auto i = n; i != k; --i)

#define debug(x) cerr << #x << " " << x << endl
#define spc << " " <<

#define mp make_pair
#define mt make_tuple

using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template<typename T>using V = vector<T>;
using Vi = vector<int>;
using VVi = vector<vector<int>>;

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

    int N, M; cin >> N >> M;
    Vi target = Vi(M+1);
    REP(i, 1, M+1) cin >> target[i];

    Vi score = Vi(N+1, 0);

    REP(game, 1, M+1) {
        REP(i, 1, N+1) {
            int pred;
            cin >> pred;
            if (pred == target[game]) ++score[i];
            else ++score[target[game]];
        }
    }

    REP(i, 1, N+1) cout << score[i] << endl;
    return 0;
}



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

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

  int min_num = 1 << 20;
  for (int i = 1; i < n; i++) {
    int a = i;
    int b = n - a;
    int sum_a = 0;
    while (a > 0) {
      sum_a += a % 10;
      a /= 10;
    }
    int sum_b = 0;
    while (b > 0) {
      sum_b += b % 10;
      b /= 10;
    }
    min_num = min(min_num, sum_a + sum_b);
  }

  cout << min_num << endl;
  return 0;
}

Measured memory_bytes: 256
fun main() {
  fun readInt():Int{ return readLine()!!.toInt()}
    fun readLong():Long{return readLine()!!.toLong()}
    fun readString():String{return readLine()!!}
    fun readIntList():List<Int>{return readLine()!!.split(" ").map { it.toInt() }}
    fun readLongList():List<Long>{return readLine()!!.split(" ").map { it.toLong() }}
    fun readStringList():List<String>{return readLine()!!.split(" ")}
    fun readIntLists(n: Int, sorted: Boolean=false):List<List<Int>>{return if(sorted){(0 until n).map { readIntList().sorted() }}else{(0 until n).map { readIntList()}}}
    fun readLongLists(n:Int, sorted: Boolean=false):List<List<Long>>{return if(sorted){(0 until n).map { readLongList().sorted() }}else{(0 until n).map { readLongList()}}}
    fun readStringLists(n:Int):List<List<String>>{return (0 until n).map { readStringList() }}

    val a=readIntList()
    if (a[0]<=a[1]*a[2]){
        println("Yes")}
    else{
        println("No")
    }
}


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

import heapq

def sumOfDigits(n):
    a = 0

    while n > 0:
        a += n%10
        n //= 10

    return a


def f(n):
    while n%2 == 0:
        n //= 2

    while n%5 == 0:
        n //= 5

    vs = [None]*n
    qs = []
    x = sumOfDigits(n)

    for i in range(1, min(n, 10)):
        vs[i] = i
        heapq.heappush(qs, (i, i))

    while len(qs) > 0:
        _, q = heapq.heappop(qs)
        q2 = q*10
        v = vs[q]
        
        for i in range(0, min(x-v, 10)):
            q3 = (q2 + i)%n
            v2 = v + i
            v3 = vs[q3]

            if v3 == None or v2 < v3:
                vs[q3] = v2
                heapq.heappush(qs, (v2, q3))
                    
            if q3 == 0 and v2 < x:
                x = v2

    return x


def test():
    assert f(6) == 3
    assert f(41) == 5
    assert f(79992) == 36


def main():
    n = int(input())
    print(f(n))


if __name__ == '__main__':
    main()


Measured memory_bytes: 20108
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

        int m=gi();

        
	    
	    
        System.out.println(48-m);
//        if (a+b>c+d) {
//        	System.out.print("Left");
//        }else if(a+b==c+d){
//        	System.out.print("Balanced");
//        }else {
//        	System.out.print("Right");
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
	
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35572
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t = 1, tt;
const ll N = 1000005;
void solve(){
	string s;
	cin>>s;
	deque<char> dq;
	rep(i,0,sz(s))
		dq.push_back(s[i]);
	ll q, type, pos, f=0;
	cin>>q;
	char c;
	while(q--){
		cin>>type;
		if(type==1)
			f^=1;
		else{
			cin>>pos>>c;
			(pos&1)^f?dq.push_front(c):dq.push_back(c);
		}
	}
	string ans="";
	while(!dq.empty()){
		ans+=dq.front();
		dq.pop_front();
	}
	if(f)reverse(all(ans));
	cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	//cin>>t;
	tt=t;
    while(t--){
        solve();
        if(t!=0)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 1368
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a[3];
  rep(i, 0, 3){
    cin >> a[i];
  }
  sort(a, a + 3);
  int b = a[1] - a[0];
  b += a[2] - a[1];
  cout << b << "\n";
}


Measured memory_bytes: 3640
N = int(input())
S = input()

wcnt=0
for i in range(1,N):
    if S[i] == "E":
        wcnt+=1

ans=wcnt
for i in range(N-1):
    if S[i] == "E" and S[i+1]=="E":
        wcnt-=1
    if S[i] == "W" and S[i+1]=="W":
        wcnt+=1
    if ans > wcnt:
        ans=wcnt
print(ans)

Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <cstdio>
#include <math.h>
#include <string>
#include <map>
#include <functional>
#include <algorithm>
#include <stack> 
#include <iomanip>
#include <stdio.h>
#include <set>
#include <array>
using namespace std; 

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

int main()
{
	int n;
	cin >> n;
	vector<int> bricks(n);
	for (auto& brick : bricks)
		cin >> brick;
	int count = 0;
	int current = 0;
	for (auto brick : bricks)
		if (brick != current + 1) ++count;
		else ++current;
		if (n == count)
			cout << "-1\n";
		else cout << count << endl;
		return 0;
}


Measured memory_bytes: 1024
H, W = map(int, input().split())

l = [['P' for _ in range(W + 2)] for _ in range(H + 2)]

for i in range(H) :
    s = list(input())
    for j in range(W) :
        l[i+1][j+1] = s[j]

dx = [0, 0, -1, 1]
dy = [-1, 1, 0, 0]

ans = True

for i in range(1, H + 1) :
    for j in range(1, W + 1) :
        if l[i][j] != "#" :
            continue
        flag = False
        for k in range(len(dx)) :
            if l[i + dx[k]][j + dy[k]] == "#" :
                flag = True
                break
        if flag == False :
            ans = False

if ans :
    print('Yes')
else :
    print('No')


Measured memory_bytes: 3064
class MyBinaryNode
  attr_accessor :parent, :left, :right
  attr_reader :id, :v

  def initialize(id, v)
    @id = id
    @parent = nil
    @left = nil
    @right = nil
    @v = v
  end

  def to_s
    @v
  end
end

def pre_order(node)
  if node.nil?
    return 
  end
  print ' '
  print node.v
  pre_order(node.left)
  pre_order(node.right)
end

def in_order(node)
  if node.nil?
    return 
  end
  in_order(node.left)
  print ' '
  print node.v
  in_order(node.right)
end

# def post_order(nodes, id)
#   if id.nil?
#     return 
#   end
#   post_order(nodes, nodes[id].left)
#   post_order(nodes, nodes[id].right)
#   print ' '
#   print id
# end

def print_nodes(node)
  in_order(node)
  puts ""
  pre_order(node)
  puts ""
end

def insert(z, root)
  y = nil
  x = root
  while !x.nil? do
    y = x
    if z.v < x.v
      x = x.left
    else
      x = x.right
    end
  end
  
  z.parent = y

  if y.nil?
    # skip
  elsif z.v < y.v
    y.left = z
  else
    y.right = z
  end

end

n = gets.to_i
root = nil
i = 0
n.times do
  order, v = gets.split
  v = v.to_i
  case order
  when "insert"
    node = MyBinaryNode.new(i, v)
    insert(node, root)
    if i == 0
      root = node
    end
    i += 1
  when "print"
    print_nodes(root)
  end
end



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

using namespace std;


int main(){
    int N,M,X,Y;
    cin >> N>>M>>X>>Y;
    vector<int> a(N);
    vector<int> b(M);
    
    int XMAX=X;
    int YMIN=Y;

    for (int i=0;i<N;i++){
        cin>>a[i];
        XMAX=max(XMAX,a[i]);
    }

    for(int i=0;i<M;i++){
        cin >> b[i];
        YMIN=min(YMIN,b[i]);
    }


    if(XMAX < YMIN) cout << "No War" << endl;
    else cout << "War" << endl;

    return 0;


}

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

using Graph = vector< vector<int> >;

int main() {
    int n, m;
    cin >> n >> m;
    
    vector<int64_t> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];

    Graph g(n);
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int ans = 0;
    for(int i = 0; i < n; i++) {
        bool flag = true;
        for(auto c : g[i]) {
            if(h[c] >= h[i]) {
                flag = false;
                break;
            }
        }
        if(flag) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

// mod
int mod = 1e9 + 7;

struct mint {
    unsigned x;

    mint() : x(0) {}

    mint(signed sig) { x = sig < 0 ? sig % mod + mod : sig % mod; }

    mint(signed long long sig) { x = sig < 0 ? sig % mod + mod : sig % mod; }

    int get() const { return (int) x; }

    mint& operator+=(mint that) {
        if ((x += that.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator-=(mint that) {
        if ((x += mod - that.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator*=(mint that) {
        x = (unsigned long long) x * that.x % mod;
        return *this;
    }

    mint& operator/=(mint that) { return *this *= that.inverse(); }

    mint operator+(mint that) const { return mint(*this) += that; }

    mint operator-(mint that) const { return mint(*this) -= that; }

    mint operator*(mint that) const { return mint(*this) *= that; }

    mint operator/(mint that) const { return mint(*this) /= that; }

    mint inverse() const {
        long long a = x, b = mod, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            std::swap(a, b);
            u -= t * v;
            std::swap(u, v);
        }
        return mint(u);
    }

    bool operator==(mint that) const { return x == that.x; }

    bool operator!=(mint that) const { return x != that.x; }

    mint operator-() const {
        mint t;
        t.x = x == 0 ? 0 : mod - x;
        return t;
    }
};

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inverse();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

class FManyManyPaths {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int r1, c1, r2, c2;
        cin >> r1 >> c1 >> r2 >> c2;

        combination cb(3000005);

        mint res = 0;
        FOR(r, r1, r2) {
            res += cb(c2 + r + 1, r + 1) - cb(c1 + r, r + 1);
        }
        cout << res.get() << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    FManyManyPaths solver;
    solver.solve(in, out);
    return 0;
}


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

int main() {
    int N, cnt=0;
    bool flag=true;
    cin >> N;

    vector<int> A(N);
    for (int i=0; i<N; i++){
        cin >> A.at(i);
    }

    while(1){
        for (int j=0; j<N; j++){
            if (A.at(j)%2==0){
                A.at(j)/=2;
                continue;
            }
            else{
                flag=false; break;
            }
        }
        if (flag==false) break;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<vector<int>> grid(3, vector<int>(3));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> grid[i][j];
        }
    }
    if(grid[1][0] - grid[0][0] == grid[1][1] - grid[0][1] &&
       grid[1][1] - grid[0][1] == grid[1][2] - grid[0][2] &&
       grid[2][0] - grid[0][0] == grid[2][1] - grid[0][1] &&
 	   grid[2][1] - grid[0][1] == grid[2][2] - grid[0][2]){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  for(int i=1;i<=b;i++){
    if(c==(a*i)%b){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int r,c,A[101][101];
    cin >> r >> c;
    for (int i = 0;i < r;i++)
        for (int j = 0;j < c;j++) cin >> A[i][j];

    for (int i = 0;i <= r;i++) A[i][c] = 0;
    for (int j = 0;j <= c;j++) A[r][j] = 0;

    for (int i = 0;i < r;i++){
        for (int j = 0;j < c;j++){
            A[i][c] += A[i][j];
            A[r][j] += A[i][j];
            A[r][c] += A[i][j];
        }
    }
    for (int i = 0;i <= r;i++) {
        for (int j = 0;j <= c;j++) {
            if(j) cout << " ";
            cout << A[i][j];
        }
        cout << endl;
    }
    return 0;
}


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

struct Node {
    int key;
    struct Node *prev, *next;
};

struct Node *nil;

void init() {
    nil = (struct Node *)malloc(sizeof(struct Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int key) {
    struct Node *x = (struct Node *)malloc(sizeof(struct Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

struct Node* listSearch(int key) {
    struct Node *cur = nil->next;
    while(cur != nil && cur->key != key ) {
        cur = cur-> next;
    }
    return cur;
}

void deleteNode(struct Node *t) {
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}
void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void printList() {
    struct Node *cur;
    cur = nil->next;
    int isf = 0;

    while(1) {
        if (cur == nil) break;
        if(isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}


int main(void) {
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for (i = 0; i < n; i++) {
        scanf("%s%d",com, &key);
        if(com[0] == 'i') {
            insert(key);
            np ++;
            size++;
        }else if(com[0] == 'd') {
            if(strlen(com) > 6) {
                if( com[6] == 'F') {
                    deleteFirst();
                }else if(com[6] == 'L') {
                    deleteLast();
                }
            }else {
                deleteKey(key);
                nd ++;
            }
            size --;
        }
    }
    printList();
    return 0;
}

Measured memory_bytes: 32984
n,k=map(int,input().split())
A=list(map(int,input().split()))
p=1
if k<=n:
    for i in range(k):
        p=A[p-1]
    print(p)
else:
    D=[0]+[-1]*(n-1)
    for i in range(n):
        p=A[p-1]
        if D[p-1]==-1:
            D[p-1]=i+1
        else:
            l=D[p-1]
            r=i+1-D[p-1]
            m=(k-l)%r+l
            break
    p=1
    for i in range(m):
        p=A[p-1]
    print(p)

Measured memory_bytes: 92736