akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void) {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int diffx = tx - sx, diffy = ty - sy;
	for (int i = 0; i < diffy; ++i) cout << 'U';
	for (int i = 0; i < diffx; ++i) cout << 'R';
	for (int i = 0; i < diffy; ++i) cout << 'D';
	for (int i = 0; i < diffx + 1; ++i) cout << 'L';
	for (int i = 0; i < diffy + 1; ++i) cout << 'U';
	for (int i = 0; i < diffx + 1; ++i) cout << 'R';
	cout << 'D' << 'R';
	for (int i = 0; i < diffy + 1; ++i) cout << 'D';
	for (int i = 0; i < diffx + 1; ++i) cout << 'L';
	cout << 'U' << endl;
	return 0;
}

Measured memory_bytes: 256
# B - Guidebook

from operator import itemgetter

N = int(input())
SP = []
for i in range(N):
    s, p = input().split()
    SP.append((int(i + 1), str(s), int(p)))

SP = sorted(SP, key=itemgetter(2), reverse=True)
SP = sorted(SP, key=itemgetter(1))
for sp in SP:
    print(sp[0])


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {

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

		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int d=0;
		for(int i=a;i<=b;i++) {
			if(c%i==0) {
				d+=1;
			}

		}
		System.out.println(d);

	}

}



Measured memory_bytes: 26304
#include"bits/stdc++.h"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill( (T*)array, (T*)(array+N), val ); }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7
int main() {
    int n;
    cin >> n;
    vector<pair<int,int>> d(n);
    REP(i, n) {
        cin >> d[i].first >> d[i].second;
    }
    bool f = false;
    REP(i, n-2){
        if (d[i].first == d[i].second && d[i + 1].first == d[i + 1].second && d[i + 2].first == d[i + 2].second)f = true;
    }
    if (f)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;
import java.util.Stack;

public class Main {

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        String[] A = scan.nextLine().split(" ");
	
        Stack<Integer> num = new Stack<Integer>();
        int a = 0;
        int b = 0;
        for (int i = 0; i < A.length; i++) {
            if (A[i].equals("+")) {
                a = num.pop();
                b = num.pop();
                num.add(b + a);
                continue;
            }
            if (A[i].equals("-")) {
                a = num.pop();
                b = num.pop();
                num.add(b - a);
                continue;
            }
            if (A[i].equals("*")) {
                a = num.pop();
                b = num.pop();
                num.add(b * a);
                continue;
            }
            if (A[i].equals("/")) {
                a = num.pop();
                b = num.pop();
                num.add(b / a);
                continue;
            }
            num.push(Integer.parseInt(A[i]));
        }
        System.out.println(num.pop());
    }
}



Measured memory_bytes: 26220
#define _GLIBCXX_DEBUG
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>


using namespace std;
int main(){
  set<char> p;
  string s;
  cin>>s;
  for(int x=0;x<s.size();x++){
    char r;
    r=s.at(x);
    p.insert(r);
  }
   int z=0;
    for(char y='a';y<='z';y++,z++){
      if(p.count(y)==false){
        cout<<y<<endl;
        break;
      }
      if(y=='z')
        cout<<"None"<<endl;
    }
  }
  
 


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,h,w,ans=0;
    scanf("%lld%lld%lld",&n,&h,&w);
    for(int i=0;i<n;i++)
    {
        long long a,b;
        scanf("%lld%lld",&a,&b);
        if(a/h>=1&&b/w>=1)
        {
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << A << endl; exit(0);}

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

  ll S = accumulate(A.begin(), A.end(), 0LL);
  if (S % (N * (N + 1) / 2) != 0)
    FINALANS("NO");
  ll K = S / (N * (N + 1) / 2);

  ll M = 0;
  for (ll i = 0; i < N; i++)
  {
    ll D = A.at((i + 1) % N) - A.at(i) - K;
    if (D > 0)
      FINALANS("NO");
    if (-D % N != 0)
      FINALANS("NO");
    M += -D / N;
  }
  cout << ((M == K) ? "YES" : "NO") << endl;
}

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

