akhauriyash/Code-Regression huggingface dataset:
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

bool m[30]={0},p[30]={0};


int main()
{
    
    int n,mx=0;
    scf(n);
    
    string s;
    cin>>s;
   
    rep(i,0,30)
    m[i]=0,p[i]=0;
    
    rep(i,0,n)
    {
        int ctr=0;
        
        rep(k,0,30)
        m[k]=0,p[k]=0;
        
        rep(j,0,i+1)
        m[s[j]-'a']=1;
        
        rep(k,i+1,n)
        p[s[k]-'a']=1;
        
        rep(l,0,26)
        if(m[l]&&p[l])
        ctr++;
        
        
        
        mx=max(mx,ctr);
        
    }
    
        
    prin(mx);
        
        
         
     

        
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << "\n"; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N;
void input(){
    fast_io();
    cin >> N;
}

int solve(){
    ll K=1;
    for (int k = 0; k <= N; k++)
    {
        if(k*(k+1)<=2*N) continue;
        K = k-1;
        break;
    }
    ll ret = 0;
    set<ll> se;
    for (int j = 1; j <= K; j++) se.insert(j);
    if(K*(K+1)!=2*N){
        ret = N-K*(K+1)/2;
        if(ret>K) se.insert(ret);
        else{
            se.insert(K+1);
            se.erase(K+1-ret);
        }
    }

    cout << se << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 512
N = int(input())
A = [int(i) for i in input().split()]
count = 0
can = True
while can :
	count += 1
	for i in range(N) :
		if A[i] % 2 == 0 :
			A[i] = int( A[i] / 2 ) 
		else :
			count -= 1
			can = False
			break
print(count)

Measured memory_bytes: 3060
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N, K, ans;

int main(){
  scanf("%lld%lld", &N, &K);
  for (ll i = K; i <= N + 1; i++){
    ll L = (i - 1) * i / 2;
    ll R = ((N - i + 1) + N) * i / 2;
    ans += R - L + 1;
    ans %= MOD;
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 3816
// ABC097D - Equals

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<int> count;

	// n要素で初期化
	UnionFind(int n) {
		par.resize(n);
		rank.resize(n, 0);
		count.resize(n, 1);
		for (int i = 0; i < n; i++) {
			par[i] = i;
		}
	}

	// 木の根を求める。
	int find(int x) {
		if (par[x] == x) {
			return x;
		} else {
			return par[x] = find(par[x]);
		}
	}

	// xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) {
			return;
		}
		
		count[x] += count[y];
		count[y] = count[x];
		if (rank[x] < rank[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if (rank[x] == rank[y]) {
				rank[x]++;
			}
		}
	}

	// xとyが同じ集合に属するか否か
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// xと同じ集合の要素数を返す。
	int getCount(int x) {
		return count[x];
	}
};

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

	int p[N];
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}

	UnionFind tree(N+1);
	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		tree.unite(x, y);
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (tree.same(p[i], i + 1)) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4760
import java.util.*;

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

        int s = sc.nextInt();
        int N = 1000000;
        int[] a = new int[N];
        a[0] = s;

        loop:for(int i=1; i<N; i++){
            if(a[i-1]%2==0){
                a[i] = a[i-1] / 2;
            }
            else if(a[i-1]%2!=0){
                a[i] = 3 * a[i - 1] + 1;
            }
            for(int j=0; j<i; j++){
                if(a[j]==a[i]){
                    System.out.println(i + 1);
                    break loop;
                }
            }
        }

    }
}

