akhauriyash/Code-Regression huggingface dataset:
n = int(input())
x = "abcdefghijklmnopqrstuvwxyz"
a = n
s = ""
while a != 0:
    if a % 26 == 0:
        s += x[a % 26 - 1]
        a = a//26 - 1
    else:
        s += x[a % 26 - 1]
        a = a//26
print(s[::-1])

Measured memory_bytes: 8972
import java.util.Scanner;

public class Main {

	public static final long MAX = 3500;

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();

		for(long h=1;h<=MAX;h++) {
			for(long n=1;n<=MAX;n++) {
				long child = N*h*n;
				long mother = 4*h*n - N*n - N*h;

				if(mother != 0 && child%mother == 0 && child/mother > 0) {
					System.out.println(h + " " + n + " " + (child/mother));
					return;
				}

			}
		}
	}
}


Measured memory_bytes: 21972
from collections import deque

N = int(input())

g = [[] for _ in range(N)]
color = [[] for _ in range(N)]
mi = [[] for _ in range(N)]
MA = [[] for _ in range(N)]
edge = {}
ans = [0]*(N-1)

for i in range(N-1):
    a,b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
    ans[i] = (a,b)

stack = deque([0])
not_visit = [True]*N
not_visit[0] = False
while stack:
    now = stack.popleft()
    for i in g[now]:
        if not_visit[i]:
            stack.append(i)
            if not mi[now]:
                mi[now] = 1
                MA[now] = 1
                mi[i] = 1
                MA[i] = 1
                color[now].append(mi[now])
                color[i].append(mi[now])
                edge[(now+1,i+1)] = mi[now]
                edge[(i+1,now+1)] = mi[now]
            else:
                if mi[now] != 1:
                    mi[now] -= 1
                    color[now].append(mi[now])
                    color[i].append(mi[now])
                    edge[(now+1,i+1)] = mi[now]
                    edge[(i+1,now+1)] = mi[now]
                    if mi[i]:
                        mi[i] = min(mi[i],mi[now])
                    else:
                        mi[i] = mi[now]
                        MA[i] = mi[now]
                else:
                    MA[now] += 1
                    color[now].append(MA[now])
                    color[i].append(MA[now])
                    edge[(now+1,i+1)] = MA[now]
                    edge[(i+1,now+1)] = MA[now]
                    if MA[i]:
                        MA[i] = max(MA[i],MA[now])
                    else:
                        MA[i] = MA[now]
                        mi[i] = MA[now]

            not_visit[i] = False

print(max(MA))
for i in range(N-1):
    print(edge[ans[i]])

Measured memory_bytes: 126352
#include <stdio.h>
#include <string.h>
 
typedef struct {
    char tango[33];
    int kaisuu;
} tlistone;
 
int comphindo(void*,void*);
int complength(void*,void*);
void tolow(char*);
 
int main(void) {
    tlistone tlist[1000];
    int tlistmax=0;
    char nowtango[32];
    int i;
    while(1) {
        if(scanf("%s",nowtango)==-1)break;
        tolow(nowtango);
        for(i=0;i<tlistmax;i++) {
            if(strcmp(tlist[i].tango,nowtango)==0) {
                tlist[i].kaisuu++;
                break;
            }
        }
        if(i>=tlistmax) {
            strcpy(tlist[tlistmax].tango,nowtango);
            tlist[tlistmax].kaisuu=1;
            tlistmax++;
        }
    }
    qsort(tlist,tlistmax,sizeof(tlistone),comphindo);
    printf("%s ",tlist[0].tango);
    qsort(tlist,tlistmax,sizeof(tlistone),complength);
    printf("%s\n",tlist[0].tango);
    return 0;
}
 
void tolow(char* data) {
    int i;
    for(i=0;data[i]!=0;i++) {
        if(data[i]>='A' && data[i]<='Z') {
            data[i]=data[i]-'A'+'a';
        }
    }
}
 
int comphindo(void* a,void* b) {
    if(((tlistone*)a)->kaisuu<((tlistone*)b)->kaisuu)
        return 1;
    else if(((tlistone*)a)->kaisuu>((tlistone*)b)->kaisuu)
        return -1;
    else return 0;
}
 
int complength(void* a,void* b) {
    if(strlen(((tlistone*)a)->tango)<
            strlen(((tlistone*)b)->tango))
        return 1;
    else if(strlen(((tlistone*)a)->tango)>
            strlen(((tlistone*)b)->tango))
        return -1;
    else return 0;
}

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

