akhauriyash/Code-Regression huggingface dataset:
N=int(input())

def divisors(N):
    result = 1e12
    for i in range(2, N):
        if i**2>N:
            break
        if N%i==0:
            B=int(N/i)
            tmp = max(len(str(B)), len(str(i)))
            result = min(result, tmp)
    # 自身でしか割れない
    if result==1e12:
        result = len(str(N))
    return result

print(divisors(N))


Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,j,n) for(int i = (int)(j); i < (int)(n); i++)
#define mrep(i,n) for (int i = (int)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20)
ll INF = 1LL << 60;
ll mod = 1e9 + 7;
ll modn = 998244353;

int main() {
	int n; cin >> n;
	int ac=0,wa=0,tle=0,re=0;
	rep(i,n) {
		string s; cin >> s;
		if(s=="AC") ac++;
		else if(s=="WA") wa++;
		else if(s=="TLE") tle++;
		else re++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
	public static void main(String[] args) {
		ALDS1_3_B();
	}

	public static void ALDS1_3_B() {

		class Pair{
			private String name;
			private int time;
			
			public Pair(String name, int time) {
				this.name = name;
				this.time = time;
			}

			String getName(){
				return this.name;
			}

			int getTime(){
				return this.time;
			}
		}

		Scanner sc = new Scanner(System.in);
		Queue<Pair> que = new LinkedList<Pair>();
		int n = sc.nextInt();
		int q = sc.nextInt();
		String[] name = new String[n];
		int[] time = new int[n];
		int[] timeAns = new int[n];
		int ans = 0;
		Arrays.fill(timeAns, 0);
		for(int i = 0; i < n; i++) {
			name[i] = sc.next();
			time[i] = sc.nextInt();
			Pair pair = new Pair(name[i], time[i]);
			que.add(pair);
		}

		Pair pair;
		while((pair = que.poll()) != null) {
			if(pair.getTime() - q > 0) {
				Pair tmp = new Pair(pair.getName(), pair.getTime() - q);
				que.add(tmp);
				ans += q;
			}else {
				System.out.println(pair.getName() + " " + (pair.getTime() + ans));
				ans += pair.getTime();
			}
		}
	}
	
}



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

struct Unionfind {
	vector<int> data;

	Unionfind(int n) { data.assign(n, -1); }

	int root(int n) {
		if (data[n] < 0) return (n);
		return (data[n] = root(data[n]));
	}

	int size(int n) { return (-data[root(n)]); };
	bool same(int x, int y) { return (root(x) == root(y)); }

	void unite(int x, int y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
	}
};

int main() {
	int n, q;
	cin >> n >> q;
	Unionfind tree(n);
	for (int i = 0; i < q; i++) {
		int c, x, y;
		cin >> c >> x >> y;
		if (c == 0) tree.unite(x, y);
		else cout << tree.same(x, y) << endl;
	}
	return (0);
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

int MAX = 1000010;

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

    string ans;
    while(n) {
        --n;
        ans += (n%26)+'a';
        n/=26;
    }
    reverse(all(ans));

    cout << ans << endl;

    return 0;
}


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

int main(){
    long A, B;
    cin >> A >> B;
    long C = min(A, B);
    long D = max(A, B);
    for(int i = 1;i <= D;i++){
        if(C * i % D == 0){
            cout << C * i << endl;
            break;
        }
        else{
            continue;
        }
    }
}

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

ab = [[a[i], b[i]] for i in range(n)]
ab.sort(key=lambda x:x[1])

a = [ab[i][0] for i in range(n)]
b = [ab[i][1] for i in range(n)]

a2 = [[a[i], i] for i in range(n)]
a2.sort(key=lambda x:x[0])

flag1 = 0
for i in range(n):
    if a2[i][0] > b[i]:
        flag1 = 1

flag2 = 1
idx = a2[0][1]
cnt = 0
while idx != 0:
    idx = a2[idx][1]
    cnt += 1

if cnt == n-1:
    for i in range(n-1):
        if a2[i+1][0] <= b[i]:
            flag2=0
            break
else:
    flag2 = 0

if flag1 == 1 or flag2 == 1:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 36136
n = int(input())
a = [0]*n
h = list(map(int,input().split()))
ans = 0
for i in range(1,n):
    if h[i]<=h[i-1]: a[i] = a[i-1]+1
    else:
        a[i]=0
        ans = max(ans,a[i-1])
ans = max(ans,a[n-1])
print(ans)

Measured memory_bytes: 15788
from math import gcd
k = int(input())
ans = 0
for a in range(1,k+1):
  for b in range(a,k+1):
    ab = gcd(a,b)
    for c in range(b,k+1):
      g = gcd(ab,c)
      if a == b == c:
        ans += g
      elif a != b !=c != a:
        ans += g*6
      else:
        ans += g*3
print(ans)



Measured memory_bytes: 9188
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, N, K, p[200001];
	scanf("%d %d", &N, &K);
	for (i = 1; i <= N; i++) scanf("%d", &(p[i]));
	
	int j;
	long long max = 0, sum[200001] = {};
	for (i = 1; i <= K; i++) sum[1] += p[i] + 1;
	max = sum[1];
	for (i = 2; i <= N - K + 1; i++) {
		sum[i] = sum[i-1] + p[K+i-1] - p[i-1];
		if (sum[i] > max) max = sum[i];
	}
	
	printf("%f\n", (double)max / 2);
	fflush(stdout);
	return 0;
}

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

