akhauriyash/Code-Regression huggingface dataset:
//============================================================================
// Name        : CF.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>
#include <unordered_map>
#define  RD(x)      scanf("%d", &x)
#define  REP(i, n)  for (int i=0; i<int(n); ++i)
#define  FOR(i, n)  for (int i=1; i<=int(n); ++i)
#define  pii        pair<int, int>
#define  piL        pair<int, long long>
//#define  mp         make_pair
#define  pb         push_back
#define  whatis(x)  cout << #x << ": " << x << endl;
//int dx[4] = {0, -1, 0, 1};
//int dy[4] = {1, 0, -1, 0};
using namespace std;
#define  N   10
#define  eps 1e-9
#define  pi  acos(-1.0)
#define  inf 0XFFFFFFFll
#define  mod 1000000007ll
#define  LL  long long
#define  ULL unsigned long long



int Main() {

	ios_base::sync_with_stdio(0);
//	freopen("cf.txt", "r", stdin);

	int n;
	string s, t;
	cin >> n >> s >> t;

	for (int i = n; i > 0; i--) {
		if (s.substr(n - i, i) == t.substr(0, i)) {
			cout << 2 * n - i << endl;
			return 0;
		}
	}

	cout << 2 * n << endl;


	return 0;
}

int main() {
	return Main();
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int N;
ll A[MAX_N + 1];
ll B[MAX_N];
ll C[MAX_N + 1];

void solve()
{
  ll ans = 0;
  ll c = 0;
  for (int i = 0; i < N; i++) {
    // 対象のものから余力を引く
    // 余力は引き継ぎできないので、先に消費する
    ll d = min(A[i], c);
    // 倒せたモンスターの数
    ans += min(A[i], B[i] + c);
    // 余力は勇者の力から、使ってしまったパワーを引く
    c = max(B[i] - (A[i] - d), (ll)0);
    // cout << ans << endl;
    // cout << c << endl;
  }
  ans += min(A[N], c);
  cout << ans << endl;
}

int main(void)
{
  cin >> N;
  REP(i, N + 1) cin >> A[i];
  REP(i, N) cin >> B[i];
  solve();
  return 0;
}


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

cnt, a[0] = sum(a), min(a[0], x)
for i in range(1, n):
    if a[i - 1] + a[i] > x:
        a[i] = x - a[i - 1]
print(cnt - sum(a))


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

using namespace std;

int main(){
    string s="0000000000";
    int point=0;
    
    string hoge;
    cin>>hoge;
    
    for(auto a:hoge){
        if(a=='0'){
            s.at(point)='0';
            point++;
        }else if(a=='1'){
            s.at(point)='1';
            point++;
        }else{
            point=max(0,point-1);
        }
    }
    
    for(int i=0;i<point;i++) cout<<s.at(i);
    cout<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define WAIT 0
#define SHOUT 1
#define CANNOT 2
class cat{
public:
  int state,time,x,y,flag;
  vector<int> edge;
  
};
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define calc(x1,x2,y1,y2) (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)
#define INF (1 << 29)
int solve(int n,cat *data,int X,int Y){
  int time=0;
  
  for(time = X;;time+=X){
    vector<int> A;
    rep(i,n){
      if ( data[i].state == SHOUT){
	data[i].time=time+Y;
	data[i].state = CANNOT;
	A.push_back(i);
      }
    }
    bool fl=0;

    rep(i,A.size()){
      rep(j,data[A[i]].edge.size()){
	int next =data[A[i]].edge[j];
	if ( data[next].state == WAIT){
	  if ( data[next].flag == true)return -1;	  
	  fl=true;
	  data[next].time=time+X;
	  data[next].flag=true;
	  data[next].state = SHOUT;
	}else if (data[next].state == SHOUT){
	  //nothing to do
	}else if ( data[next].state == CANNOT){	  
	  if ( data[next].time < time){
	    if ( data[next].flag == true)return -1;	    
	  }
	}
      }
    }
    
    if ( fl == false)break;
    
    //cannot clear check
    rep(i,n){
      if ( data[i].state == CANNOT){
	if (data[i].time <=time){
	  data[i].time = 0;
	  data[i].state =WAIT;
	}
      }
    }


  }
  return time;
}

main(){
  int te;
  cin>>te;
  while(te--){
  int n,X,Y;
  while(cin>>n>>X>>Y){
    cat data[n];
    int sx,sy;
    cin>>sx>>sy;
    bool tet=0;
    rep(i,n){
      cin>>data[i].x>>data[i].y;
      data[i].flag = false;
      data[i].state =WAIT;
      if ( calc(data[i].x,sx,data[i].y,sy) <=100){
	data[i].state=SHOUT;
	data[i].time=X;
	data[i].flag = true;
	tet=true;
      }

    }


    rep(i,n){
      rep(j,n){
	if (i == j)continue;
	if ( calc(data[i].x,data[j].x,data[i].y,data[j].y)<=50*50){
	  data[i].edge.push_back(j);
	}
      }
    }

    if (tet == false){
      cout << 0 << endl;
      continue;
    }

    int ans = solve(n,data,X,Y);
    if ( ans == -1){
      cout <<"You're always welcome!"<<endl;
    }else cout <<ans<<endl;    
  }
  return false;
}
}

Measured memory_bytes: 1064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array1 = new int[n];
		int[] array2 = new int[n];
		for(int i = 0; i < n; i++) {
			array1[i] = sc.nextInt();
			array2[i] = sc.nextInt();
		}
		
		boolean ans = false;
		for(int i = 0; i < n - 2; i++) {
			if(array1[i] == array2[i]) {
				if(array1[i+1] == array2[i + 1]) {
					if(array1[i + 2] == array2[i + 2]) {
						ans = true;
						break;
					}
				}
			}
		}
		
		if(ans) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		sc.close();
	}
}


