akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair <int,ii>
#define iil pair<ll,ll>
#define iiil pair<ll,iil>
#define max3(a,b,c) max(a, max(b,c))
#define min3(a,b,c) min(a, min(b,c))
#define s(v) sort(v.begin(),v.end())
#define pf printf
#define sf scanf
#define MIN INT_MIN
#define MAX INT_MAX
#define accepted 0
#define GCD(x,y)  __gcd(x, y)
#define endl "\n"
using namespace std;
const int maxn = 1e5 + 69;
//int vis[maxn];
//int indegree[maxn];
//vector<int> graph[maxn];
//vector<int> order;
/**
int gx[]= {2,2,-2,-2,1,-1,1,-1};
int gy[] ={1,-1,1,-1,2,2,-2,-2};

void DFS(int a,bool tpsort){
        vis[a] = 1;
    for(int i=0;i<graph[a].size();i++){
        int r = graph[a][i];
            if(vis[r]==0){
                DFS(r,tpsort);
            }
    }
    if(tpsort)order.push_back(a);
}

int vis[maxn],l[maxn],l2[maxn];
vector<int> graph[maxn];
vector<int> cst[maxn];
int mx,ans;
void BFS(int root){
    memset(vis,0,sizeof(vis));
    memset(l,0,sizeof(l));
    vis[root] = 1;
    l[root] = 0;
    queue <int> q;
    ans = 0;
    mx = root;
    q.push(root);
    while(!q.empty()){
        int cur = q.front();
        q.pop();
        int p = graph[cur].size();
        for(int i=0;i<p;i++){
            int r = graph[cur][i];
            if(vis[r]==0){
                vis[r] = 1 ;
                l[r] = l[cur] + cst[cur][i];
                if(l[r]>ans){
                    ans = l[r];
                    mx = r;
                }
                q.push(r);
            }
        }
    }
   // cout<< ans <<endl;
}
void ultapoth(int root){
    memset(vis,0,sizeof(vis));
    memset(l2,0,sizeof(l2));
    vis[root] = 1;
    l2[root] = 0;
    queue <int> q;
    q.push(root);
    while(!q.empty()){
        int cur = q.front();
        q.pop();
        int p = graph[cur].size();
        for(int i=0;i<p;i++){
            int r = graph[cur][i];
            if(vis[r]==0){
                vis[r] = 1 ;
                l2[r] = l2[cur] + cst[cur][i];
                q.push(r);
            }
        }
    }
   // cout<< ans <<endl;
}
**/
int main(){
    //fast
    int n;  sf("%d",&n);
        if(n>=30)pf("Yes\n");
        else pf("No\n");

    return accepted;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
int a[1005];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0; i<n; i++)
        cin>>a[i];
    sort(a,a+n);
    int ans=0;
    for(int i=0; i<k; i++)
        ans+=a[i];
    cout<<ans;
    return 0;
}

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

signed main(){
	int N; cin>>N;
	map<int,int> dic1,dic2,dic3,dic4;
	for(int i=1;i<=N;i++){
		int a; cin>>a;
		dic1[a-i]++;
		dic2[a+i]++;
		dic3[-a-i]++;
		dic4[-a+i]++;
	}
	int ans=0;
	for(auto p : dic1){
		ans+=dic3[p.first]*p.second;
	}
	for(auto p : dic2){
		ans+=dic4[p.first]*p.second;
	}
	cout<<ans/2<<endl;
}

Measured memory_bytes: 72228
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int main(void) {
  int a, b;
  while (scanf("%d %d", &a, &b) == 2) {
    if (a == 0 && b == 0) break;

    int lasta = 0, lastb = 0;
    int suma = 0, sumb = 0;
    for (int i = 2; i <= a || i <= b; ++i) {
      if (a%i == 0) {
        while (a%i == 0) a /= i;
        lasta = i;
        suma += i;
      }
      if (b%i == 0) {
        while (b%i == 0) b /= i;
        lastb = i;
        sumb += i;
      }
    }

    if (2*lasta-suma > 2*lastb-sumb) puts("a");
    else puts("b");
  }
  return 0; 
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = long long;
using u32 = unsigned long long;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << (H - h) * (W - w) << endl;
  return 0;
}


Measured memory_bytes: 384
#B
N, K = map(int, input().split())
h = [int(x) for x in input().split()]
c = [float('inf')] * N

for i in range(N):
    if i == 0:
        c[i] = 0
    elif i == 1:
        c[i] = abs(h[1]-h[0])
    else:
        j = 1
        while j <= K and i-j >= 0:
            now = abs(h[i]-h[i-j])+c[i-j]
            c[i] = min(c[i], now)
            j += 1
print(int(c[N-1]))