using namespace std;

#define IMP "Impossible"
#define POS "Possible"

int a[1234567];

int main() {
  int n;
  scanf("%d", &n);
  int d = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    d = max(d, a[i]);
  }
  multiset <int> s;
  for (int i = 0; i < n; i++) {
    s.insert(a[i]);
  }
  int lowest = d + 1;
  for (int i = 0; i <= d; i++) {
    int cur = max(i, d - i);
    if (s.find(cur) == s.end()) {
      puts(IMP);
      return 0;
    }
    s.erase(s.find(cur));
    lowest = min(lowest, cur);
  }
  if (!s.empty() && *(s.begin()) <= lowest) {
    puts(IMP);
  } else {
    puts(POS);
  }
  return 0;
}


Measured memory_bytes: 256
X, N = map(int, input().split())
p = list(map(int, input().split()))
p = sorted(p)

if X not in p:
    print(X)


else:
    c = list(set([i for i in range(102)]) ^ set(p))
    c_x = [abs(c_-X) for c_ in c]
    print(c[c_x.index(min(c_x))])




Measured memory_bytes: 9208
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>


using namespace std;


int main(void)
{
	vector<char> s(100+2);

	while(scanf("%100[a-z]\n", &s[0])==1)
	{
		int l=strlen(&s[0]);
		vector<char> t(l+1), t_(l+1);
		int c, ans, i;

		ans=l;
		for(i=0;i<l;i++)
		{
			if(s[i]!=s[0]) break;
		}
		if(i==l) ans=0;

		t=s;
		for(int i=0;i<l;i++)
		{
			int x=s[i];
			t_=s;
			for(int l_=l;l_>1;l_--)
			{
				c=0;
				t=t_;
				for(int j=0;j<l_-1;j++)
				{
					if(t[j]==x)
					{
						t_[j]=x;
						c++;
					}
					else if(t[j+1]==x)
					{
						t_[j]=x;
						c++;
					}
					else
					{
						t_[j]=t[j];
					}
				}
				t[l_-1]='\0';
				if(c>=l_-1)
				{
					ans=min(ans, l-l_+1);
					break;
				}
			}
		}
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Map<String, Integer> map = new HashMap<String, Integer>();
        
        int N = Integer.parseInt(sc.next());
        
        for(int n=0; n<N; n++){
            String s = sc.next();
            if(map.get(s) == null){
                map.put(s, 1);
            }else{
                map.put(s, map.get(s) + 1);
            }
        }
        
        int M = Integer.parseInt(sc.next());
        for(int m=0; m<M; m++){
            String t = sc.next();
            if(map.get(t) == null){
                map.put(t, -1);
            }else{
                map.put(t, map.get(t) -1);
            }
        }
        
        int answer = 0;
        for(String key : map.keySet()){
            int value = map.get(key);
            if(value > answer){
                answer = value;
            }
        }
        
        System.out.println(answer);
    }
}

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

int main(){
    int K,X;
    int MIN = -1000000, MAX= 1000000;
    cin >> K >> X;

    for (int i=(K-1); i >= 0; i--){
        if (X-i <= MIN) continue;
        cout << X-i << " "; 
    }
    for (int j=1; j< K; j++){
        if (X+j >= MAX) continue;
        cout << X+j << " "; 
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}
        static void myerr(Object t){System.err.println(t);}
        static String getStr(){return sc.next();}
        static int getInt(){return sc.nextInt();}
        static Long getLong(){return sc.nextLong();}
        static boolean isNext(){return sc.hasNext();}
        static char[] splitSingle(String str){return str.toCharArray();}
        public static void main(String[] args){
          long A = getLong();
          long B = getLong();
          long C = getLong();
          if(A % 2 == 0 || B % 2 == 0  || C % 2 == 0){
            myout(0);
            return;
          }else{
            myout(Math.min(A*B,Math.min(A*C,B*C)));
          }
          
        }
        //便利メソッド追加枠ここから

        //便利メソッド追加枠ここまで
}