Measured memory_bytes: 36064
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e5+10;
const LL INF=1LL<<60;
int A,B,Q;
LL a[N],b[N];

LL getleftA(LL x) {
	int t=lower_bound(a+1,a+A+1,x)-a;
	if (t>A || a[t]>x) t--;
	if (t==0) return -INF;
	return a[t];
}

LL getleftB(LL x) {
	int t=lower_bound(b+1,b+B+1,x)-b;
	if (t>B || b[t]>x) t--;
	if (t==0) return -INF;
	return b[t];
}

LL getrightA(LL x) {
	int t=upper_bound(a+1,a+A+1,x)-a;
	if (t>A) return INF;
	return a[t];
}

LL getrightB(LL x) {
	int t=upper_bound(b+1,b+B+1,x)-b;
	if (t>B) return INF;
	return b[t];
}

int main()
{
	scanf("%d%d%d",&A,&B,&Q);
	for (int i=1;i<=A;i++) scanf("%lld",&a[i]);
	for (int i=1;i<=B;i++) scanf("%lld",&b[i]);

	for (int i=1;i<=Q;i++) {
		LL x; scanf("%lld",&x);
		LL ans=INF,t;
		t=getleftA(x); ans=min(ans,(x-t)+min(t-getleftB(t),getrightB(t)-t));
		t=getrightA(x); ans=min(ans,(t-x)+min(t-getleftB(t),getrightB(t)-t));
		t=getleftB(x); ans=min(ans,(x-t)+min(t-getleftA(t),getrightA(t)-t));
		t=getrightB(x); ans=min(ans,(t-x)+min(t-getleftA(t),getrightA(t)-t));
		printf("%lld\n",ans);  
	}
	return 0;
}

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

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;

int main()
{
	// freopen("input.in", "r", stdin);

	int n; cin >> n;
	string s, t; cin >> s >> t;
	for(int i = 0; i < 2*n; i++)
	{
		if(i%2 == 0) cout << s[i/2];
		else cout << t[i/2];
	}
	cout << "\n";

}

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

