akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
	// your code goes here
	int i,n,m,l,r;
	cin >> n >> m;
	int leftPtr = 1, rightPtr = n;

	for(i=0;i<m;i++){
		cin >> l >> r;
		leftPtr = max(leftPtr, l);
		rightPtr = min(rightPtr, r);
	}

	int ans = rightPtr - leftPtr + 1;
	if(ans<0)
		ans = 0;
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
d_ca=max(a,c)-min(a,c)
d_ab=max(a,b)-min(a,b)
d_bc=max(b,c)-min(b,c)
if d_ca<=d:
    print('Yes')
elif d_bc<=d and d_ab<=d:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
#define debug(V) rep(i, V.size()) cout << V[i] << " ";
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*988244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v;
string S, T;
vl A, B;
void solve() {
    t = 1;
    while(k-- && t) {
        B = vl(n + 1, 0);
        t = 0;
        rep(i, n) {
            B[max(0LL, i - A[i])]++;
            B[min(n, i + A[i] + 1)]--;
        }

        // debug(B);

        rep(i, n) {
            if(i > 0)
                B[i] += B[i - 1];
        }

        rep(i, n) {
            if(A[i] != B[i]) {
                A[i] = B[i];
                t = 1;
            }
        }
    }

    rep(i, n) { cout << A[i] << " "; }
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    rep(i, n) {
        cin >> x;
        A.pb(x);
    }
    solve();
}

Measured memory_bytes: 7944
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  string ans = "";
  sort(ALL(a));
  if (n%3 == 0) {
    bool ok = true;
    int m = n/3;
    vvi d(3, vi(m));
    int k = 0;
    rep(i, 3) rep(j, m) {d[i][j] = a[k]; ++k;};
    rep(i, 3) if (d[i][0] != d[i][m-1]) ok = false;
    if (ok) {
      int v = d[0][0] ^ d[1][0] ^ d[2][0];
      if (v != 0) ok = false;
    } 
    if (ok && d[0][0] == 0) {
      if (d[1][0] != d[2][0]) ok = false;
    }
    if (ok) ans = "Yes";
    else ans = "No";
  } else {
    if (a[n-1] == 0) ans = "Yes";
    else ans = "No";
  }
  cout << ans << endl;
}

Measured memory_bytes: 4248
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
const int N = 2e5+5, inf = 1e9+7;
int n, k, i, j;
int A[N], dp[N][2];
vi adj[N];
inline int expo(int n, int k, int p = inf) {int r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline int mul(int& a, int b){ a=a*b%inf; }
void dfs(int id, int par){
    dp[id][0] = dp[id][1] = 1;
    for(auto i:adj[id]) if(i!=par) {
        dfs(i, id);
        mul(dp[id][0], dp[i][0]+dp[i][1]);
        mul(dp[id][1], dp[i][0]);
    }
}

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int i, j, a, b, ans = 0;
    cin>>n;
    rep(i, 1, n){
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    dfs(1, 1);
    cout<<(dp[1][1]+dp[1][0])%inf;
}

Measured memory_bytes: 18560
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int C = sc.nextInt();

        int[] B = new int[M];
        for (int i = 0; i < M; i++) {
            B[i] = sc.nextInt();
        }

        int[][] A = new int[N][M];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < M; j++) {
                A[i][j] = sc.nextInt();
            }
        }

        int cnt = 0;
        for (int i = 0; i < N; i++) {
            long sum = C;
            for (int j = 0; j < M; j++) {
                sum += A[i][j] * B[j];
            }
            if (sum > 0) cnt++;
        }

        System.out.println(cnt);

        return;
    }

}

Measured memory_bytes: 21968
import java.util.*;

class Main{

    public static void main(String[] args){
	int a,b,c,n;
	int[] ina = new int[2000];
	int[] inb = new int[2000];
	int[] inc = new int[2000];
	int[] num = new int[2000];
	int[] tof = new int[2000];  
	Scanner in = new Scanner(System.in);
	while(true)
	    {
		a = in.nextInt();
		b = in.nextInt();
		c = in.nextInt();
	
		Arrays.fill(num,-1);
		if(a == 0 && c == 0 && b == 0)break;
		n = in.nextInt();
		for(int i=1;i<=n;i++)
		    {
			ina[i] = in.nextInt();
			inb[i] = in.nextInt();
			inc[i] = in.nextInt();
			tof[i] = in.nextInt();
			if(tof[i] == 1)
			    {
				num[ina[i]] = 1;
				num[inb[i]] = 1;
				num[inc[i]] = 1;
			    }
		    }
		for(int i=1;i<=n;i++)
		    {
			if(tof[i] == 1)continue;
			if(num[ina[i]] == 1 && num[inb[i]] == 1)
			    {
				num[inc[i]] = 0;
			    }
			else if(num[ina[i]] == 1 && num[inc[i]] == 1)
			    {
				num[inb[i]] = 0;
			    }
			else if(num[inb[i]] == 1 && num[inc[i]] == 1)
			    {
				num[ina[i]] = 0;
			    }
			//	System.out.println("DE num[" + ina[i]  + "] = " + num[ina[i]] + ", num[" + inb[i] + "] = " + num[inb[i]] + ", num[" + inc[i] + "] = " + num[inc[i]]);
		    }

		for(int i=1;i<=a+b+c;i++)
		    {
			if(num[i] == -1)System.out.println("2");
			else System.out.println(num[i]);
		    }


	    }


    }


}