int main(void){
	int N;
	ll sumA=0,sumB=0,minA=INT_MAX,minB=INT_MAX;
	cin>>N;
	vector<int> p(N+1),add(N+1);
	vector<ll> a(N+1),b(N+1);
	
	rep1(i,N)cin>>p[i];
	rep1(i,N)add[p[i]]=i;
	
	rep1(i,N){
		sumA+=add[i];
		a[i]=i+sumA;
		sumB+=add[N+1-i];
		b[N+1-i]=i+sumB;
	}

	rep1(i,N)minA=min(minA,a[i]);
	rep1(i,N)a[i]-=minA-1;
	rep1(i,N)minB=min(minB,b[i]);
	rep1(i,N)b[i]-=minB-1;

	rep1(i,N-1)cout<<a[i]<<" ";
	cout<<a[N]<<endl;
	rep1(i,N-1)cout<<b[i]<<" ";
	cout<<b[N]<<endl;

	return 0;
}


Measured memory_bytes: 1024
#D
N = int(input())
A = list(map(int,input().split()))

if 1 not in A:
    print(-1)
else:
    ans = 0
    now = 0
    for i in range(N):
        if A[i] == now+1:
            now+=1
        else:
            ans+=1
    print(ans)



Measured memory_bytes: 26268
#include<stdio.h>
#include<list>
#include<string.h>
#include<stdlib.h>
class tr{
 public:
  int num;
  int count;
  int flg;
  tr(int n){
    num=n;
    count=1;
    flg=0;
  }
};