Measured memory_bytes: 23252
import numpy as np

n,k = map(int, input().split())

cnt = np.array(list([0]*n))

for _ in range(k):
    d = int(input())
    a = np.array(list(map(int, input().split())))
    for i in a:
        cnt[i-1] += 1

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

Measured memory_bytes: 27228
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i;
  cin>>n;
  int a[n];
  int b[n];
  int c[n-1];
 
  for(i=1;i<=n;i++)
    cin>>a[i];
  for(i=1;i<=n;i++)
    cin>>b[i];
  for(i=1;i<=n-1;i++)
    cin>>c[i];
  int ans=b[a[1]];
  
  for(i=2;i<=n;i++)
  {
    if(a[i]!=(a[i-1]+1))
    {
       ans=ans+b[a[i]];
    }
    else
    {
       ans=ans+b[a[i]]+c[a[i-1]];
    }
  }
  cout<<ans<<endl;
  
  return 0;
  
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

#define MAX 410
int H,W;
string s[MAX];
int par[MAX*MAX];

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

void unite(int x,int y) {
  x = find(x), y = find(y);
  if( x != y ) par[x] = y;
}

bool used[MAX][MAX];
int d[] = {0,1,0,-1};

void dfs(int x,int y) {
  int col = ( s[y][x] == '.' );
  rep(i,4) {
    int nx = x + d[i], ny = y + d[(i+1)%4];
    if( !( 0 <= nx && nx < W && 0 <= ny && ny < H ) ) continue;
    int ncol = ( s[ny][nx] == '.' );
    if( col == ncol ) continue;
    unite(x+y*W,nx+ny*W);
    if( used[ny][nx] ) continue;
    used[ny][nx] = true;
    dfs(nx,ny);
  }
}

const bool debug = 0;

void compute() {
  rep(i,(H*W)) par[i] = i;
  rep(i,H) {
    rep(j,W) {
      if( !used[i][j] ) {
	used[i][j] = true;
	dfs(j,i);
      }
    }
  }
  if( debug ) {
    rep(i,H) {
      rep(j,W) {
	cout << find(j+i*W) << " ";
      } puts("");
    }puts("");
  }
  map<int,int> mp[2];
  rep(i,H) {
    rep(j,W) {
      int col = ( s[i][j] == '.' );
      ++mp[col][find(j+i*W)];
    }
  }
  ll ans = 0;
  for(auto v : mp[0]) {
    int id = v.first;
    ll cnt = v.second;
    ans += ( (ll)mp[1][id] * cnt );
  }
  cout << ans << endl;
}

int main() {
  cin >> H >> W;
  rep(i,H) cin >> s[i];
  compute();
  return 0;
}