Measured memory_bytes: 0
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String []args){
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1,in,out);
        out.close();
    }
    static class Task{
        public void solve(int testNumber,Scanner in,PrintWriter out){
            String s = in.next();
            int a = s.charAt(0) - '0';
            int b = s.charAt(1) - '0';
            int c = s.charAt(2) - '0';
            int d = s.charAt(3) - '0';
            int sum = 0;
            char op1='0',op2='0',op3='0';
            for(int i = 0 ; i < 2 ; i++){
                for(int j = 0 ; j < 2 ; j++){
                    for(int k = 0 ; k < 2 ; k++){
                        if(i == 0){
                            op1 = '+';
                            sum = a + b;
                        } else {
                            op1 = '-';
                            sum = a - b;
                        }
                        if(j == 0){
                            op2 = '+';
                            sum += c;
                        } else {
                            op2 = '-';
                            sum -= c;
                        }
                        if(k == 0){
                            op3 = '+';
                            sum += d;
                        } else {
                            op3 = '-';
                            sum -= d;
                        }
                        if(sum == 7){
                            break;
                        }
                    }
                    if(sum == 7){
                        break;
                    }
                }
                if(sum == 7){
                    break;
                }
            }
            out.print(a);
            out.print(op1);
            out.print(b);
            out.print(op2);
            out.print(c);
            out.print(op3);
            out.println(d + "=7");
        }
    }
}


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

typedef long long ll;

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

    string S;
    cin >> S;

    if(S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
   
int F[102][102];
int xg,yg,w,h;
   
   
void DFS(int Y,int X,int c){
  //if(Y < 1 || X < 1)
    //return;
  if(F[Y][X] != c){
    return;
  }
   
  F[Y][X] = -1;
  DFS(Y+1,X  ,c);
  DFS(Y-1  ,X,c);
  DFS(Y,X+1  ,c);
  DFS(Y  ,X-1,c);
}
   
   
int main(){
  int xs,ys,n;
  while(1){
    cin >> w >> h;
    if(w == 0 && h == 0)
      break;
for(int i=0; i<102; i++){
      for(int j=0; j<102; j++){
        F[i][j] = 10;
      }
    }
       F[0][102] = 0;
    cin >> xs >> ys >> xg >> yg >> n;
   
   
    for(int i=0;i<n;i++){
      int c,d,x,y;
      cin >> c >> d >> x >> y;
      if(c == 0)
         c = 1919810;
      if(d == 0){
        for(int j=0;j<4;j++){
          F[x+j][y] = c;
          F[x+j][y+1] = c;
        }
      } else {
        for(int j=0;j<4;j++){
          F[x][y+j] = c;
          F[x+1][y+j] = c;
        }
      }
    }
  DFS(xs,ys,F[xs][ys]);
   
  if(F[xg][yg] == -1){
    cout << "OK" << endl;
  } else {
    cout << "NG" <<endl;
  }
  }
}


Measured memory_bytes: 3704
#include <iostream>

using namespace std;

int main(){
    int x,h,m;
    cin >> x;
    h = x/3600;
    x = x%3600;
    m = x/60;
    x = x%60;
    cout << h << ":" << m << ":" << x << endl;
    
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<string>
#include<vector>
#include <cstdlib>


using namespace std;

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

	int count_red_all = 0,count_red=0;
	for (int i = 0; i < n; i++)
		if (data[i] == 'R')
			count_red_all++;
	for (int i = 0; i < count_red_all; i++)
		if (data[i] == 'R')
			count_red++;
	cout <<count_red_all - count_red << endl;

	return 0;
	
}

Measured memory_bytes: 3740
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_C&lang=jp
 */

import java.util.*;
import java.util.Arrays;


public class Main {
    class Card implements Comparable {
        String s;
        int n;
        int m;
        Card(String s, int n) {
            this.s = s;
            this.n = n;
        }
        public String toString() {
            return s + " " + n;
        }
        public int compareTo(Object c) {
            return n - ((Card) c).n;
        }
    }
    void swap(Card[] A, int a, int b) {
        Card tmp = A[a];
        A[a] = A[b];
        A[b] = tmp;
    }
    int partition(Card[] A, int p, int r) {
        int x = A[r].n;
        int i = p - 1;
        for (int j = p; j < r; j++) {
            if (A[j].n <= x) {
                i++;
                swap(A, i, j);
            }
        }
        swap(A, i+1, r);
        return i+1;
    }
    void quickSort(Card[] a, int p, int r) {
        if (p < r) {
            int q = partition(a, p, r);
            quickSort(a, p, q-1);
            quickSort(a, q+1, r);
        }
    }
    void printCards(Card[] a) {
        for (int i = 0; i < a.length; i++) {
            System.out.println(a[i]);
        }
    }

    boolean isSameOrder(Card[] a, Card[] b) {
        for (int i = 0; i < a.length; i++) {
            if (a[i] != b[i]) return false;
        }
        return true;
    }
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Card[] a = new Card[n];
        Card[] b = new Card[n];
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            int x = sc.nextInt();
            a[i] = b[i] = new Card(s, x);
        }
        quickSort(a, 0, a.length-1);
        Arrays.sort(b);
        if (isSameOrder(a, b)) {
            System.out.println("Stable");
        } else {
            System.out.println("Not stable");
        }
        printCards(a);
    }
    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 99604
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        try {
            String inputData = scan.nextLine();
            while (inputData != null && !"".equals(inputData)) {
                String[] inputDataSP = inputData.split(" ");
                long a = Long.parseLong(inputDataSP[0]);
                long b = Long.parseLong(inputDataSP[1]);
                long gcd = gcd(a, b);
                long lcm = (a * b) / gcd;
                System.out.println(gcd + " " + lcm);
                inputData = scan.nextLine();
            }
            scan.close();
        } catch (Exception e) {
            System.exit(0);
        }
    }

    private static long gcd(long a, long b) {
        if (a < b) {
            long tmp = a;
            a = b;
            b = tmp;
        }
        long mod = -1;
        while ((mod = a % b) != 0) {
            a = b;
            b = mod;
        }
        return b;
    }
}