Measured memory_bytes: 55392
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N, K = input_nums()
    S = input()
    print(S[0:K-1] + S[K-1].lower() + S[K:])

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		if(H == 1 || W == 1){
			Console.WriteLine(1);
			return;
		}
		
		long even = (W + 1) / 2;
		long odd = W / 2;
		long ans = 0;
		ans += (even + odd) * (H / 2);
		if(H % 2 == 1){
			ans += even;
		}
		Console.WriteLine(ans);
	}
	long H,W;
	public Sol(){
		var d = rla();
		H = d[0]; W = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
#include <iostream>
#include <climits>
using namespace std;
void solve()
{
	int n;
	cin >> n;
	int a[n][3];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin >> a[i][j];
		}
	}
	int dp[n][3]={0};
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			if(!i)
			{
				dp[i][j]=a[i][j];
			}
			else
			{
				dp[i][j]=max(dp[i][j],a[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]));
			}
		}
	}
	int ans=0;
	for(int i=0;i<3;i++)
	{
		ans=max(ans,dp[n-1][i]);
	}
	cout << ans << "\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

int main() {
 // ここにプログラムを追記
  int A,B,C,D,L,R;
  cin >> A >> B >> C >> D;
  
  L = A+B;
  R = C+D;
  
  if(L>R)
    cout << "Left" << endl;
  else if(L<R)
    cout << "Right" << endl;
  else
    cout << "Balanced" << endl;
  
}


Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{ 
 
  long long int a[2001][2001],MOD=1000000000+7,ans;
  int i,j,k,s,x,y;
  for(i=1;i<=2000;i++)
  {
    for(j=1;j<=2000;j++)
    if(i==1||j==1){a[i][j]=1;}
    else
    {
      a[i][j]=a[i-1][j]+a[i][j-1];
      a[i][j]=a[i][j]%MOD;
    }
  }
  cin>>s;
  ans=0;
  x=1;y=s-3+1;
  while(y>0)
  {
    ans+=a[x][y];
    ans=ans%MOD;
    x++;
    y-=3;
  }
  cout<<ans;
  
}

Measured memory_bytes: 34900
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=(1LL<<61) - 600;
const ll mod=1e9+7 ;
const int MAX = 1000000;
const int MOD = 1000000007;


int main(){
  string S; cin >> S; int N = S.size(); string T="keyence";
  rep(i, N){
    rep(j, 8){
      if(S.substr(0, j)+S.substr(N-7+j, 7-j)==T){
        cout << "YES" << endl; return 0;
      }
    }
  }
  cout << "NO" << endl;
}
    

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
template<typename T>
bool all_same(vector<T> v1,vector<T> v2)
{
    sort(ALL(v1));
    sort(ALL(v2),greater<T>());
    return v1 == v2;
}
   
// g++ -std=c++11 prac.cpp
ll Max=-1e9,Min=1e9+1;

int main(){
    ll b,d,x,y,z,n,m,k,l,w,sum=100000,sum2=0,ans=0;
    string s,t;
    bool ok=true;
    VB a(4,false);
    char c[4] = {'S','N','E','W'};
    cin >> s;   
    rep(i,s.size()){
        rep(j,4){
            if(s[i]==c[j]){
                a[j]=true;
            }
        }
    }
    for(int i=0;i<3;i+=2){
        if(a[i]==true){
            if(a[i+1] != true){
                ok = false;
            }
        }
        else{
            if(a[i+1] == true){
                ok = false;
            }
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0

for i in range(N-1):
    if A[i+1] == A[i]+1:
        ans = ans + C[A[i]-1]
ans = ans + sum(B)

print(ans)

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

int main () {
  string S;
  cin >> S;
  int number = 0;
  for ( int i = 0; i < S.size(); i++) {
    if ( S.at(i) == '+' ) number++;
    else number--;
  }
  cout << number << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    if(a > b && a > c)cout << a*(1<<k) + b + c;
    else if (b > a && b > c)cout << b*(1<<k) + a + c;
    else cout << c*(1<<k) + a + b;

}


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

typedef long long ll;
ll a[3];

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

    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]==a[1] && a[1]==5 && a[2]==7) cout<<"YES";
    else cout<<"NO";


}


Measured memory_bytes: 256
N, M, K = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])

for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(len(a)):
    if a[i] > K:
        break
    while a[i] + b[j] > K:
        j -= 1
    ans = max(ans, i + j)

print(ans)

Measured memory_bytes: 47384
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define ll long long
#define faltu ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define binary(x) std::string binary = std::bitset<25>(x).to_string(); //to binary
#define inf 1000000007
#define mod 1000000007
#define pi pair<int,int>
#define lpi pair<int,int>
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define lvi vector<long long int>
#define pie 3.14159265358979323846
using namespace std;
int main()
{
	faltu;
  int a,b;
  cin>>a>>b;
  if(a>=13)cout<<b<<endl;
  else if(a>=6&&a<=12)cout<<b/2<<endl;
  else cout<<"0"<<endl;

}





