akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long       ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define f first
#define s second
#define fore(i, b, e)    for (int i = (int)b; i < (int)e; i++)
#define forr(i, b, e)    for (int i = (int)b; i < (int)e; i++)
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);
const double EPS = 1e-9;
const double PI = acos(-1);
#define tam 3200
int peso[tam],cantidad[tam];
vector<int> g[tam];
int n;
int c=1;
void dfs(int num)
{
    //cout<<num<<"herhe\n";
    queue<int> cola;
    cola.push(num);
    peso[num]=0;
    while(!cola.empty())
    {
        num=cola.front();cola.pop();
        for(int v:g[num])
        {
            if (peso[v]==-1)
            {
                peso[v]=peso[num]+1;
                cola.push(v);
            }
        }
    }
    forr(j,c++,n+1)
    {
        //cout<<peso[j]<<" "<<j<<endl;
        cantidad[peso[j]]++;
    }
}
int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    int x,y;
    cin>>n>>x>>y;
    g[x].pb(y);
    g[y].pb(x);
    forr(i,1,n)
    {
        g[i].pb(i+1);
        g[i+1].pb(i);
    }
    
    forr(i,1,n)
    {
        memset(peso,-1,sizeof peso);
        dfs(i);
    }
    forr(i,1,n)
    cout<<cantidad[i]<<endl;
}
// PLUS ULTRA!


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#define REP(i, N) for(int i = 0; i < N; ++i)
#define REEP(i, N) for(int i = N - 1; i >= 0; --i)
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,m,n) for(int i = m; i < n; ++i)
#define RFOR(i,m,n) for(int i = n - 1; i >= m; --i)
#define CIN(a) cin >> a
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a << endl
#define COUT2(a, b) cout << a << " " << b << endl
#define COUT3(a, b, c) cout << a << " " << b << " " << c << endl
#define pb(v, a) v.push_back(n)
#define VINT(v, n) vector<int> v(n); REP(i, n) { v[i] = 0 }
#define VINT2(v, n, m) vector<vector<int> > v(n, vector<int>(m)); REP(i, n) { REP(j, m) { v[i][j] = 0 } }
#define VCHAR(v, n) vector<char>v(n)
#define MAX(a, b) a > b ? a : b;
#define MIN(a, b) a < b ? a : b;
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;}
#define sp(n) setprecision(n)
#define INF 100000000

using namespace std;

int main() {
	string S;
	CIN(S);
	REP(i, S.size()) {
		if(S[i] == ',') {
			S[i] = ' ';
		}
	}
	COUT(S);
}


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

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

using ll=long long;
using pi=pair<int,int>;

template<typename T>
using vec=vector<T>;
template<typename T>
using mat=vector<vec<T>>;

mat<int> dist;
mat<pi> gr;

void dijkstra(int s){
	priority_queue<pi,vec<pi>,greater<pi>> que;
	dist[s][s]=0;
	que.emplace(dist[s][s],s);
	while(!que.empty()){
		int cost,idx;
		tie(cost,idx)=que.top(); que.pop();
		if(dist[s][idx]<cost) continue;
		for(auto &e:gr[idx]){
			int ncos=cost+e.second;
			if(dist[s][e.first]<=ncos) continue;
			dist[s][e.first]=ncos;
			que.emplace(dist[s][e.first],e.first);
		}
	}
}