Measured memory_bytes: 25940
#include <iostream>
using namespace std;
const int TAX8=8;
const int TAX10=10;
const int MAX=100000;
int main(){
    int a,b;
    cin>>a>>b;
    int price_a,price_b;
    for(int i=0;i<MAX;i++){
        int tax_a=i*TAX8/100;
        int tax_b=i*TAX10/100;
        if(tax_a==a&tax_b==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
// Edit Distance (Levenshtein Distance)
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <set>
#include <string>
using namespace std;
#define MAX 1050
string str1,str2;
int size1,size2,num;
int dp[MAX][MAX] = {0};

int main(){
  cin >> str1 >> str2;
  size1 = str1.length();
  size2 = str2.length();
  // ??????????????\??????????????????
  // ?????????
  dp[0][0] =0;
  for (int tate=1 ; tate <= size1 ; tate++) dp[tate][0] = tate;
  for (int yoko=1 ; yoko <= size2 ; yoko++) dp[0][yoko] = yoko;
  
  for (int tate=1 ; tate <= size1 ; tate++)
    for (int yoko=1 ; yoko <= size2 ; yoko++) {
      num = min(dp[tate][yoko-1]+1,dp[tate-1][yoko]+1);
      if (str1[tate-1] == str2[yoko-1]) dp[tate][yoko] = min(dp[tate-1][yoko-1],num);
      else dp[tate][yoko] = min(dp[tate-1][yoko-1]+1,num);
    }
  cout << dp[size1][size2] << endl;
  return 0;
}

Measured memory_bytes: 5292
#include<iostream>
#include<vector>
#include<algorithm>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
	int n;cin>>n;
  		ll sum=0;
  rep(i,n){
      if( (i+1)%3==0 || (i+1)%5==0){;}else{sum+=(i+1);} 
         }
  cout<<sum<<endl;
return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
long long t,a,b,c,d;
long long gcd(long long x,long long y){return !y?x:gcd(y,x%y);}
int main()
{
	cin>>t;
	while(t--)
	{
		cin>>a>>b>>c>>d;
		if(a<b||d<b){puts("No");continue;}
		if(c>=b-1){puts("Yes");continue;}
		long long g=gcd(d,b);
		if(b-c-1>=g){puts("No");continue;}
		puts(((c-a+1)%g+g)%g>((b-a-1)%g+g)%g||(c-a+1)%g==0?"No":"Yes");
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)
{
  char s[4];
  
  cin>>s;
  
  if(((s[0]=='A')&&(s[1]=='A'))&&(s[2]=='A')){
    puts("No"); return 0;
  }
  
  if(((s[0]=='B')&&(s[1]=='B'))&&(s[2]=='B')){
    puts("No"); return 0;
  }
  
  puts("Yes");
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>

using namespace std;


int main() {
	int i, j, k;
	string str;

	cin >> str;

	int cnt = 0;
	for (i = 0; i < str.length(); i++) {
		if (str[i] == '1') cnt++;
	}

	cout << cnt << endl;


	getchar();
	getchar();
	return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007
// 時間を0.5秒刻みで調べる(100001 * 2)
#define MAXNUM 200002

using namespace std;

typedef long long ll;

int main()
{
    int N, C;;
    cin >> N >> C;
    int s[N], t[N], c[N];
    REP(i, N)
    {
        cin >> s[i] >> t[i] >> c[i];
        c[i]--;
    }

    // 各チャネンルが各時刻において放送中であるか調べる
    int needRecoderNum[MAXNUM] = {0};
    REP(i, C)
    {
        // 各時刻でチャンネルi が放送中であるかを記録する
        // 0 : 放送してない, 1 : 放送してる
        int recordTime[MAXNUM] = {0};
        REP(j, N)
        {
            if (i == c[j])
            {
                recordTime[2 * s[j] - 1] = 1;
                // -1 は録画を止める時刻を示す
                recordTime[2 * t[j]] = -1;
            }
        }
        for (int j = 1; j < MAXNUM; ++j)
        {
            // 前の時刻が放送中なら、録画を止めない限り次の時刻も放送中である
            // 録画を止めた以降は、再び放送が始まるまで0となる
            recordTime[j] += recordTime[j - 1];
        }
        REP(j, MAXNUM)
        {
            if (recordTime[j] == 1)
            {
                needRecoderNum[j]++;   
            }
        }
    }

    int ans = 0;
    REP(i, MAXNUM)
    {
        ans = max(ans, needRecoderNum[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <chrono>
#include <thread>
#include <thread>
#include <fstream>

using namespace std;

//const bool debug = false;

#ifndef M_PI
    const double M_PI = acos(-1.0);
#endif // M_PI

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
//#define ll long long
const int mod = int(1e9) + 7;
//const int inf = 1e7;
//const long long infLL = 1e16;
//const int MX2 = 10100500; //  e7
//const long long INF = 1e18 + 0.5;
const int MX = 100500; //       e6
const int SZ = 122;

long long a[MX];
int n;


int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    long long ans = 0;
    while(true){
        bool ok = true;
        for(int i = 0 ; i < n; i++){
            if(a[i] < n) ok = false;
        }
        if(ok) break;
        int pos = 0;
        for(int i = 0; i < n; i++){
            if(a[i] > a[pos]) pos = i;
        }
        if(a[pos] <= n - 1){cout << ans << endl; return 0;}
        a[pos] -= n + 1;
        for(int i = 0; i < n; i++){
            a[i]++;
        }
        ans++;
    }
    for(int i = 0; i < n; i++){
        long long extra = a[i] - (n - 1);
        long long z = extra / (n + 1);
        //if(extra % n < z) z--;
        //extra -= z;
        //z = extra / n;
        ans += z + n * z;
        a[i] -= z + n * z;
    }
    while(true){
        int pos = 0;
        for(int i = 0; i < n; i++){
            if(a[i] > a[pos]) pos = i;
        }
        if(a[pos] <= n - 1){cout << ans << endl; return 0;}
        a[pos] -= n + 1;
        for(int i = 0; i < n; i++){
            a[i]++;
        }
        ans++;

    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            while (a % 2 == 0) {
                a /= 2;
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35076
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		String s=scanner.next();
		List<Integer>list=new ArrayList<>();
		int cnt=0;
		for(int i=0;i<s.length();i++) {
			char c=s.charAt(i);
			if(c=='B') {
				cnt++;
			}else {
				list.add(cnt);
			}
		}
		long ans=0;{
			for(int x:list) {
				ans+=x;
			}
		}
		System.out.println(ans);
	}
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 25812
import sys
N, Y = map(int,input().split())
for i in range(N + 1):
	if i * 10000 == Y  and i == N:
		print('{0} 0 0'.format(i))
		sys.exit()
	for j in range(N - i + 1):
		if i * 10000 + j * 5000 == Y and i + j == N:
			print('{0} {1} 0'.format(i, j))
			sys.exit()
		if i * 10000 + j * 5000 + (N - i - j) * 1000 == Y:
			print('{0} {1} {2}'.format(i, j, N-i-j))
			sys.exit()
print('-1 -1 -1')


Measured memory_bytes: 41068
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
int T,A;
int H[1010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	cin>>T>>A;
	T*=1000;
	A*=1000;
	int dif=1<<30;
	int be=0;
	FOR(i,N) {
		cin>>H[i];
		H[i]=T-H[i]*6;
		if(abs(A-H[i])<dif) dif=abs(A-H[i]), be=i;
	}
	cout<<(be+1)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)


int main()
{
    int n,t;
    int cost[105]={};
    int tt[105]={};
    scanf("%d %d\n",&n,&t);
    int min=114514;
    REP(i,n)
    {
        scanf("%d %d\n",&cost[i],&tt[i]);
        if(tt[i]<=t && min>cost[i])min=cost[i];
    }
    if(min==114514)printf("TLE\n");
    else printf("%d\n",min);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,x,ans=0,i,j,k;
    cin>>a>>b>>c>>x;
    for (i=0;i<=a&&500*i<=x;i++){
        for (j=0;j<=b&&100*j+500*i<=x;j++){
            for (k=0;k<=c&&50*k+100*j+500*i<=x;k++){
                if (500*i+100*j+50*k==x){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
speed_up;
vector<string> vec;
int n, l, i;
string s;
cin>>n>>l;
i = n;
while(i--)
{
    string s;
    cin>>s;
    vec.push_back(s);
}
sort(vec.begin(), vec.end());
for(i = 0; i<n; i++)
{
    cout<<vec[i];
}


return 0;
}




Measured memory_bytes: 3652
import java.util.*;
public class Main{
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int A = sc.nextInt();
        int cnt = 0;
        
        for(int i=0;i<(10*10*10*10);i++){
        	H -= A;
            cnt++;
            if(H<=0){
            	System.out.println(cnt);
                System.exit(0);
            }
        }
        //System.out.println(R);
    }
}

Measured memory_bytes: 23764
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 210000;

int n;
ll a[MAXN];
ll b[MAXN];
ll x[MAXN];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		cin >> b[i];
	ll ans = 0;
	for (int i = 0; i <= 28; ++i) {
		for (int j = 0; j < n; ++j)
			x[j] = a[j] % (1 << (i + 1));
		sort(x, x + n);
		ll cnt = 0;
		for (int j = 0; j < n; ++j) {
			ll cur = b[j] % (1 << (i + 1));
			if (cur >= (1 << i)) {
				cur -= (1 << i);
				int lb = lower_bound(x, x + n, (1 << i) - cur) - x;
				int rb = lower_bound(x, x + n, (1 << (i + 1)) - cur) - x;
				cnt += lb;
				cnt += n - rb;
			}
			else {
				int lb = lower_bound(x, x + n, (1 << i) - cur) - x;
				int rb = lower_bound(x, x + n, (1 << (i + 1)) - cur) - x;
				cnt += rb - lb;
			}
		}
		if (cnt % 2 == 1)
			ans += (1 << i);
	}
	cout << ans << "\n";
	return 0;
}




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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  
  int btn = 1, ans = 0;
  for(int i = 0; i < N; i++){
    btn = vec.at(btn - 1);
    ans++;
    if( btn == 2){
      cout << ans << endl;
      break;
    }
    if(i == N-1){
      cout << -1 << endl;
    }
  }
  
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define int long long 
using namespace std;

int32_t main(){

    int a,b;    cin >> a >> b;
    
    if(a == b){
        cout << (a) << endl;
        return 0;
    }
    
     a--;

    int big,small;
    if(b % 4 == 0) big = b;
    else if(b % 4 == 1) big = 1;
    else if(b % 4 == 2) big = b+1;
    else big = 0;


    if(a <= 0) small = 0;
    else if(a % 4 == 0) small = a;
    else if(a % 4 == 1) small = 1;
    else if(a % 4 == 2) small = a+1;
    else small = 0;

    cout << (big ^ small) << endl;


    return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

simulate :: [Int] -> Int -> String -> Int -> Int
simulate [] a' d c = c
simulate (a : as) a' d c
  | a' == (-1) = simulate as a "even" c
  | a == a' = simulate as a' d c
  | d == "even" && a > a' = simulate as a "up" c
  | d == "even" && a < a' = simulate as a "down" c
  | d == "up" && a > a' = simulate as a "up" c
  | d == "up" && a < a' = simulate as a "even" (c + 1)
  | d == "down" && a < a' = simulate as a "down" c
  | d == "down" && a > a' = simulate as a "even" (c + 1)

main = do
  n <- getInt
  as <- getIntList
  print $ simulate as (-1) "" 0 + 1


Measured memory_bytes: 7160
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner
var out *bufio.Writer

func main() {
	sc = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	buf := make([]byte, 1<<20)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n, q := nextInt(), nextInt()
	c := nextInts(n)
	c = append([]int{0}, c...)

	qmap := make([][]query, n+1)
	for i := 0; i < q; i++ {
		l, r := nextInt(), nextInt()
		qmap[r] = append(qmap[r], query{l, i})
	}

	bit := newBIT(n)
	lastColorIndex := make([]int, n+1)
	result := make([]int, q)
	for right := 1; right <= n; right++ {
		color := c[right]
		if lastColorIndex[color] > 0 {
			bit.add(lastColorIndex[color], -1)
		}
		bit.add(right, 1)
		lastColorIndex[color] = right

		for _, query := range qmap[right] {
			result[query.index] = bit.rangesum(query.left, right)
		}
	}

	for i := 0; i < q; i++ {
		fmt.Fprintln(out, result[i])
	}
}

type query struct {
	left  int
	index int
}

// BinaryIndexedTree 部分列を求める
type BinaryIndexedTree struct {
	array []int
	n     int
}

func newBIT(n int) *BinaryIndexedTree {
	bit := new(BinaryIndexedTree)
	bit.array = make([]int, n+1)
	bit.n = n + 1
	return bit
}
func (bit BinaryIndexedTree) add(i, x int) {
	for ; i < bit.n; i += i & -i {
		bit.array[i] += x
	}
}
func (bit BinaryIndexedTree) sum(i int) int {
	result := 0
	for ; i > 0; i -= i & -i {
		result += bit.array[i]
	}
	return result
}
func (bit BinaryIndexedTree) rangesum(i, j int) int {
	return bit.sum(j) - bit.sum(i-1)
}

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}


Measured memory_bytes: 54072
n,a,b=map(int,input().split())
X=[int(x) for x in input().split()]
hirou=0

for i in range(n-1):
    if (X[i+1]-X[i])*a>=b:
        hirou+=b
    else:
        hirou+=(X[i+1]-X[i])*a

print(hirou)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  char vec[a][b];
  for(int i = 0;i < a;i++){
    for(int j = 0;j < b;j++){
      cin >> vec[i][j];
    }
  }
  int count = 0;
  
  for(int i = 0;i < a;i++){
    for(int j = 0;j < b;j++){
      if(vec[i][j] == '#' && vec[i][j-1] == '.' && vec[i][j+1] == '.' && vec[i-1][j] == '.' && vec[i+1][j] == '.'){
        count++;
      }
    }
  }
  
  if(count == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
 
int g(int a,int b){
  int r=a%b;
  if(r<1)return b;
  else return g(b,r);
}
int main(){
  int k;
  cin>>k;
  int ans=0;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
        ans +=g(g(i,j),l);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N;
	map<int,int>M;
	ll res=0;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int t;
		cin>>t;
		M[t]++;
	}
	for(map<int,int>::iterator it=M.begin();it!=M.end();it++)
	{
		if(it->second<it->first)res+=it->second;
		else if(it->second>it->first)res+=it->second-it->first;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 4736
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

n, m = map(int, input().split())
from collections import defaultdict
ns = defaultdict(set)
pps = [set() for _ in range(n)]
for i in range(n-1+m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    ns[a].add(b)
    pps[b].add(a)

for i,s in enumerate(pps):
    if not s:
        r = i
        
def tps(start):
    q = [start]
    # 行きがけ順
    seen = [None] * n
    # 帰りがけ順
    done = [None] * n
    d0 = 0
    d1 = n
    while q:
        u = q.pop()
        if u>=0:
            if seen[u]:
                continue
            seen[u] = d0
            d0 += 1
            q.append(~u)
            for v in ns[u]:
                if seen[v] is None:
                    q.append(v)
        else:
            d1 -= 1
            done[~u] = d1
    return seen, done

done = [None]*n
seen = [False]*n
def dfs(u, val):
    for v in ns[u]:
        if seen[v]:
            continue
        seen[v] = True
        val = dfs(v, val)
    val = val - 1
    done[u] = val
    return val

# dfs(r, n)
seen, done = tps(r)
ps = [-1] * n
ps[r] = 0
for i in range(n):
    if i==r:
        continue
    val = max(pps[i], key=lambda item: done[item])
    ps[i] = val+1
write("\n".join(map(str, ps)))

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

const string lts = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

pair<string, int> parse(const string &, int);

pair<string, int> letter(const string &s, int i) {
  if (i >= s.size()) throw "last";
  if (s[i] == '+') {
    auto res = letter(s, i+1);
    if (res.first[0] != 'Z')
      ++res.first[0];
    else
      res.first[0] = 'A';
    return res;
  } else if (s[i] == '-') {
    auto res = letter(s, i+1);
    if (res.first[0] != 'A')
      --res.first[0];
    else
      res.first[0] = 'Z';
    return res;
  }
  if ('A' <= s[i] && s[i] <= 'Z')
    return make_pair(string(1, s[i]), i+1);
  else
    throw "bad";
}

pair<string, int> str(const string &s, int i) {
  if (i >= s.size()) throw "last";
  if (s[i] == '[') {
    auto res = parse(s, i+1);
    reverse(begin(res.first),end(res.first));
    if (res.second >= s.size() || s[res.second] != ']') throw "bad";
    ++res.second;
    return res;
  }
  return letter(s, i);
}

pair<string, int> parse(const string &s, int i) {
  auto res = str(s, i);
  while(res.second < s.size() && s[res.second] != ']'){
    auto res2 = str(s, res.second);
    res.first += res2.first;
    res.second = res2.second;
  }
  return res;
}

string search(string &s, int i = 0) {
  if (i >= s.size()) {
    try {
      //cout<<s<<':';
      return parse(s, 0).first;
    } catch(...) {
      return "";
    }
  }
  if (s[i] != '?') return search(s, i+1);
  string res = "";
  for (char c:lts){
    if(!c) break;
    s[i] = c;
    string t = search(s, i+1);
    //cout<<t<<endl;
    if ((t != "" && t < res) || res == "") {
      res = t;
    }
  }
  s[i] = '?';
  return res;
}

int main() {
  while(1){
    string s;
    cin>>s;
    if(s==".") break;
    cout << search(s) << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long ll;

ll A, B, N, ans;

ll check( ll X ) {
    ll a1 = (A*X)/B;
    ll a2 = (X/B)*A;
    return( a1 - a2 );
}

int main()
{
    optimiza_io
    cin >> A >> B >> N;
    ll act = 1;
    while( act <= N ) {
        ll val = check( act );
        ll l = act, r = N;
        while( l < r ) {
            ll m = ( l + r + 1 ) / 2;
            if( check( m ) == val )
                l = m;
            else
                r = m - 1;
        }
        ans = max( ans , check( act ) );
        act = l + 1;
    }
        
    cout << ans << "\n";
    return 0;
}

// CHECAR LIMITES 

// 10 2 100

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

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

  int h, w;
  cin >> h >> w;

  vector<vector<char>> res(h + 2, vector<char>(w + 2, '#'));

  for (int i = 1; i < h + 1; i++) {
    for (int j = 1; j < w + 1; j++) {
      cin >> res[i][j];
    }
  }
  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++) {
      cout << res[i][j];
    }
    cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long A, B, C, D;
  cin >> A >> B >> C >> D;
  while(A > 0 && C > 0){
    C -= B;
    if(C <= 0){
      cout << "Yes" << endl;
      return 0;
    }
    A -= D;
    if(A <= 0){
      cout << "No" << endl;
      return 0;
    }
  }
  return 0;
}

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

int main() {
	int a,b,c,d;cin>>a>>b>>c>>d;
	int r;
	if(a==c){
		r=b-d;
	}else{
		r=a-c;
	}
	if(r<0){
		r*=-1;
	}
	int sub1,sub2;
	sub1=a-c;
	sub2=b-d;
	int x3=c+(b-d);
	int y3=d+(c-a);
	int x4=x3+(d-y3);
	int y4=y3+(x3-c);
	cout<<x3<<' '<<y3<<' '<<x4<<' '<<y4<<endl;

	return 0;
}


Measured memory_bytes: 256
import random

class Dice():
    def __init__(self):
        self.face = [i for i in range(6)]
        self.memo = [i for i in range(6)]

    def setface(self,initface):
        for i in range(6):
            self.face[i] = initface[i]

    def roll(self,direction):
        for i in range(6):
            self.memo[i] = self.face[i]
        index = {'E':(3,1,0,5,4,2),'N':(1,5,2,3,0,4),'S':(4,0,2,3,5,1),'W':(2,1,5,0,4,3)}
        for i in range(6):
            self.face[i] = self.memo[index[direction][i]]

    def top(self):
        return self.face[0]

dice = Dice()
initface = list(map(int,input().split()))
dice.setface(initface)
q = int(input())
for _ in range(q):
    u,f = map(int,input().split())
    while True:
        dice.roll(['E','N','S','W'][random.randint(0,3)])
        if dice.face[0]==u and dice.face[1]==f:
            print(dice.face[2])
            break


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

#define scanf abacaba
#define printf abacaba

 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
using namespace std;
 
 
/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
 
multiset<pair<int, int>> sl;
multiset<pair<int, int>> sr;
 
ll solve(int x) {
	ll ans = 0;
	ll cur = 0;
	int fl = 0;
	for (int i = x; !sl.empty() && fl < 2; ++i) {
		pair<int, int> p;
		if (i % 2 == 0) {
			p = *sl.rbegin();
			if (p.first <= cur && p.second >= cur) {
				fl += 1;
				continue;
			}
			sl.erase(sl.find(p));
			sr.erase(sr.find(make_pair(p.second, p.first)));
		}
		else {
			p = *sr.begin();
			swap(p.first, p.second);
			if (p.first <= cur && p.second >= cur) {
				fl += 1;
				continue;
			}
			sl.erase(sl.find(p));
			sr.erase(sr.find(make_pair(p.second, p.first)));
		}
		fl = 0;
		if (cur < p.first) {
			ans += abs(p.first - cur);
			cur = p.first;
		}
		else {
			ans += abs(p.second - cur);
			cur = p.second;
		}
	}
	ans += abs(cur);
	return ans;
}
 
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int l, r;
		cin >> l >> r;
		sl.insert(make_pair(l, r));
		sr.insert(make_pair(r, l));
	}
	auto tmpl = sl;
	auto tmpr = sr;
	ll ans = solve(0);
	sl = tmpl;
	sr = tmpr;
	ans = max(ans, solve(1));
	cout << ans << "\n";
	return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  int n = 999;
  vector<int> s(n);

  int tmp = 0;
  for(int i = 0; i < n; i++){
    s[i] =  tmp + i+1;
    tmp = s[i];
    //cout << s[i] << " ";
  }

  int idx = b-a-2;//前の塔番号
  int ans = s[idx] - a;


  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//package atCoder;
//package atCoder;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        if(a + b + c >= 22)
        {
            System.out.println("bust");
        }
        else
        {
            System.out.println("win");
        }
        scan.close();
    }

}


Measured memory_bytes: 23892
#include<iostream>
using namespace std;
int main() {
	int W, H, x, y, r;
	cin >> W >> H  >> x >> y >> r;
	
	if (x - r >= 0 && x + r <= W && y -r >= 0 && y + r <= H) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}

}

Measured memory_bytes: 1124
#include <stdio.h>
#include <string.h>

int main(){

  char s[120], t[120], tmp[3];
  int len_s, len_t, i, j, c;

  scanf("%s %s", s, t);

  len_s = strlen(s);
  len_t = strlen(t);

  for(i=0; i<len_s; i++){
    c=i;
    for(j=i; j<len_s; j++){
      if(s[j]<s[c]) c=j;
    }
    tmp[0] = s[i];
    s[i] = s[c];
    s[c] = tmp[0];
  }

  for(i=0; i<len_t; i++){
    c=i;
    for(j=i; j<len_t; j++){
      if(t[j]>t[c]) c=j;
    }
    tmp[0] = t[i];
    t[i] = t[c];
    t[c] = tmp[0];
  }

  if(strcmp(s,t)<0) puts("Yes");
  else puts("No");

  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    int n,a[101],i,f[101]={0},ff=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++){
        if(a[i]%2==0){
            if(a[i]%3!=0 && a[i]%5!=0) f[i]=1;
        }
        
    }
    for(i=0;i<n;i++){
        if(f[i]==1) ff++;
    }
    if(ff==0){
        printf("APPROVED\n");
    }else{
        printf("DENIED\n");
    }
    return 0;
    
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  long long N, M, X;
  cin >> N >> M >> X;
  vector<long long> C(N);
  vector<vector<long long>> A(N, vector<long long>(M, 0));
  rep(i, N)
  {
    cin >> C[i];
    rep(j, M)
    {
      cin >> A[i][j];
    }
  }

  long long ans = INT64_MAX;
  rep(div, 1 << (N + 1) - 1)
  {
    long long price = 0;
    vector<long long> skill(M, 0);
    rep(bit, N)
    {
      if (div >> bit & 1)
      {
        price += C[bit];
        rep(i, M)
        {
          skill[i] += A[bit][i];
        }
      }
    }

    bool is_ok = true;
    rep(i, M)
    {
      if (skill[i] < X)
        is_ok = false;
    }
    if (is_ok)
      ans = min(ans, price);
  }

  if (ans == INT64_MAX)
    ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define debug(x) cout<<#x<<": "<<x<<endl
typedef long long ll;
struct Point{double x,y;};
bool comp(Point a,Point b) {return (a.x==b.x ? a.y<b.y : a.x<b.x);}

int main(void){
    int N,K,X,Y;
    cin>>N>>K>>X>>Y;
    if(N>K)cout<<K*X+(N-K)*Y<<endl;
    else cout<<N*X<<endl;

    return 0;
}


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

using ll=long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define ALL(v) v.begin(),v.end()

string buf="";
string s="";

void dfs(ll pos, vector<vector<ll>>& adj, vector<bool>& used,set<ll>& leaf) {
	used[pos]=true;
	if((ll)adj[pos].size()==0)  {
		leaf.insert(pos);
		return;
	}
	REP(i,(ll)adj[pos].size()) {
		if(!used[adj[pos][i]]) dfs(adj[pos][i],adj,used,leaf);
	}
	return;
}

int main(){
	while(1) {
		ll n;
		cin>>n;
		if(n==0) break;
		ll cnt=0;
		vector<string> sp;	
		map<string,ll> dict;
		vector<vector<ll>> adj(2000);
		REP(i,n) {
			cin>>s;
			buf="";
			vector<string> used;
			REP(j,(ll)s.length()) {
				if(s[j]==':') {
					sp.push_back(buf);
					used.push_back(buf);
					if(dict.count(buf)==0) {
						dict[buf]=cnt;
						cnt++;
					}
					buf="";
				} else if(s[j]==','||s[j]=='.') {
					used.push_back(buf);
					if(dict.count(buf)==0) {
						dict[buf]=cnt;
						cnt++;
					}
					buf="";
				} else buf+=s[j];
			}
			for(ll j=1; j<(ll)used.size(); j++) {
				adj[dict[used[0]]].push_back(dict[used[j]]);
			}
		}
		for(auto x:dict) {
			//cout<<"piyo"<<x.first<<" "<<x.second<<endl;
		}
		set<ll> leaf;
		vector<bool> used(2000,false);
		dfs(dict[sp[0]],adj,used,leaf);
		cout<<(ll)leaf.size()<<endl;
	}	
	return 0;
}


Measured memory_bytes: 3236
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i64 = read();
    let k: i64 = read();
    let mut current = 1;

    for _ in 0..n {
        if current * 2 < current + k {
            current *= 2;
        } else {
            current += k;
        }
    }
    println!("{}", current);
}


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

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

typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> s = a;
    sort(s.rbegin(),s.rend()); //降順ソート,s[0]が最大
    rep(i, n) {
        int ans = s[0];
        if (s[0] == a[i]) ans = s[1]; //最大値を取り除く場合は2番目が一番大きい
        cout << ans << endl; //そのほかは最大値が答え
    }
    return 0;	
}

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

using namespace std;

int n, ar[100005], ans;

int main()
{
    scanf("%d", &n);
    for(int i=1;i<=n;i++)scanf("%d", ar+i);
    sort(ar+1, ar+n+1);
    int a = ar[n];
    int mi = 2e9+7;
    for(int i=1;i<n;i++){
        int k = abs(a-2*ar[i]);
        if(k < mi){
            mi = k;
            ans = ar[i];
        }
    }
    printf("%d %d\n", ar[n], ans);
    return 0;
}


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



    long long GCD(long long x, long long y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

int main() {
    int K;
   scanf("%d",&K);
    long long res = 0;
    for (int a = 1; a <= K; ++a) {
        for (int b = 1; b <= K; ++b) {
            for (int c = 1; c <= K; ++c) {
                res += GCD(GCD(a, b), c);
            }
        }
    }

   printf("%d",res);
}

Measured memory_bytes: 1736
s = list(input())

switch = 0 #カウント開始、0でオフ1でオン
all = len(s)
aC = 0
bC = 0
ans = 0
aC = s.index('A')
s = s[::-1]
bC = s.index("Z")
ans = (all - bC) - aC

print(ans)


Measured memory_bytes: 6180
function main(input) {
  var s = parseInt(input.split(" ")[0], 10);
  var arr=[s];
  var judge=0;
  var ans=1;
  while(judge==0){
    if(s%2==0){
      s=s/2
    }else{
      s=(3*s)+1
    }
    ans++
    if(arr.indexOf(s)>=0){
      judge++
    }else{
      arr.push(s)
    }
  }
  console.log(ans);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

struct Point {
	int x, y;
	Point operator + (const Point &p) const {
		return {x + p.x, y + p.y};
	}
	bool operator != (const Point &p) const {
		return x != p.x || y != p.y;
	}
};

vector<Point> get_path(int X, int Y, int K) {
	if (abs(X) + abs(Y) == K) {
		vector<Point> res = {{X, Y}};
		return res;
	}
	
	bool xneg = X < 0, yneg = Y < 0;
	X = abs(X);
	Y = abs(Y);
	
	bool rot = X > Y;
	if (rot) swap(X, Y);
	
	Point tgt = {X, Y};
	vector<Point> res;
	int step = (X + Y + K - 1) / K;
	if (X + Y >= K || (X + Y < K && (X + Y) % 2 == 0)) {
		if (X + Y < K || step * K % 2 != (X + Y) % 2) step++;
		int waste = (step * K - X - Y) / 2;
		
		Point cur = {-waste, K - waste};
		res.push_back(cur);
		assert(cur.y <= Y);
		
		while (cur != tgt) {
			int dx = min(K, tgt.x - cur.x), dy = K - dx;
			res.push_back({dx, dy});
			cur = cur + res.back();
		}
	}
	else {
		res.push_back({X, K - X});
		vector<Point> vec = get_path(0, -(K - X - Y), K);
		assert(vec.size() == 2);
		for (Point &p : vec) {
			res.push_back(p);
		}
	}
	
	for (Point &p : res) {
		assert(abs(p.x) + abs(p.y) == K);
		if (rot) swap(p.x, p.y);
		if (xneg) p.x *= -1;
		if (yneg) p.y *= -1;
	}
	
	return res;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int K, X, Y;
	cin >> K >> X >> Y;
	if ((abs(X) + abs(Y)) % 2 == 1 && K % 2 == 0) {
		cout << "-1\n";
		return 0;
	}
	
	auto ans = get_path(X, Y, K);
	Point cur = {0, 0};
	cout << ans.size() << '\n';
	for (int i = 0; i < ans.size(); i++) {
		cur = cur + ans[i];
		cout << cur.x << " " << cur.y << '\n';
	}
	
	return 0;
}

Measured memory_bytes: 3952
/*
??¢??????
lowlink
*/
#include <bits/stdc++.h>
#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()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
const int MAX_V=100000;
vector<int> G[MAX_V];
int ord[MAX_V],low[MAX_V];
int I;
int sum[MAX_V];
vector<int> arts;
void dfs(int v,int p){
	ord[v]=++I;
	low[v]=ord[v];
	sum[v]=1;
	int mx=0,c=0;
	for(int u:G[v]) if(u!=p){
		if(ord[u]) chmin(low[v],ord[u]);
		else{
			dfs(u,v);
			c++;
			sum[v]+=sum[u];
			chmin(low[v],low[u]);
			chmax(mx,low[u]);
		}
	}
	if(p<0){
		if(c>1) arts.pb(v);
	}else{
//		cout<<"v="<<v<<"  mx="<<mx<<endl;
		if(ord[v]<=mx) arts.pb(v);
	}
}
void arti(int N){
	rep(i,N) if(ord[i]==0) dfs(i,-1);
}
int main(){
	int N,M;
	cin>>N>>M;
	rep(i,M){
		int a,b;
		cin>>a>>b;
		G[a].pb(b);G[b].pb(a);
	}
	arti(N);
	sort(all(arts));
	for(int a:arts) cout<<a<<endl;
}

Measured memory_bytes: 5116
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO ;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            string S=Console.ReadLine();
            string ans="Good";
            for(int i=0;i<3;i++){
            
            
                if(S[i]==S[i+1])
                {
                    ans="Bad";

                }
            }
            Console.WriteLine(ans);


        }
    }
}

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

int main() {
    int X, A;
    cin >> X >> A;
    if (X < A) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n=int(input())
cnt=0
for i in range(n):
  x=int(input())
  s=0
  for j in range(2,(int(pow(x,0.5)//1)+1)): 
    if x%j==0:
      s=1
      break
  if s==0:
    cnt+=1
print(cnt)


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	cout << x * x*x << endl;
}


Measured memory_bytes: 3200
#include <stdio.h>
#include <ctype.h>
 
#define MAX 100000
#define _MAX 1500000

int par[MAX];
 
void init(int);
int depth(int);
int input(void);

char *p;
char in[_MAX];
int tree[MAX][15],idx[MAX];

int main(){
  int n,i,j,id,k,c;

  fread(in,sizeof(in),1,stdin);  
  p = in;

  n = input(); init(n);
  for(i = 0 ; i < n ; i++){
    id = input();
    k = input();
    for(j = 0 ; j < k ; j++){
      c = input();
      par[c] = id;
      tree[id][idx[id]++] = c;
    }
  }
 
  for(i = 0 ; i < n ; i++){
    printf("node %d: parent = %d, depth = %d, "
           ,i,par[i],depth(i));
    
    if(par[i] == -1){
      printf("root, [");
    }else if(!idx[i]){
      printf("leaf, [");
    }else{
      printf("internal node, [");
    }

    for(j = 0 ; j < idx[i] ; j++){
      printf("%d",tree[i][j]);
      if(j < idx[i]-1) printf(", ");
    }
    puts("]");
  }
  return 0;
}

void init(int n){
  int i;
  for(i = 0 ; i < n ; i++){
    par[i] = -1;
  }
}

int depth(int x){
  if(par[x] == -1) return 0;
  return depth(par[x]) + 1;
}

int input(){
  int v = 0;
  while(!isdigit(*p)) ++p;
  v = *p++&15;
  while(isdigit(*p)){
    v = (v<<3)+(v<<1)+(*p++&15);
  }
  return v;
}

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

int main(){
	int A,B,C;
	cin >> A >> B >> C;
	int K;
	cin >> K;
	int ans=A;
	int minK=K-(A+B);
	if(minK>0){
		cout << ans-minK << endl;
	}else if(minK<0){
		cout << K << endl;
	}else{
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3640
bilding = [[[0 for x in range(10)] for x in range(3)]for x in range(4)] 
n = int(input())
for k in range(n):
    b, f, r, v = map(int, raw_input().split())
    bilding[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        print(" "+" ".join(map(str, bilding[b][f])))
    if b != 3:
        print("#"*20)

Measured memory_bytes: 4232
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        Set<Integer> set = new HashSet<>();
        set.add(a);
        set.add(b);
        set.add(c);
        System.out.println(set.size());
    }
}

Measured memory_bytes: 21588