Measured memory_bytes: 256
t = list(map(str, input()))
ans = t[:]

if len(t) == 1:
    if t[0] == "?":
        ans[0] = "D"
else:
    if t[0] == "?":
        if t[1] == "P":
            ans[0] = "D"
        else:
            ans[0] = "P"

    for i in range(1, len(t)-1):
        if t[i] == "?":
            if ans[i - 1] == "P":
                ans[i] = "D"
            else:
                if t[i + 1] == "D" or t[i + 1] == "?":
                    ans[i] = "P"
                else:
                    ans[i] = "D"

    if t[-1] == "?":
        ans[-1] = "D"

print("".join(ans))


Measured memory_bytes: 12080
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
ll edge[510][510] = {};
void calc(ll lv, ll rv, ll d){
    if(rv - lv == 1) return;
    ll mid = (lv + rv+1) / 2;
    rep(i,lv,mid){
        rep(j,mid,rv){
            edge[i][j] = d;
            edge[j][i] = d;
        }
    }
    calc(lv, mid, 2*d);
    calc(mid, rv, 2*d);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    calc(0, N, 1);
    vector<ll> v;
    rep(i,0,N){
        rep(j,0,N){
            if(i != j) v.push_back(edge[i][j]);
        }
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    rep(i,0,N){
        rep(j,0,N){
            if(i == j) continue;
            ll pos = lower_bound(v.begin(), v.end(), edge[i][j]) - v.begin();
            edge[i][j] = pos+1;
        }
    }
    rep(i,0,N-1){
        rep(j,i+1,N){
            cout << edge[i][j] << " \n"[j==N-1];
        }
    }

    
}

Measured memory_bytes: 4592
def main():
    n = int(input())
    dp = [0]*(n+1)
    for i in range(1,n+1):
        j = 1
        while i*j <= n:
            dp[i*j] += 1
            j += 1

    #print(dp)
    pairs = 0
    for c in range(1,n):
        x = n-c
        count = dp[x]
        #print(c,x,count)
        pairs += count

    print(pairs)
    

main()


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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
    int x,n; cin>>x>>n;
    int p[n];
    rep(i,n) cin>>p[i];
    bool neko=true;
    rep(i,n){
        if(p[i]==x) neko=false;
    }
    if(neko){
        cout<<x<<endl;
        return 0;
    }
    int a= x-1, b=x+1;
    rep(i,n){
        bool an=true,bn=true;
        for(int j=0; j<n;j++){
            if(p[j]==a) an=false;
            if(p[j]==b) bn=false;
        }
        if(an){
            cout<<a<<endl;
            return 0;
        }
        if(bn){
            cout<<b<<endl;
            return 0;
        }
        a--; b++;
    }
    cout<<a<<endl;
}


Measured memory_bytes: 3600
# D - FT Robot

s = input()
x, y = map(int, input().split())

f = [len(x) for x in s.split("T")]
x -= f[0]
fx = f[2::2]
fy = f[1::2]

x_possible_set = set([0])
for dx in fx:
    x_possible_set = set([xi + dx for xi in x_possible_set] + [xi - dx for xi in x_possible_set])

y_possible_set = set([0])
for dy in fy:
    y_possible_set = set([yi + dy for yi in y_possible_set] + [yi - dy for yi in y_possible_set])