int main(void){
	int N,R; cin>>N>>R;
	dist.resize(N,vec<int>(N,INT_MAX));
	gr.resize(N);
	rep(i,R){
		int s,t,d; cin>>s>>t>>d;
		--s,--t; gr[s].emplace_back(pi(t,d)),gr[t].emplace_back(pi(s,d));
	}
	rep(i,N) dijkstra(i);
	
	int longest=0;
	for(int i=0; i<N; ++i){
		for(int j=i+1; j<N; ++j){
			longest=max(longest,dist[i][j]);
		}
	}
	
	vec<bool> unuse(N,true);
	vec<pi> course;
	for(int i=0; i<N; ++i){
		for(int j=i+1; j<N; ++j){
			if(dist[i][j]==longest){
				course.emplace_back(i,j);
				unuse[i]=unuse[j]=false;
			}
		}
	}
	
	vec<int> ans;
	for(int i=0; i<N; ++i){
		if(!unuse[i]) continue;
		for(int j=0; j<course.size(); ++j){
			int x=course[j].first,y=course[j].second;
			if(dist[x][i]+dist[i][y]==dist[x][y]){
				unuse[i]=false; break;
			}
		}
		if(unuse[i]) ans.emplace_back(i+1);
	}
	
	cout<<ans.size()<<endl;
	for(auto &e:ans) cout<<e<<endl;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector <long long> h(n);
    rep(i,n) cin >> h[i];

    vector <bool> good(n,true);

    rep(i,m){
        int a , b;
        cin >> a >> b;
        long long ha = h[a-1], hb = h[b-1];
        if(ha > hb){
            good[b-1] = false;
        }
        if(ha < hb){
            good[a-1] = false;
        }
        if(ha == hb){
            good[a-1] = false;
            good[b-1] = false;
        }
    }

    int ans=0;
    rep(i,n){
        if(good[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4056
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int age = sc.nextInt();

        if (age == 3 || age == 5 || age == 7)  {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
 
typedef double ll;
typedef string str;
 
// ll power(ll x, ll y, ll p) 
// { 
//     ll res = 1;     
  
//     x = x % p;   
//     while (y) 
//     { 
//         if (y & 1) 
//             res = (res*x) % p; 
//         y = y>>1;  
//         x = (x*x) % p; 
//     } 
//     return res; 
// } 
 
// ll nCrModP(ll n, ll r, ll p) 
// { 
//     if (!r) 
//       return 1; 
  
// 	ll fac[n+1]; 
//    	fac[0] = 1; 
//     for (ll i=1 ; i<=n; i++) 
//         fac[i] = fac[i-1]*i%p; 
  
//     return (fac[n]* power(fac[r], p-2,p) % p * power(fac[n-r], p-2,p) % p) % p; 
// }
 
// ll gcd(ll a, ll b){ 
//     if (a == 0) 
//         return b;  
//     return gcd(b % a, a);
// }
 
void fast(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main ()
{
	
	ll t,n,m,k,i,j,a,b;
	// cin >> t;
    str st,s;
    cin >> n >> m >> k;
    t=n/k;
    // deb(t,n,k);
    if(t<=m)
    	cout << "Yes\n";
    else
    	cout << "No\n";
    return 0;
}

Measured memory_bytes: 3752
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
#define function function2
#define int long long int
int memo[3001][3001];
int function(int arr[],int i,int j,int status)
{
	if(i>j)
	  return 0;
	if(memo[i][j]!=-1)
	   return memo[i][j];
	else
	{
		if(status==0)
		{
			int x=arr[i]+function(arr,i+1,j,1-status);
			int y=arr[j]+function(arr,i,j-1,1-status);
			int here=max(x,y);
			memo[i][j]=here;
			return here;
		}
		else
		{
			int x=function(arr,i+1,j,1-status);
			int y=function(arr,i,j-1,1-status);
			int here=min(x,y);
			memo[i][j]=here;
			return here;
		}
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int j,arr[n];
	for(j=0;j<n;j++)
	   cin>>arr[j];
	int i;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=n;j++)
		  memo[i][j]=-1;
	}
	int answer=function(arr,0,n-1,0);
	int total=0;
	for(j=0;j<n;j++)
	  total+=arr[j];
	int x=answer;
	int y=total-answer;
	cout<<x-y<<endl;
}


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

int main(){
	ll n,a,b,c,d,e;
	cin>>n>>a>>b>>c>>d>>e;
	ll buf[5];
	buf[0]=a;
	buf[1]=b;
	buf[2]=c;
	buf[3]=d;
	buf[4]=e;
	ll res=0;
	ll t=0,tmp=0;

	for(int i=0;i<5;i++){
		if(i==0){
			t+=n/buf[i];
			if(n%buf[i]!=0)t++;
			continue;
		}
		tmp=n/buf[i];
		if(n%buf[i]!=0){
			tmp++;
		}
		t++;
		if(tmp+i>t)t=tmp+i;
	}
	int cnt=0;
	for(int i=0;i<4;i++){
				if(buf[i]==buf[i+1])cnt++;
	}
	if(cnt==4&&n<=a)t=5;
	cout<<t<<endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

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

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back


int main(void){
  int n;
  int t;
  cin >> n;
  n *= 2;
  vector<int> l;
  rep(i,n){
    cin >> t;
    l.eb(t);
  }
  sort(all(l));
  int ans = 0;
  for(int i = 0; i < n; i+=2){
    ans += l[i];
  }
    
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
   cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  
  bool ans = true; 
  int count = 0;
  while(ans){
    for(int i=0; i<N; i++){
      if(vec[i]%2==1){
        ans = false;
        break;
      }
      vec[i] /= 2;
    }
    count++;
  }
  cout << count-1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define D(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long LL;
int T,A,B,C,D;LL n;
map<LL,LL>mp;
LL sol(LL n){
	if(mp.count(n))return mp[n];
	LL res=1e18;
	LL k1=n/2*2,k2=(n+1)/2*2,k3=n/3*3,k4=(n+2)/3*3,k5=n/5*5,k6=(n+4)/5*5;
	if(n<=1e18/D)res=n*D;
	res=min({res,abs(k1-n)*D+A+sol(k1/2),abs(k2-n)*D+A+sol(k2/2),abs(k3-n)*D+B+sol(k3/3),abs(k4-n)*D+B+sol(k4/3),abs(k5-n)*D+C+sol(k5/5),abs(k6-n)*D+C+sol(k6/5)});
//	D("mp[%lld]=%lld\n",n,res);
	return mp[n]=res;
}
int main(){
	scanf("%d",&T);
	while(T--){
		scanf("%lld%d%d%d%d",&n,&A,&B,&C,&D);
		mp.clear(),mp[0]=0,mp[1]=D;
		printf("%lld\n",sol(n));
	}
	return 0;
}

Measured memory_bytes: 4652
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#define mp make_pair
#define pb push_back
using namespace std;

typedef long long li;
template<class T>inline void read(T &x) {
  x = 0;
  T tmp = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') tmp = -1, c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + c - '0', c = getchar();
  x *= tmp;
}
template<class T>inline void Max(T &x, T y) {
  if (y > x) x = y;
}
template<class T>inline void Min(T &x, T y) {
  if (y < x) x = y;
}

const int inf = 1e9;
int n;

int Calc(int x) {
  int res = 0;
  while (x) {
    res += x % 10;
    x /= 10;
  }
  return res;
}

int main(void) {
  read(n);
  int ans = inf;
  for (int a = 1; a <= n / 2; ++a) {
    int b = n - a;
    Min(ans, Calc(a) + Calc(b));
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 128
import numpy as np 
N,W=map(int,input().split())
w,v=[],[]
for i in range(N):
    a,b=map(int,input().split())
    w+=[a]
    v+=[b]
DP=np.zeros(W+1,dtype=int)
for i in range(N):
    DP[w[i]:]=np.maximum(DP[:-w[i]]+v[i],DP[w[i]:])
print(max(DP))

Measured memory_bytes: 15476
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys


def solve(N, M, Xs):
    if M <= N:
        return 0

    diffs = []
    for i in range(M - 1):
        diffs.append(Xs[i+1] - Xs[i])
    diffs.sort()

    return sum(diffs[:M - N])


N, M = map(int, input().split())
Xs = sorted(list(map(int, input().split())))
print(solve(N, M, Xs))


Measured memory_bytes: 16576
#include<iostream>
//#include<windows.h>
//#include<cstring>
//#include<algorithm>
//#include<sec_api/stdio_s.h>
//#include<structuredquerycondition.h>
#include<string>
//#define R register
//#define A 10010
//#pragma GCC optimize(2)
//#define mswap(a,b) ((&(a)==&(b)) or \
//					(((a)-=(b)),((b)+=(a)),((a)=(b)-(a))))

using namespace std;

/*inline void Pcyan()
{
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
	FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
}
inline char GETCHAR()
{
	static char buf[A],*p1=buf,*p2=buf;
	return p1==p2 and (p2=(p1=buf)+fread(buf,1,A,stdin),p1==p2)?EOF:*p1++;
}
template <class T> void read(T &x)
{
	x=0;int flag=0;char ch=GETCHAR();
	while(!isdigit(ch)) {flag|=ch=='-',ch=GETCHAR();}
	while(isdigit(ch)) {x=(x<<3)+(x<<1)+(ch^48);ch=GETCHAR();}
	x=flag?-x:x;
}
inline void write(int x)
{
	if(x<0) {putchar('-'),x=-x;}
	if(x>9) write(x/10);
	putchar(x%10+48);
}
inline void swap(int a,int b){a^=b^=a;}
inline int cmp(unsigned int a,unsigned int b)
{
	#define _M (1<<31)
	return (a^b) and
		!(((a&_M)^(b&_M)) and (b&_M)) and
		(((a&_M)^b&_M) and (a&_M) or cmp(a<<1,b<<1));
	#undef _M
}
inline int min(int x,int y){return y+((x-y)&((x-y)>>(sizeof(int)*CHAR_BIT-1)));}
inline int max(int x,int y){return x-((x-y)&((x-y)>>(sizeof(int)*CHAR_BIT-1)));}*/
string a,b,c;

int main()
{
//	Pcyan();
	cin>>a>>b>>c;
	cout<<a[0]<<b[0]<<c[0]<<'\n';
}

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

int main () {
  int n, ans = 0;
  string s;
  cin >> n >> s;
  
  for (int i = 2; i < n; i++) {
    if (s[i-2]=='A' && s[i-1]=='B' && s[i]=='C') {
      ans ++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def getinputdata():

    # 配列初期化
    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

a = int(arr_data[0][0])
b = int(arr_data[0][1])


print(max(a*b,max(a+b,a-b)))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <set>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

int main(){
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int maxt;

    if(A >= K){
        maxt = K;
    }
    else if(K >= A && A+B >= K){
        maxt = A;
    }
    else{
        maxt = A - K + A + B;
    }

    cout << maxt << endl;

}

Measured memory_bytes: 3624
import sys
input=sys.stdin.readline
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
x=abs(a-b)
if v<=w:
    print('NO')
else:
    if (v-w)*t>=x:
        print('YES')
    else:
        print('NO')








Measured memory_bytes: 61608
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793




int main(){
    int x,y;
    cin >> x >> y;
    int ans=0;
    if(x==1)ans+=300000;
    if(x==2)ans+=200000;
    if(x==3)ans+=100000;
    if(y==1)ans+=300000;
    if(y==2)ans+=200000;
    if(y==3)ans+=100000;
    if(x==1 && y==1)ans+=400000;
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>

int main()
{
	int a,b,c,x,d,T=0;

	scanf("%d %d %d",&a,&b,&c);
	for (x=a;x<=b;x++) {
		if (c%x==0) {T++;}
	}
	printf("%d\n",T);
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<string.h>
int main(){
	int a, b;
	char s[15];
	char t[15];
	char u[15];
	scanf("%s %s", &s, &t);
	scanf("%d %d", &a, &b);
	scanf("%s", u);
	if(strcmp(u,s)==0){
	printf("%d %d", a-1, b);}
	if (strcmp(u,t)==0){
	printf("%d %d", a, b-1);}
	return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
typedef  long long int ll;
typedef long double ld;
#define pb  push_back
#define vll vector<ll>
#define mll map<ll,ll>
const double PI = 2*acos(0.0);
#define gcd(a,b)   __gcd((a),(b))
#define lcm(a,b)   ((a)/(__gcd((a),(b)))*(b))
#define INF         LLONG_MAX
#define ln  INT_MAX
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
int main() {
string p;
cin>>p;

    ll a,c=0;

    for(int i=0; i<p.size(); i++){
        a=p[i]-'0';
      c=c+a;
    }
    if(c%9==0){puts("Yes");}
    else{puts("No");}

return 0;
}


Measured memory_bytes: 3704
n = int(input())
a = list(map(int, input().split()))

MOD = 10 ** 9 + 7

sum = sum(a) % MOD
ans = 0

for i in range(len(a)):
    sum -= a[i]
    sum %= MOD
    ans += a[i] * sum
    ans %= MOD

print(ans)



Measured memory_bytes: 31696
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main(){
    int N;
    cin>>N;
    map<long long,int> mp;
    mp[0] = 1;
    long long s = 0;
    long long res = 0;

    for(int i = 0; i < N;i++){
        int A;
        cin>>A;
        s += A;
        res += mp[s];
        mp[s]++;
    }

    cout<<res<<endl;   
}

Measured memory_bytes: 12800
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        Set<Integer>[] set1 = new HashSet[m];
        Set<Integer>[] set2 = new HashSet[n];

        for (int i = 0; i < n; i++) {
            int k = scanner.nextInt();
            for (int j = 0; j < k; j++) {
                int l = scanner.nextInt() - 1;
                (set2[i] == null ? set2[i] = new HashSet<>() : set2[i]).add(l);
                (set1[l] == null ? set1[l] = new HashSet<>() : set1[l]).add(i);
            }
        }

        boolean[] visited = new boolean[n];
        boolean[] visitedLanguage = new boolean[m];
        Deque<Integer> deque = new ArrayDeque<>();
        deque.add(0);
        visited[0] = true;
        while (!deque.isEmpty()) {
            int i = deque.poll();
            for (int j : set2[i]) {
                if (!visitedLanguage[j]) {
                    visitedLanguage[j] = true;
                    for (int k : set1[j]) {
                        if (!visited[k]) {
                            deque.add(k);
                            visited[k] = true;
                        }
                    }
                }
            }
        }

        for (boolean b : visited) {
            if (!b) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll n,i,m,i1,i2,val,suma = 0;
	cin >> n  >> m >> val;
	vector< ll >v1(n),v2(m);
	for(i = 0; i < n; i++)cin>>v1[i] , suma += v1[i];
	for(i = 0; i < m; i++)cin>>v2[i];
	i2 = 0;
	ll ans = 0 , sumb = 0;
	for(i = n ; i>=0 ; i--){
		if(i<n)suma -= v1[i];
		while(i2 < m && suma + sumb + v2[i2] <=val){
			sumb += v2[i2];
			i2++;
		}
		if(suma + sumb <= val && suma + sumb != 0 )ans = max(ans , i + i2 );
	}
	cout << ans << nl;
}

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


Measured memory_bytes: 6356
#include <iostream>
#include <queue>
#include <iomanip>
#include <map>
#include <algorithm>

using namespace std;

using ll = long long;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main() {
    string N;
    cin >> N;

    bool flag = (N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3]);
    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n, x;
    cin >> n >> x;
    vector<int> v(n);
    for(auto& i : v) cin >> i;

    int ans = 1, d = 0;

    REP(i, n){
        d += v[i];
        if(d <= x) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

vector<ll> yakusu(ll n){
    vector<ll> ret;
    for(ll i = 1; i*i <= n; i++){
        if(n % i != 0) continue;
        ret.push_back(i);
        if(i*i != n) ret.push_back(n/i);
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, 1, n+1) {
        ll tmp = 0;
        auto v = yakusu(i);
        for(auto e : v) tmp += e % 2;
        ans += (tmp == 8);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
def calc_money(open_time,F,P):
    money = 0
    for i in range(len(F)):
        overlap_time=0
        for j in range(len(open_time)):
            overlap_time+= open_time[j]*F[i][j]
        #overlap_time = sum(list(map(lambda x, y:x*y,zip(open_time,F[i]))))
        money+=P[i][overlap_time]
    return money


        


def main():
    N = int(input())
    F = []
    for i in range(N):
        F.append(list(map(int,input().split())))
    P = []
    for i in range(N):
        P.append(list(map(int,input().split())))

    max_money=0
    for i in range(1024):
        if i==0: continue
        num=str(bin(i))[2:]
        open_time = []

        for j in range(10-len(num)):
            open_time.append(0)
        for j in range(len(num)):
            open_time.append(int(num[j]))
        money = calc_money(open_time,F,P)
        if i==1:
            max_money=money
        elif max_money<money:
            max_money=money
    print(max_money)
            


main()


Measured memory_bytes: 3064
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let abc: Vec<(usize, usize, i64)> = (1..n)
        .map(|_| {
            let a = input();
            let b = input();
            let c = input();
            (a, b, c)
        })
        .collect();
    let q: usize = input();
    let k: usize = input();
    let xy: Vec<(usize, usize)> = (0..q)
        .map(|_| {
            let x = input();
            let y = input();
            (x, y)
        })
        .collect();

    let mut t = vec![vec![]; n + 1];
    for (a, b, c) in abc {
        t[a].push((b, c));
        t[b].push((a, c));
    }

    let mut d = vec![-1; n + 1];
    dfs(k, 0, &t, &mut d);

    for (x, y) in xy {
        println!("{}", d[x] + d[y]);
    }
}

fn dfs(cur: usize, dist: i64, t: &Vec<Vec<(usize, i64)>>, d: &mut Vec<i64>) {
    d[cur] = dist;
    for &(next, cost) in &t[cur] {
        if d[next] >= 0 {
            continue;
        }
        dfs(next, dist + cost, t, d);
    }
}


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

//typedef
//------------------------------------------
typedef int64_t LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define EACH(i,c) for(decltype((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) whole(sort, c)
#define RSORT(c) rwhole(sort, c)

//constant
//--------------------------------------------
constexpr double EPS = 1e-10;
constexpr double PI  = M_PI;
constexpr int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

template<class T,class U> void chmax(T&a,U b){if(a<b)a=b;}
template<class T,class U> void chmin(T&a,U b){if(b<a)a=b;}
LL gcd(LL a, LL b) { return b?gcd(b,a%b):a;}
LL lcm(LL a, LL b) { return a/gcd(a,b)*b;}

//main code

int main(int argc, char *argv[])
{
	int h,w, n;
	cin >> h >> w >> n;
	int m = max(h,w);
	cout << n/m + (n%m==0?0:1) << endl;
	return 0;
}


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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}


 main()

{
    fast
    int n;
    cin>>n;
    int a[n+5];
    f(i,1,n)
    {
        cin>>a[i];
    }
    int dp_in[n+5],dp_dec[n+5];
    dp_in[n]=1;
    dp_dec[n]=1;
    rf(i,n-1,1)
    {
        if(a[i]<=a[i+1])
        {
            dp_in[i]=dp_in[i+1]+1;
        }
        else dp_in[i]=1;
         if(a[i]>=a[i+1])
        {
            dp_dec[i]=dp_dec[i+1]+1;
        }
        else dp_dec[i]=1;
    }
    int cnt=0;
    f(i,1,n)
    {
        int x=dp_in[i];
        int y=dp_dec[i];
        int r1=i+x-1;
        int r2=i+y-1;
        if(r1>=r2)
        {
            i=r1;
            cnt++;
        }
        else
        {
            i=r2;
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;

}





































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

typedef long long ll;
const ll MOD = 1e9+7;
const int K = 26;

vector<int>v[K];
string s,t;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>s>>t;

    for(int i=0;i<s.length();i++){
        v[s[i]-'a'].push_back(i+1);
    }

    for(int i=0;i<t.length();i++){
        if(v[t[i]-'a'].empty()){
            cout<<-1;
            return 0;
        }
    }

    ll ans=0,prevans=0;
    int p=0;


    for(int i=0;i<t.length();i++){
        int c=t[i]-'a';
        int l=0;
        int r=(int)v[c].size()-1;
        int ind=-1;

        while(l<=r){
            int mid=(l+r)>>1;
            if(v[c][mid]>p){
                r=mid-1;
                ind=v[c][mid];
            }else{
                l=mid+1;
            }
        }

        if(ind!=-1){
            ans=prevans+1LL*ind;
            p=ind;
        }else{
            ans=prevans+1LL*s.length();
            prevans=ans;
            p=0;
            i--;
        }
    }

    cout<<ans;
    return 0;
}


Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	string S;
	int N;	cin>>N;
	map<string,int>mp;
	rep(i,0,N){
		cin>>S;
		mp[S]++;
	}
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
	return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
// typedef vector<int,vector<int>> vvec;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
// inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
// inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

//----***定数***----
const int MOD=1e9+7;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define here  cout<<"Here"<<endl;


//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

int K;
set<int> st{1,2,3,4,5,6,7,8,9};
int ue;

void dfs(int i){
  if(st.count(i))return;
  st.insert(i);
  if(st.size()>K){return;}
  int tmp_i=i%=10;
  if(tmp_i>0){
    dfs(10*i+tmp_i-1);
  }
  dfs((10*i+tmp_i));
  if(tmp_i!=9){
    dfs(10*i+1);
  }

}

signed main(){
  cin>>K;
  queue<int> que;
  each(s,st){
    que.push(s);
  }
  while(st.size()<=K){
    int target =que.front();que.pop();
    int i=target%10;
    if(i>0){
      st.insert(10*target+(i-1));
      que.push(10*target+(i-1));
    }
    st.insert(10*target+i);
    que.push(10*target+(i));
    if(i!=9){
      st.insert(10*target+(i+1));
      que.push(10*target+(i+1));
    }
    if(st.size()>K)break;
  }
  int ans,idx=0;
  each(s,st){
    //debug(s);
    if(idx==K-1){
      ans=s;
      break;
    }
    idx++;
  }
  //if(st.count(3234566667)){here}
  print(ans)
}


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

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

   vector<int> V;

   for(int i = 0; i < n; i++){
     string a, b;
     int slength[2];

    
     cin >> a >> b;

     slength[0] = a.length();
     slength[1] = b.length();


     if(a.length() != 1)reverse(a.begin(), a.end());
     if(b.length() != 1)reverse(b.begin(), b.end());

     if(a.length() > b.length()){
       for(int j = 0; j < slength[0] - slength[1]; j++) b+="0";
     }else{
       for(int j = 0; j < slength[1] - slength[0]; j++) a+="0";
     }
     int flag = 0;

     for(int j = 0; j < a.length(); j++){
       if(flag){
	 a[j]++;
	 flag--;
       }
       if((a[j]+b[j]-96)/10 == 0){
	 V.push_back(a[j]+b[j]-96);
       }else{
	 flag++;
	 V.push_back((a[j]+b[j]-96)%10);
       }
     }
 
     if(flag) V.push_back(1);

     if(V.size()-1 >= 80){
       cout << "overflow" <<endl;
     }else{
       for(int j = V.size()-1; j >= 0; j--){
	 cout << V[j];
       }
       cout << endl;
     }
     V.clear();
   }  
   return 0;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

vector<ll> tmp_list;
vector<ll> ans_list;

int main() {
  // std::cout << std::fixed << std::setprecision(10);

  ll Na, Nb, Nc, K;
  scanf("%lld %lld %lld %lld", &Na, &Nb, &Nc, &K);

  vector<ll> alist(Na);
  vector<ll> blist(Na);
  vector<ll> clist(Na);

  for (ll i = 0; i < Na; i++) {
    ll v;
    scanf("%lld", &v);
    alist[i] = v;
  }
  for (ll i = 0; i < Nb; i++) {
    ll v;
    scanf("%lld", &v);
    blist[i] = v;
  }
  for (ll i = 0; i < Nc; i++) {
    ll v;
    scanf("%lld", &v);
    clist[i] = v;
  }

  sort(alist.begin(), alist.end(), greater<ll>());
  sort(blist.begin(), blist.end(), greater<ll>());
  sort(clist.begin(), clist.end(), greater<ll>());

  for (ll i = 0; i < alist.size(); i++) {
    for (ll j = 0; j < blist.size(); j++) {
      ll sum = alist[i] + blist[j];
      tmp_list.emplace_back(sum);
    }
  }
  sort(tmp_list.begin(), tmp_list.end(), greater<ll>());
  tmp_list.resize(K);

  for (ll i = 0; i < tmp_list.size(); i++) {
    for (ll j = 0; j < clist.size(); j++) {
      ll sum = tmp_list[i] + clist[j];
      ans_list.emplace_back(sum);
    }
  }
  sort(ans_list.begin(), ans_list.end(), greater<ll>());

  for (ll i = 0; i < K; i++) {
    cout << ans_list[i] << endl;
  }
}


Measured memory_bytes: 42728
#import sys
#input = sys.stdin.readline
Q = 10**9 + 7
def main():
    N = int( input())
    A = list( map( int, input().split()))
    T = [[0]*60 for _ in range(N)]
    P = [0]*60
    for i in range(N):
        a = A[i]
        for j in range(60):
            T[i][j] = a%2
            P[j] += a%2
            a //= 2
    ans = 0
    for i in range(60):
        plus = P[i]
        minus = N - plus
        ans = (ans + plus*minus%Q*pow(2,i,Q))%Q
    print(ans)
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 204492
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;

int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    vvc c(H, vc(W));
    int ans = 0;

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> c[i][j];
        }
    }

    for (int bit = 0; bit < (1 << H + W); bit++)
    {
        vvc buf_c(c);
        vector<int> S;

        for (int i = 0; i < H + W; i++)
        {
            if (bit & (1 << i))
            {
                if (i <= H-1)
                {
                    for (int j = 0; j < W; j++)
                        buf_c[i][j] = 'R';
                }
                else
                {
                    for (int j = 0; j < H; j++)
                        buf_c[j][i - H] = 'R';
                }
            }
        }
        int c_K = 0;
        for (int i = 0; i < H; i++)
            for (int j = 0; j < W; j++)
                if(buf_c[i][j]=='#')c_K++;
        if(c_K==K)ans++;
    }

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

Measured memory_bytes: 3628
S = list(input())
T = list(input())
alpha_s = [0 for _ in range(26)]
alpha_t = [0 for _ in range(26)]
ans = 'Yes'
for i in range(len(S)):
	alpha_s[ord(S[i]) - 97] += 1
	alpha_t[ord(T[i]) - 97] += 1
	if alpha_s[ord(S[i]) - 97] != alpha_t[ord(T[i]) - 97]:
		ans = 'No'
		break
print(ans)

Measured memory_bytes: 6704
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	ll h, w;
	cin >> h >> w;
	if (h == 1 || w == 1) cout << 1 << endl;
	else cout << (h*w+1)/2 << endl;
	return 0;
 }



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int
vector<vector<int>> f(int l, int len, int m) {

  vector<vector<int>> ans;
  if (len == 1) {
    for (int i = l; i <= m; i++) {
      ans.push_back({i});
    }
    return ans;
  }
  for (int i = l; i <= m; i++) {
    auto s = f(i, len - 1, m);
    for (auto t : s) {
      t.push_back(i);
      ans.push_back(t);
    }
  }
  return ans;
}
void solve(long long N, long long M, long long Q, std::vector<long long> a,
           std::vector<long long> b, std::vector<long long> c,
           std::vector<long long> d) {
  auto all = f(1, N, M);
  lli ret = 0;
  for (auto s : all) {
    reverse(s.begin(), s.end());
    lli re = 0;
    rep(i, Q) {
      if (s[b[i] - 1] - s[a[i] - 1] == c[i])
        re += d[i];
    }
    chmax(ret, re);
  }
  cout << ret << endl;
}

signed main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  long long Q;
  scanf("%lld", &Q);
  std::vector<long long> a(Q);
  std::vector<long long> b(Q);
  std::vector<long long> c(Q);
  std::vector<long long> d(Q);
  for (int i = 0; i < Q; i++) {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
    scanf("%lld", &c[i]);
    scanf("%lld", &d[i]);
  }
  solve(N, M, Q, std::move(a), std::move(b), std::move(c), std::move(d));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


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

typedef unsigned long long ll;
const int MAXL = 60;
ll tot;
struct LinearBasis{
    ll a[MAXL + 1];
    LinearBasis(){
        std::fill(a,a+MAXL+1,0);
    }
    void insert(ll t){
        for(int j=MAXL;j>=0;--j){
            if(!(t&(1ll<<j)))   continue;
            if(a[j])    t^=a[j];
            else{
                for(int k=0;k<j;++k)    if(t&(1ll<<k))  t^=a[k];
                for(int k=j+1;k<=MAXL;++k)  if(a[k]&(1ll<<j))   a[k]^=t;
                a[j]=t;
                return;
            }
        }
    }
    void PRINT(){
        cout<<"=========="<<endl;
        for(int j=MAXL;j>=0;--j)
            if(a[j])
                cout<<1;
            else cout<<0;
        cout<<endl<<"^^^^^^^^^^"<<endl;
    }
};
const int maxn = 100000+10;
ll a[maxn];
int main()
{
    int N;
    cin>>N;
    for(int i=0;i<N;++i)    cin>>a[i];
    for(int i=0;i<N;++i)    tot^=a[i];
    for(int i=0;i<N;++i)
        a[i]&=~(tot);
    LinearBasis LB;
    for(int i=0;i<N;++i)
        LB.insert(a[i]);
    ll ans=0;
    for(int j=0;j<=MAXL;++j)
        ans^=LB.a[j];
    //LB.PRINT();
    cout<<tot+ans*2<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int bubbleSort(int[],int);
int main(){

int i,j,N;

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

int bubbleSort(int A[ ],int N){
  int i,j,tmp;
  int flag;
  int count = 0;
  flag = 1;
  i = 0;
  while(flag){
    flag = 0;
    for(j = N-1; j>= i+1; j--){
      if(A[j] < A[j-1]){
        tmp = A[j];
        A[j] = A[j-1];
        A[j-1] = tmp;
        flag = 1;
        count++;
      }
    }
    i++;
  }
  for(i = 0; i < N; i++){
  if(i){
    printf(" ");
  }
    printf("%d",A[i]);
  }
  printf("\n%d\n",count);
}

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

using namespace std;

int main(){
	
	char a,b;
	
	cin>>a>>b;
	
	if(a=='H' && b=='H'){
	cout<<"H"<<endl;
	}
	if(a=='H' && b=='D'){
	cout<<"D"<<endl;
	}
	if(a=='D' && b=='H'){
	cout<<"D"<<endl;
	}
	if(a=='D' && b=='D'){
	cout<<"H"<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
import sys
from collections import deque, defaultdict
import copy
import bisect
#input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)


N, M = list(map(int, input().split()))
k=[]
s=[]
for i in range(M):
    S = list(map(int, input().split()))
    k.append(S[0])
    s.append(S[1:])
p = list(map(int, input().split()))

def on_off(kumi, s, p):
    for i in range(M):
        atai = 0
        for j in s[i]:
            atai += kumi[j - 1]
        atai = atai % 2
        if atai != p[i]:
            return 0
    return 1

num = 0
kumi = [0 for i in range(N)]
for i in range(2**N):
    kumi = [0 for i in range(N)]
    for j in range(N):
        kumi[j] = (i & (2**j))//(2**j)
    num += on_off(kumi, s, p)

print(num)

Measured memory_bytes: 42220
<?php

fscanf(STDIN, "%d", $n);
$H = array_map('intval', explode(' ', trim(fgets(STDIN))));

$total = 0;
for ($i = 100; $i >= 1; --$i) {

    $r = 0;
    $cnt = 0;
    for ($l = 0; $l < $n; ++$l) {
        while ($r < $n && ($r <= $l || $H[$r] == $i)) {
            ++$r;
        }

        if ($H[$r - 1] == $i) {
            /* echo "i: $i, l: $l, r: $r", PHP_EOL; */
            ++$cnt;
        }

        $l = $r - 1;
    }

    for ($l = 0; $l < $n; ++$l) {
        if ($H[$l] == $i) {
            --$H[$l];
        }
    }

    $total += $cnt;
    /* echo "i: $i, cnt: $cnt, total: $total", PHP_EOL; */
}
echo $total;


Measured memory_bytes: 4728
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

void
solve() {
  ll n;
  cin>>n;

  if (n % 2 == 1) {
    cout<<0<<endl;
  }
  else {
    n /= 2;

    ll ans = 0;
    while (n > 0) {
      ans += n / 5;
      n /= 5;
    }
    cout<<ans<<endl;
  }
}

int 
main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 256
n, m = map(int, input().split())

requests = []
for _ in range(m):
    a, b = map(int, input().split())
    requests.append([a, b])

requests = sorted(requests, key=lambda x: x[1])

cnt = 1
cutting = requests[0][1]-1
for i in range(1, m):
    if not requests[i][0] <= cutting <= requests[i][1]:
        cnt += 1
        cutting = requests[i][1]-1

print(cnt)

Measured memory_bytes: 22104
#include<iostream>
using namespace std;
int n,a[10002],m,b,c,d,e;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	cin>>m;
	for(int i=1;i<=m;i++)
	{
		d=0;
		cin>>b>>c;
		e=a[b];a[b]=c;
		for(int j=1;j<=n;j++)
		{
			d+=a[j];
		}
		cout<<d<<endl;
		a[b]=e;
	}
	return 0;
}//AC

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

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

	if(a <= b) printf("unsafe\n");
	else printf("safe\n");
	return 0;
}


Measured memory_bytes: 3764
N,M=map(int,input().split())
a=[]
b=[0]*N
for i in range(M):
    a.append(int(input()))
if M==0:
    j=-1
else:
    j=0
if N==1:
    b[0]=1
elif M>0 and a[0]==1:
    b[0]=0
    b[1]=1
elif M>0 and a[0]==2:
    b[0]=1
    b[1]=1
else:
    b[0]=1
    b[1]=2
for i in range(N-2):
    if j==M-1 or (j>=0 and (i+2)!=a[j] and (i+1)!=a[j]):
        b[i+2]=b[i+1]+b[i]
    if j>0 and a[j]==a[j-1]+1:
        b[N-1]=0
    if j+1<M and a[j+1]==a[j]+1:
        b[N-1]=0
    elif j>=0 and (i+2)==a[j]:
        b[i+2]=b[i]
    elif j>=0 and j+1<M and (i+1)==a[j]:
        j+=1
        b[i+2]=b[i+1]
    elif j>=0 and (i+1)==a[j]:
        b[i+2]=b[i+1]
print(b[N-1]%1000000007)

Measured memory_bytes: 463928
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin>>N;
    int mt=0,mx=0,my=0;
    bool check = true;
    for(int i=0;i<N;i++)
    {
        int t,x,y;
        cin>>t>>x>>y;
        int tmpt=fabs(mt-t);
        int tmpx=fabs(mx-x);
        int tmpy=fabs(my-y);
        
        int zxy = (tmpx + tmpy)%2==0?2:1;
        int zt = tmpt%2==0?2:1;
        bool parity=(zxy!=zt);
        if(tmpt<tmpx+tmpy||tmpx==0&&tmpy==0)
        {
            cout<<"No"<<endl;
            check = false;
            break;
        }
        else if(parity)
        {
            cout<<"No"<<endl;
            check = false;
            break;        
        }
        mt=t;
        mx=x;
        my=y;
    }
    if(check)
    {
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 3596