Measured memory_bytes: 26024
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
namespace io
{
	const int N=1<<20;
	char buf[N],*t1=buf,*t2=buf;
	#ifdef cjy 
	#define getc() getchar()
	#else
	#define getc() t1==t2&&(t2=(t1=buf)+fread(buf,1,N,stdin),t1==t2)?EOF:*t1++
	#endif
	inline int read()
	{
		static int an,f;an=0,f=1;
		static char ch;ch=getc();
		while(ch<48||ch>57)ch=='-'?f=-1:0,ch=getc();
		while(ch>=48&&ch<=57)an=(an<<3)+(an<<1)+(ch^48),ch=getc();
		return an*f;
	}
	char buff[N],*T=buff;
	inline void flush(){fwrite(buff,1,T-buff,stdout);}
	inline void putc(char ch){T==buff+N?flush(),T=buff:0;*T++=ch;}
	inline void print(int x)
	{
		if(!x){putc('0');return;}
		static int st[20],tp;
		while(x)st[++tp]=x%10,x/=10;
		while(tp)putc(st[tp--]^48);
	}
}
using io::read;
using io::putc;
using io::flush;
using io::print;
int n,a[100010];
long long po[100010],cnt[100010],ans;
int main()
{
	n=read();
	po[0]=1;
	for(int i=1;i<=n;++i)
	{
		po[i]=2*po[i-1];
		if(po[i]>1e14)po[i]=1e14;
	}
	for(int i=0;i<=n;++i)a[i]=read();
	for(int i=n;~i;--i)
	{
		cnt[i]=cnt[i+1]+a[i];
		if(cnt[i]>po[i])cnt[i]=po[i];
	}
	if(cnt[0]<a[0])return printf("-1"),0;
	for(int i=0;i<n;++i)
	{
		cnt[i+1]=min(cnt[i+1],2*(cnt[i]-a[i]));
		if(cnt[i+1]<a[i+1])return printf("-1"),0;
	}
	for(int i=0;i<=n;++i)ans+=cnt[i];
	printf("%lld",ans);
	flush();
	return 0;
}