Measured memory_bytes: 16256
#include <iostream>
using namespace std;
#define abs(x) ((x) < 0 ? -(x) : (x))
int main()
{
    int x, n, p, ans, abs_min = 99999;
    int q[201] = {};
    cin >> x >> n;
    for (int i = 0; i < n; i++) {
        cin >> p;
        q[p] = 1;
    }
    for (int j = -100; j <= 200; j++) {
        if ((j < 0 || q[j] == 0) && abs_min > abs(x-j)) {
            ans = j;
            abs_min = abs(x-j);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

int main(){
	int i,j,k,n,x;
	while(1){
		int count =0;
	scanf("%d %d",&n,&x);
	if(n==0 && x ==0){
		break;
	}
	for(i=1;i<=n;i++){
		for(j=i+1;j<=n;j++){
			for(k=j+1;k<=n;k++){
					if(i+j+k == x){
						count++;
					}
				}
			}
		}
	printf("%d\n",count);
	}
}

Measured memory_bytes: 1028
/*
   Creator - Glitched
   Yeet!!
*/
#include "bits/stdc++.h"

using namespace std;

#define testcases ll T;cin>>T;while(T--)
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define loopr(i,x,n) for(ll i=n-1;i>=x;i--)
#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<"\n"
#define mod 1000000007
#define L LONG_MAX
#define fastio ios_base::sync_with_stdio(false)
const string yes = "YES", no = "NO";

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

    cout<<floor(log(n)/log(k)) + 1;
    flush;
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <map>
#include <queue>
#include <string>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define inf (int)(1e9)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

ll n,a,b;
vector<ll> h;
bool enough(ll t){
  ll tmp=t;
  for(int i=0;i<h.size();i++){
    if(h[i]-b*t<=0) continue;
    tmp-=(h[i]-b*t + a-b-1)/(a-b);
  }
  if(tmp>=0) return true;
  return false;
}

int main(void){
  ll x;
  cin>>n>>a>>b;
  for(int i=1;i<=n;i++){
    cin>>x;
    h.pb(x);
  }
  sort(h.begin(),h.end());
  ll l,r,m;
  l=0;r=inf;
  while(l<r-1){
    m=(l+r)/2;
    //printf("%lld %lld : %lld %d\n",l,r,m,enough(m));
    if(enough(m)) r=m;
    else l=m;
  }
  
  cout<<r<<endl;
  return 0;
}


Measured memory_bytes: 1400
def main():
    from itertools import permutations

    n, m, r, *x = map(int, open(0).read().split())
    to = x[:r]

    dis = [[0 if i == j else float("Inf") for j in range(n + 1)] for i in range(n + 1)]

    for a, b, c in zip(*[iter(x[r:])] * 3):
        dis[a][b] = c
        dis[b][a] = c

    for k in range(1, n + 1):
        for i in range(1, n + 1):
            for j in range(1, n + 1):
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j])

    ans = float("Inf")
    for p in permutations(to):
        tmp = 0
        for nw, nx in zip(p, p[1:]):
            tmp += dis[nw][nx]
    
        ans = min(ans, tmp)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 83324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int prime[100001];
bool is_prime[100001];

void sieve(int n) {
  int p = 0;
  for (int i = 0; i <= n; i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= n; i++) {
    if (is_prime[i]) {
      prime[p++] = i;
      for (int j = 2*i; j <= n; j+= i) is_prime[j] = false;
    }
  }
}


int main() {
  sieve(100000);
  int num[100001];
  
  num[0] = 0;
  for (int i = 1; i <= 100000; i++) {
    if (is_prime[i] && is_prime[(i+1)/2]) {num[i] = num[i-1]+1;}
    else {num[i] = num[i-1];}
  }
  
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    cout << num[r] - num[l-1] << endl;
  }
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <cmath>
#include <utility>
#include <string>

using namespace std;

int main(){

    int X, A,B = 0;
    cin >> X >> A >> B;

    X = (X - A) % B;

    cout << X;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll mod_pow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1){
			res=res*x%MOD;
		}
		x=x*x%MOD;
		n>>=1;
	}
	return res;
}