print("Yes" if x in x_possible_set and y in y_possible_set else "No")

Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,d;
string s[101];
int main(){
	cin>>n;
	a=n%10;
	b=n/10%10;
	c=n/100%10;
	d=n/1000;
	if(((a==b)and(b==c))or((d==c)and(b==c)))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

#define N 100000

int main(void){
    ios::sync_with_stdio(false);
    vector<bool> prime(N+1,true);
    prime[0]=prime[1]=false;
    for (size_t i = 2; i*i <= N; i++)
    {
        if (prime[i])
        {
            for (size_t j = 2; i*j <= N; j++)
            {
                prime[i*j]=false;
            }
        }
    }
    int likeCnt[N];
    for (size_t i = 1; i <= N; i++)
    {
        likeCnt[i]=likeCnt[i-1]+(i%2==1&&prime[i]&&prime[(i+1)/2]);
    }
    /**************************************/
    int q;
    scanf("%d", &q);
    int l,r;
    for (size_t i = 0; i < q; i++)
    {
        scanf("%d%d", &l, &r);
        printf("%d\n", likeCnt[r] - likeCnt[l-1]);
    }
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
import copy
list = []
for i in range(n):
    k = int(input())
    list.append(k)
list1 = copy.deepcopy(list)
first = max(list1)
list1.remove(first)
second = max(list1)
for li in list:
    if li == first:
        print(second)
    else:
        print(first)


Measured memory_bytes: 14548
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int maxv = max({ a,b,c });
	int sum = 0;
	if ((3*maxv-a-b-c)%2 == 0)sum = 3 * maxv;
	else sum = 3 * (maxv + 1);
	cout << (sum - (a + b + c)) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 


ll N;
ll Q;
vll S;
vll T,X,D;

ll ltmp;
string stmp;
double dtmp;

map<string,ll> getT;
vll listS;



#include <queue>
typedef pair<ll,ll> P;  
priority_queue<P,vector<P>, greater<P>> que;
priority_queue<P,vector<P>, greater<P>> que_tmp;

ll llmin(ll a,ll b){
    if(a>=b) return b;
    return a;
}
ll llmax(ll a,ll b){
    if(a<=b) return b;
    return a;
}
string getKey(ll S,ll X){
    return to_string(S) + to_string(X);
}
int main(){

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

    cin >> N;
    cin >> Q;

    rep(ni,N){
        ll Si,Ti,Xi;
        cin >> Si >> Ti >> Xi;
        X.push_back(Xi);
        S.push_back(Si);
        T.push_back(Ti);
    }

    rep(qi,Q){
        cin >> ltmp;
        D.push_back(ltmp);    
    }

    rep(ni,N){
        ll Si,Ti,Xi;
        Xi = X[ni];
        Si = llmax(0,S[ni]-Xi);
        Ti = llmax(0,T[ni]-Xi-1);
        que.push(P(Si,Xi));
        getT[getKey(Si,Xi)] = Ti;
    }

    ll si=0;
    vll ans;
    for( ll di = 0 ; di <Q ; di++ ){
        ll Di = D[di];
        //cout << "Di " << Di << endl;
        while(1){
            if(que.size()==0){
                break;
            }else{
                P Psx = que.top();
                ll Xi = Psx.second;
                ll Si = Psx.first;
                if(Di<Si) break;
                else{
                    que_tmp.push(P(Xi,Si));
                    //cout << "gets " << Xi << endl;
                    que.pop();
                }
            }
        }

        while(1){
            if(que_tmp.size()==0){
                ans.push_back(-1);
                break;
            }else{
                P Pxs = que_tmp.top();
                ll Xi = Pxs.first;
                ll Si = Pxs.second;
                ll Ti = getT[getKey(Si,Xi)];
                //cout << "top " << Xi << endl;
                if(Di<Si){
                    ans.push_back(-1);
                    break;
                }
                else if(Ti<Di){
                    que_tmp.pop();
                    //cout << "Ti " << Ti << endl;
                    //cout << "pop " << Xi << endl;
                }
                else{
                    ans.push_back(Xi);
                    break;
                }
            }
        }
    }

    rep(ai,ans.size()){
        cout << ans[ai] << endl;
    }


}

Measured memory_bytes: 44152
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    int N,K;

    cin >> N >> K;
    
    if((N + 1) / 2 >= K)cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int search(vector<int>,int,int);
int main(void){
    int n,q,t,key,count = 0;
    vector<int> S;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> t;
        S.push_back(t);
    }
    cin >> q;
    for(int i=0;i<q;i++){
        cin >> key;
        if(search(S,n,key)){
            count++;
        }
    }
    cout << count << '\n';
    return 0;
}
int search(vector<int> A,int n,int key){
    int i=0;
        A.push_back(key);
        while(A[i]!= key){
            i++;
        }
        return i !=n;
}


Measured memory_bytes: 3200
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        aa: [u32;n]
    }
    let mut bb = vec![0;n];
    for i in (1..n+1).rev() {
        let mut c = 0;
        let mut j = i;
        while j <= n {
            if i % j != 0 {
                c += bb[j-1];
            }
            j += i;
        }
        if c % 2 == aa[i-1] {
            bb[i-1] = 0;
        } else {
            bb[i-1] = 1;
        }
    }
    println!("{}", bb.iter().filter(|i| **i == 1).count());
    // println!("{:?}", bb);
    for i in 0..n {
        if bb[i] == 1 {
            print!("{} ", i+1);
        }
    }
}


Measured memory_bytes: 7164
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