int main(){
  int num,c;
  using namespace std;
  char hoge[1000],*ca;
  list<tr> t1;
  list<tr>::iterator it;
  do{
    fgets(hoge,1000,stdin);
    if(!strcmp(hoge,"\n")) break;
    ca=strchr(hoge,',');
    *ca='\0'; ca++;
    num=atoi(hoge);
    c=atoi(ca);
    it=t1.begin();
    while(it!=t1.end()){
      if(it->num==num){
	it->count++;
	break;
      }
      it++;
    }
    if(it==t1.end()){
      it=t1.begin();
      while(it!=t1.end()){
	if(it->num>num) break;
	it++;
      }
      t1.insert(it,*(new tr(num)));
    }
  }while(1);
  it=t1.begin();
  while(it!=t1.begin()){
    printf("%d %d\n",it->num,it->count);
  }
  do{
    if(!fgets(hoge,1000,stdin)) break;
    ca=strchr(hoge,',');
    *ca='\0'; ca++;
    num=atoi(hoge);
    c=atoi(ca);
    it=t1.begin();
    while(it!=t1.end()){
      if(it->num==num){
	it->count++;
	it->flg=1;
	break;
      }
      it++;
    }
  }while(1);
  it=t1.begin();
  while(it!=t1.end()){
    if(it->flg) printf("%d %d\n",it->num,it->count);
    it++;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long long int n,x;
    cin>>n;
    x=n%10;
    if(x==2 || x==4 || x==5 || x==7 || x==9)
        cout<<"hon";
    else if(x==1 || x==0 || x==6 || x==8)
        cout<<"pon";
    else
        cout<<"bon";
}


Measured memory_bytes: 3636
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int K, A, B; cin >> K >> A >> B;
	eFOR(i, A, B) {
		if (i%K == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;

	return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <math.h>
 
#define N 1000000
 
using namespace std;
 
int main(){
    bool prm[N];
    for(int i=0;i<N;i++)prm[i]=true;
    int upto = (int)sqrt(N);
    for(int i=2;i<=upto;i++){
        if(prm[i]){
            for(int j=2;i*j<=N;j++) prm[i*j] = false;
        }
    }
    int n;
    while(cin >> n){
        int count = 0;
        for(int i=2;i<=n;i++){
            if(prm[i]) count++;
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define	       MEM(a,b)         memset(a,(b),sizeof(a))
#define	       CLR(p)           memset(p,0,sizeof(p))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
#define	       ff               first
#define	       sc              second
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//memset(ar,-1,sizeof(ar));
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
// string x(w.size(),'1');
#define MAX 1000005
#define precision(a) fixed << setprecision(a)

#define mod 1000000007

ll ar[MAX],br[MAX];

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

   for(ll i=0;i<n;i++)
   {
       ll a,b;
       cin>>a>>b;
       ar[i]=a+b;
       br[i]=b-a;
   }
   sort(ar,ar+n);sort(br,br+n);
   ll ans=max(abs(ar[0]-ar[n-1]),abs(br[0]-br[n-1]));
   cout<<ans<<nn;

    return 0;
}


Measured memory_bytes: 6728
#include <iostream>

using namespace std;
int n;
int v[101];
int suma, minim, maxim;
int main()
{
    cin >> n;
    cin.get();
    for (int i = 1; i<=n; ++i)
    {
        char c;
        c = cin.get();
        if (c == '(')
            v[i] = 1;
        else v[i] = -1;
        suma+=v[i];
        minim = min (suma, minim);
    }
    for (int i = minim; i<0; ++i)
        cout << "(";
    for (int i = 1; i<=n; ++i)
    {
        if (v[i] == 1)
            cout << "(";
        else cout << ")";
    }
    for (int i = 1; i<=suma - minim; ++i)
        cout << ")";
    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 REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {//言語変えろ言語変えろ言語変えろ言語変えろ言語変えろ
            
int ta,th,aa,ah;
  cin>>th>>ta>>ah>>aa;
  int win=0;
  
  while(th>0&&ah>0){
    ah=ah-ta;
    if(ah<=0){win=1;break;}
    th=th-aa;
    if(th<=0){win=2;break;}
  }
    
  if(win==1){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x,res=0;
	while(cin>>n>>x){
		if(n==0&&x==0)break;
		res=0;
		for(int i=1;i<=n;i++)
			for(int j=i+1;j<=n;j++)
				for(int k=j+1;k<=n;k++)
					if(i+j+k==x)res++;
		cout<<res<<endl;
	}
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std; 
const int maxn = 5000500;
const int mod = 1e9 + 7;
int a[maxn], pref[maxn], cntzer[maxn];
long long dp[maxn];
vector < int > v[maxn];
long long add(long long a, long long b){
    a += b;
    if(a >= mod) a -= mod;
    return a;
}

long long mul(long long a, long long b){
    return (a * b) % mod;
}

long long solve_fixed(int n, int X){
    dp[pref[n - 1]] = 1;
    long long ans = (pref[n - 1] == X ? 1:0);
    for(int i = n - 2 ; i >= 0 ; --i){
        if(pref[i] == X) ans = add(ans, dp[0]);
        dp[pref[i]] = add(dp[pref[i]],dp[X ^ pref[i]]);
    }
    return ans;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    long long xr = 0;
    for(int i = 0 ; i < n ; ++i)
        cin >> a[i];
    pref[0] = a[0];
    cntzer[0] = (a[0] ? 0:1);
    v[a[0]].push_back(0);
    for(int i = 1 ; i < n ; ++i){
        pref[i] = a[i] ^ pref[i - 1];
        cntzer[i] = !pref[i] + cntzer[i - 1];
        v[pref[i]].push_back(i);
    }
    long long ans = solve_fixed(n, 0);
    for(int i = 1 ; i < maxn ; ++i){
        if((int)v[i].size() == 0 || (v[i][(int)v[i].size() - 1] != n - 1 && pref[n - 1])) continue;
        long long smx = 1, sm0 = !pref[n - 1];
        ans = add(ans, smx);
        for(int j = (int)v[i].size() - 2 ; j >= 0 ; --j){
            sm0 = add(sm0, mul(cntzer[v[i][j + 1]] - cntzer[v[i][j]], smx));
            ans = add(ans, sm0);
            smx = add(smx, sm0);
        }
    }
    cout << ans << '\n';
    return 0;

}

Measured memory_bytes: 149108
import scala.io.StdIn.readLine

object Main extends App {
  val seq1 = for(i<-1 to 9) yield List(i,i,i)
  val seq2 = for(i<-1 to 7) yield List(i,i+1,i+2)

  def check(m:List[Int], count:Int,u:Int,v:Int):Boolean =
    if(m.length != count) false
    else if(count==2) m(0)==m(1)
    else (u to 8).exists( i=> check(m diff seq1(i),count-3,i+1,v)) || (v to 6).exists(i=> check(m diff seq2(i),count-3,u,i))

  Iterator.continually(readLine).takeWhile ( _!=null ).foreach { line =>
    val l = line.map(_.asDigit).toList
    val m = (1 to 9).filter { i=> if(l.count( _==i ) >= 4) false else check(i::l,14,0,0) }
    if(m.length>0) println(m.mkString(" ")) else println(0)
  }
}

Measured memory_bytes: 67844
a, b = map(int, input().split())

if a > 0:
    print("Positive")
elif a <= 0 and b >= 0:
    print("Zero")
else:
    if (b - a) % 2 == 0:
        print("Negative")
    elif (b - a) % 2 == 1:
        print("Positive")

Measured memory_bytes: 3060
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, a, b;
    vector<pair<int, int>> l;
    cin >> n;
    F0R(i,n)
    {
        cin >> a >> b;
        l.pb(make_pair(b, a));
    }
    sort(l.begin(), l.end());
    int curr = 0;
    F0R(i,n)
    {
        curr += l.at(i).s;
        if(curr>l.at(i).f)
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";

    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////
/* AtCoder Beginner Contest 106 (๑•﹏•๑｀) */

int main(){
	int A,B;SCD2(A,B);
	PRINTD((A-1)*(B-1));
	return 0;
}

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

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

        int k = sc.nextInt();
        String s = sc.next();

        if (s.length()<=k)
            System.out.println(s);
        else
            System.out.println(s.substring(0,k)+"...");
    }
}

Measured memory_bytes: 38576
s = int(input())

A = []
ans = 1

def seq(a):
  if a % 2 == 0:
    a = a // 2
  else:
    a = 3 * a + 1
  return a

while s not in A:
  A.append(s)
  s = seq(s)
  ans += 1
else:
  print(ans)

Measured memory_bytes: 2940
s = gets
cnt = 0
cntmax = 0
s.size.times do |hoge|
    if s[hoge] == "A" or s[hoge] == "C" or s[hoge] == "G" or s[hoge] == "T" then
        cnt += 1
    else
        if cntmax < cnt then
            cntmax = cnt
        end
        cnt = 0

    end
end

puts cntmax

Measured memory_bytes: 1788
#include <iostream>
#include <queue>

using namespace std;

struct bar {
	int h, p, q;
	
	bool operator <(const bar& b) const {
		return h < b.h;
	}
};

struct P {
	int height, line;
};

int main() {
	int n, m, a;
	while(cin >> n >> m >> a, n|m|a){
		priority_queue<bar> bars;
		for(int i=0; i<m; i++){
			int h, p, q;
			cin >> h >> p >> q;
			bars.push({h, p, q});
		}
		P pos = {1000, a};
		while(!bars.empty()){
			bar b = bars.top(); bars.pop();
			if(b.h < pos.height){
				if(b.p == pos.line){
					pos = {b.h, b.q};
					continue;
				}
				if(b.q == pos.line){
					pos = {b.h, b.p};
					continue;
				}
			}
		}
		cout << pos.line << endl;
	}
	return 0;
}

Measured memory_bytes: 1240
import sys
import re
import math
import collections

# import bisect

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
# MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    d=[]
    for _ in range(n):
        d.append(list(ns()))
    d.sort()

    cnt=0
    for i in range(n):
        cnt+=d[i][1]
        if k <= cnt:
            print(d[i][0])
            break

if __name__ == '__main__':
    main()


Measured memory_bytes: 28408
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

ret = 0
for i in range(1, K+1):
    prev = '?'
    for j in range(len(T) // K + 1):
        if i + K*j - 1 >= len(T):
            continue
        now = T[i + K*j - 1]
        
        if prev == now:
            prev = '?'
        else:
            prev = now
            if now == 'r':  
                ret += P
            elif now == 's':
                ret += R
            else:
                ret += S
            
print(ret)

      


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

int main() {
    int n, m, x, co1 = 0, co2 = 0, ans = 0;
    cin >> n >> m;
    vector<vector<int>> a(m);
    rep(i, m) {
        cin >> x;
        a[i].push_back(x);
        rep(j, a[i][0]) {
            cin >> x;
            a[i].push_back(x);
        }
    }
    vector<int> p(m);
    rep(i, m) cin >> p[i];
    for (int bit = 0; bit < (1 << n); ++bit) {
        vector<int> on;
        co2 = 0;
        for (int i = 0; i < n; ++i) {
            if (bit & (1 << i))
                on.push_back(i + 1);
        }
        for (int i = 0; i < m; ++i) {
            co1 = 0;
            for (int j = 1; j <= a[i][0]; ++j) {
                for (int k = 0; k < on.size(); ++k) {
                    if (on[k] == a[i][j])
                        co1++;
                }
            }
            if (co1 % 2 == p[i])
                co2++;
        }
        if (co2 == m)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include<stdio.h>
int main(){
  int a;
  int b;
  scanf("%d",&a);
  scanf("%d",&b);
  if (a<=b){
    for(int i=0;i<b;i++){
      printf("%d",a);
    }
  }else{
    for(int i=0;i<a;i++){
      printf("%d",b);
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define iter(it,a) for(auto it=a.begin();it!=a.end();it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define endl '\n'
typedef long long ll;
typedef long double ld;

vector<int> v[100000+10];

ll MOD=1e9+7;
ll powermod(ll base, ll exp){
    ll ans = 1;
    while(exp){
        if(exp&1) ans = (ans*base)%MOD;
        base = (base*base)%MOD;
        exp>>=1;
    }
    return ans;
}

const ll N=2e5+2;
ll fact[N+10];
ll inv[N+10];

void func(){
    fact[0]=1;
    inv[0]=1;
    for(int i=1;i<=N;i++){
        fact[i] = i*fact[i-1];
        fact[i] %= MOD;
        inv[i] = powermod(fact[i], MOD-2);
    }
}

ll C(ll a,ll b){
    if(a<b){
        return 0;
    }
    ll ans = fact[a];
    ans*=(inv[b]);
    ans%=MOD;
    ans*=inv[a-b];
    ans%=MOD;
    return ans;
}

int main(){
    cin.tie(0);ios_base::sync_with_stdio(0);
    func();
    int n,x;
    cin>>n;
    rep(i,0,n+1){
        cin>>x;
        v[x].pb(i);
    }
    rep(i,1,n+1){
        if(v[i].size()==2){
            x = v[i][1]-v[i][0]+1;
        }
    }
    rep(k,1,n+2){
        cout<<(C(n+1,k)-C(n+1-x,k-1)+MOD)%MOD<<endl;
    }
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int main(){
  ull n,a,b,c,d,e;
  cin >> n >> a >> b >> c >> d >> e;
  ull mn = min({a,b,c,d,e});
  ull ans = (n + mn - 1) / mn + 4;
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> V(10, vector<int>(10));
  for (int i = 1; i <= N; i++) {
    if (i % 10 == 0) continue;
    string tmp = to_string(i);
    V.at(tmp.front() - '0').at(tmp.back() - '0')++;
  }
  int ans = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      ans += V.at(i).at(j) * V.at(j).at(i);
    }
  }
  cout << ans << "\n";
}

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

public class Main {
	static FastReader in = new FastReader();

	public static void main(String[] args) {
		solve();
	}

	static void solve() {
		int n = in.nextInt();
		String input = in.nextLine();
		input = input.substring(0, input.lastIndexOf("R") + 1);
		char[] s = input.toCharArray();
		
		int rnum = 0;
		for(char i : s) if(i == 'R') rnum++;
		
		int ans = 0;
		for(int i = 0; i < rnum; i++)
		{
			if(s[i] == 'W') ans++;
		}
		
		System.out.println(ans);
		
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}





Measured memory_bytes: 36736
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!


void solve(){
    
    int n;cin>>n;
    int maxF=0;
    map<string,int> freq;
    for(int i=0;i<n;i++){
        string s;cin>>s;
        freq[s]++;
        maxF=max(maxF,freq[s]);
    }
    for(auto p:freq){
        if(p.Se==maxF){
            cout<<p.Fi<<endl;
        }
    }
    
}





int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 19272
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    
    int ans=0;
    for(int i=0;i<3;i++){
        if(S[i] == '1'){
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <vector>
#define rep(i,n) for( int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main()
{
  ll h, w, k;
  cin >> h >> w >> k;
  
	vector<vector<int>> c(h, vector<int>(w));
  
  string tmp; 
  for (int i = 0; i < h; i++) {
	  cin >> tmp ; 
    for (int j = 0; j < w; j++) {
      if ( tmp.substr(j,1) == "." ){
        c.at(i).at(j) = 0;
			}
      else if ( tmp.substr(j,1) == "#" ){
        c.at(i).at(j) = 1;
			}
    }
  }	
  
  int ans = 0;

  int tmpi = 0;
  for (int biti = 0; biti < (1<<h); ++biti) {
    for (int bitj = 0; bitj < (1<<w); ++bitj) {
      tmpi = 0;
      for( int i = 0; i < h; i++ ){
        for( int j = 0; j < w; j++ ){
          if( biti & ( 1 << i ) || bitj & ( 1 << j ) ){
          }
          else{
            if( c.at(i).at(j) == 1 )tmpi++;
          }
        }
      }
      if ( tmpi == k ) ans++;
    }
  }

	cout << ans << endl;

  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long int lli;
typedef long long ll;

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

    vector<int> row;
    row.push_back(s);
    int ans;
    bool find = false;
    while(true){
        if(row.back() % 2 == 0) row.push_back(row.back()/2);
        else row.push_back(row.back()*3+1);

        rep(i,row.size()-1){
            if(row.back() == row[i]){
                ans = row.size();
                find = true;
                break;
            }
        }
        if(find) break;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define N (ll)(1e17+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll t=1;
   //cin>>t;
   while(t--)
   {
     string s;
     cin>>s;
     for(ll i=0;i<s.length();i++)
     {
         cout<<"x";
     }  
     cout<<"\n";
   }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100010
std::vector<int> s[MAX_N];
int low[MAX_N],v[MAX_N]={0},Time=0,ans=0;
void dfs(int x,int p){
    int i,r,is=0,add=0;
    low[x]=v[x]=++Time;
    for(i=0;i<(int)s[x].size();++i){
        if(!v[r=s[x][i]]){
            dfs(r,x),++add;
            low[x]=std::min(low[x],low[r]);
            if(v[x]<=low[r])is=1;
        }
        if(r!=p)low[x]=std::min(low[x],v[r]);
    }
    if(is)++ans;
    if(x==p&&add<2)--ans;
}
int deg[MAX_N];
int cnt[MAX_N];
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        deg[--a]++;
        deg[--b]++;
        s[a].push_back(b);
        s[b].push_back(a);
    }
    for(int i=0;i<n;i++){
        if(deg[i]%2){
            puts("No");
            return 0;
        }
        cnt[deg[i]]++;
    }
    for(int i=n-1;i>=6;i--)
        if(cnt[i]){
            puts("Yes");
            return 0;
        }
    if(cnt[4]>2){
        puts("Yes");
        return 0;
    }
    dfs(0,0);
    if(ans>1){
        puts("Yes");
        return 0;
    }
    puts("No");
}

Measured memory_bytes: 12160
let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let ps = Array.init n (fun _ -> Scanf.scanf "%d " (fun p -> p - 1)) in
  let das = Array.init n (fun _ -> 1) in
  let dbs = Array.init n (fun _ -> -1) in
  Array.iteri (fun i p ->
    das.(p) <- das.(p) + i + 1;
    dbs.(p) <- dbs.(p) - i - 1) ps;
  let (a :: as_) =
    Array.fold_left (fun (a, as_) da -> (da + a, da + a :: as_)) (1, []) das
      |> snd
      |> List.rev in
  Printf.printf "%d" a;
  List.iter (Printf.printf " %d") as_;
  print_newline ();
  let (b :: bs) =
    Array.fold_left (fun (b, bs) db -> (db + b, b :: bs)) (1000000000, []) dbs
      |> snd
      |> List.rev in
  Printf.printf "%d" b;
  List.iter (Printf.printf " %d") bs;
  print_newline ()


Measured memory_bytes: 4480
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a != 1 && b != 1) {
        cout << 1 << endl;
    } else if (a != 2 && b != 2) {
        cout << 2 << endl;
    } else {
        cout << 3 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int w, h, x, y;
    scanf("%d %d %d %d", &w, &h, &x, &y);
    printf("%.6f", (double)w*h/2);
    if (w % 2 == 0 && x == w/2 && h % 2 == 0 && y == h/2){
        printf(" %d\n", 1);
    }
    else{
        printf(" 0\n");
    }
    return 0;
}


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

using namespace std;

int w[100];

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

	int sum = 0;

	for(int i = 0; i < n; ++i){
		cin >> w[i];
		sum += w[i];
	}

	int min = sum;

	for(int i = 0; i < n; ++i){
		sum -= 2*w[i];
		if(min > abs(sum)){
			min = abs(sum);
		}else{
			break;
		}
	}

	cout << min << endl;

	return 0;
}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;

  vs s(n);
  vll t(n);
  rep(i, n) {
    cin >> s[i] >> t[i];
  }

  string x;
  cin >> x;

  ll ans = 0;
  rep(i, n) {
    ans += t[i];
    if (s[i] == x)
      ans = 0;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int sa = s.IndexOf('A');
            int sz = s.LastIndexOf('Z');
            Console.WriteLine(sz - sa + 1);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 3416
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int n;
  while(cin>>n,n){
    vector<int> a(n+1);
    LOOP(i,1,n+1)cin>>a[i];
    LOOP(i,1,n+1)a[i+1]+=a[i];
    int ans=-INF;
    LOOP(i,1,n+1){
      LOOP(j,0,i){
        ans=max(ans,a[i]-a[j]);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#include<iostream>
#include<string>
using namespace std;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int a[n];
    for(int i = 0; i < n; i++){
        a[i] = s[i]- '0';
    }
    int b = 0;
    for(int i = 1; i < n; i++){
        if(a[i] != 9){
            b = 1;
            break;
        }
    }
    int sum;
    if(b) sum = a[0] - 1 + 9*(n-1);
    else{
        sum = a[0] + 9*(n-1);
    }
    cout << sum << endl;
    return 0;
}

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

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	const int N = inputVal<int>();
	const int X = inputVal<int>();
	const vector<int> L = inputVec<int>(N);

	int i = 0;
	int pos = 0;
	for (; i <= N; ++i) {
		if (pos > X) break;
		pos += L[i];
	}

	outputVal(i);
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << std::fixed << std::setprecision(15);
	Main();

	double tmp;
	cin >> tmp;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n;	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)	cin>>a[i];
	int ans=1e9;
	for(int i=-100;i<=100;i++){
		int tmp=0;
		for(int j=0;j<n;j++){
			tmp+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ans,tmp);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N,K,*as=$<.read.split.map(&:to_i)
as.unshift(0) # dummy

check=Array.new(N+1,0)
check[1]=1
cnt2 = 0
i = nxt = 1
loop do
    cnt2 += 1
    nxt = as[i]
    break if check[nxt] != 0
    check[nxt] = 1
    i = nxt
end

i = 1
cnt1 = 0
while i != nxt
    i = as[i]
    cnt1 += 1
end

if K<=cnt1
    i = 1
    K.times do
        i = as[i]
    end
    puts i
else
    loopcnt = cnt2-cnt1
    # p [nxt,cnt1,cnt2,loopcnt]
    i = nxt
    ((K-cnt1)%loopcnt).times do
        i = as[i]
    end
    puts i
end

Measured memory_bytes: 31268
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (200001)
#define MOD (1000000007)

int main(void)
{
    ll p,q,r;
    scanf("%ld %ld %ld",&p,&q,&r);
    
    ll a1 = p+q, a2 = p+r, a3 = r+q;
    ll ans = min(a1,a2);
    ans = min(ans,a3);
    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
string a,m,l;
int i=0,h=0;
int main()
{
	getline(cin,a);
	m=a[0];
	for(;;)
	{
		if(a[i]=='\0') break;
		if(i>1) h++;
		i++;
	}
	l=a[i-1];
	cout<<m<<h<<l<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main(string[] args) {
        //入力
        string s = Console.ReadLine();
        int N = int.Parse(s.Split(' ')[0]);
        int X = int.Parse(s.Split(' ')[1]);

        string t = Console.ReadLine();

        //変数の割り当て
        int[] L = new int[N];
        int sum = 0; //すべての和
        for (int i = 0; i < N; i++) {
            L[i] = int.Parse(t.Split(' ')[i]);
            sum += L[i];
        }

        //検証
        //回答となる数値
        int ans = 0;
        //現在の数直線における場所
        int now_pos = 0;
        int index = 0;

        if (sum > X) {
            while (now_pos <= X) {
                ans++;
                now_pos += L[index];
                index++;
            }
        }
        

        else {
            ans = N + 1;
        }


        //出力
        Console.WriteLine(ans);


    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int X = sc.nextInt();
        int upper = X + (K - 1);
        int lower = X - (K - 1);
        for (int i = lower; i <= upper; i++) {
            if (i == upper) {
                System.out.println(i);
            } else {
                System.out.print(i + " ");
            }
        }

    }
}


Measured memory_bytes: 21844
#include <cstdio>
using namespace std;
int N; double A[101];
int main() {
  scanf("%d", &N);
  A[0] = 1;
  for(int i = 1; i <= N; ++i) {
    scanf("%lf", &A[i]);
    A[0] *= A[i];
  }
  double sum;
  for(int i = 1; i <= N; ++i) {
    sum += A[0]/A[i];
  }
  printf("%.10lf\n", (double)A[0]/sum);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+9;
ll a[N],p[69],n,sum,res;
void insert(ll x){
    for(int i=60;i>=0;i--)if(x&(1ll<<i)){
        if(!p[i]){p[i]=x;break;}
        x^=p[i];
    }
}
void solve(){
    for(int i=60;i>=0;i--){
        if(res+(res^sum)<(res^p[i])+(res^p[i]^sum))res^=p[i];
    }
}
int main(){
  //  freopen("tt.in","r",stdin),freopen("tt.out","w",stdout);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i],sum^=a[i];
    for(int i=0;i<60;i++)if(sum&(1ll<<i)){
        for(int j=1;j<=n;j++)if(a[j]&(1ll<<i))a[j]^=(1ll<<i);
    }
    for(int i=1;i<=n;i++)insert(a[i]);
    solve();
    cout<<res+(res^sum)<<endl;
    return 0;
}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	ll n, m; cin >> n >> m;
	ll sum = 0LL;
	for(ll i=0;i<m;i++){
		int a; cin >> a;
		sum += a;
	}
	if(sum>n){
		cout << -1 << endl;
		return 0;
	}else{
		cout << n-sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
import itertools

S=input()

for i in itertools.product(["+","-"],repeat=3):
    ans=""
    for j in range(3):
        if i[j]=="+":
            ans+=S[j]+i[j]
        elif i[j]=="-":
            ans+=S[j]+i[j]
    ans+=S[-1]
    sum1=eval(ans)
    if sum1==7:
        print(ans+"="+str(7))
        exit()

Measured memory_bytes: 3060
import Data.List

main = do
  x:y:_ <- map read . words <$> getLine :: IO [Int]
  putStrLn $ show $ path x y

path :: Int -> Int -> Int
path x y | mod (x+y) 3 /= 0 = 0
         | otherwise = let n = div (x+y) 3 in
                       if (x-n) < 0 || (y-n) < 0 then 0
                       else cmb n (x-n)

cmb :: Int -> Int -> Int
cmb n r = times (foldl times 1 [(n-r+1)..n]) (foldl times 1 $ map (invMod 1000000007) [1..r])
    where times x y = mod (x * y) 1000000007

invMod :: Int -> Int -> Int
invMod n x = mod (xgcd n x !! 1) n
xgcd :: Int -> Int -> [Int]
xgcd a b |     a < b = xgcd b a
         | otherwise = xgcdRec [1,0,0,1] a b
         where xgcdRec m a 0 = m
               xgcdRec [x,y,x',y'] a b = let d = div a b in xgcdRec [x',y',x-d*x',y-d*y'] b (mod a b)


Measured memory_bytes: 1020
import sys

# D - Megalomania
N = int(input())
jobs = []

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

# 締め切り時刻の順にソート
jobs.sort(key=lambda x:x[1])

time = 0

for i in range(N):
  time += jobs[i][0]

  if time > jobs[i][1]:
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 40852
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    int N,K;
    cin >> N >> K;
    int Z[N+K] = {};
    int Score[4] = {};
    cin >> Score[1] >> Score[2] >> Score[3];
    string T;
    cin >> T;
    rep(i,N){
        if(T[i] == 'r') Z[i] = 3;
        else if(T[i] == 's')Z[i] = 1;
        else Z[i] = 2;
    }
    rep(i,N){
        if(Z[i] == Z[i+K]){
            Z[i+K] = 0;
        }
    }
    long long sum = 0;
    rep(i,N){
        sum += Score[Z[i]];
        //cout << Z[i] << " ";
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N=55555;
bool is_prime[MAX_N];
int prime[MAX_N];
int main(){
  int n;
  cin>>n;
  int dp[1001][1001];
  for(int nn=0;nn<n;nn++){
    string s1,s2;
    cin>>s1>>s2;
    for(int i=0;i<1001;i++)fill(dp[i],dp[i]+1001,0);
    for(int i=0;i<s1.size();i++){
      for(int j=0;j<s2.size();j++){
        if(s1[i]==s2[j]) dp[i+1][j+1]=max(dp[i][j]+1,max(dp[i][j+1],dp[i+1][j]));
        else dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
      }
    }
    cout<<dp[s1.size()][s2.size()]<<endl;
  }
  return 0;
}



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

bool search(const vector<string> &mp, int h, int w, int i, int j)
{
    bool res = true;
    if(0 <= i-1 && mp.at(i-1).at(j)=='#') res = false;
    if(i+1 < h && mp.at(i+1).at(j)=='#') res = false;
    if(0 <= j-1 && mp.at(i).at(j-1)=='#') res = false;
    if(j+1 < w && mp.at(i).at(j+1)=='#') res = false;
    return res;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    vector<string> mp(h);
    for(int i=0; i<h; i++) cin >> mp.at(i);

    bool ans = true;
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            if(mp.at(i).at(j) == '#')
            {
                if(search(mp, h, w, i, j)) ans = false;
            }
        }
    }
    cout << (ans?"Yes":"No") << '\n';
    return 0;
}

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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf LLONG_MAX

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

ll visited[1000005]={0};
ll final[1000005]={0};

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

    ll test=1;
    // cin>>test;
    while(test--)
    {
        ll n;
        cin>>n;

        set<ll> st;

        for(ll i=0;i<n;i++)
        {
            ll x;
            cin>>x;

            if(visited[x]==0)
            st.insert(x);
            else
            {
                final[x]=1;
            }

            visited[x]=1;
            
        }

        if(st.empty())
        {
            cout<<0<<endl;
            continue;
        }

        ll mx=1000005;

        for(auto i=st.begin();i!=st.end();i++)
        {
            ll x=*i;

            for(ll j=x*2;j<mx;j+=x)
            st.erase(j);
        }

        ll sz=0;

        for(auto i:st)
        {
            if(!final[i])
            sz++;
        }

        cout<<sz;
    }
}

Measured memory_bytes: 27692
import math

a, b, h, m = list(map(int,input().split()))

hangle = h * 30 + m * 0.5
mangle = m * 6

angle = hangle - mangle

len = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(angle)))

print(len)

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

int main()
{
    int d,n,a,res;
    cin>>d>>n;
    if(d==0)a=1;
    else if(d==1)a=100;
    else a=10000;
    res=a+(n-1)*a;
    if(d==0 && res==100)res++;
    else if(d==1 && res==10000)res+=100;
    else if(d==2 && res==1000000)res+=10000;
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

void swap(int *a,int *b)
{
	int temp = *a;
	*a = *b;
	*b = temp;
}

int main(void)
{
	int a[3],b[3];
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	if(a[1] < a[0])
		swap(&a[1],&a[0]);
	if(a[2] < a[0])
		swap(&a[2],&a[0]);
	if(a[2] < a[1])
		swap(&a[2],&a[1]);
	printf("%d %d %d\n",a[0],a[1],a[2]);	return 0;
}

Measured memory_bytes: 596