ll extgcd(ll a,ll b,ll& x,ll& y){
	ll d=a;
	if(b!=0LL){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1;
		y=0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

ll fact[105]={1,682498929,491101308,76479948,723816384,67347853,27368307,625544428,199888908,888050723,927880474,281863274,661224977,623534362,970055531,261384175,195888993,66404266,547665832,109838563,933245637,724691727,368925948,268838846,136026497,112390913,135498044,217544623,419363534,500780548,668123525,128487469,30977140,522049725,309058615,386027524,189239124,148528617,940567523,917084264,429277690,996164327,358655417,568392357,780072518,462639908,275105629,909210595,99199382,703397904,733333339,97830135,608823837,256141983,141827977,696628828,637939935,811575797,848924691,131772368,724464507,272814771,326159309,456152084,903466878,92255682,769795511,373745190,606241871,825871994,957939114,435887178,852304035,663307737,375297772,217598709,624148346,671734977,624500515,748510389,203191898,423951674,629786193,672850561,814362881,823845496,116667533,256473217,627655552,245795606,586445753,172114298,193781724,778983779,83868974,315103615,965785236,492741665,377329025,847549272,698611116};

ll get_fact(ll x){
	if(x%10000000==0){
		return fact[x/10000000];
	}
	ll res=fact[x/10000000];
	for(ll i=(x/10000000)*10000000+1;i<=x;i++){
		res=res*i%MOD;
	}
	return res;
}

ll mod_fact(ll n,ll p,ll& e){
	e=0;
	if(n==0)return 1;
	ll res=mod_fact(n/p,p,e);
	e+=n/p;
	if(n/p%2!=0){
		return res*(p-get_fact(n%p))%p;
	}
	return res*get_fact(n%p)%p;
}

ll mod_comb(ll n,ll k,ll p){
	if(n<0 || k<0 || n<k)return 0;
	ll e1,e2,e3;
	ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
	if(e1>e2+e3)return 0;
	return a1*mod_inverse(a2*a3%p,p)%p;
}



int main(void){
	int n,a,b;
	/*
	ll fac=1;
	for(int i=1;i<=MOD;i++){
		fac=fac*i%MOD;
		if(i%10000000==0){
			printf("%lld,",fac);
		}
	}
	*/
	scanf("%d%d%d",&n,&a,&b);
	ll ans=mod_pow(2,n)-1LL;
	ans+=(MOD-mod_comb(n,a,MOD));
	ans+=(MOD-mod_comb(n,b,MOD));
	ans%=MOD;
	printf("%lld\n",ans);
	return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++)
  {
    cin >> p[i];
  }
  int cnt = 0;
  for (int i = 1; i < n - 1; i++)
  {
    if (p[i] > p[i - 1] and p[i] < p[i + 1] or p[i] < p[i - 1] and p[i] > p[i + 1])
      cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main()
{
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if ((x >= r && x <= W - r) && (y >= r && y <= H - r))
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}



Measured memory_bytes: 3168
#include<stdio.h>
int main(){
  int A,B,C;
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&C);
  if(A*B<=C){
    printf("%d\n",A*B);
  }else{
    printf("%d\n",C);
  }
  return 0;
}
    

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
#define MAX_N 40
int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> A(N), sum(N+1);
  rep(i, N) {
    cin >> A[i];
    sum[i+1] = sum[i] + A[i];
  }
  vector<ll> B;
  rep(l, N+1) REP(r, l+1, N+1) B.push_back(sum[r]-sum[l]);
  int M = B.size();
  vector<vector<int>> D(M, vector<int>(MAX_N));
  rep(k, MAX_N) {
    rep(i, M) {
      D[i][MAX_N-1-k] = (B[i]>>k)&1;
    }
  }
  vector<set<int>> vse(2);
  rep(i, M) vse[0].insert(i);
  ll ans = 0;
  ll pw = 1LL<<(MAX_N-1);
  int id = 1;
  rep(k, MAX_N) {
    vse[id].clear();
    for(int i: vse[1-id]) {
      if(D[i][k]) vse[id].insert(i);
    }
    if(vse[id].size() >= K) {
      ans += pw;
    } else {
      vse[id].clear();
      for(int i: vse[1-id]) vse[id].insert(i);
    }
    pw >>= 1;
    id = 1-id;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 148976
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  int count=0;
  vector<long long>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    if(A.at(i)%2==1){
      count++;
    }
  }
  if(count%2==0){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}
  


Measured memory_bytes: 4040
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
typedef long long ll;
 
  int a[200008];
  int v[200008];
 
int main(){
  ll k;
  int n;
  int i,j;
  int t;
  int sum1 = 0;
  int sum2 = 0;
  int now;
 
  scanf("%d %lld", &n, &k);
 
  for(i = 1;i <= 200000;i++) v[i] = 0;
 
  for(i = 1;i <= n;i++) scanf("%d", &a[i]);
 
  now = 1;
 
  while(1){
    if(v[now] == 1){
      t = now;
      break;
    }
 
    else{
      v[now] = 1;
      now = a[now];
      sum1++;
    }
  }

  if(k < sum1){
    now = 1;
    while(k){
      now = a[now];
      k--;
    }

    printf("%d\n", now);
    return 0;
  }
 
  now = 1;
  while(now != t){
    now = a[now];
    sum2++;
  }
 
  sum1 = sum1 - sum2;
 
  k = (k - sum2) % sum1;
 
  now = t;
  while(k > 0){
    now = a[now];
    k--;
  }
 
  printf("%d\n", now);
 
  return 0;
}

Measured memory_bytes: 3244
arr = list(map(str,input().split()))

stack = []
def push(x):
    stack.append(x)
    
def pop():
    popnum = stack[-1]
    stack = stack[:-1]
    return popnum

for i in range(len(arr)):

    if arr[i] == "+" or arr[i] == "-" or arr[i] == "*":
        a = stack[-1]
        b = stack[-2]
        if arr[i] == "+":
            c = a+b
        elif arr[i] == "-":
            c = b-a
        elif arr[i] == "*":
            c = a*b
        stack =stack[:-2]
        stack.append(c)
    
    else:
        push(int(arr[i]))

print(stack[-1])


Measured memory_bytes: 5600
function Main(input) {
  attack = (H) => {
    if (H === 1) {
      return 1;
    } else if (H % 2 === 1) {
      H--;
    }
    return attack(H / 2) * 2 + 1;
  }
  console.log(this.attack(Number(input.trim())))
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>
#define fr first
#define se second

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll A[N + 5];
ll B[N + 5];
 multiset<ll,greater<ll>> s;
int main()
{
  finp;
  ll ans = 0;
  ll inc = 0;
 
  ll n;
  cin>>n;
  afor(i,1,n)cin>>A[i];
  afor(i,1,n)cin>>B[i];

  afor(i,1,n)
  {
    if(A[i] < B[i])
    {
      ++ans;
      inc+= B[i] - A[i];
    }
    else if(A[i] > B[i])s.insert(A[i] - B[i]);
  }

  while(inc > 0)
  {
    if(!s.size())
    {
      cout<<"-1";
      return 0;
    }
    auto xx = s.begin();
    ll avl = *xx;
    ll tored = min(inc,avl);
    ++ans;
    inc-= tored;
    avl-= tored;

    if(avl <= 0)s.erase(xx);
  }

  cout<<ans;
return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll x;
	cin>>x;
	ll ans=x/11*2;
	ll r=x%11;
	if(r==0) cout<<ans<<endl;
	else if(r<=6) cout<<ans+1<<endl;
	else cout<<ans+2<<endl;
}

Measured memory_bytes: 256
// Problem : B - Minor Change
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
	int cnt=0;
string s,t;cin>>s>>t;
for(int i=0;s[i];i++)
if(s[i]!=t[i])
cnt++;
cout<<cnt;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3820
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n)-1;i>=(j);i--)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

int n;

int main(){
    cin>>n;
    vector<int> s(n);
    int sum=0;
    rep(i,0,n){
        cin>>s[i];
        sum+=s[i];
    }
    int ans=0;
    if(sum%10!=0) ans=sum;
    else{
        sort(s.begin(),s.end());
        rep(i,0,n){
            if(s[i]%10!=0){
                ans=sum-s[i];
                break;
            }
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;

    for(int i=0;i<S.size();i++){
        char c = S[i];
        if(char(c + N) > 'Z'){
            cout << char(c + N - 26);
        }else{
            cout << char(c + N);
        }
    }
    cout << endl;

}

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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::max;
use std::cmp::min;

fn main() {
    input!{
        n: usize,
        a: [usize; n],
    }
    let mut b = [0u32; 9];

    for i in 0..n {
        let m = a[i]/400;
        let p = min(m, 8);
        b[p] = b[p]+1;
    }

    let mut mi = 0;
    for i in 0..8 {
        if b[i] > 0 {
            mi = mi + 1;
        }
    }

    let mut ma = mi;
    mi = max(mi, 1);
    ma = ma + b[8];
    println!("{} {}", mi, ma);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
ll ncr(ll x, ll y) {
	ll ans = 1;
	for (ll i = 1; i <= y; ++i) {
		ans *= (x - y + i);
		ans /= i;
	}

	return ans;
}
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if (n > 1)
        result -= result / n;
    return result;
}
int main()
{
    fio;
    ll n;
    cin>>n;
    ll ans = 0;
    for(int i=1;i<=n;i++)
    {
        ans += ((n-1)/i);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3608
N = int(input())
M = [int(i) for i in input().split(" ")]
m = sorted(M)
count = 0
min = 1
if m[0]!=1:
  print(-1)
else:
  for j in range(N):
    if M[j]==min:
      min+=1
    else:
      count+=1
      M[j]=0
  print(count)

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

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

  vector<int64_t> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }
  sort(data.begin(), data.end());

  vector<int64_t> cumsum(N);
  int min_eater= 0;
  for(int i=0; i<N-1; i++){
    cumsum.at(i)= (i > 0) ? data.at(i)+ cumsum.at(i-1)
                          : data.at(i);

    if(2*cumsum.at(i) < data.at(i+1)){
      min_eater= i+1;
    }
  }

  int ans= N- min_eater;

  cout << ans << endl;
}

Measured memory_bytes: 4836
#include "bits/stdc++.h"
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define ll long long
#define ld long double
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
typedef pair<ll, ll> pll;
typedef vv<bool> vbool;
typedef vv<ll> vll;
typedef vv<ld> vld;
typedef vv<pll> vpll;
#ifdef LOCAL
#include "prettyprint.hpp"
#define LG(args...)                           \
{                                             \
	string _s = #args;                        \
	replace(_s.begin(), _s.end(), ',', ' ');  \
	stringstream _ss(_s);                     \
	err(istream_iterator<string>(_ss), args); \
	cerr << endl;                             \
}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
#define fastio
#else
#define LG(...)
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
#define endl "\n"
#endif
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;

ll modExp(ll b, ll p, ll m=MOD){
	if(m <=2)
		return b%m;
	p%= m-1;
	b%= m;
	ll ans=1;
	while(p > 0){
		if(p&1)
			ans = (ans*b)%m;
		b= (b*b)%m;
		p>>=1;
	}
	return ans;
}


int main(){
	fastio;
	ll n;
	cin>>n;
	cout<< (modExp(10, n) - 2*modExp(9, n) + modExp(8,n) +  2*MOD)%MOD;
}

Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
	ios::sync_with_stdio(false);
cin.tie(nullptr);
	int a,b;
	char op;
	scanf("%d %c %d",&a,&op,&b);
	//cout<<b<<endl;
	if(op=='+')
	{
		cout<<a+b<<'\n';
	}
	else
	{
		cout<<a-b<<'\n';
	}
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
#define rank __RANK
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
const int maxn = 2005;
const int mod = 1e9+7;
int f[maxn],n,k;
int main(){
	n = rd(),k = rd();
	mem(f,0);
	f[0] = 1;
	Rep(i,1,k){
		Rep(j,1,i-1) f[j]=0;
		Rep(j,i,n) f[j] = (f[j] + f[j-1]) % mod;
	}
	ll ans = f[n];
	Rep(i,1,n-k-1)ans=ans*2%mod;
	writeln(ans);
}


Measured memory_bytes: 256
using System;


namespace B_005_55
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            new Logic_A().Start();//OK

        }


        public class Logic_A
        {
            public void Start()
            {
                var N = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine(N * 800 - (N / 15) * 200);
            }
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const double PI = 3.14159265358979323846;

int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  bool flag = false;
  for(int i = 0; i <= x; i++) {
    for(int j = 0; j <= x; j++) {
      for(int k = 0; k <= x; k++) {
        int A = a * (1 << i);
        int B = b * (1 << j);
        int C = c * (1 << k);
        if(A < B && B < C && i + j + k <= x) flag = true;
      }
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}
    

Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,k,c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vec l(k),r(k);
  ll idk=0;
  for(ll i=0;i<n&&idk<k;i++) {
    if(s[i]=='o') {
      l[idk]=i;
      idk++;
      i+=c;
    }
  }
  idk--;
  for(ll i=n-1;i>-1&&idk>-1;i--) {
    if(s[i]=='o') {
      r[idk]=i;
      idk--;
      i-=c;
    }
  }
  for(ll i=0;i<k;i++) {
    if(l[i]==r[i]) cout << l[i]+1 << endl;
  }
}

Measured memory_bytes: 4996
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 1e9 + 7;
const int MX = 1000100;
ll dp[MX], s[MX];

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	dp[0] = 1;
	ll ans = 0;
	
	rep(i, n){
		(s[i + 1] += s[i]) %= mod;
		(dp[i] += s[i]) %= mod;
		(dp[i + 1] += dp[i]) %= mod;
		
		//for(int j = i + 3; j <= n; j++) (dp[j] += dp[i]) %= mod;
		(s[i + 3] += dp[i]) %= mod;
		
		if(i < n - 1){
			//for(int j = max(2, n - i); j <= n; j++) (ans += dp[i]) %= mod;
			(ans += dp[i] * max(0, n - max(2, n - i) + 1)) %= mod;
			
			
			(ans += (n - 1ll) * (n - 1) % mod * dp[i] % mod) %= mod;
		}
		else{
			(ans += (n - 1) * dp[i]) %= mod;
		}
	}
	(ans += dp[n] + s[n]) %= mod;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 15872
#include <cstdio>

using namespace std;

int main() {
    int a, b, c;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if (a == b && b == c) {
        puts("Yes");
    } else {
        puts("No");
    }
    
    return 0;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    string n;
    cin >> n;
    int ans = 0;
    for(int i=0;i<3;i++){
        if(n[i]=='1') {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector<char> A(3);
    for (int i = 0; i < 3; i++) {
        cin >> A.at(i);
    }
    int C = 0;
    int D = 0;
    for (int i = 0; i < 3; i++) {
        if (A.at(i) == '5') {
            C++;
        }
        else if (A.at(i) == '7') {
            D++;
        }
    }
    if (C == 2 && D == 1) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>


#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

const int cons = 1e9 + 7;

//D
int main(void) {
	vector<pair<ll, ll>> xy = vector<pair<ll, ll>>();
	vector<pair<ll, ll>> yx = vector<pair<ll, ll>>();

	int n, k;
	cin >> n >> k;
	rep(0, n) {
		ll x, y;
		cin >> x >> y;
		xy.push_back(make_pair(x, y));
		yx.push_back(make_pair(y, x));
	}
	sort(xy.begin(), xy.end());
	sort(yx.begin(), yx.end());

	unsigned ll ans = (xy[xy.size() - 1].first - xy[0].first) * (yx[yx.size() - 1].first - yx[0].first);
	
	for (int xl = 0; xl < n; xl++) {
		for (int xr = n - 1; xl < xr; xr--) {
			if (xy[xl].first >= xy[xr].first)break;

			for (int ybottom = 0; ybottom < n; ybottom++) {
				for (int ytop = n - 1; ybottom < ytop; ytop--) {
					if (yx[ytop].first <= yx[ybottom].first) break;

					int count = 0;
					rep(0, n) {
						pair<int, int> point = xy[i];
						if (xy[xl].first <= point.first && point.first <= xy[xr].first
							&& yx[ybottom].first <= point.second && point.second <= yx[ytop].first) {
							count++;
							if (count >= k) {
								unsigned ll area = (xy[xr].first - xy[xl].first) * (yx[ytop].first - yx[ybottom].first);
								if (area < ans)ans = area;
								break;
							}
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
}

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

int main(){
    //freopen("in.txt", "r", stdin);
    string s;
    int n, k;

    cin>>n>>k;
    cin>>s;

    for (int i=0;i<n;++i){
        if (i+1 == k) printf("%c", tolower(s[i]));
        else cout<<s[i];
    }
    cout<<endl;

    return 0;
}

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

std::vector<int> bitSum(30,0);

int main(){
    int N;
    std::cin >> N;
    std::vector<std::vector<int>> Bit (N,std::vector<int>(30,0));
    for(int i=0;i<N;i++){
        int a_i;
        std::cin >> a_i;
        for(int j=0;j<30;j++){
            if((1 & a_i >> j) == 1){
                Bit[i][j] ++ ;
                bitSum[j] ++ ;
            }
        }
    }

    for(int i=0;i<N;i++){
        int ans = 0;
        int reverseNum =0;
        for(int j=0;j<30;j++){
            if(Bit[i][j] == 1){
                reverseNum = N - bitSum[j];
            }else{
                reverseNum = bitSum[j];
            }
            if(reverseNum % 2 == 0){
                ans += ((Bit[i][j]) << j);
            }else{
                ans += ((Bit[i][j] ^ 1) << j);
            }
        }
        std::cout << ans << std::endl;
    }
    return 0;
}



Measured memory_bytes: 33008
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()

int main()
{
	int A, B;
	cin >> A >> B;
	int ans = max({ A + B, A - B, A*B });
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n,t = map(int,input().split())
list = [list(map(int,input().split())) for i in range(n)]

c = 2000
for i in list:
    if i[1] <= t and c > i[0]:
        c = i[0]
if c != 2000:
    print(c)
else:
    print("TLE")

Measured memory_bytes: 3060
#include "bits/stdc++.h"

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")



using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int res=0;
    char a,b,c,d,e,f;
    cin>>a>>b>>c;
    cin>>d>>e>>f;
    if(a==d)
        res++;
    if(b==e)
        res++;
    if(c==f)
        res++;
    cout<<res<<'\n';
    return 0;
}


Measured memory_bytes: 256
#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++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;

struct UnionFind{
    vector<int> data;
    //data[i] = -x ... iが根であり、サイズがx
    //data[i] = x ... iの親がx

    //最初は全員根
    UnionFind(int size): data(size,-1){}

    bool union_set(int x, int y){//サイズがx>yになるようにしてから、xにyをつなげる
        x=root(x);
        y=root(y);
        if(x != y){
            if(data[y] < data[x]) swap(x,y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find_set(int x, int y){//ルートが一致するかどうかを返す
        return root(x) == root(y);
    }
    int root(int x){//根を見つける。ついでに深さ2にしちゃう
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

int main() {
    int N,M; cin >> N >> M;
    UnionFind uf(N);
    REP(i,M){
        int a,b ;cin >> a >> b;
        uf.union_set(a,b);
    }
    int ans = 0;
    REP(i,N){
        if(uf.data[i] < 0){
            ans = max(ans, -uf.data[i]);
        }
    }

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

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)


int main() {
	lli x;
	cin >> x;

	lli ans = 0;
	ans += floor(x / 500) * 1000;

	x %= 500;
	ans += floor(x/5) * 5;

	cout << ans << endl;



}

Measured memory_bytes: 256