int main(){
    int N;
    cin>>N;
    cout<<(N-1)/2+1;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
















bool check(ll &n, vector<vector<ll>>& g, vector<ll>& a, vector<ll>& b){
    REP(i, n){
        queue<ll> que;
        que.push(a[i]);
        vector<bool> used(51);
        used[a[i]] = true;
        while(!que.empty()){
            ll now = que.front(); que.pop();
            for(auto &v : g[now]){
                if(!used[v]){
                    que.push(v);
                    used[v] = true;
                }
            }
        }
        if(!used[b[i]]){
            return false;
        }
    }
    return true;
}


int main(){
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    REP(i, n){
        cin >> a[i];
    }
    REP(i, n){
        cin >> b[i];
    }
    
    set<ll> st;
    for(ll i = 49; i >= 0; i--){
        vector<vector<ll>> g(51);
        for(ll j = 50; j >= 1; j--){
            for(ll k = 1; k <= i; k++){
                g[j].push_back(j % k);
            }
            for(auto &x : st){
                g[j].push_back(j % x);
            }
        }
        if(!check(n, g, a, b)) st.insert(i + 1);
    }
    
    vector<vector<ll>> g(51);
    ll ans = 0;
    for(auto &x : st){
        // cerr << x << endl;
        ll p = 1;
        for(ll i = 1; i <= x; i++){
            p *= 2;
        }
        ans += p;
        for(ll i = 1; i <= 50; i++){
            g[i].push_back(i % x);
        }
    }
    cout << (check(n, g, a, b)? ans : -1) << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x1 = Integer.parseInt(sc.next());
        int y1 = Integer.parseInt(sc.next());
        int x2 = Integer.parseInt(sc.next());
        int y2 = Integer.parseInt(sc.next());

        int vx = x2 - x1;
        int vy = y2 - y1;

        int x3 = 0, y3 = 0, x4 = 0, y4 = 0;
        x3 = x2 - vy;
        y3 = y2 + vx;
        x4 = x1 - vy;
        y4 = y1 + vx;

        System.out.printf("%d %d %d %d\n", x3, y3, x4, y4); 
    }
}

Measured memory_bytes: 23636
package main

import "fmt"

const MAX = 2001
const MOD = 1000000007

var fac, finv, inv [MAX]int

func cominit() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for i := 2; i < MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