Measured memory_bytes: 4420
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B81 solver = new B81();
        solver.solve(1, in, out);
        out.close();
    }

    static class B81 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            for (int i = 1; i <= Math.sqrt(n) && i <= 9; i++) {
                if (n % i == 0) {
                    if (i <= 9 && n / i <= 9) {
                        out.println("Yes");
                        return;
                    }
                }
            }
            out.println("No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



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

int main(){
  vector <int> g1 ={1,3,5,7,8,10,12},
    g2 = {4,6,9,11},
    g3 = {2};
  bool p;
  
  
  int x,y;
  cin >> x >> y;
  
  if ( x == 2) {
    if ( y == 2){
      cout << "Yes" << endl;
      return 0;
    }
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  
  for(int i=0; i<g1.size(); i++){
    if ( x == g1.at(i) ) p = 0;
  }
  for(int i=0; i<g2.size(); i++){
    if ( x == g2.at(i) ) p = 1;
  }
  
  if ( p == 0){
    for(int i=0; i<g1.size(); i++){
      if ( y == g1.at(i) ){
	cout << "Yes" << endl;
	return 0;
      }
    }
  }
    
  if ( p == 1){
    for(int i=0; i<g2.size(); i++){
      if ( y == g2.at(i) ){
	cout << "Yes" << endl;
	return 0;
      }
    }
  }
 
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    int n;
    char s[10001];
    scanf("%d%s",&n,s);
    for(int i=0;strlen(s)>i;++i){
        s[i]+=n;
        if(s[i]>90)
        s[i]=s[i]-26;
    }
    for(int i=0;strlen(s)>i;++i)
    printf("%c",s[i]);
    return 0;
}

Measured memory_bytes: 128
import numpy as np

W,H,N=[int(i) for i in input().split()]
lst=[]
for j in range(N):
    lst.append([int(i) for i in input().split()])
#print(lst)

square=np.zeros(H*W,dtype=np.int64).reshape(H,W)
#print(square)

for i in lst:
    x=i[0]
    y=i[1]
    a=i[2]
    if(a==1):
        for j in range(x):
            for k in range(H):
                square[k][j]=1
        #print(square)
    elif(a==2):
        for j in range(x,W):
            for k in range(H):
                square[k][j]=1
        #print(square)
    elif(a==3):
        for j in range(H-y,H):
            for k in range(W):
                square[j][k]=1
        #print(square)
    else:
        for j in range(H-y-1,-1,-1):
            for k in range(W):
                square[j][k]=1
        #print(square)

print(np.count_nonzero(square ==0))


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

long long ceros(long long i) {
  int n = 0;
  while (i) {
    i /= 10;
    n++; 
  }
  return pow(10, n + 1);
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long x, next, actual = 100, ans = 0;
  cin >> x;
  next = (long long)(actual * 0.01);
  while (x - actual > next) {
    actual += next;
    next = (long long)(actual * 0.01);
    ans++;
  } 
  cout << (ans + 1) << '\n';
  
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*DP使ったほうがよくない？？WOWWOW*/

int main(){
  int x,y,z; cin>>x>>y>>z;
  cout<<z<<" "<<x<<" "<<y;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

unsigned long long int calc(int count){
	if(count == 0)return 1;
	else{
		return 2*calc(count-1);
	}
}

 int main(){

	 int ans;
	 unsigned long long int N;
	 scanf("%llu",&N);

	 for(int i = 0; ; i++){
		 if(calc(i) > N){
			 ans = i;
			 break;
		 }
	 }

	 printf("%d\n",ans);

	 return 0;
}

Measured memory_bytes: 2740
ina = input()
inb = input()
inc = input()

next = "a"

while True:
  if next == "a":
    if ina == "":
      break
    next = ina[0]
    ina = ina[1:]
  elif next == "b":
    if inb == "":
      break
    next = inb[0]
    inb = inb[1:]
  else:
    if inc == "":
      break
    next = inc[0]
    inc = inc[1:]
print(next.upper())

Measured memory_bytes: 3064
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)
const int INF = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    //数列aのに含まれる、最長の1,2,3,...の長さを知りたい
    int p = 0;
    rep(i, n) {
        if (a[i] == p + 1) p++;
    }
    if (p == 0) cout << -1 << endl;
    else cout << n - p << endl;
 	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <tuple>

using namespace std;

int H, W, Ch, Cw, Dh, Dw;
string S;
bool b[1001][1001];
int t[1001][1001];

pair<int,int> d[4]{{0,1}, {0,-1}, {1,0}, {-1,0}};

int main() {
  fill((int*)t,(int*)t+1001*1001,-1);
  
  cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
  for (int i = 1; i <= H; ++i) {
    cin >> S;
    for (int j = 1; j <= W; ++j) {
      b[i][j] = S[j-1] == '.';
    }
  }

  priority_queue<tuple<int,int,int>, vector<tuple<int,int,int>>,
                 greater<tuple<int,int,int>>> q;
  q.emplace(0,Ch,Cw);
  t[Ch][Cw] = 0;
  while(!q.empty()) {
    auto [T,h,w] = q.top();
    q.pop();
    if (t[h][w] < T) continue;    
    for (auto [dh,dw]: d) {
      int nh = h + dh, nw = w + dw;
      if (nh < 1 || nh > H || nw < 1 || nw > W || !b[nh][nw]) continue;
      int nt = t[nh][nw];
      if (nt != -1 && nt <= T) continue;
      t[nh][nw] = T;
      q.emplace(T,nh,nw);
    }
    
    for (int dw = -2; dw !=3; ++dw) {
      for (int dh = -2; dh !=3; ++dh) {
        int nh = h + dh, nw = w + dw;
        if (nh < 1 || nh > H || nw < 1 || nw > W || !b[nh][nw]) continue;
        int nt = t[nh][nw];
        if (nt != -1 && nt <= T + 1) continue;
        t[nh][nw] = T + 1;
        q.emplace(T+1,nh,nw);
      }
    }
  }

  cout << t[Dh][Dw] << endl;
}


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

using namespace std;
using lint = long long;
const lint MOD = 1e9 + 7;

int main() {
    lint n, k;
    cin >> n >> k;

    lint ans = 0;
    for (int i = k; i <= n + 1; i++) {
        ans = (ans + i * (n - i + 1) + 1) % MOD;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n,b=1,ans=0; cin >>n;

  for(int i=0; i<n; i++)
  {
    int a; cin >>a;
    if(a!=b) ans++;
    else b++;
  }

  if(n>ans) cout<<ans;
  else cout <<"-1";
  
return 0;
}

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

using namespace std;

bool cmp(vector<long> a, vector<long> b) {
    return a[1] > b[1];
}

int main() {
    vector<int> v;
    int N, M;
    cin >> N >> M;
    vector<vector<long>> T;
    long a;
    for (int i = 0; i < N; ++i) { 
        cin >> a;
        T.push_back({1, a});
    }
    long b, c;
    for (int i = 0; i < M; ++i) { 
        cin >> b >> c;
        T.push_back({b, c});
    }
    sort(T.begin(), T.end(), cmp);
    long s = 0;
    int cap = 0;
    for (int i = 0; i < N+M; ++i) { 
        if (cap + T[i][0] < N){
            cap += T[i][0];
            s += T[i][0]*T[i][1];
        } else {
            s += (N - cap)*T[i][1];
            break;
        }
    }
    printf("%ld\n", s);
    return 0;
}

Measured memory_bytes: 12588
#include <stdio.h>

int main() {
    long int a[6], ans, min=1000000000000000;
    int i;

    for(i=0; i<6; i++) {
        scanf("%ld", &a[i]);
        if(i>0) {
            if(min > a[i]) {
                min = a[i];
            }
        }
        // printf("%ld\n", a[i]);
    }

    ans = a[0]/min;
    // printf("%ld %ld %ld %ld\n", a[0], ans, min, ans*min);
    if(a[0]%min == 0) {
        ans -= 1;
    }

    ans += 5;

    // printf(%)

    printf("%ld\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <functional>

#define PAIR		pair< char, int >

struct SResult
{
	int begin;
	int end;
	int val;

	SResult(){ Init(); }

	void Init()
	{
		begin	= -1;
		end		= -1;
		val		= -1;
	}

	bool operator < ( const SResult& e) const
	{
		return begin < e.begin;
	}
	bool operator > (const SResult& e) const
	{
		return begin > e.begin;
	}
	bool IsValid() const
	{
		return ( begin >= 0 ) && ( end >= 0 ) && ( val >= 0 );
	}
};

using namespace std;

int main()
{
	stack< PAIR > s;
	priority_queue< SResult, vector< SResult >, greater< SResult > >	res;

	// ??\???.
	string input;
	cin >> input;

	//??\?????????????????§?????¢????¨?????????§.
	int allRegion = 0;
	for( int i = 0; i < input.size(); ++i ){
		PAIR factor = make_pair( input[i], i );

		if( cin.eof() ){
			break;
		}

		if( factor.first == '\\' ){
			// ?????????????????????.
			s.push( factor );
		}
		else if( factor.first == '/' ){
			// ?????????????????????????????¨????????????????????¢???????¨??????????.
			if( s.empty() ){
				// ?????????????????????????????????????????§????????????????????????.
				continue;
			}

			PAIR top = s.top();	s.pop();

			// ?§?????????????????°´??????????????¢?????????????????????.
			SResult tmp;
			tmp.begin	= top.second;
			tmp.end		= factor.second;
			tmp.val		= tmp.end - tmp.begin;
			res.push(tmp);

			// ????????§?????¨??¢??????????¨?????????¨???.
			allRegion += tmp.val;
		}
	}

	// ???????????¢????????±???????????????.
	vector< SResult > output;
	SResult root;
	while( res.size() > 0 ){
		SResult tmp = res.top();	res.pop();
		if( root.IsValid() ){
			if( root.begin < tmp.begin && tmp.end < root.end ){
				// ???????????\??£??????????????§??±???.
				root.val += tmp.val;
			}
			else{
				// ?????????????????????????????§????????£.
				output.push_back( root );
				root = tmp;
			}
		}
		else{
			root = tmp;
		}
	}
	// ???????????\????????????????????£??????????????§??\??????.
	if( root.IsValid() ){
		output.push_back( root );
	}

	// ??????.
	std::cout << allRegion << endl;
	std::cout << output.size();
	for( int i = 0; i < (int)output.size(); ++i ){
		std::cout << " " << output[i].val;
	}
	std::cout << endl;

	return 0;
}

Measured memory_bytes: 1420
N = int(input())
ls = []
ans = 10**13
for i in range(1,int(N**0.5)+1):
  if N%i==0:
    j = N//i
    if abs(i-1)+abs(j-1)<ans:
      ans = abs(j-1)+abs(i-1)
print(ans)
    

Measured memory_bytes: 40428
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
typedef pair<int,int>P;
typedef pair<int,P>P2;
typedef pair<string,P>PP;
#define F first
#define S second
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};


signed main(){
  int n;
  cin>>n;
  vector<PP>v;
  r(i,n){
    string s;
    int p;
    cin>>s>>p;
    v.push_back(PP(s,P(-p,i+1)));
  }
  sort(v.begin(),v.end());
  r(i,n){
    cout<<v[i].S.S<<endl;
  }
}

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

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int m = ni();
		int nsum = 0;
		long result = 0;
		List<Shop> s = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			s.add(new Shop(ni(),ni()));
		}
		
		s.sort((a, b) -> a.v - b.v);
		for(Shop s1:s) {
			//System.out.println(nsum + " " + s1.v + " " + s1.n);
			if(nsum + s1.n <= m) {
				nsum += s1.n;
				result += (long)s1.v * s1.n;
			} else {
				result += (long)s1.v * (m - nsum);
				break;
			}
		}
		System.out.println(result);
		
	}
	
	static class Shop {
		int v;
		int n;		
		public Shop(int v, int n) {
			this.v = v;
			this.n = n;
		}		
	}

	//Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 120544
#include <algorithm>
#include <cmath>
#include <ctime>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
template<class T>
void printv(vector<T> vec){ for(T e: vec)cout << e << ' '; cout << endl;}
template<class T>
void print2v(vector<vector<T> >v){ for(auto& i: v){ for(auto& j: i) cout<<j<<' '; cout<<endl;}}

 struct TreeNode {
     int val;
     TreeNode *left;
     TreeNode *right;
     TreeNode() : val(0), left(nullptr), right(nullptr) {}
     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};


 class Solution {
 public:
     int searchInsert(vector<int>& nums, int target) {
         int left = 0, right = nums.size() - 1, mid = 0;
         bool isLeft;
         while (left <= right) {
             mid = (left + right) / 2;
             if (target < nums[mid]) {
                 right = mid - 1;
                 isLeft = true;
             }               
             else if (target > nums[mid]) {
                 left = mid + 1;
                 isLeft = false;
             }                
             else return mid;
         }

         if (isLeft) return right;
         else return left + 1;
         return mid;
     }
 };

int main() {  
    vector<int> nums{ 1,3,5,6 };   
    long long N;
    while (cin >> N) {
        string res;
        while (N) {
            int m = N % 26;
            if (m) {
                res = (char)('a' + m - 1) + res;
                N /= 26;
            }
            else {
                res = 'z' + res;
                N /= 26;
                N--;
            }
            
        }
        cout << res << endl;
    }
    

	return 0;
}

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

int top,S[1000];

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}
int main(){
  int a,b;
  top=0;
  int x;
  char s[100];

  while( scanf("%s",s) != EOF ){
    if ( s[0] == '+' ){
      a=pop();
      b=pop();
      push(a+b);

    } else if ( s[0] == '-' ){
      b=pop();
      a=pop();
      push(a-b);

    } else if ( s[0] == '*' ){
      a=pop();
      b=pop();
      push(a*b);

    } else {
      push(atoi(s));

    }
  }
  printf("%d\n",pop());

  return 0;
}



Measured memory_bytes: 2052
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int N, M;
    int count = 0;
    vector<vector<int>> connection;
    vector<int> arrange;

    cin >> N >> M;
    connection.resize(N, vector<int>());
    arrange.resize(N);
    for (int i = 0; i < N; i++){
        arrange[i] = i;
    }

    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        connection[a - 1].push_back(b - 1);
        connection[b - 1].push_back(a - 1);
    }

    do{
        if(arrange[0] == 0){
        bool ok = true;
        for (int i = 0; i < N - 1; i++){
            bool alive = false;
            for (int j = 0; j < connection[arrange[i]].size(); j++){
                if(connection[arrange[i]][j] == arrange[i + 1]){
                    alive = true;
                    break;
                }
            }
            if(!alive){
                ok = false;
                break;
            }
        }
        if(ok){
            count++;
        }
        }
    } while (next_permutation(arrange.begin(), arrange.end()));

    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,i,j,k;
	ll ans=0;
	ll a[100001];
	ll b[100001];
	cin>>n;
	for(i=0;i<=n;i++) cin>>a[i];
	for(i=0;i<n;i++) cin>>b[i];
	for(i=0;i<n;i++){
		if(b[i]>a[i]){
			ans+=a[i];
			b[i]-=a[i];
			if(b[i]>a[i+1]){
				ans+=a[i+1];
				a[i+1]=0;
			}
			else{
				ans+=b[i];
				a[i+1]-=b[i];
			}
		}
		else ans+=b[i];
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <vector>
#include <set>


int main(void)
{
	int ansar = 0;

	int n;
	std::cin >> n;
	std::set<int> arr;

	for (size_t i = 0; i < n; i++)
	{
		int in = 0;
		std::cin >> in;
		arr.insert(in);
	}
	std::cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		int in = 0;
		std::cin >> in;
		if (arr.find(in) != arr.end())ansar++;
	}
	std::cout << ansar <<std::endl;

	return 0;
}

Measured memory_bytes: 3120
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){

    LL x,y;

    cin >> x >> y;

    if((x >= 0 && y > 0) || (x < 0 && y <= 0)){
        if(x <= y)cout << y - x;
        else cout << x - y + 2;
    } else {
        if(x+y < 0)cout << (x+y) * (-1) + 1;
        else cout << x + y + 1;
    }

    return 0;
}


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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define pb push_back
#define f first
#define s second
#define INF 1000000000000
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MAXN = 100100, MAXK = 25;
const ll MOD = 1e9+7;