int main() {
    int n, m; cin >> n >> m;
    vector<int> x(m), y(m - 1);;
    for (int i = 0; i < m; i++) {
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    
    for (int i = 0; i < m - 1; i++) {
        y[i] = x[i + 1] - x[i];
    }
    sort(y.begin(), y.end());

    int ans = 0;
    for (int i = 0; i < m - n; i++) {
        ans += y[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
//
//  main.cpp
//  codeforces
//
//  Created by cfhaiteeh on 21/5/2018.
//  Copyright © 2018 cfhaiteeh. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#define  LL long long

using namespace  std;
const int maxn=123456;

LL n,H;
void init(){
    
    
}
LL ans;
//r 2e9
LL br(LL l,LL r,LL P,LL len){
    LL MIN=0;
    while(l<=r){
        LL mid=(l+r)/2;
        LL t1=(1+mid-1)*(mid-1)+mid-P;
        t1=n-t1;
        if(t1<0){
            r=mid-1;
        }
        else{
            LL x=t1/mid;
            if(t1%mid!=0)x++;
            LL need=(mid-1)*2+1-len;
            need+=x;
            
            if(MIN==0)MIN=need;
            else MIN=min(MIN,need);
            l=mid+1;
        }
    }
    return MIN;
}
void play(){
    LL p=2e9;
    LL l=1,r=min(H,p);
    
    //ans=LONG_MAX;
    
    while(l<=r){
        LL mid=(l+r)/2;
        //top
        LL le=n-(1+mid)*mid/2;
        if(le<0){
            r=mid-1;
            
        }
        else{
            LL x=le/mid;
            if(le%mid!=0)x++;
            // cout<<x <<" "<<mid<<endl;
            ans=min(ans,x+mid);
            //  if(mid==1)cout<<"de"<<" "<<le<<endl;
            LL x2=br(mid+1, 2e9, (1+mid)*mid/2-mid,mid-1 );
            if(x2!=0){
                ans=min(ans,x2);
                // cout<<"x2"<<" "<<x2<<endl;
            }
            l=mid+1;
            
        }
    }
}
void pri(){
    printf("%lld\n",ans);
    
}
int main() {
    // insert code here...
    
    //   cout<<p*p/2<<endl;
    int a,b;
    while(scanf("%d%d",&a,&b)!=EOF){
        int c=a+b;
        int d=a-b;
        int e=a*b;
        c=max(c,d);
        c=max(c,e);
        printf("%d\n",c);
    }
    return 0;
}


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

int main() {
  int N, M; cin >> N >> M;
  if (M == 1) cout << 0 << endl;
  else if (N >= M) cout << 0 << endl;
  else {
    int X[M]; for (int i = 0; i < M; ++i) cin >> X[i];
    sort(X, X + M);
    int dif[M - 1];
    for (int i = 0; i < M - 1; ++i) dif[i] = X[i + 1] - X[i];
    sort(dif, dif + M - 1, greater<int>());
    int mov_count = X[M - 1] - X[0];
    for (int i = 0; i < N - 1; ++i) {
      mov_count = mov_count - dif[i];
    }
    cout << mov_count << endl;
  }
}

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

using namespace std;

int main(){
  int n;
  cin>>n;
  vector<vector<int>> grid(n, vector<int>(3));
  for(int i=0; i<n; i++) cin>>grid[i][0]>>grid[i][1]>>grid[i][2];
  for(int i=1; i<n; i++){
    grid[i][0] += max(grid[i-1][1], grid[i-1][2]);
    grid[i][1] += max(grid[i-1][0], grid[i-1][2]);
    grid[i][2] += max(grid[i-1][0], grid[i-1][1]);
  }
  int maxm = -1;
  for(int i=0; i<3; i++) maxm = max(grid[n-1][i], maxm);
  cout<<maxm<<endl;
  return 0;
}


Measured memory_bytes: 5760
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
	int n;
  cin>>n;
  if(n==1){
    cout<<1<<endl;
    return 0;
  }
  map<int, ll> mp;
  for(int i=2; i<=n; i++){
    int i0=i;
    for(int j=2; j*j<=i0; j++){
      if(i0%j==0){
        ll e=0;
        while(i0%j==0){
          i0/=j;
          e++;
        }
        mp[j]+=e;
      }
    }
    if(i0>1) mp[i0]+=1;
  }
  ll ans=1;
  for(auto p:mp){
    ans*=(p.second+1);
    ans%=MOD;
  }
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.List

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

solve :: Int -> Int 
solve n = foldl' ff 1 $ takeWhile (<= n) primes
    where
        ff acc x = modf $ acc * count x
        modf = (`mod` 1000000007)
        count p = check 1 [2..n]
            where
                check acc (x : xs) 
                    | x `mod` p == 0 = check (acc + 1) (x `div` p : xs)
                    | otherwise = check acc xs
                check acc _ = acc 

primes :: [Int]
primes = calc [2..]
    where
        calc (x : xs) = x : calc (filter (\n -> n `mod` x /= 0) xs)

Measured memory_bytes: 1020
#include <stdio.h>
#include <queue>
using namespace std;
struct rmq{
    int n;
    int l;
    int r;
};
struct two{
    int n;
    int t;
};
rmq b[1000000];
two a[1000000];
void init(int l,int r,int now){
    b[now].l=l;
    b[now].r=r;
    b[now].n=0;
    if(r==l){
        a[r].t=now;
        return;
    }
    int mid=(l+r)/2;
    init(l,mid,now*2);
    init(mid+1,r,now*2+1);
}
void maintain(int now){
    if(b[now].r==b[now].l)b[now].n=a[b[now].l].n;
    else b[now].n=b[now*2].n+b[now*2+1].n;
    if(now>1)maintain(now/2);
}
int dp(int now,int l,int r){
    if(b[now].l>=l&&b[now].r<=r)return b[now].n;
    else if(b[now].l>r||b[now].r<l){
        return -1;
    }
    int a,b;
    a=dp(now*2,l,r);
    b=dp(now*2+1,l,r);
    if(a<0&&b<0)return -1;
    if(a<0)return b;
    if(b<0)return a;
    return a+b;
}
int main(){
    int n,q,temp,x,y;
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++)a[i].n=0;
    init(1,n,1);
    for(int i=0;i<q;i++){
        scanf("%d%d%d",&temp,&x,&y);
        if(temp==0){
            a[x].n+=y;
            maintain(a[x].t);
        }
        else{
            printf("%d\n",dp(1,x,y));
        }
    }
}

Measured memory_bytes: 6560
main = do
  [n,a,b] <- map read.words <$> getLine :: IO [Int]
  case n of
    1 -> if a == b then print 1 else print 0
    _ -> if a > b
          then
            print 0
          else
            print $ ((b*(n-1)+a)-(b+(n-1)*a))+1


Measured memory_bytes: 508
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int N;
string S;
string S_left;
string S_right;
map < pair < string, string > , ll > cnt_left;
map < pair < string, string > , ll > cnt_right;

int main () {

    cin >> N >> S;
    S_left  = S.substr(0, N);
    S_right = S.substr(N, N * 2);

    for (int i = 0; i < (1 << N); i++) {
        string R,B;
        REP(j,N) {
            if ((i >> j) & 1) R.push_back(S_left[j]);
            else B.push_back(S_left[j]);
        }
        reverse(B.begin(), B.end());
        cnt_left[make_pair(R, B)] ++;
    }

    for (int i = 0; i < (1 << N); i++) {
        string R,B;
        REP(j,N) {
            if ((i >> j) & 1) R.push_back(S_right[j]);
            else B.push_back(S_right[j]);
        }
        reverse(B.begin(), B.end());
        cnt_right[make_pair(R, B)] ++;
    }

    ll ans = 0;
    for (auto itr : cnt_left) {
        pair < string, string > pt = itr.first;
        swap(pt.first, pt.second);
        ans += cnt_right[pt] * itr.second;
    }

    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 103424
// AOJ Volume 0 Problem 0082

#include <stdio.h>
#include <string.h>

int main(void)
{
	int guest[8];
	int ride[] = {4, 1, 4, 1, 2, 1, 2, 1,   4, 1, 4, 1, 2, 1, 2, 1,   4 , 1};
	int min_ride[8];
	int i, j;
	int remain, min_remain;
	
	while (scanf("%d%d%d%d%d%d%d%d", 
					&guest[0], &guest[1], &guest[2], &guest[3], 
					&guest[4], &guest[5], &guest[6], &guest[7]) != EOF){

		min_remain = 999999999;
		min_ride[0] = min_ride[1] = min_ride[2] = min_ride[3] = 
		min_ride[4] = min_ride[5] = min_ride[6] = min_ride[7] = 9;
		for (i = 0; i < 8; i++){
			remain = 0;
			for (j = 0; j < 8; j++){
//			printf("(%d %d)", guest[j], ride[i + j]);
				if (ride[i + j] < guest[j]){
//					printf("[%d]", (guest[j] - ride[i + j]));
					remain += (guest[j] - ride[i + j]);
				}
			}
//			printf("\n<%d %d>\n", i, remain);
			if (min_remain > remain){
				min_remain = remain;
				memcpy(min_ride, &ride[i], sizeof(int) * 8);
			}
			else if (min_remain == remain){
				for (j = 0; j < 8; j++){
					if (min_ride[j] > ride[j + i]){
						memcpy(min_ride, &ride[i], sizeof(int) * 8);
						break;
					}
					else if (min_ride[j] < ride[j + i]){
						break;
					}
				}
			}
		}
		printf("%d %d %d %d %d %d %d %d\n",
				min_ride[0], min_ride[1], min_ride[2], min_ride[3],
				min_ride[4], min_ride[5], min_ride[6], min_ride[7]);
	}
	return (0);
}

Measured memory_bytes: 0
/**
  @date Time-stamp: <2019-05-25 21:14:54 tagashira>
  @file b.cpp
  @title B - Algae
  @brief https://atcoder.jp/contests/abc127/tasks/abc127_b
**/

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream> // std::ostringstream
#include <string>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
  uint r, D, x2000;
  cin >> r >> D >> x2000;

  vector<int> x(11, r * x2000 - D);

  for (int i = 0; i < 10; i++) {
    cout << x[i] << endl;
    x[i + 1] = r * x[i] - D;
  }

  return 0;
}


Measured memory_bytes: 256
n=int(input())
alist = list(int(i) for i in input().split())

gokei=sum(alist)
now=0

for i in range(n):
    now+=alist[i]
    if now>=gokei//2:
        break
    mae=now

#print(gokei)
#print(mae, now)
ans=min(gokei-mae*2,now*2-gokei)
print(ans)

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

using ll = long long int;
const int mod = 1e9+7;
const int inf = 1e9+5;


int main(){
	int n, W;
	cin>>n>>W;
	vector<ll>dp(W+1);
	//dp[w] = total value with exactly w weight
	for(int item = 0; item < n; item++){
		int weight, value;
		cin>>weight>>value;
		for(int already = W-weight; already >= 0; already--){ //this is for one item will be take exactly one time or not
		//for(int already = 0; already <= W-weight; already++){ this is for one item can be take as infinite number of time
			//if(already
			dp[already+weight] = max(dp[already+weight], dp[already]+value);
		}
	}
	ll ans = 0LL;
	for(int w = 0; w <=W ; w++){
		ans = max(ans, dp[w]);
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

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

  int n;
  cin >> n;

  string res;
  if (n == 0) res = '0';
  else {
    while (n != 0) {
      int r = n%(-2);
      n /= -2;
      if (r < 0){
        r += 2;
        n += 1;
      }
      res = (char)('0'+r) + res;
    }
  }

  cout << res << endl;

  return 0;
}



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

int main() {
  
  char x,y;
  cin >> x >> y;
  
  if (x == y) cout << '=' << endl;
  if (x < y) cout << '<' << endl;
  if (x > y) cout << '>' << endl;
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int> 
#define rep(i,a,n) for(i=(a);i<(n);i++)
#define INF (int)1000000007

//setprecision()<<

using namespace std;

void fin(int i,int n,vin &a){
    rep(i,0,n){
        cin>>a.at(i);
    } 
} 

signed main() {
    int i,j;
    int N;
    cin>>N;
    vector<ldouble> x(N);
    vector<ldouble> y(N);
    rep(i,0,N){
        cin>>x.at(i)>>y.at(i);
    }
    ldouble sum=0;
    rep(i,0,N-1){
        rep(j,i+1,N){
            sum+=(N-1)*2*sqrt((x.at(i)-x.at(j))*(x.at(i)-x.at(j))+(y.at(i)-y.at(j))*(y.at(i)-y.at(j)));
        }
    }
    ldouble wari=N*(N-1);
    if(wari==0){
        wari=1;
    }
    // rep(i,1,N+1){
    //     wari*=i;
    // }
    //cout<<wari<<endl;
    cout<<setprecision(10)<<sum/wari<<endl;
return 0;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N  = parseInt(arg[0].split(" ")[0]);
    let H  = parseInt(arg[0].split(" ")[1]);
    let ab = arg.slice(1, N + 1).map(n=>n.split(" ").map(l=>parseInt(l)));
    
    ab.sort((a,b)=>b[0] - a[0]);
    
    const aMax = ab[0][0];
    
    ab = ab.sort((a,b)=>b[1] - a[1]).filter(n=>n[1] > aMax);

    let damage = 0;
    let answer = 0;
    
    for(let i in ab) {
        H -= ab[i][1];
        answer++;
        
        if(H <= 0) {
            console.log(answer);
            return;
        }
    }
    
    const directAttack = Math.ceil(H / aMax);
    
    console.log(answer + directAttack);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

int func(int n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}

int main(){
    int n,a,b;
    cin>>n>>a>>b;

    int ans=0;
    for(int i=1;i<=n;++i){
        int temp=func(i);
        if(a<=temp&&temp<=b) ans+=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Scanner;

import javax.xml.crypto.Data;
public class Main{
	static int INF = 2 << 28;
	static int[] vxL = {0,0,1,-1};
	static int[] vxR = {0,0,-1,1};
	static int[] vyL = {1,-1,0,0};
	static int[] vyR = {1,-1,0,0};
	static int w;
	static int h;
	static int Lx;
	static int Ly;
	static int Rx;
	static int Ry;
	static char[][] mapL;
	static char[][] mapR;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			w = sc.nextInt();
			h = sc.nextInt();
			if(w == 0 && h == 0) break;
			mapL = new char[h][];
			mapR = new char[h][];
			for(int i = 0; i < h; i++) {
				mapL[i] = sc.next().toCharArray();
				mapR[i] = sc.next().toCharArray();
			}
			Lx = 0;
			Ly = 0;
			Rx = 0;
			Ry = 0;
			
			for(int i = 0; i < h; i++) {
				for(int j = 0; j < w; j++) {
					if(mapL[i][j] == 'L') {
						Ly = i;
						Lx = j;
						mapL[i][j] = '.';
					}
					if(mapR[i][j] == 'R') {
						Ry = i;
						Rx = j;
						mapR[i][j] = '.';
					}
				}
			}
			boolean ans = BFS();
			if(ans) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
	}	
	static boolean BFS() {
		boolean[][][][] use = new boolean[w][h][w][h];
		ArrayDeque<Data> queue = new ArrayDeque<Data>();
		queue.add(new Data(Lx,Ly,Rx,Ry));
		while(!queue.isEmpty()) {
			Data tmp = queue.poll();
			if(use[tmp.Lx][tmp.Ly][tmp.Rx][tmp.Ry]) continue;
			use[tmp.Lx][tmp.Ly][tmp.Rx][tmp.Ry] = true;
			for(int i = 0; i < 4; i++) {
				
				int Ltx = tmp.Lx + vxL[i];
				int Lty = tmp.Ly + vyL[i];
				int Rtx = tmp.Rx + vxR[i];
				int Rty = tmp.Ry + vyR[i];
				
				int  L = Rcheck(Ltx,Lty,mapL);
				int  R = Rcheck(Rtx,Rty,mapR);
				
				if(L == 2 && R == 2) return true;
				if(L == 2 && R != 2) continue;
				if(L != 2 && R == 2) continue;
				if(L == 0 && R == 0) continue;
				if(L == 0) {
					Ltx = tmp.Lx;
					Lty = tmp.Ly;
				}
				if(R == 0) {
					Rtx = tmp.Rx;
					Rty = tmp.Ry;
				}
				queue.addLast(new Data(Ltx,Lty,Rtx,Rty));
			}
		}
		return false;
		
	}
	static int Rcheck(int x,int y,char[][] map) {
		if(x < 0 || y < 0 || x >= w || y >= h) return 0;
		if(map[y][x] == '#') return 0;
		if(map[y][x] == '.') return 1;
		if(map[y][x] == '%') return 2;
		return -1;
	}
	
	static class Data {
		int Lx;
		int Ly;
		int Rx;
		int Ry;
		Data(int a, int b, int c, int d) {
			Lx = a;
			Ly = b;
			Rx = c;
			Ry = d;
		}
		public boolean equals(Object o) {
			Data c = (Data)o;
			if(this.Lx != c.Lx) return false;
			if(this.Ly != c.Ly) return false;
			if(this.Rx != c.Rx) return false;
			if(this.Ry != c.Ry) return false;
			return true;
		}
	}
}

Measured memory_bytes: 324148
// AOJ 0600
#include<iostream>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

typedef long long int number;

const number NMAX = 100020;
number N;
number A[NMAX], acc[NMAX];

number length(number l, number r) {
  if (l > r) {
    return acc[N] - length(r, l);
  } else {
    return acc[r - 1] - acc[l - 1];
  }
}

int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    acc[i] = acc[i - 1] + A[i];
  }

  number a = 1, b = 2, c = 3;
  number ans = -1, counter = 0;

  while (counter < N + 4) {
//    cout << "(" << a << " " << b << " " << c << ")" << endl;
    number asize = length(a, b), bsize = length(b, c),
           csize = length(c, a);
    number minimum = min(asize, min(bsize, csize));
    ans = max(ans, minimum);

    if (asize == minimum) {
      b = b % N + 1;
    } else if (bsize == minimum) {
      c = c % N + 1;
    } else if (csize == minimum) {
      a = a % N + 1;
      counter++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 2720
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    string s;cin>>s;
    int n = s.size();
    string t;
    rep(i,n){
        if(s[i] == 'A')t.push_back('T');
        if(s[i] == 'T')t.push_back('A');
        if(s[i] == 'G')t.push_back('C');
        if(s[i] == 'C')t.push_back('G');
    }
    cout<<t;
}



Measured memory_bytes: 256
n = int(input())
a, b = map(int,input().split())
li = list(map(int,input().split()))
x = 0
y = 0
z = 0

for i in li:
    if i <= a:
        x += 1
    elif i <= b:
        y += 1
    else:
        z += 1

print(min(x,y,z))

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
  int ans = 0;
  int a;
  
  scanf("%d", &a);
  
  if(a / 1000 == 2){
    ans++;
  }
  a = a % 1000;
  
  if(a / 100 == 2){
    ans++;
  }
    a = a % 100;
  
  if(a / 10 == 2){
    ans++;
  }
    a = a % 10;
  
  if (a == 2){
    ans++;
  }
  
  printf("%d", ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <cstddef>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>

int main() {
  std::string s;
  std::cin >> s;

  if (s == "AAA" || s == "BBB")
    std::cout << "No\n";
  else {
    std::cout << "Yes\n";
  }
  return 0;
  }


Measured memory_bytes: 256
import sys
import math
from collections import deque
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

input = sys.stdin.readline


K = I()
def gcd(a,b):
    while b!=0:
        c = a%b
        a=b
        b=c
    return a
ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            ans += gcd(gcd(i+1,j+1),k+1)

print(ans)


Measured memory_bytes: 73916
import sys
from collections import defaultdict
from copy import deepcopy
import itertools
input = sys.stdin.readline
# 文字列の場合は普通のinput()を使うか下を使う
# input = sys.stdin.readline().rstrip()

M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if D2 < D1:
    print(1)
else:
    print(0)

Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int e;
    while (cin >> e && e != 0) {
        int ans = 1000000;
        for (int z = 0; z * z * z <= e; ++z) {
            for (int y = 0; y * y <= e; ++y) {
                int x = e - z * z * z - y * y;
                if (x >= 0 && x <= e) ans = min(ans, x + y + z);
            }
        }
        cout << ans << endl;
    }
}



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

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define RREPS(i,n) RFOR(i,1,n+1)
#define ALL(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using ll = long long;
//#define int ll

bool Fcomp(const pair<int,int>& firstElof, const pair<int,int>& secondElof)
{return firstElof.F < secondElof.F;}
bool Scomp(const pair<int,int>& firstElof, const pair<int,int>& secondElof)
{return firstElof.S < secondElof.S;}

//**********
//10:57-11:05, 15:05-

signed main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<pair<int, int>> red(n,{0,0});
    vector<pair<int, int>> blue(n,{0,0});
    REP(i,n){cin >> red[i].F >> red[i].S;}
    REP(i,n){cin >> blue[i].F >> blue[i].S;}
    
    int ans = 0;
    int flag[100] = {};
    
    sort(ALL(red),Scomp);
    sort(ALL(blue));
  
    REP(i,n){
        int max_y = -INF;
        int sel_red = -1;
        REP(j,n){
            if(red[j].F<blue[i].F && red[j].S<blue[i].S && flag[j] != 1){
                if(chmax(max_y, red[j].S)) sel_red = j;
            }
        }
        //cout << "blue[" << i << "] (" << blue[i].F << "," << blue[i].S << ") -> " << sel_red << endl;
        if(sel_red != -1) flag[sel_red] = 1;
    }

    REP(i,n){if(flag[i]) ans++;}

    printf("%d\n",ans);
    
    return 0;
    
}


Measured memory_bytes: 256
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        Queue<Integer> q = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            q.add(Integer.parseInt(sc.next()));
        }
        int ans = 0;
        for (int i = 0; i < k; i++) {
            ans += q.poll();
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 38116
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 2000000
#define MOD 1000000007
#define INF 10000000000000000

ll solve(vector<ll> &tree,int a,int b,int i,int left,int right){
  if(b<=left||right<=a){
    return 0;
  }
  if(a<=left&&right<=b){
    return tree.at(i);
  }
  return max<ll>(solve(tree,a,b,2*i+1,left,(left+right)/2),solve(tree,a,b,2*i+2,(left+right)/2,right));
}

int main(){
  int N;
  cin>>N;
  vector<int> h(N);
  vector<ll> a(N);
  for(int i=0;i<N;i++){
    cin>>h.at(i);
    h.at(i)--;
  }
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }

  int n=1;
  while(n<N){
    n<<=1;
  }
  vector<ll> tree(2*n-1,0);
  for(int i=0;i<N;i++){
    ll v=solve(tree,0,h.at(i),0,0,n);
    int j=n-1+h.at(i);
    tree.at(j)=v+a.at(i);
    while(j>0){
      j=(j-1)/2;
      tree.at(j)=max<ll>(tree.at(2*j+1),tree.at(2*j+2));
    }
  }

  ll ans=0;
  for(int i=0;i<N;i++){
    ans=max<ll>(ans,tree.at(n-1+i));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6656
n = int(input())
f = []
for _ in range(n):
    f.append(list(map(int, input().split())))
p = []
for _ in range(n):
    p.append(list(map(int, input().split())))
ans = - (10 ** 9)
for i in range(1, 1<<10):
    store = {lll : 0 for lll in range(10)}
    k = "0" * (10 - len(bin(i)) + 2) + bin(i)[2:]
    calc = 0
    for nn in range(n):
        count = 0
        for j, kk in enumerate(k):
            if kk == "1":
                if f[nn][j] == 1:
                    count += 1
        calc += p[nn][count]
    ans = max(ans, calc)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define PII pair<int,int>
#define s second
#define f first
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
ll MOD = 998244353;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x)%MOD;
        }
        p = p >> 1;
        x = (x*x)%MOD;
    }
    return res;
}
int main() {
    IO;
    int n;
    cin >> n;
    int arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    int dp[n];
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        dp[i] = INT_MAX;
        if(i-2 >= 0){
          dp[i] = abs(arr[i]-arr[i-2]) + dp[i-2];
        }
        dp[i] = min(dp[i], abs(arr[i]-arr[i-1]) + dp[i-1]);
    }
    cout << dp[n-1];

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main()
{

	int n;
	int a[101];
	int i;
	
	cin>>n;	
	for( i=0; i<n; i++ ) {
		cin>>a[i];
	}
	for( i=n-1; 0<=i; i-- ) {
		if( 0 != i ) {
			cout <<a[i]<<" ";
		} else {
			cout <<a[i]<<endl; 
		}
	}
	
    return 0;
}

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

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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> A(N);
    for (auto &i : A) cin >> i;

    sort(A.begin(), A.end(), greater<int>());

    ll ans = 0;
    int idx = 0;
    rep(i, N-1) {
        if (i == 0) {
            ans += A[idx];
            idx++;
            continue;
        }
        ans += A[idx];
        if (i % 2 == 0) idx++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    
    vec<int> A(N);
    rep(i, N) cin >> A[i];

    ll ans = 0;
    ll before = A[0];
    rep(i,N){
        if(A[i]<before) ans+=(before-A[i]),A[i]=before;
        before = A[i];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3980
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> a(N+1, 0);
	for (int i = 1; i <= N; i++)
	{
		int tmp;
		cin >> tmp;
		a[tmp]++;
	}
	sort(a.begin(), a.end(),greater<int>());
	
	int k_sum = 0;
	for (int i = 0; i < K; i++)
	{
		k_sum += a[i];
	}
	int ans = N - k_sum;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
class BIT:
    """
    Binary Index Tree
    ###1-origin####

    add :L[i]+=x
    sum: sum(L[:l])
    range_sum : sum(L[l:r])

    #material http://hos.ac/slides/20140319_bit.pdf
    """

    def __init__(self, N, init_val=0):
        self.init_val = init_val
        self.size = N
        self.L = [init_val]*(N+1)

    def sum(self, r):
        """
        sum[,r)
        calc sum from L[0] to L[r-1]
        """
        ret = self.init_val
        while r > 0:
            ret += self.L[r]
            r -= r & (-r)

        return ret

    def range_sum(self, l, r):
        
        """
        idx周りが怪しい?
        sum[l,r)
        calc sum from L[l] to L[r-1]
        """
        return self.sum(r-1)-self.sum(l-1)

    def add(self, i, x):
        """
        L[i] += x
        """
        while i <= self.size:
            self.L[i] += x
            i += i & (-i)

    def bisect(self,k:float)->int:
        """ binary search on BIT
        get index x s.t self.sum(,)>=k

        RETURN:
            res:index of x
        """
        k+=1 #convert k into 1-index

        res=0
        N=1
        while N<self.size:
            N*=2

        i=N//2
        while i>0:
            if(res+i<self.size and self.L[res+i]<k): #move to rignt on tree
                k-=self.L[res+i]
                res+=i
            #else move to left
            i//=2
        return res+1
N,K = map(int,input().split())
MOD=998244353
ranges=[list(map(lambda x:int(x),input().split())) for _ in range(K)]


B=BIT(N+1)
dist=[0]*(N+1)

B.add(1,1)
dist[1]=1

for i in range(2,N+1):
    for l,r in ranges:
        left=min(max(i-l,0),N)
        right=min(max(i-r,0),N)
        dist[i]+=B.range_sum(right,left+1)
    dist[i]%=MOD
    B.add(i,dist[i])


print(dist[-1]%MOD)


Measured memory_bytes: 72380
#include <cstdint>
#include <cstdio>
#include <algorithm>

int main() {
  intmax_t a, b, n;
  scanf("%jd %jd %jd", &a, &b, &n);

  auto f = [&](intmax_t x) {
    return (a*x) / b - a * (x/b);
  };

  intmax_t res = f(n);
  if (n >= b) res = std::max(res, f(b-1));

  printf("%jd\n", res);
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int v[n];
  rep(i,0,n) cin>>v[i];
  map<int,int> a;
  map<int,int> b;
  rep(i,0,n){
    if(i%2==0){
      a[v[i]]++;
    }
    else{
      b[v[i]]++;
    }
  }
  P af=P(-1,0);
  P as=P(-1,0);
  for(auto p:a){
    if(p.second>af.second){
      as=af;
      af=p;
    }
    else if(p.second>as.second){
      as=p;
    }
  }
  P bf=P(-1,0);
  P bs=P(-1,0);
  for(auto p:b){
    if(p.second>bf.second){
      bs=bf;
      bf=p;
    }
    else if(p.second>bs.second){
      bs=p;
    }
  }
  if(af.first!=bf.first){
    cout<<n-(af.second+bf.second)<<endl;
  }
  else{
    cout<<n-max((af.second+bs.second),(as.second+bf.second))<<endl;
  }
}

Measured memory_bytes: 5376
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >> N >> X;
  ll l[N];
  ll d = 0;
  rep(i, N) cin >> l[i];
  rep(i, N){
    d = l[i]+d;
    if (d>X){
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << N+1 << endl;
  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define MOD 100000007
long long N;
long long M;
int k;
using Graph = vector<vector<long long>>;
vector<int> color(100000,0);
vector<bool> used(100000,false);
//vector<bool> ans(100000,false);

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};
int ans = 0;

int solve(int a,int b)
{
    int ans = 0;
    for(int i=0;i<a;i++)
    {
        for(int j=i+1;j<a;j++)
        {
            for(int k=j+1;k<a;k++)
            {
                if(i+j+k+3 == b)
                {
                    ans++;
                }
            }
        }
    }
    return ans;
}
int main()
{
    int a,b,c,x,y;
    cin >> a>>b>>c>>x>>y;
    
    // x==a+c/2 y = b+c/2
    int i,j,k;
    
    long long ans = LONG_LONG_MAX;
    for(int r=0;r<200001;r++)
    {
        int p=x-r/2;
        int q=y-r/2;
        if(p<0 && q<0)
        {
            break;
        }
        
        long long temp = a*max(p,0) + b * max(q,0) + c*r;
        ans = min(temp,ans);
        if(ans == temp)
        {
            i = p;
            j = q;
            k=r;
        }
        
    }
    
    
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int main(){
    string s;cin>>s;
    string t[4] = {"maerd","remaerd","esare","resare"};
    reverse(ALL(s));
    while(!s.empty()){
        bool f = false;
        rep(i,4){
            if(s.substr(0,t[i].size())==t[i]){
                s.erase(0,t[i].size());
                f = true;
            }
        }
        if(!f){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}



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

using namespace std;
#define Pi acos(-1)
#define _terminated return 0
#define endl "\n"
#define yes cout << "Yes" << endl 
#define no cout << "No" << endl 
#define booster ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<long> > v2l;

const int mod = 1e+5;
const int mx = 2e+5;
const ll inf = 1e18;

void upper_bubble_sort(){
     int i,j,temp,number_of_input;
     int array[100];
     cin >> number_of_input;
     for(i=0; i<number_of_input; i++)
         cin >> array[i];
         for(i=0; i<number_of_input; i++){
             for(j=0; j<(number_of_input-i-1); j++){
               if(array[j] > array[j+1]){
                 temp = array[j];
                 array[j] = array[j+1];
                 array[j+1] = temp;
                }
              }
         }
    for(i=0; i<number_of_input; i++)
      cout << array[i] << endl;
}
void bst(void){
          int low,high,mid,keynum,num,array[100];
          cin >> keynum;
          low = 1;
	         high = num;
         	do{
		        mid = (low + high) / 2;
		         if(keynum < array[mid])
			         high = mid - 1;
		         else if (keynum > array[mid])
			         low = mid + 1;
	         } 
          while (keynum != array[mid] && low <= high);
	        if(keynum == array[mid]){
            cout << "number located at " << mid +1 << endl;}
         else
           no;
}

void solvio(void){
     string s,t;
     cin >> s >> t;
     cout << t << s << endl;
}

int main(){
    booster;
    solvio();
    _terminated;
} 

Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

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

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int x,n;cin>>x>>n;
  map<int,int> m;
  rep(i,n){
    int a;cin>>a;
    m[a]++;
  }
  int mini = INF;
  int ans = 0;
  rep(i,110){
    if(m[i] == 0)if(chmin(mini,abs(x-i))) ans = i;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll k;
    string s;
    cin  >> k >> s;

    if(s.size() <= k)cout << s;
    else {
        while(s.size() > k)s.pop_back();
        cout << s << "..." << endl;
    }
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
ll powt[1000100];
ll powtwo[1000100];
ll fact[1000100];
ll inv[1000100];
ll invfact[1000100];
ll dp[1000100];
ll ans;
int n, m, l;

ll com(int u, int v)
{
	ll ret=1;
	ret=(ret*fact[u])%mod;
	ret=(ret*invfact[v])%mod;
	ret=(ret*invfact[u-v])%mod;
	return ret;
}

int main(void)
{
	cin>>n>>m>>l;
	n++;
	inv[1]=1;
	invfact[0]=1;
	fact[0]=1;
	invfact[1]=1;
	fact[1]=1;
	int i, j, k;
	for(i=2 ; i<=1000000 ; i++)
	{
		inv[i]=((mod-mod/i)*inv[mod%i])%mod;
		fact[i]=(i*fact[i-1])%mod;
		invfact[i]=(invfact[i-1]*inv[i])%mod;
	}
	powt[0]=1;
	powt[1]=3;
	powtwo[0]=1;
	powtwo[1]=2;
	for(i=2 ; i<=1000000 ; i++)
	{
		powt[i]=(3*powt[i-1])%mod;
		powtwo[i]=(2*powtwo[i-1])%mod;
	}
	if(l<m)
	{
		ll temp=l;
		l=m;
		m=temp;
	}
	ll sp=0;
	for(k=0 ; k<=m+l ; k++)
	{
		ll x=powtwo[k];
		sp=(2*sp)%mod;
		if(k>m)
		{
			sp=(sp+com(k-1,k-m-1))%mod;
		}
		if(k>l)
		{
			sp=(sp+com(k-1,k-l-1))%mod;
		}
		x=(x-sp)%mod;
		ll add=1;
		add=(add*x)%mod;
		add=(add*powt[m+l-k])%mod;
		add=(add*com(n+k-2,k))%mod;
		ans=(ans+add)%mod;
	}
	cout<<(ans+mod)%mod;
}

Measured memory_bytes: 39296