func combination(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func main() {
	cominit()

	var n, k int
	fmt.Scan(&n, &k)

	for i := 1; i <= k; i++ {
		a := combination(n-k+1, i)
		b := combination(k-1, i-1)
		fmt.Println(a * b % MOD)
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

struct Edge {
    int source, to, cost;
    bool operator<(const Edge& o) const {
        return cost < o.cost;
    }
};

const int SIZE = 100000;

struct UnionFind {
    int gid[SIZE], rank[SIZE];
    int groups;

    void init(int n) {
        for (int i = 0; i < n; ++i) {
            gid[i] = i;
            rank[i] = 0;
        }
        groups = 0;
    }

    int find(int x) {
        if (gid[x] == x) {
            return x;
        }
        return gid[x] = find(gid[x]);
    }

    bool equals(int a, int b) {
        return find(a) == find(b);
    }

    int merge(int x, int y) {
        int rx = find(x);
        int ry = find(y);
        if (rx != ry) {
            if (rank[rx] < rank[ry]) {
                gid[rx] = ry;
            } else {
                gid[ry] = rx;
            }
            groups--;
        }
        return groups;
    }
};

const int MAX_V = 10000;
const int INF = 1 << 28;

int V, E;
bool done[MAX_V];

int main() {
    cin >> V >> E;
    Edge edges[E];
    for (int i = 0; i < E; ++i) {
        int s, t, w;
        cin >> s >> t >> w;
        edges[i] = (Edge) { s, t, w };
    }
    sort(edges, edges + E);
    UnionFind uf = UnionFind();
    uf.init(V);
    int costSum = 0;
    for (Edge e: edges) {
        if (uf.equals(e.source, e.to)) {
            continue;
        }
        costSum += e.cost;
        if (uf.merge(e.source, e.to) == 1) {
            break;
        }
    }

    cout << costSum << endl;
}

Measured memory_bytes: 5060
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=1000005*2;
int n;
char s[N];
int a[N];
int pre[N],nxt[N];
int del[N];
int cnt[3];
void erase(int x){
	pre[nxt[x]]=pre[x];
	nxt[pre[x]]=nxt[x];
	del[x]=1;
	cnt[a[x]]--;
}
struct Node{
	int x,y,z;
	Node(){}
	Node(int _x,int _y,int _z){
		x=_x,y=_y,z=_z;
	}
};
queue <Node> q0[3],q1[3][3];
void Ins(int i){
	if (i==0||i==n+1)
		return;
	int x=pre[i],y=i,z=nxt[i];
	if (x==0||z==n+1||a[x]!=a[z])
		q0[a[y]].push(Node(x,y,z));
	else
		q1[a[y]][a[x]].push(Node(x,y,z));
}
int main(){
	cin>>(s+1);
	n=strlen(s+1);
	nxt[0]=1,pre[n+1]=n;
	a[n+1]=-1;
	For(i,1,n)
		nxt[i]=i+1,pre[i]=i-1;
	For(i,1,n)
		cnt[a[i]=s[i]-'A']++;
	for (int i=nxt[0];i!=n+1;i=nxt[i])
		while (a[i]==a[nxt[i]])
			erase(nxt[i]);
	for (int i=nxt[0];i!=n+1;i=nxt[i])
		Ins(i);
	while (1){
		int id[3]={0,1,2};
		sort(id,id+3,[&](int a,int b){return cnt[a]>cnt[b];});
		int c0=id[0],c1=id[1];
		if (cnt[0]==cnt[1]&&cnt[0]==cnt[2])
			break;
		if (!q0[c0].empty()){
			Node now=q0[c0].front();
			q0[c0].pop();
			if (del[now.x]||del[now.y]||del[now.z])
				continue;
			erase(now.y);
			Ins(now.x);
			Ins(now.z);
		}
		else {
			assert(!q1[c0][c1].empty());
			Node now=q1[c0][c1].front();
			q1[c0][c1].pop();
			if (del[now.x]||del[now.y]||del[now.z])
				continue;
			int w=pre[now.x];
			erase(now.x);
			erase(now.y);
			Ins(w);
			Ins(now.z);
		}
	}
	for (int i=nxt[0];i!=n+1;i=nxt[i])
		putchar('A'+a[i]);
	puts("");
	return 0;
}
//ACCBCCABBB

Measured memory_bytes: 48896
#include <iostream>
#include <string>

using namespace std;

typedef struct LinkedList LinkedList;

struct LinkedList {
  LinkedList *front = NULL;
  LinkedList *back = NULL;
  int key = -1;
};

int main() {
  int N, key;
  string command;
  LinkedList *first = NULL;
  LinkedList *last = NULL;
  int index = 0;
  LinkedList *temp;

  cin >> N;
  for (int i = 0; i < N; i ++) {
    cin >> command;
    if (command == "insert") {
      cin >> key;
      LinkedList *insert_temp = new LinkedList();
      insert_temp->key = key;
      if (first != NULL) {
        first->front = insert_temp;

        insert_temp->back = first;
        first = insert_temp;

      } else {
        first = insert_temp;
        last = insert_temp;
      }
      index ++;
    } else if (command == "delete") {
      cin >> key;
      temp = first;
      while (true) {
        if (temp->key == key) {
          if (temp->back == NULL) {
            last = temp->front;
            last->back = NULL;
          } else if (temp->front == NULL) {
            first = temp->back;
            first->front = NULL;
          } else {
            temp->front->back = temp->back;
            temp->back->front = temp->front;
          }
          break;
        }
        if (temp->back == NULL) break;
        else temp = temp->back;
      }

    } else if (first != NULL) {
      if (command == "deleteFirst") {
        first = first->back;
        if (first != NULL) first->front = NULL;
        else last = NULL;
      } else if (command == "deleteLast") {
        last = last->front;
        if (last != NULL) last->back = NULL;
        else first = NULL;
      }
    }
  }

  while (true) {
    cout << first->key;
    if (first->back == NULL) {
      break;
    } else {
      cout << " ";
    }
    first = first->back;
  } 
  cout << endl;

  return 0;
}





Measured memory_bytes: 37512
#include<iostream>
using namespace std;
typedef long long ll;

const ll MOD = 1e+9 + 7;

ll dp[61][3];

int main() {
	ll N;
	cin >> N;
	for (int i = 0; i < 61; i++) {
		for (int j = 0; j < 3; j++) dp[i][j] = 0;
	}
	dp[60][0] = 1;
	for (int i = 59; i >= 0; i--) {
		// Nのiビット目に注目
		if ((N >> i) & 1) {
			dp[i][0] = dp[i + 1][0];
			dp[i][1] = dp[i + 1][0] + dp[i + 1][1];
			dp[i][2] = 2 * dp[i + 1][1] + 3 * dp[i + 1][2];
		}
		else {
			dp[i][0] = dp[i + 1][0] + dp[i + 1][1];
			dp[i][1] = dp[i + 1][1];
			dp[i][2] = dp[i + 1][1] + 3 * dp[i + 1][2];
		}
		for (int j = 0; j < 3; j++) {
			dp[i][j] %= MOD;
		}
	}
	ll ans = 0;
	for (int i = 0; i < 3; i++) {
		ans = (ans + dp[0][i]) % MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  if (n < 1200) {
    cout << "ABC" << endl;
  } else if (n < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;

template <typename T>
void l(T print){
	cout << print;
}
template <typename T>
void ll(T print){
	cout << print << endl;
}
template <typename T>
void ll(vector<T> print){
	for(auto i=0; i < print.size(); i++)
		cout <<"["<<i<<"]: " << print[i] << endl;
}

void solve(int n,int x,vector<int> items){
	sort(items.begin(),items.end(),std::less<int>());
	int count = 0;
	for(int i=0; i < items.size();++i){
		if(x >= items[i]){
			x-=items[i];
			count++;
		}
	}
	if(count==items.size()){
		while(x>0){
			if(x>=items[0]){
				x-=items[0];
				count++;
			}else
				break;
		}
	}

	cout << count << endl;
}

int main() {
	int n=0,x=0;
	cin>>n; cin>>x;
	vector<int> items(n);
	for(int i = 0; i < n; ++i) cin >> items[i];
//	n=3;x=1000;
//	items.push_back(120);
//	items.push_back(100);
//	items.push_back(140);

	solve(n,x,items);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007, size = 100005;
long long factrial(long long x){
    long long y = 1;
    for (int i = 1; i <= x; i++)
    {
        y *= i;
        y %= mod;
    }
    return y;
}
long long power(long long x, long long n, long long M = mod){
    long long res = 1;
    if(n > 0){
        res = power(x, n / 2, M);
        if(n%2 == 0)res = (res * res) % M;
        else res = (((res * res) % M) * x) % M;
    }
    return res;
}
int main(){
    int h, w, a, b;
    cin >> h >> w >> a >> b; 
    long long start1 = factrial(b+h-a-1), start2 = factrial(w-b+a-2);
    start1 *= power(factrial(h-a-1), mod-2);
    start1 %= mod;
    start1 *= power(factrial(b), mod-2);
    start1 %= mod;
    start2 *= power(factrial(w-b-1), mod-2);
    start2 %= mod;
    start2 *= power(factrial(a-1), mod-2);
    start2 %= mod;
    long long A[size], B[size];
    A[0] = start1;B[0] = start2;
    for (int i = 1; i < w-b; i++)
    {
        A[i] = A[i-1] * (b+h-a-1+i);
        A[i] %= mod;
        A[i] *= power(b+i, mod-2);
        A[i] %= mod;
        B[i] = B[i-1] * power((w+a-b-2-i+1), mod-2);
        B[i] %= mod;
        B[i] *= w-b-i;
        B[i] %= mod;
    }
    long long ans = 0;
    for (int i = 0; i < w-b; i++)
    {
        ans += A[i] * B[i];
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main() {
	int a, b, c;
	int k;
	scanf("%d%d%d %d", &a, &b, &c, &k);

	int max = a;
	if ( max < b ) {
		max = b;
	}
	if ( max < c) {
		max = c;
	}

	int sum = a + b+ c;
	for (int i = 0; i < k; i++) {
		sum += max;
		max *= 2;
	}
	printf("%d\n", sum);
}


Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll INF=1e18;
const ll mod=1e9+7;

int main(){
    ll n,p;
    cin >> n >> p;
    ll ans=1;
    if(n==1){
        cout << p << endl;
        return 0;
    }
    else{
        for(ll i=2;i<=1000000;i++){
            ll v=p;
            ll cnt=0;
            while(v%i==0){
                cnt++;
                v/=i;
            }
            if(cnt>=n){
                ans=i;
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>

int main(){
  int X,Y;
  scanf("%d",&X);
  scanf("%d",&Y);
  for (int i=0; i<=X; i++){
    if (i*2 + (X-i)*4 == Y){
      printf("Yes");
      return 0;
    } 
  }
  printf("No");
  return 0;
}

Measured memory_bytes: 1736
#include <stdio.h>

int main()
{
	char s[100001] = {};
	scanf("%s", s);
	
	int i, count[3] = {}, min, max;
	for (i = 0; s[i] != 0; i++) count[s[i] - 'a']++;
	min = (count[0] <= count[1])? ((count[0] <= count[2])? count[0]: count[2]): (count[1] <= count[2])? count[1]: count[2];
	max = (count[0] <= count[1])? ((count[1] <= count[2])? count[2]: count[1]): (count[0] <= count[2])? count[2]: count[0]; 

	if (max - min <= 1) printf("YES\n");
	else printf("NO\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int counter = 0;
      	int N = scan.nextInt();
      	int M = scan.nextInt();
      	int C = scan.nextInt();
      	int[] B = new int[M];
      	for(int i = 0; i < M; i++){
        	B[i] = scan.nextInt();
        }
      	for(int k = 0; k < N; k++){
      		int[] A = new int[M];
      		for(int i = 0; i < M; i++){
        		A[i] = scan.nextInt();
        	}
      		int sahen = 0;
      		for(int j = 0; j < M; j++){
        		sahen = sahen + A[j] * B[j];
        	}
      		if(sahen + C > 0){
        		counter++;
        	}
        }
      	System.out.print(counter);
      	
    }
 
}

Measured memory_bytes: 22100
n = int(input())
h = list(map(int, input().split()))

max_ = 0
for i in range(n):
  if h[i]>=max_: max_=h[i]
  else:
    h[i]+=1
    if h[i]>=max_: max_=h[i]
    else: 
      print('No')
      exit(0)
print('Yes')

Measured memory_bytes: 14396
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 200000;

int main(){
    
    int n;
    ll tmp=1;
    ll ans = 0;
    vector<ll> a(maxn),b(maxn);
    
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        cin >> b[i];
    }
    
    rep(i,30){
        vector<ll> sub_a(maxn);
        vector<ll> sub_b(maxn);
        ll cnt = 0;
        rep(j,n){
            sub_a[j] = a[j] % (2*tmp);
            sub_b[j] = b[j] % (2*tmp);
        }
        sort(sub_a.begin(),sub_a.begin()+n);
        rep(j,n){
            int cnt_1 = sub_a.begin()+n - lower_bound(sub_a.begin(),sub_a.begin()+n,tmp-sub_b[j]);
            int cnt_2 = lower_bound(sub_a.begin(),sub_a.begin()+n,2*tmp-sub_b[j])-sub_a.begin();
            int cnt_3 = sub_a.begin()+n - lower_bound(sub_a.begin(),sub_a.begin()+n,3*tmp-sub_b[j]);
            int cnt_4 = lower_bound(sub_a.begin(),sub_a.begin()+n,4*tmp-sub_b[j])-sub_a.begin();
            cnt = cnt + (cnt_1+cnt_2+cnt_3+cnt_4-2*n);
        }
        if(cnt%2==1)ans+=tmp;
        tmp *= 2;
    }
    
    cout << ans<<endl;
    
    return 0;
}


Measured memory_bytes: 6552
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};

//探索、更新にO(log n)
struct segment_tree{
    in init ; //　空いてる値はこれになる
    in n; //　n個のデータ
    vector<in> data; // データ置き場・n-1~2n-1に元データ

    //(個数、初期値)
    //初期化　nを2の累乗に直す  初期値は最も選ばれない値にする
    segment_tree(in a, in b) : init(b) {
        n = 1;
        while( n < a ) n *= 2;
        data.assign(n * 2 - 1,init);
    }

    //+とかにしてもいい、結合法則はいる
    //選ぶ方の決め方（ここでは小さい方）
    in which(in a, in b){
        // if(a > b) return b;
        // else return a;
        return a+b;
    }

    // k番目をaに更新
    void update(in k, in a){
        k += n-1;
        data[k] = a;

        //下から上に更新
        while( k > 0 ){
            k = (k - 1) / 2;
            data[k] = which( data[k*2+1] , data[k*2+2] );
        }
    }

    // [a, b)の最小値を求める
    // 後ろのほうの引数は、計算の簡単のための引数。
    // kは節点の番号、l, rはその節点が[l, r)に対応づいていることを表す。
    // したがって、外からはquery(a, b, 0, 0, n)として呼ぶ。
    in query( in a, in b, in k, in l, in r){

        // [a, b)と[l, r)が交差しなければ、MAX_in
        if(r <= a || b <= l) return init;

        // [a, b)が[l, r)を完全に含んでいれば、この節点の値
        if(a <= l && r <= b) return data[k];

        // そうでなければ、2つの子の最小値
        in vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        in vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return which( vl, vr );
    }

    // 外から呼ぶとき用
    // [a, b)の最小値を求める
    in query( in a, in b){
        return query( a, b, 0, 0, n);
    }

    // a番目のデータを見る
    // query(a,a+1)で良くね？
    in look(in a){
        return data[a+n-1];
    }
};

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n,q;
    cin>>n>>q;
    vector<in> a(n);
        rep(i,n) cin>>a.at(i);
    
    segment_tree sg(n,0);
    rep(i,n) sg.update(i,a[i]);
    in x,y,z;
    rep(i,q){
        cin>>x>>y>>z;
        if(x){
            cout<<sg.query(y,z)<<endl;
        }
        else{
            sg.update(y,sg.look(y)+z);
        }
    }
}/*
./problem.exe
*/

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

/* debugging */
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << ": " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<"| ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int32_t main(){
    boost;

   
    
    int n , x;
    cin >> n >> x;

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

    for(int i = 1 ; i < n ; ++i){
    	a[i] += a[i-1];
    }

    int ans = 0;
    for(int i = 0 ; i <n ; ++i){
    	if(a[i] <= x)
    		++ans;
    }

    cout << ans + 1;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    int k;
    cin >> s >> k;
    REPS(c, s) {
        if (c != '1') {
            cout << c << endl;
            return;
        }
        if (--k == 0) {
            cout << 1 << endl;
            return;
        }
    }
    cout << 1 << endl;
}


Measured memory_bytes: 256