int main(){
  long long int n;
  cin>>n;
  vector<long long int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  long long int ans=1;
  sort(a.begin(),a.end());
  long long int np=a[0];
  for(int i=1;i<n;i++){
    //cout<<np<<" "<<a[i]<<endl;
    if(np*2>=a[i]){
      ans++;
    }else{
      ans=1;
    }
    np+=a[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define int long long
using namespace std;
int n, m;
vector<pair<int, int>> vec[114514];
string ans[114514];
signed main() {
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		int p, y;
		cin >> p >> y;
		vec[p].push_back(make_pair(y,i));
	}
	for (int i = 1; i <= n; i++) {
		sort(vec[i].begin(), vec[i].end());
		string s = to_string(i);
		while (s.size() <= 5)s = '0' + s;
		for (int j = 0; j < vec[i].size(); j++) {
			string t = to_string(j + 1);
			while (t.size() <= 5)t = '0' + t;
			ans[vec[i][j].second] = s + t;
		}
	}
	for (int i = 1; i <= m; i++)cout << ans[i] << endl;
}

Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    int n, k;
    cin >> n >> k;
    combination c(4000);
    for (int i = 1; i <= k; i++) {
        mint blue = c(n-k+1,i);
        mint red = c(k-1,i-1);
        mint ans = blue*red;
        printf("%lld\n", ans.x);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long int X;
    int ans=0;
    cin>>X;
    long long int yokin=100;
    while (yokin<X){
        yokin=yokin*1.01;
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3192
using DataStructures
MOD = 2019

a = readline() |> s -> split(s,"") |> xs -> parse.(Int,xs) |> reverse
n = length(a)

dp = zeros(Int, n+1)
for i in 1:n
  dp[i+1] = (powermod(10, i-1, MOD) * a[i] + dp[i]) % MOD
end

[x * (x-1) ÷ 2 for (_,x) in counter(dp)] |> sum |> println

Measured memory_bytes: 235772
#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; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;

int x[3];
int main() {
  int a=0;
  string s[3];
  cin>>s[0]>>s[1]>>s[2];
  while(x[a] - s[a].size()) {
    a = s[a][x[a]++]-'a';
  }
  cout << char('A' + a) << endl;
}

Measured memory_bytes: 256
N = int(input())
count = 0
max = 0
for _ in range(N):
  x, y = map(int, input().split())
  if x == y:
    count +=1
  else:
    count = 0
  
  if count > max:
    max = count

if max >= 3:
  print('Yes')
else:
  print('No')

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

using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    auto x=max(n,m);
    auto y=min(n,m);
    if(x==y) cout<<x+y;
    else cout<<x+x-1;
    cout<<endl;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

int n,k;
string s;

int main(){
    cin >> n >> k >> s;
    rep(i,n){
        if(i == k-1)cout << (char)(s[i] - 'A' + 'a');
        else cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<String> list = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			String s = sc.next().chars()
		    	      .sorted()
		    	      .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
		    	      .toString();
			list.add(s);
		}
		list.sort(null);
		list.add("");
		
		sc.close();
		
		int count = 1;
		long result = 0;
		for(int i = 1; i < list.size(); i++) {
			if(list.get(i).equals(list.get(i - 1))) {
				count++;
			}
			else {
				result += ((long)count * ((long)count - 1))/2;
				count = 1;
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 68212
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define mkp make_pair
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<<endl;}}
#define print1d(mat,n){for(int i=0;i<(int)(n);i++)cout<<mat[i]<<" ";cout<<endl;}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define printpair(v) for(auto val: v){cout<<val.fi<<":"<<val.se<<", ";}cout<<endl;
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<endl;
#define init(v,x) for (auto &itr:v){itr=x;}
#define ln length()
const int mod = 1e9+7;
#define sz size()
const int inf = 1e18;
int findDivisors(int n)
{

    // Array to store the count
    // of divisors
    int div[n + 1];
    memset(div, 0, sizeof div);

    // For every number from 1 to n
    for (int i = 1; i <= n; i++) {

        // Increase divisors count for
        // every number divisible by i
        for (int j = 1; j * i <= n; j++)
            div[i * j]++;
    }

    // Print the divisors
    int ans=0;
    for (int i = 1; i <= n; i++)
        ans+=div[i];
    return ans;
}
void solve() {
    int n;
    cin>>n;
    int ans=0;

    cout<<findDivisors(n-1)<<endl;
}

int32_t main(){
    fastIO
#ifndef ONLINE_JUDGE
    freopen(R"(C:\Users\swast\CLionProjects\untitled\input.txt)", "r", stdin);
#endif
    int t=1;
//    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 11420
import numpy as np

N, M = map(int, input().split())

if M == 0:
    print(0)
    exit()

cakes = np.zeros((N, 3))
for i in range(N):
    cakes[i, :] = list(map(int, input().split()))

Calc = []
temp = np.zeros((N, 3))
tot = np.zeros(N)
for i in range(2):
    temp[:, 0] = cakes[:, 0] * (-1) ** i
    for j in range(2):
        temp[:, 1] = cakes[:, 1] * (-1) ** j
        for k in range(2):
            temp[:, 2] = cakes[:, 2] * (-1) ** k
            tot = np.sort(temp.sum(axis = 1))[::-1]
            Calc.append(tot[:M].sum())

print(int(max(Calc)))

Measured memory_bytes: 22172
function Main(input)
{
    input = input % 10;
    if (input === 3) {
        console.log("bon");
    } else if ([2,4,5,7,9].includes(input)) {
        console.log("hon");
    } else {
        console.log("pon");
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

int main()
{
	int N;
	int a[101];
	int max = 0;
	int index = 0;
	int res = 0;

	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}
	
	for(int i = 0; i < N; i++){
		max = 0;
		for(int i = 0; i < N; i++){
			if(a[i] > max){
				max = a[i];
				index = i;
			}
		}
		if(i%2 == 0){
			res = res + max;
		}
		else{
			res = res - max;
		}
		a[index] = 0;
	}
	
	cout << res << endl;

	return 0;
}


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

using namespace std;

int main() {
  int r,g,b;
  int ans = 0;

  cin >> r >> g >> b;
  ans += r * 100;
  ans += g * 10;
  ans += b;
  if(ans % 4 == 0) cout <<"YES"<<endl;
  else cout <<"NO"<<endl;
}


Measured memory_bytes: 384
R={"*":2,"/":2,"+":1,"-":1,"(":0,")":0}
for _ in[0]*int(input()):
 L=[];t=''
 for e in input()[:-1]:
  if e.isdigit():t+=e
  else:
   if t:L+=[t];t=''
   L+=e
 if t:L+=[t]
 P,S=[],[]
 for i in L:
  if"("==i:S+=i
  elif")"==i:
   while"("!=S[-1]:P+=S.pop()
   S.pop()
  elif i in R:
   while S and R[S[-1]]>=R[i]:P+=S.pop()
   S+=i
  else:P+=[i]
 while S:P+=S.pop()
 for x in P:S+=[str(int(eval(S.pop(-2)+x+S.pop())))if x in"+-*/"else x]
 print(*S)


Measured memory_bytes: 5608
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int D,G;
  cin >> D >> G;
  G/=100;
  int ans=10100;
  int p[20],c[20];
  for(int i=0;i<D;i++){
    cin >> p[i] >> c[i];
    c[i]/=100;
    //cout << c[i] << endl;
  }
  for(int bit=0;bit<(1<<D);bit++){
    int point=0;
    int cnt=0;
    //cout << cnt << endl;
    for(int i=0;i<D;i++){
      if(bit >> i & 1){
        point+=(i+1)*p[i]+c[i];
        cnt+=p[i];
        //cout << "a" << i << " " << cnt << endl;
      }
    }
    if(point>=G){
      ans=min(ans,cnt);
      continue;
    }
    bool flag =false;
    for(int i=D-1;i>=0;i--){
      if(flag)break;
      if((bit >> i & 1)==0){//bit^1などの真偽判定が重要
        //cout << "b"<< i << endl;
        int sum=0;
        while(G>point && p[i]>sum){
          point+=(i+1);
          cnt++;
          sum++;
        }

        flag=true;
      }
    }
    if(point>=G){
      ans=min(ans,cnt);
      //cout << ans << endl;
      //cout << endl;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
 
#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>
 
#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 100010;

int n;
int a[N], b[N];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &a[i]);
  if (count(a + 1, a + n + 1, 0) == n) {
    puts("Yes");
    return 0;
  }
  if (n % 3) {
    puts("No");
    return 0;
  }
  sort(a + 1, a + n + 1);
  copy(a + 1, a + n + 1, b + 1);
  int m = unique(b + 1, b + n + 1) - b - 1;
  if (m == 2 && b[1] == 0 && count(a + 1, a + n + 1, 0) == n / 3) {
    puts("Yes");
  } else if (m == 3 && (b[1] == (b[2] ^ b[3])) && count(a + 1, a + n + 1, b[1]) == n / 3 && count(a + 1, a + n + 1, b[2]) == n / 3 && count(a + 1, a + n + 1, b[3]) == n / 3)
    puts("Yes");
  else
    puts("No");
  return 0;
}


Measured memory_bytes: 1024
using System;

namespace tst
{
    class Program
    {
        public static long num = 1;
        public static long move = 0; 
        public static void Devide(long x)
        {
            if (x == 1)
            {
                return;
            }
            //分裂した分だけ分解回数が増える
            move+=num;
            double val = x/2;
            val= Math.Floor(val);
            //何体に分裂したか
            num *= 2;
            Devide((long)val);
        }
        public static void Main()
        {
            long h = long.Parse(Console.ReadLine());
            Devide(h);
            Console.WriteLine(num + move);
        }

    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int x, y;
    cin >> x >> y;

    int a, b, c;
    cin >> a >> b >> c;

    vector<int> p(a), q(b), r(c + x + y);
    for (int i = 0; i < a; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < b; i++) {
        cin >> q[i];
    }
    sort(p.begin(), p.end(), greater<>());
    sort(q.begin(), q.end(), greater<>());

    for (int i = 0; i < c; i++) {
        cin >> r[i];
    }
    for (int i = 0; i < x; i++) {
        r[c + i] = p[i];
    }
    for (int i = 0; i < y; i++) {
        r[c + x + i] = q[i];
    }
    sort(r.begin(), r.end(), greater<>());

    ll s = 0;
    for (int i = 0; i < x + y; i++) {
        s += r[i];
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 2304
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef string str;
typedef std::pair<ll,ll> pl;
typedef std::map<string, ll> msl;
typedef std::map<ll, ll> mll;
typedef std::vector<ll> vl;
const long double EPS = 1e-9;
 
#define rep(i, n) for(ll (i) = 0; (i) < (n) ; (i)++ )
#define For(i, a, b) for(ll (i) = (a); (i) < (b) ; (i)++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tol(c) char((c)+0x20)
#define tou(c) char((c)-0x20)
#define pb push_back
#define mp make_pair
#define pr(a) cout << (a)
#define prl(a) cout << (a) << endl
#define prl2(a,b) cout << (a) << " " << (b) << endl
#define prs(a) cout << (a) << " "
#define yn(condition) if ((condition)) prl("Yes"); else prl("No");
#define YN(condition) if ((condition)) prl("YES"); else prl("NO");
#define rpr(i,n,ans) rep((i),(n)) prs((ans[(i)]))
#define cpr(i,n,ans) rep((i),(n)) prl((ans[(i)]))
#define in1(a) cin >> (a)
#define in2(a,b) cin >> (a) >> (b)
#define in3(a,b,c) cin >> (a) >> (b) >> (c)
#define in4(a,b,c,d) cin >> (a) >> (b) >> (c) >> (d)
#define rin1(i,n,a) rep((i),(n)) cin >> (a[(i)])
#define rin2(i,n,a,b) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)])
#define rin3(i,n,a,b,c) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)]) >> (c[(i)])
#define e1 first
#define e2 second
#define ctol(c) ll((c)) - ll('0')
#define ltos(n) to_string((n))
#define items(kv, v) for(auto &(kv): (v))
#define ndig(N, n) ctol(ll(ltos((N))[ll(ltos((N)).length()) - (n)]))
#define beto(a,b,c) (a) < (b) && (b) < (c)
#define betc(a,b,c) (a) <= (b) && (b) <= (c)
#define rsort(a,n) sort(a,a+n,greater<>())
 
const ll mod = 1e9 + 7;
const ll INF = mod * mod;
const ll MAX_N = 100;
 
int main(void){
    ll a,b,c;
    str s,t,u;

    in3(a,b,c);
    yn(a == b + c || b == a + c || c == b + a);

    return 0;
}

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

int	main()
{
	int N;
	int	A;
	bool	non_decreasing = true;
	bool	non_increasing = true;
	int	cnt = 1;
	int	prev_A;
	cin >> N >> prev_A;
	for (int i = 1; i < N; ++i) {
		cin >> A;
		if (prev_A < A && non_increasing)
			non_increasing = false;
		if (prev_A > A && non_decreasing)
			non_decreasing = false;
		if (!non_increasing && !non_decreasing) {
			++cnt;
			non_increasing = true;
			non_decreasing = true;
		}
		prev_A = A;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var N, K int
	var S string

	fmt.Scanln(&N, &K)
	fmt.Scanln(&S)

	fmt.Println(S[0:K-1] + strings.ToLower(string(S[K-1])) + S[K:])
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
  int tramp[13][4]={0};//S=[x][0] H=[x][1] C=[x][2] D=[x][3]
  int n,i,num;
  char pic;
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    scanf("\n%c %d",&pic,&num);//改行も含まないと値がおかしくなる
    switch(pic){
    case 'S':tramp[num-1][0]=1;break;
    case 'H':tramp[num-1][1]=1;break;
    case 'C':tramp[num-1][2]=1;break;
    case 'D':tramp[num-1][3]=1;break;
    default:break;
    }
  }
  for(i=0;i<4;i++){
    for(n=0;n<13;n++){
      if(tramp[n][i] == 0){
	switch(i){
	case 0:printf("S %d\n",n+1);break;
	case 1:printf("H %d\n",n+1);break;
	case 2:printf("C %d\n",n+1);break;
	case 3:printf("D %d\n",n+1);break;
	default:break;
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 596
# use strict;
for ($n=<>;$n--;){
    @a=glob<>;
    $dt=abs($a[0]-$t);
    $dx=abs($a[1]-$x);
    $dy=abs($a[2]-$y);
    if ($dx+$dy>$dt || ($dt-$dx-$dy)%2) {
        print "No";
        exit;
    }
    $t = $a[0];
    $x = $a[1];
    $y = $a[2];
}
print "Yes"

Measured memory_bytes: 58232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+100;

ll qpow(ll x,ll n,int mod)
{
    ll sum=1;
    while(n){
        if(n&1) sum=sum*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return sum;
}

int ans(int x)
{
    if(x==0) return 0;
    int kk=__builtin_popcount(x);
    return 1+ans(x%kk);
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n;cin>>n;
    string s;cin>>s;
    int one=0;
    for(int i=0;i<n;i++){
        if(s[i]=='1') one++;
    }
    int p1=0,p2=0;
    for(int i=0;i<n;i++){
        if(one!=1){
            p1=(p1*2+s[i]-'0')%(one-1);
        }
        p2=(p2*2+s[i]-'0')%(one+1);
    }
    for(int i=0;i<n;i++){
        if((s[i]=='1'&&one==1)){
            cout<<0<<endl;
        }
        else if(s[i]=='1'){
            cout<<1+ans((p1-qpow(2,n-i-1,one-1)+(one-1))%(one-1))<<endl;
        }
        else if(s[i]=='0'){
            cout<<1+ans((p2+qpow(2,n-i-1,one+1)+(one+1))%(one+1))<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3708
#include <stdio.h>

int main(){
    
    int W,H,x,y,r,e=1;
    
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    
    e = (x-r>=0)?e:0;
    e = (y-r>=0)?e:0;
    e = (x+r<=W)?e:0;
    e = (y+r<=H)?e:0;
    
    printf("%s\n",(e)?"Yes":"No");
    
    return 0;
}

Measured memory_bytes: 2684
import java.awt.geom.Point2D;
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	int DP(int n,int st[][],int ed[][]){
		int xy[][] = new int [n+1][n+1];
		for(int i = 2;i < n+1;i++){
			for(int j = 2;j < i+1;j++){
				int cnt = 0;
				for(int k = 1;k < j;k++){
					if(k == 1){
						xy[i][j] = st[i-k][j-k]*ed[i-k][j-k]*st[i][k]*ed[i][k]+xy[i-k][j-k]+xy[i][k];
					}else{
						cnt = st[i-k][j-k]*ed[i-k][j-k]*st[i][k]*ed[i][k]+xy[i-k][j-k]+xy[i][k];
						if(xy[i][j] > cnt) xy[i][j] = cnt;
					}
				}
			}
		}
		/*
		for(int k = 1;k < n+1;k++){
			for(int l = 1;l < n+1;l++){
				System.out.print(xy[k][l]+" ");
			}
			System.out.println();
		}
		*/
		return xy[n][n];
	}
	void doIt() { 
		int n = sc.nextInt();
		int st[][] = new int [n+1][n+1];
		int ed[][] = new int [n+1][n+1];
		for(int i = 1;i < n+1;i++){
			st[i][1] = sc.nextInt();
			ed[i][1] = sc.nextInt();
		}
		for(int i = 2;i < n+1;i++){
			for(int j = i;j < n+1;j++){
				st[j][i] = st[j-1][i-1];
				ed[j][i] = ed[j][i-1];
			}
		}
		//確認
		/*
		for(int i = 1;i < n+1;i++){
			for(int j = 1;j < n+1;j++){
				System.out.print(st[i][j]);
				//System.out.print(ed[i][j]);
			}
			System.out.println();
		}
		*/
		System.out.println(DP(n, st, ed));
     }
    public static void main(String[] args) {
    	// TODO Auto-generated method stub
    	new Main().doIt();
    }
}

Measured memory_bytes: 21116
/*
**    author : dhiraj govindvira
**      date : 20-Sep-2020 ~ Sunday
**      time : 10:16:42 AM
*/

#ifdef Dhiraj
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define cerr if(0) cerr
#endif

// Macro --------------------------------------------------------------------

#define ll                  long long int
#define FOR(i, a, b, s)     for(ll i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define FOR1(b)             FOR(i, 0, b, 1)
#define FOR2(i, b)          FOR(i, 0, b, 1)
#define FOR3(i, a, b)       FOR(i, a, b, (a) <= (b) ? 1 :-1)
#define FOR4(i, a, b, s)    FOR(i, a, b, s)
#define GET5(a, b, c, d, e, ...) e
#define FORC(...)           GET5(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)
#define loop(...)           FORC(__VA_ARGS__)(__VA_ARGS__)
#define all(x)              (x).begin(), (x).end()
#define rall(x)             (x).rbegin(), (x).rend()
#define endl                '\n'

// Template -----------------------------------------------------------------

// multiple input
template <typename... T> 
inline void inp(T&... args) {
    ((cin >> args), ...);
}
// scan vector
template <typename T> 
inline istream& operator >>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream& operator >>(istream &in, pair<T, U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(int &T)
{
    ll n;
    cin >> n;

    vector<pair<ll, ll>> a(n);
    cin >> a;

    loop(i, n - 2)
    {
        int ok = 0;
        loop(j, 3) {
            ok += (a[i + j].first == a[i + j].second);
        }
        if(ok == 3) {
            cout << "Yes\n";
            return;
        }
    }
    cout << "No\n";
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt", "r", stdin);
        freopen("D:/dhiraj/Programming/o1.txt", "w", stdout);
        // freopen("D:/dhiraj/Programming/e1.txt", "w", stderr);
    #endif

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

    int t = 1;
    for(int i = 1; i <= t; i++) {
        cerr << "Case #" << i << "\n";
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
int lcm(int a, int b){
  return a / gcd(a,b) * b;
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int main(){
  int h,n; cin >> h >> n;
  vector<int> dp(h+1,INF);
  dp[0] = 0;
  rep(i,n){
    int a,b; cin >> a >> b;
    rep(j,h){
      int nj = min(j+a,h);
      dp[nj] = min(dp[nj],dp[j]+b);
    }
  }
  cout << dp[h] << endl;
  
  return 0;
}

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

typedef long long LL;
const int N = 1e5 + 5;

int a[N << 1], n;

inline bool judge(int x) {
  if (a[n] <= x && (a[n + 1] <= x || a[n - 1] <= x)) return 0;
  if (a[n] > x && (a[n + 1] > x || a[n - 1] > x)) return 1;
  int L = 0, R = 0;
  for (int i = n; i > 1; i --)
    if ((a[i] <= x) == (a[i - 1] <= x)) {L = i; break;}
  for (int i = n; i < (n << 1) - 1; i ++)
    if ((a[i] <= x) == (a[i + 1] <= x)) {R = i; break;}
  if (!L && !R) return a[1] > x;
  else if (L) {
    if (R) {
      if ((a[L] <= x) == (a[R] <= x)) return a[L] > x;
      if (n - L < R - n) return a[L] > x;
      else return a[R] > x;
    }
    else return a[L] > x;
  }
  else return a[R] > x;
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i < (n << 1); i ++) scanf("%d", &a[i]);
  int l = 1, r = (n << 1) - 1, ans = 0, k, mid;
  while (l <= r) {
    mid = (l + r) >> 1;
    k = judge(mid);
    if (!k) ans = mid, r = mid - 1;
    else l = mid + 1;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
temp=-100
for i in range(n):
    num=a[i]
    ans+=b[num-1]
    if(num==temp+1):
        ans+=c[temp-1]
    temp=num
print(ans)



Measured memory_bytes: 3064
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int N, K;
	cin >> N >> K;

	int A[200200];
	rep(i, N) cin >> A[i];

	rep(p, min(K, 100)) {
		int B[200200] = {};
		rep(i, N) {
			B[max(0, i - A[i])]++;
			B[min(N, i + A[i] + 1)]--;
		}
		rep(i, N) {
			B[i + 1] += B[i];
		}
		rep(i, N) A[i] = B[i];
	}

	rep(i, N) cosp(A[i]);




	Would you please return 0;
}

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

int main() {
	int n;
	cin>>n;
	vector<int> v(n), c(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	for(int i=0;i<n;i++){
		cin>>c[i];
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		if(v[i]>c[i]){
			ans += (v[i]-c[i]);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fo(i,x,y) for(int i=x;i<=y;i++)
#define fd(i,x,y) for(int i=x;i>=y;i--)
using namespace std;

const int maxn=500007;

int n,Q,D,a[maxn],Low[maxn],Cur[maxn];

int main(){
	scanf("%d%d",&n,&D);
	Cur[0]=D;
	fo(i,1,n){
		scanf("%d",&a[i]);
		Cur[i]=min(Cur[i-1],abs(Cur[i-1]-a[i]));
	}
	Low[n+1]=1;
	fd(i,n,1){
		if (Low[i+1]*2<=a[i]) Low[i]=Low[i+1];
		else Low[i]=Low[i+1]+a[i];
	}
	scanf("%d",&Q);
	fo(i,1,Q){
		int Now;
		scanf("%d",&Now);
		if (Cur[Now-1]>=Low[Now+1]) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 7808
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;
#define ll long long
#define INF (int)(1e9+5)
#define MOD (int)(1e9 + 7) 
#define pi 3.14159265

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int len, n;
    cin >> len >> n;
    vector<int> arr(n);
    for(int &i : arr) cin >> i;
    vector<int> res;
    for(int i = 0; i < n - 1; ++i) {
        res.push_back(arr[i+1] - arr[i]);
    }
    res.push_back(len - arr[n-1] + arr[0]);
    sort(res.begin(), res.end());
    int ans = 0;
    for(int i = 0; i < n - 1; ++i) {
        ans += res[i];
    }
    cout << ans << '\n';
    return 0;
}



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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
template<class T> lint gcd(T a, T b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T> lint lcm(T a, T b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

template<class T, class Q> inline bool chmin(T& a, Q b) {
    if (a > b) { 
        a = b;
        return true; 
    }
    return false;
}

template<class T, class Q> inline bool chmax(T& a, Q b) {
    if (a < b) { 
        a = b; 
        return true; 
    }
    return false;
}

// 定数 //
#define pi acos(-1)
#define mod 1000000007
#define MOD 998244353
#define inf ((1LL << 62) - 1 + (1LL << 62))

// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
        
    int N, X, Y;
    cin >> N >> X >> Y;
    vvi graph(N);
    graph[X - 1].push_back(Y - 1);
    graph[Y - 1].push_back(X - 1);
    
    rep(i, N - 1) {
        graph[i].push_back(i + 1);
        graph[i + 1].push_back(i);
    }
    queue<int> seen;

    vi dist(N, -1);
    vi cnt(N, 0);
    
    rep(i, N) {
        seen.push(i);
        dist[i] = 0;
        while (seen.size()) {
            int v = seen.front(); seen.pop();
            for (auto x : graph[v]) {
                if (dist[x] != -1) continue;
                seen.push(x); dist[x] = dist[v] + 1;
                cnt[dist[x] - 1]++;
            }
        }
        dist.assign(N, -1);
    }
    rep(i, N - 1) {
        cou(cnt[i] / 2);
    }

}

Measured memory_bytes: 384
from collections import defaultdict
N=int(input())
def prime_factor(n):
    i = 2
    table = defaultdict(int)
    while i * i <= n:
        while n % i == 0:
            n //= i
            table[i]+=1
        i += 1
    if n > 1:
        table[n]+=1
    return table
table=prime_factor(N)

s=str(N)+":"
for i,j in table.items():
    for _ in range(j):
        s+=" "+str(i)
print(s)



Measured memory_bytes: 6000
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

visited = [False]*n
i = 0
ans=0
f = False
while visited[i]==False:
    if i == 1:
        print(ans)
        f = True
        break
    ans+=1
    visited[i]=True
    i = a[i]-1
if not f:
    print(-1)

Measured memory_bytes: 7852
#include <stdio.h>
int find(void);
int Thenumber(int);

int w[100000],n,k;

int main(void){
  int i;
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++)
    scanf("%d",&w[i]);
  printf("%d\n",find());
  return 0;
}

int find(){
  int left,right,mid,quantity;
  left=0;
  right=1000000000;//Max Quantity_total(100000*10000)最大積載量
  while(right-left>1){
    mid=(right+left)/2;
    quantity=Thenumber(mid);
    if(quantity>n)right=mid;
    else left=mid;
    if(quantity==n)return mid;
  }
  return right;
}

//midで積める荷物の個数(per k)
int Thenumber(int mid){
  int i,j,sum;
  for(i=0,j=0;j<k;j++){
    sum=0;
    while(sum+w[i]<=mid){
      sum+=w[i];
      if(++i==n)return ++i;
    }
  }
  return i;
}


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

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

  int Q;
  cin >> Q;

  deque<char> ans;
  for (char c : S) ans.push_back(c);

  bool reversed = false;
  rep(i,0,Q-1) {
    int t;
    cin >> t;

    if (t == 1) reversed = !reversed;
    else {
      int f; char C;
      cin >> f >> C;

      if (reversed) {
        if (f == 1) ans.push_back(C);
        else ans.push_front(C);
      } else {
        if (f == 1) ans.push_front(C);
        else ans.push_back(C);
      }
    }
  }

  auto print = [](const char& n) { cout << n; };

  if (reversed) {
    for_each(ans.rbegin(), ans.rend(), print);
  } else {
    for_each(ans.begin(), ans.end(), print);
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 4028
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int r = parseInt(sc.next());
		sc.close();
		out.println(r*r*3);
	}
}


Measured memory_bytes: 23124
#include<stdio.h>
int main()
{
    char a,b;
    scanf("%c %c",&a,&b);
    if(a=='H'){
        if(b=='H')printf("H");
        if(b=='D')printf("D");
    }
    if(a=='D'){
        if(b=='H')printf("D");
        if(b=='D')printf("H");
    }
    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++){
        for (int j = 1; j <= 9; j++){
            if (n == i * j){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;

int main() {

    ll N;
    cin >> N;
    vector<ll> A(N);
    int count = 0;
    REP(i, N){
        cin >> A[i];
    }
    ll ans = A[0];
    REP1(i, N){
        ans = __gcd(ans, A[i]);        
    }
    cout << ans << endl;


}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (1) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
}


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

set<int> divisors(int n)
{
    set<int> res;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            int q = n / i;
            res.insert(i);
            res.insert(q);
        }
    }
    return res;
}

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

    vector<int> res;
    vector<int> cnt(N);
    for (int i = N; i > 0; i--)
    {
        if (cnt.at(i - 1) % 2 != a.at(i - 1))
        {
            res.push_back(i);
            for (auto &&j : divisors(i))
            {
                cnt.at(j - 1)++;
            }
        }
    }

    cout << res.size() << endl;
    for (auto &&i : res)
    {
        cout << i << " ";
    }
    cout << endl;
}

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

const int MAXN = 100010;
int nxt[MAXN][2], end[MAXN], dep[MAXN], idx = 1;
char buf[MAXN];
typedef long long LL;
LL get(LL x) { return x ? 1 << __builtin_ctzll(x) : 0; }
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	int n; LL L; std::cin >> n >> L;
	while (n --> 0) {
		std::cin >> buf; char * cur = buf;
		int now = 1;
		while (*cur) {
			int & nt = nxt[now][*cur++ - '0'];
			if (!nt) dep[nt = ++idx] = dep[now] + 1;
			now = nt;
		}
		end[now] = true;
	}
	LL ans = 0;
	for (int i = 1; i <= idx; ++i) if (!end[i])
		for (int j = 0; j != 2; ++j) if (!nxt[i][j])
			ans ^= get(L - dep[i]);
	std::cout << (ans ? "Alice" : "Bob") << std::endl;
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
typedef long long ll;
typedef long double ld;

int main(){
    ll ans = 0;
    ll N ,M;
    cin >> N;
    vector<string> S(N);
    ll cnt_AC = 0;
    ll cnt_WA = 0;
    ll cnt_TLE = 0;
    ll cnt_RE = 0;
    for(int i = 0; i < N; i++){
        cin >> S[i];
        if(S[i] == "AC") cnt_AC++;
        if(S[i] == "WA") cnt_WA++;
        if(S[i] == "TLE") cnt_TLE++;
        if(S[i] == "RE") cnt_RE++;
    } 

    cout << "AC x " << cnt_AC << endl;
    cout << "WA x " << cnt_WA << endl;
    cout << "TLE x " << cnt_TLE << endl;
    cout << "RE x " << cnt_RE << endl;
}

Measured memory_bytes: 6424
#include<bits//stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;
ll h, m, n;
ll sum = 0;
int main() {
    cin >> n; vector<int> k(n);
    rep(i, n) {
        ll a, b;cin >> a >> b;
        sum += b;
        k[i] = a + b;
    }
    sort(k.rbegin(),k.rend());
    ll ans = 0;
    for (int i = 0; i < n; i += 2) {
        ans += k[i];
    }
    cout << ans - sum << endl;
}

Measured memory_bytes: 640
A, B = [int(x) for x in input().split()]
S = input()

ans = True
for i in range(len(S)):
    if i == A:
        if S[i] != "-":
            ans = False
            break
    else:
        if S[i] == "-":
            ans = False
            break

print("Yes" if ans else "No")


Measured memory_bytes: 2940
k=int(input())

a=[]
judge=0
a.append("")
a.append(7%k)
for i in range(2,10**6+1):
    a.append((a[i-1]*10+7)%k)
for i in range(1,10**6+1):
    if a[i]==0:
        print(i)
        judge=1
        break
if judge==0:
    print(-1)

Measured memory_bytes: 48556
/*
*/
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<cmath>
#define M 404
#define ll long long
using namespace std;

int read() {
	int nm = 0, f = 1;
	char c = getchar();
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) nm = nm * 10 + c - '0';
	return nm * f;
}
char s[M][M];
int vis[M][M], cor;
int f[M][M], b[M][M];
int n, m, tot1, tot2;
ll ans = 0;

void dfs(int x, int y, int c) {
	if(x > n || x < 1 || y > m || y < 1) return;
	if(f[x][y] != c) return;
	if(vis[x][y]) return;	
	vis[x][y] = 1;
	if(b[x][y]) tot1++;
	else tot2++;
	dfs(x + 1, y, c);
	dfs(x - 1, y, c);
	dfs(x, y + 1, c);
	dfs(x, y - 1, c);
}

int main() {
	//freopen(".in", "r", stdin), freopen(".out", "w", stdout);
	n = read(), m = read();
	for(int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			if(s[i][j] == '#') b[i][j] = 1, f[i][j] = 1;
			if((i + j) & 1) f[i][j] = !f[i][j];
		}
	}
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			if(!vis[i][j]) {
				tot1 = 0, tot2 = 0;
				dfs(i, j, f[i][j]);
				ans += 1ll * tot1 * tot2;
			}
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 12288