ll dp[MAXN];
int w[MAXN];
ll v[MAXN];

int main()
{
    FAST_IO;

    int n, W; cin >> n >> W;
    FOR(i, 1, n) cin >> w[i] >> v[i];

    FOR(j, 1, n) for (int i = W; i >= 0; i--)
        if (i + w[j] <= W)
            dp[i+w[j]] = max(dp[i+w[j]], dp[i]+v[j]);

    ll ans = 0;
    FOR(i, 0, W) ans = max(ans, dp[i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
a,b,c,x,y=map(int,input().split())

_1=a*x+b*y

if x>=y:
  _2=c*2*y+(x-y)*a
  _3=2*x*c
else:
  _2=c*2*x+(y-x)*b
  _3 = 2*y*c

print(min(_1,_2,_3)  )

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

bool dfs(string s)
{
    if(s=="ABC") return true;

    int S = s.size();

    bool ret = false;
    bool ng[3]={};

    int idx = 0;
    while(idx<S)
    {
        if(idx<S-2 && s[idx]=='A' && s[idx+1]=='B' && s[idx+2]=='C') idx+=3;
        else ng[s[idx++]-'A'] = true;
    }

    rep(i,3)if(!ng[i])
    {
        string t = "";
        idx = 0;
        while(idx<S)
        {
            if(idx<S-2 && s[idx]=='A' && s[idx+1]=='B' && s[idx+2]=='C')
            {
                t += 'A'+i;
                idx+=3;
            }
            else
            {
                t += s[idx];
                ++idx;
            }
        }
        if(t!=s) ret |= dfs(t);
    }

    return ret;
}

int main()
{
    string s;
    cin >>s;
    cout << (dfs(s)?"Yes":"No") << endl;
    return 0;
}

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

int main(){
  
  ll N,W;
  cin >> N >> W;
  
 vector<ll> w(N);
 vector<ll> v(N);
  
 rep(i,N)
   cin >> w.at(i) >> v.at(i);
  
  vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));
  
  rep(i,W)
    dp.at(0).at(i)=0;
 // cout << "22" << endl;
  
  for(int i=1;i<N+1;i++){
    rep(j,W+1){
      if(j<w.at(i-1))
        dp.at(i).at(j)=dp.at(i-1).at(j);
      else
        dp.at(i).at(j)=max(dp.at(i-1).at(j),dp.at(i-1).at(j-w.at(i-1))+v.at(i-1));
     // cout << j << ' ' << dp.at(i).at(j) << endl;
    }
  }
  
 
  cout << dp.at(N).at(W) << endl;
 
}






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

typedef pair<int, int> P;

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<P> c;
    REP(i,n) {
        int a, b;
        cin >> a >> b;
        c.push_back(P(a,b));
    }
    sort(c.begin(), c.end(), greater<P>());
    ll ans = c[0].second+c[0].first;
    cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
using namespace std;
int main(void){
   int a,b,c,count=0;
   cin>>a>>b>>c;
   for(int x=a;x<=b;x++){
       if(c%x==0){
       count+=1;
       }
    }
    cout<<count<<endl;
    return 0;
}



Measured memory_bytes: 3120
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int ans = 0;
		int count = 0;
		for(int i = 1;i <= n;i = i + 2){
			count = 0;
			for(int j = 1;j <=i;j++){
				if(i % j == 0){
					count++;
				}
			}
			if(count == 8){
				ans++;
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21460
#include <iostream>
#include <list>
#include <queue>

using namespace std;
using ll = long long;

int main(){
    int N;
    cin >> N;
    int mod2 = N%2;
    deque<ll> dq;
    for(int i=1;i<=N;i++){
        int tmp;
        cin >> tmp;
        if(i%2==mod2){
            dq.push_front(tmp);
        }else{
            dq.push_back(tmp);
        }
    }

    for(int i=0;i<N;i++){
        cout << dq[i];
        if(i < N-1){
            cout << " ";
        }
    }
    cout << endl;
    return 0;

}

Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

int main() {
  unsigned int n,a,b,c;
  std::cin >> n;
  for(unsigned int i=0;i<n;i++) {
    scanf("%d %d %d", &a, &b, &c); 
    std::vector<unsigned int> v;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(),v.end());
    if((v[0]*v[0])+(v[1]*v[1])==(v[2]*v[2])) {
      std::cout << "YES" << std::endl;
    }
    else {
      std::cout << "NO" << std::endl;
    }
  }
}

Measured memory_bytes: 3068
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int main(){
  int n;cin>>n;
  string s,t;cin>>s>>t;
  char ans[200];
  rep(i,n){
    ans[2*i]=s[i];
    ans[2*i+1]=t[i];
  }
  rep(i,2*n){
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
a = [int(i) for i in input().split()]

count = 0
half = 0
for i in range(N):
    if a[i]%4 == 0:
        count += 1
    elif a[i]%2 == 0:
        half +=1

if count >= N//2:
    print("Yes")
elif count >= (N//2 - half//2):
    print("Yes")
else:
    print("No")

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

int main() {
  int  i,j;
  int N;
  cin >> N ;
  int a[N];
  for(i=0;i<N;i++){
    cin >>a[i];
  }
  int odd_num=0;
  int count=0;
  while(1){
    for(i=0;i<N;i++){
      if (a[i]%2==0){
        a[i]/=2;
      }else{odd_num+=1;}
    }
    if(odd_num>0)break;
    odd_num=0;
    count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n,m,k;
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes";
    }else{
        cout << "No";
    }

}

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

int main() {
	int N, a;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		if ((a % 2) == 0) {
			if (a % 3 == 0 || a % 5 == 0)
				continue;
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    int flag = 0;
    bool ans = false;
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        if (a == b && flag == 0) {
            flag = 1;
        } else if (a == b && flag == 1) {
            flag = 2;
        } else if (a == b && flag == 2) {
            ans = true;
        } else if (a != b) {
            flag = 0;
        }
    }
    if (ans) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>

using namespace std;
int main (){
    int a,b,c,d;cin >> a >> b >> c >> d;
    
    int i = 0;
    while(a > 0 && c > 0){
    	if(i % 2 == 0){
        	c -= b;
        }else{
          	a -= d;
        }
      	i++;
    }
    if(--i % 2 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
p = 7+10**9
def comb(n, r, p):
    numer = 1
    denom = 1
    for i in range(n-r+1, n+1):
        numer = numer * i % p
    for i in range(1, r+1):
        denom = denom * i % p
    return numer * pow(denom, p-2, p) % p

n, a, b = map(int, input().split())
print(((pow(2, n, p) - comb(n, a, p) - comb(n, b, p) - 1)) % p)


Measured memory_bytes: 3064