akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsgned ll
#define db double
#define pint pair<int,int>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline ll read(){
	ll x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
ll A,B;
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	A=read(),B=read();
	if(A==B)return puts("1"),0;
	Red(i,60,0)if((A>>i&1)!=(B>>i&1)){
		A&=(1ll<<i+1)-1,B&=(1ll<<i+1)-1;
		Red(j,i-1,0)if(B>>j&1){
			ll p=1ll<<i,q=1ll<<j;
			if(2*q<=A)return cout<<p+2*q-A+p-A,0;
			else return cout<<2*p-A,0;
		}ll p=1ll<<i;if(A==0&&B==1)return puts("2"),0;
		return cout<<p-A+1+p-A<<'\n',0;
	}
	return 0;
}





Measured memory_bytes: 3628
def L(a, b):
    res = a - 1
    b -= res
    a -= res
    b -= 1
    res += 1
    return res + (b-a)//2

def R(a, b):
    return L(n - b + 1, n - a + 1)
    
n, a, b = map(int, input().split())
if a > b: a, b = b, a
if (a - b) % 2 == 0:
    ans = (b - a) // 2
else:
    ans = min(L(a, b), R(a, b))
print(ans)

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

int main() {
  int a, b, c;
  cin >> a >> b;
 c = ( a * b ) % 2;
if(c == 0){
  cout << "Even" <<endl;
}
if(c == 1){
  cout << "Odd" <<endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const ll mod = 1e9+7;
const ll maxn = 1e6+9;
ll fat[maxn];



template <typename T>
T extGcd(T a, T b, T& x, T& y) {
    if (b == 0) {
        x = 1; y = 0; return a;
    }
    else {
        T g = extGcd(b, a % b, y, x);
        y -= a / b * x; return g;
    }
}
 
template <typename T>
T modInv(T a, T m) {
    T x, y;
    extGcd(a, m, x, y);
    return (x % m + m) % m;
}
 
template <typename T>
T modDiv(T a, T b, T m) {
    return ((a % m) * modInv(b, m)) % m;
}

template<typename T>
T modMul(T a, T b, T m) {
	T x = 0, y = a % m;
	while (b > 0) {
		if (b % 2 == 1) x = (x + y) % m;
		y = (y * 2) % m; b /= 2;
	}
	return x % m;
}

void calc(){
    fat[0] = 1;
    rep(i, 1, maxn){
        fat[i] = modMul((ll)i, fat[i-1], mod);
        //cout << fat[i] << ' ';
    }
    //cout << '\n';
    }


int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    ll x, y;
    cin >> x >> y;
    if ((x + y) % 3){
        cout << 0 << '\n';
        return 0;
    }
    
    
    ll n = (x+y)/3, k = (2*y - x)/3;
    if (x < n || x > 2*n || y < n || y > 2*n){
        cout << 0 << '\n';
        return 0;
    }
    calc();
    ll num = fat[n], den = modMul(fat[k], fat[n-k], mod);
    cout << modDiv(num, den, mod) << '\n';
    return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int sum=0,cnt=0;
    while(sum<b)
    {
        sum+=a;
        cnt++;
        if(sum<b) sum--;
    }
if(b==1)
    cout<<0<<endl;
else
    cout<<cnt<<endl;
 return 0;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner kb = new Scanner(System.in);

		int[][] bingos = new int[3][3];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				bingos[i][j] = kb.nextInt();
			}
		}
		boolean[][] realbingo = new boolean[3][3];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				realbingo[i][j] = false;
			}
		}

		int numbtocompare = kb.nextInt();
		int[] comparing = new int[numbtocompare];
		for(int i = 0; i<comparing.length; i++) {
			comparing[i] = kb.nextInt();
		}
		
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				for(int k = 0; k<comparing.length; k++)
				if (bingos[i][j] == comparing[k]) {
					realbingo[i][j] = true;
				}

			}
		}
		for (int i = 0; i < 3; i++) {
			if (realbingo[i][0] == true && realbingo[i][1] == true && realbingo[i][2] == true) {
				System.out.println("Yes");
				return;
			} else if (realbingo[0][i] == true && realbingo[1][i] == true && realbingo[2][i] == true) {
				System.out.println("Yes");
				return;
			}

		}
		if (realbingo[0][0] == true && realbingo[1][1] == true && realbingo[2][2] == true) {
			System.out.println("Yes");
			return;
		} else if (realbingo[0][2] == true && realbingo[1][1] == true && realbingo[2][0] == true) {
			System.out.println("Yes");
			return;
		} else {
			System.out.println("No");
		}
		
		
	}
}


Measured memory_bytes: 23124
#include<iostream>
#include<cmath>
using namespace std; 
int main(){
	int a,b;
	cin>>a>>b;
	if(a==b){
		cout<<a;
	}
	else if(a>b){
		cout<<a-1;
	}
	else{
		cout<<a;
	}
	
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int N ,M;
    cin >> N >> M;
    vector<pair<ll, ll>> pr;
    rep(i, N){
        ll a, b;
        cin >> a >> b;
        pr.push_back(make_pair(a,b));
    }
    sort(pr.begin(), pr.end());

    int cnt = 0; //これまでに買った数
    ll money = 0;
    for(auto itr : pr){
        int sub = M - cnt;
        int count = min(itr.second, (ll)sub);
        money += count * itr.first;
        cnt += count;
    }
    cout << money << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}

ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x,n;
	cin>>x>>n;
	set <ll> s;
	for(ll i=1;i<=101;i++)
		s.insert(i);
	for(ll i=0;i<n;i++){
		ll temp;
		cin>>temp;
		s.erase(temp);
	}

	set <ll> :: iterator a=upper_bound(all(s),x);
	if(s.size()==0){
		cout<<0<<"\n";
		return 0;
	}
	if(a==s.begin())
		cout<<((*a)-x>=x?0:*a)<<"\n";
	else if(a==s.end())
		cout<<*(--a)<<"\n";
	else{
		set <ll> :: iterator b=a;
		b--;
		if((x-(*b))<=((*a)-x))
			cout<<*b<<"\n";
		else
			cout<<*a<<"\n";
	}
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.regex.Pattern;

public class Main {
    public void solve(Stdin stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        int n = stdin.nextInt();
        int a = stdin.nextInt();
        int b = stdin.nextInt();
        String s = stdin.next();

        int c = 0;
        int d = 1;
        for (char ch : s.toCharArray()) {
            if (ch == 'a') {
                if (c < a + b) {
                    stdout.println("Yes");
                    c++;
                } else {
                    stdout.println("No");
                }
            } else if (ch == 'b') {
                if (c < a + b && d <= b) {
                    stdout.println("Yes");
                    c++;
                    d++;
                } else {
                    stdout.println("No");
                }
            } else {
                stdout.println("No");
            }
        }
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        Stdin stdin = new Stdin();
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }

    public static class Stdin {
        private Deque<String> queue;
        private BufferedReader stdin;
        private Pattern delimiter;

        public Stdin() {
            queue = new ArrayDeque<>();
            stdin = new BufferedReader(new InputStreamReader(System.in));
            delimiter = Pattern.compile(" ");
        }

        public String next() throws IOException {
            if (queue.isEmpty()) {
                delimiter.splitAsStream(stdin.readLine()).forEach(queue::addLast);
            }
            return queue.removeFirst();
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 28428
#include <bits/stdc++.h>
using namespace std;
/*
	__________   _____     _________   __            __    __________    ________     _________
	----------  | ----\    ---------   \ \   		/ /    |  _______|	| _____  \    ---------
		||      ||    ||  	  ||		\ \		   / /	   | |			| |		\ \	     ||
		||      ||____//      ||		 \ \      / /	   | |_____ 	| |		 | |	 ||
		||      |__ __/       ||		  \ \    / /	   | _____|		| |		 | |	 ||
		||      || \\         ||		   \ \  / /	   	   | |			| |		 | |	 ||
		||      ||  \\     ___||____        \ \/ /         | |_______ 	| |_____/ /   ___||____
		||		|| 	 \\    _________         \__/		   |_________|	|________/	  _________
*/
/********************************************************************/
/*
Codeforces : @a.trivedi
Codechef   : @adityat25
HackerRank : @adityatrivedi

/********************************************************************/
#define M1 1000000007
#define M3 1000000009
#define M2 998244353
#define ll long long
#define pll pair<ll,ll>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPR(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
/********************************************************************/
const double pi = 3.1415926535;
/********************************************************************/
//FAST IO//
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
/********************************************************************/
ll fun(ll curr, ll last, ll tot, vi acts[3], ll dp[][3]) {
	if (curr == tot)
		return 0;
	else {
		ll ans = -1;
		ll ind = -1;
		for (int j = 0; j < 3; j++) {
			if (j != last) {
				ll val = acts[j][curr] ;
				if (dp[curr][j] != -1)
					val += dp[curr][j];
				else {
					dp[curr][j] = fun(curr + 1, j, tot, acts, dp);
					val = acts[j][curr] + dp[curr][j];
				}
				if (ans < val) {
					ans = val;
					ind  = j;
				}
			}


		}
		//cout << (char)('A' + ind) << " " << ans << endl;
		return ans;
	}
	return -1;

}
int main() {
	FAST();
	ll days;
	cin >> days;
	vi acts[3];
	ll a, b, c;
	ll dp[days + 5][3] = {};

	for (int i = 0; i < days; i++) {
		cin >> a >> b >> c;
		acts[0].pb(a);
		acts[1].pb(b);
		acts[2].pb(c);
		dp[i][0] = -1; dp[i][1] = -1; dp[i][2] = -1;
	}
	cout << fun(0, -1, days, acts, dp);

	return 0;
}

Measured memory_bytes: 14560
#include <cstdio>
#include <numeric>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <array>
using i64 = long long;
using namespace std;

int gcd(int a, int b) {
  while (b) {
    int t = b;
    b = a % b;
    a = t;
  }
  return a;
}
int main() {
  int k;
  cin >> k;
  i64 s = 0;
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= k; j++) {
      int g1 = gcd(i, j);
      if (g1 == 1) { s += k; continue; }
      for (int l = 1; l <= k; l++) {
        s += gcd(l, g1);
      }
    }
  }
  cout << s << endl;
}

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

int main(void){

    int N; cin>>N;
    vector<long> A(N);
    for (int i = 0; i < N; ++i) {
        cin>>A[i];
    }
    vector<long> L(N), R(N);
    L[0] = 0;
    for (int i = 1; i < N; ++i) {
        L[i] = __gcd(L[i-1], A[i-1]);
    }

    R[N-1] = 0;
    for (int i = N-2; i >= 0; --i) {
        R[i] = __gcd(R[i+1], A[i+1]);
    }

    long ans=0;
    for (int i = 0; i < N; ++i) {
        ans = max(ans, __gcd(L[i], R[i]));
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
         
        using namespace std;
         
        int main() {
          int x, y;
          scanf("%d %d", &x, &y);
          if(y&1) {
            printf("No\n");
          } else {
            int b = (y >> 1) - x;
            int a = x - b;
            if(a < 0 || b < 0) {
              printf("No\n");
            } else {
              printf("Yes\n");
            }
          }
          return 0;
        }

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 999999999
#define ll long long
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
50
)");
#define cin input
#endif

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

	int count = 0;

	FOR(i,1,k)
	{
		count += (k-(i+1))/2+1;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define pb emplace_back
#define gg return puts("-1"),0
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=1e5+5;
int a[N],n;ll mn,mx,l,r;
inline int dec(R int x,R int y){return y?x-y:0;}
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%d",&a[i]);
	mx=mn=2,a[0]=1;
	if(2%a[n])gg;
	for(R int i=n;i;--i){
		l=mn,r=mx;
		mn=(l+a[i-1]-1)/a[i-1]*a[i-1];
		mx=(r+a[i]-1)/a[i-1]*a[i-1];
//		printf("%lld %lld %lld %lld\n",l,r,mn,mx);
		if(mn>mx)gg;
	}
	printf("%lld %lld\n",mn,mx);
	return 0;
}

Measured memory_bytes: 764
// by gantheory™
#include <bits/stdc++.h>

using namespace std;

const int N = 8000 + 10;

string s;
int x, y;

bool find_partition( vector< int >& now ) {
  int n = now.size() - 1;
  int sz = n + 10;
  bool dp[ N ][ sz ];
  for ( int i = 0; i <= 8000; ++i )
    for ( int j = 0; j <= n; ++j )
      dp[ i ][ j ] = false;
  for ( int i = 0; i <= n; ++i )
    dp[ 0 ][ i ] = true;

  int sum = accumulate( now.begin(), now.end(), 0 );
  if ( sum % 2 ) return false;
  for ( int i = 1; i <= sum / 2; ++i ) {
    for ( int j = 1; j <= n; ++j ) {
      if ( i - now[ j ] >= 0 )
        dp[ i ][ j ] = dp[ i ][ j - 1 ] or dp[ i - now[ j ] ][ j - 1 ];
      else
        dp[ i ][ j ] = dp[ i ][ j - 1 ];
    }
  }
  return dp[ sum / 2 ][ n ];
}
int main() {
  ios_base::sync_with_stdio( 0 ); cin.tie( 0 );
  cin >> s >> x >> y;
  for ( int i = 0; i < (int)s.size(); ++i ) {
    if ( s[ i ] == 'F' ) {
      --x;
      if ( i == (int)s.size() - 1 ) s.clear();
    }
    else {
      s = s.substr( i, s.size() - i );
      break;
    }
  }

  vector< int > sum[ 2 ];
  sum[ 0 ].push_back( 0 ); sum[ 1 ].push_back( 0 );
  int now = 0;
  for ( int i = 0; i < (int)s.size(); ++i ) {
    if ( s[ i ] == 'T' ) {
      if ( (int)sum[ now ].size() != 0 and sum[ now ].back() == 0 ) sum[ now ].pop_back();
      now ^= 1;
      sum[ now ].push_back( 0 );
    }
    else sum[ now ].back() += 1;
  }
  sum[ 0 ].push_back( abs( x ) ); sum[ 1 ].push_back( abs( y ) );

  cout << ( ( find_partition( sum[ 0 ] ) and find_partition( sum[ 1 ] ) ? "Yes" : "No" ) ) << '\n';
}


Measured memory_bytes: 21248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair
#define eb emplace_back

const int MAX_N = 2e6+10;

int x;

void solve()
{
	if(x) cout<<0;
	else cout<<1;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> x;
	solve();
	return 0;
}

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

int main() {
  int n;
  scanf("%d", &n);
  int *a = malloc(sizeof(int) * n);
  int i;
  for(i = 0; i < n; i++) scanf("%d", &a[i]);
  int m = 0;
  int *b = malloc(sizeof(int) * n);
  for(i = n - 1; i >= 0; i--) {
    if(i <= n / 2) {
      int tmp = i + 1;
      int count = 0;
      tmp += i + 1;
      while(tmp <= n) {
        if(b[tmp - 1] == 1) count++;
        tmp += i + 1;
      }
      if(a[i] == 0) {
        if(count % 2 == 0) b[i] = 0;
        else               b[i] = 1;
      } else {
        if(count % 2 == 0) b[i] = 1;
        else               b[i] = 0;
      }
      if(b[i] == 1) m++;
    } else {
      if(a[i] == 0) b[i] = 0;
      else          b[i] = 1;
      if(b[i] == 1) m++;
    }
  }
  printf("%d\n", m);
  for(i = 0; i < n; i++) {
    if(b[i] == 1) printf("%d\n", i + 1);
  }
  return 0;
}

Measured memory_bytes: 2432
n, k = map(int, input().split())
aa = list(map(int, input().split()))
cnts = [0] * (k + 1)
ans = 1e6
existing = 0
r = 0
for l in range(n - k + 1):
    while r < n and existing < k:
        a = aa[r]
        if a <= k:
            cnts[a] += 1
            if cnts[a] == 1:
                existing += 1
        r += 1
    if k == existing:
        ans = min(ans, r - l)
    a = aa[l]
    if a <= k:
        cnts[a] -= 1
        if cnts[a] == 0:
            existing -= 1

print(ans if ans < 1e6 else 0)

Measured memory_bytes: 18424
//#include"stdc++.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define cases ll t;cin>>t;while(t--)
#define f1(a,n) for(int i=a;i<n;i++)
#define f2(b,n) for(int j=b;j<n;j++)
#define INF 1000000000000009
#define pb push_back
ll ar[100005];
#define MAX 1000005
vector<vector<ll> > g(MAX);
ll dp[MAX];
ll dfs(ll i)
{
    if(dp[i]!=-1)
        return dp[i];
    ll temp=0;
    for(auto &j:g[i])
        temp=max(dfs(j)+1,temp);
    dp[i]=temp;
    return temp;
}
int main() {
    fast
    ll n,m;
    cin>>n>>m;
    
    memset(dp,-1,sizeof(dp));
    f1(0,m)
    {
        ll u,v;
        cin>>u>>v;
        u-=1;
        v-=1;
        g[u].pb(v);
    }
    ll res=0;
    f1(0,n)
        res=max(res,dfs(i));
    
    cout<<res;
    
    return 0;
}




Measured memory_bytes: 37120
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    vector<string> vec(n);
    for (int i=0; i<n; i++) {
        cin >> vec[i];
    }
    
    bool ans = true;
    for (int i=0; i<n-1; i++) {
        for (int j=i+1; j<n; j++) {
            if (vec[i] == vec[j]) ans = false;
        }
    }

    for (int i=0; i<n-1; i++) {
        if (vec[i+1][0] != vec[i][vec[i].size()-1]) ans = false;
    }

    if (ans == true) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 100005
#define NTL -1

struct Node{
  int p,q,r;
};

struct Node T[N];
int n,U[N];

void print(int w){
  int i,t;

  printf("node %d: ",w);
  printf("parent = %d, ",T[w].p);
  printf("depth = %d, ",U[w]);

  if(T[w].p==NTL)
    printf("root, ");
  else if(T[w].q==NTL)
    printf("leaf, ");
  else
    printf("internal node, ");
  printf("[");

  for(i=0,t=T[w].q;t!=NTL;i++,t=T[t].r){
    if(i)
      printf(", ");
    printf("%d",t);
  }
  printf("]\n");
}

void re(int w,int p){
  U[w]=p;
  if(T[w].r!=NTL)
    re(T[w].r,p);

  if(T[w].q!=NTL)
    re(T[w].q,p+1);
}

int main(){

  int i,j,v,d,t,q,r,n;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=T[i].q=T[i].r=NTL;
  }

  for(i=0;i<n;i++){
    scanf("%d",&v);
    scanf("%d",&d);
    for(j=0;j<d;j++){
      scanf("%d",&t);
      if(j==0)
	T[v].q=t;
      else
	T[q].r=t;
      q=t;
      T[t].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==NTL){
      r=i;
    }
  }

  re(r,0);
  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}



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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

int main()
{
    int n;
    cin >> n;
    
    map<string, int> mp;
    string s;
    
    for(int i = 0; i < n; i++)
        cin >> s, mp[s]++;
        
    cout << "AC x " << mp["AC"] << '\n';
    cout << "WA x " << mp["WA"] << '\n';
    cout << "TLE x " << mp["TLE"] << '\n';
    cout << "RE x " << mp["RE"] << '\n';
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N; cin >> N;
    string S; cin >> S;

    int d;
    while(true){
        d = 0;
        bool f = true;
        REP(i, S.size()){
            if(S[i] == '(') d++;
            else d--;
            if(d < 0){
                f = false;
                S = '(' + S;
                break;
            }
        }
        if(f) break;
    }
    REP(i, d) S = S + ')';
    cout << S;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

int main() {
  int a,b;
  cin>>a>>b;
  if(a<b){rep(i,b){cout<<a;}}else{rep(i,a){cout<<b;}}
  cout<<endl;
}


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

for i in range(n):
    for j in range(n):
        s = p.copy()
        tmp = 0
        tmp = s[i]
        s[i] = s[j]
        s[j] = tmp
        if s == t:
            print("YES")
            exit()
print("NO")







Measured memory_bytes: 3060
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7

N = i()
a = l()
table = [0]*N
ans = []
for i in range(N-1,-1,-1):
    bit = 0
    for j in range(i,N,i+1):
        bit = bit^table[j]
    bit = bit^a[i]
    if bit == 1:
        ans.append(i+1)
    table[i] = bit
print(len(ans))
print(*ans)

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

int N;
vector<int> ans;

bool is_p(int x)
{
	for(int i=2;i*i<=x;++i){
		if(x%i==0) return false;
	}
	return true;
}

void solve()
{
	for(int i=2;i<=55555;++i){
		if(is_p(i) && i%5==1) ans.push_back(i);
	}
	for(int i=0;i<N;++i) cout << ans[i] << ' ';
	cout << '\n';
}

int main()
{
	cin >> N;
	solve();
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  string S;
  cin >> N >> S;
  if(N%2 == 0){

    bool ans = true;
    for(int i = 0; i < N/2; i++){
      if(S[i] != S[i+N/2]){
        ans = false;
      }
    }

    if(ans){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }

  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import           Control.Exception (assert)
import           Data.Char         (toLower)

main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine
  s <- getLine
  assert (length s == n) $
    putStrLn $ solve k s

solve :: Int -> String -> String
solve 1 (c : cs) = toLower c : cs
solve k (c : cs) = c : solve (k - 1) cs
solve _ _        = undefined


Measured memory_bytes: 508
import sys
 
cnt = {}
 
for line in sys.stdin:
  for l in line:
    if l.isalpha():
      c = l.lower()
      cnt[c] = cnt.get(c,0)+1
 
for i in range(26):
  c = chr(ord('a')+i)
  print( c, " : ", cnt.get(c,0), sep = '' )


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

string f(ll n){
    if(n == 0) return "";
    n--;
    return f(n/26) + string(1,'a' + n%26);
}

int main(){
    ll n;
    cin >> n;
    cout << f(n) << endl;
    return 0;
}

Measured memory_bytes: 3628
#AOJ1160
def search(w,h,data):
    for i in range(h):
        if 1 in data[i]:
            return (i,data[i].index(1))
    return (-1,-1)

def main(w,h):
    data=[list(map(int,input().split())) for j in range(h)]
    start=search(w,h,data)
    island=0
    while start!=(-1,-1):
        island+=1
        checking=[start]
        data[start[0]][start[1]]=0
        while len(checking)>0:
            now=checking.pop()
            for j in range(now[0]-1,now[0]+2):
                for k in range(now[1]-1,now[1]+2):
                    if (j,k)!=now and j>=0 and k>=0 and j<h and k<w:
                        if data[j][k]==1:
                            data[j][k]=0
                            checking.append((j,k))
        start=search(w,h,data)
    return island          

w,h=map(int,input().split())
while w!=0 and h!=0:
    print(main(w,h))
    w,h=map(int,input().split())


Measured memory_bytes: 5628
#include <iostream>

using namespace std;

int main()
{
	string S;
	long K;
	cin >> S >> K;
	
	long n = min((long)S.size(), K);
	for (long i = 0; i < n; i++)
	{
		// 1以外の最初に見つかった数字を出力します。
		if (S[i] >= '2')
		{
			cout << S[i] << endl;
			return 0;
		}
	}
	// 全て1の場合
	cout << '1' << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#define rep(a,b,c) for(ll a=b;a<=c;a++)
#define per(a,b,c) for(ll a=b;a>=c;a--)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 5;
const int M = 2e5 + 5;
int n;
char s[N];
int a[N];

int main(){
    scanf("%s", s + 1);
    n = strlen(s + 1);
    //printf("n=%d\n", n);
    rep(i,1,n) a[i] = 1;
    rep(i,1,n){
        if(s[i] == 'R' && s[i-1] == 'R'){
            a[i] += a[i-1];
            a[i-1] = 0;
        }
    }
    per(i,n,1){
        if(s[i] == 'L' && s[i+1] == 'L'){
            a[i] += a[i+1];
            a[i+1] = 0;
        }
    }
    rep(i,1,n-1){
        if(s[i] == 'R' && s[i+1] == 'L'){
            int tmp = a[i]/2;
            int tmp2 = a[i+1]/2;
            a[i] = a[i] - tmp + tmp2;
            a[i+1] = a[i+1] - tmp2 + tmp;
        }
    }
    printf("%d", a[1]);
    rep(i,2,n) printf(" %d", a[i]);
    puts("");
    return 0;
}


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

int X;

main()
{
    cin >> X;

    int max = 1;
    for (int i = 2; i < X; i++) {
        for (int j = 2; pow(i, j) <= X; j++) {
            int p = pow(i, j);
            if (max < p) {
                max = p;
            }
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = scan.nextInt();
        int ans = Integer.MAX_VALUE;
        int low = 1, high = 1000000000;
        while (low <= high) {
            int mid = (low + high) / 2;
            int cnt = 0;
            for (int i = 0; i < n; i++) cnt += (a[i] - 1) / mid;
            if (cnt <= k) {
                ans = mid;
                high = mid - 1;
            } else low = mid + 1;
        }
        System.out.println(ans);
    }
}


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


int main() {
	int n;
	cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; i++) {
		cin >> vec[i];
	}

	sort(vec.begin(), vec.end());
	cout << vec[vec.size()-1] - vec[0] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    double m;
    cin >> n >> m;
    vector<int>a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int sumVote = 0;
    for(int i = 0; i < n; i++) sumVote += a[i];
    sort(a.begin(), a.end(), greater<int>());
    double jadgeLine = 1 / (4*m);
  //  cout << jadgeLine << endl;
    int canSelect = 0;
    for(int i = 0; i < m; i++){
        if(a[i] >= sumVote*jadgeLine) canSelect += 1;
    }
  //  cout <<  sumVote << endl;
    if(canSelect == m) cout << "Yes";
    else cout << "No";
}


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

int main() {
  ll x;
  cin >> x;
  double rate = 1.01;
  ll money = 100;
  for (int year = 1; year <= 4000; year++){
    money = money * rate;
    if(money >= x){
      cout << year << endl;
      return 0;
    }
  }
}

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

int n,k,a[10];
string s,t;

int main() {
  cin >> s;
  int ans=0;
  for(auto c:s){
    if(c=='1') ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int x,y,s,i,j,max,bef,aft;
    for(;;){
        scanf("%d %d %d", &x, &y, &s);
        if(x==0 && y==0 && s==0) break;
        max=0; //?????????
        for(i=1;i<s;i++){ //??????????????????1~s-1?????§????????????
            for(j=1;j<s;j++){
                bef = i*(100+x)/100 + j*(100+x)/100;
                if(bef==s){ //????????????x%?¨??????????????¨????s?????¨???
                    aft = i*(100+y)/100 + j*(100+y)/100; //y%?¨??????????????¨????
                    if(max<aft) max = aft; //?????§?????´??°
                }
            }
        }
        printf("%d\n", max);
    }
    return 0;
}

Measured memory_bytes: 600
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    r = kwargs["r"]
    res = 2 * r * math.pi
    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    #kwargs["n"] = cin[0]
    #kwargs["n"], kwargs["k"] = cin
    kwargs["r"] = [int(i) for i in cin][0]
    #kwargs["n"], kwargs["k"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Measured memory_bytes: 31072
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
ar=[0]*60
for i in a:
  for j in range(60):
    if i&(1<<j):
      ar[j]+=1


for i ,j in enumerate(ar):
  b=n-j
  ans+= j*b*2**i

print(ans%mod)

Measured memory_bytes: 122808
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  int ans = INF;
  for (int p = 1; p <= 100; p++) {
    int temp = 0;
    for(int x: v) {
      temp += pow((x-p), 2);
    }
    ans = min(ans, temp);
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 3588
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	ll N; cin >> N;
	vector<ll> A(N), B(N); rep(i, N)cin >> A[i] >> B[i];

	vector<pair<ll, ll>> AB(N);
	rep(i, N) {
		AB[i].first = A[i];
		AB[i].second = B[i];
	}

	sort(ALL(AB));

	cout << AB[N - 1].first + AB[N - 1].second << endl;
}

Measured memory_bytes: 11136
#include <cstdio>

int a[100005];

int main()
{
    int n, m;
    long long ans = 0;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
        int x; scanf("%d", &x);
        a[x]++;
        ans += 1LL * x;
    }
    scanf("%d", &m);
    while(m--)
    {
        int b, c;
        scanf("%d%d", &b, &c);
        ans -= 1LL * a[b] * b;
        ans += 1LL * a[b] * c;
        printf("%lld\n", ans);
        a[c] += a[b];
        a[b] = 0;
    }
    return 0;
}

Measured memory_bytes: 2120
#include <iostream>
#include<vector>
#include <cmath>
using namespace std;

int main(){
    int n,t,a;
    cin >> n >> t >> a;
    vector <double> h(n);
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    float min=1000000;
    int ans=0;
    for(int j=0;j<n;j++){
        double hei = t - 0.006*h[j];
        double sub = abs(hei-a);
        if(sub < min){
            min = sub;
            ans = j+1;
        }     
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
    a:usize,
    b:usize,
    c:[usize;b*2],
  }
    let mut v = vec![0; a];
    for i in 0..b*2 {
        v[c[i]-1]+=1;
    }
    for i in 0..a {
        println!("{}",v[i])
    }
}

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

using namespace std;


int main()
{
    //string S, T, U;
    int H, A;
    int count = 0;

    //double K, S;
    //double x, y, z;


    cin >> H >> A;

  
    while (1) {
        if ( H <= count* A) { break; }
        count++; 
    }

    
    
    cout << count << endl;


 

     return 0;

}




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

int main(){
    double a,b,x;
    double pi = acos(-1);
    cin >> a >> b >> x;
    if(x == a*a*b/2){
        cout << fixed << setprecision(15) << 45.0000000000 << endl;
    }else if (x < a*a*b/2){
        cout << fixed << setprecision(15) << 90 - atan(2*x/(a*b*b)) * 180 / pi << endl;
    }else if (x > a*a*b/2){
        cout << fixed << setprecision(15) << 90 - atan(a*a*a/(2*(a*a*b-x))) * 180 / pi << endl;
    }
    return 0;
}


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

int main() {
  int D; cin >> D;
  if (D == 25) cout << "Christmas" << endl;
  if (D == 24) cout << "Christmas Eve" << endl;
  if (D == 23) cout << "Christmas Eve Eve" << endl;
  if (D == 22) cout << "Christmas Eve Eve Eve" << endl;
}


Measured memory_bytes: 256
import java.util.InputMismatchException;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
	try {
	    Scanner scan = new Scanner(System.in);
	    int a = scan.nextInt();
	    int b = scan.nextInt();
	    int s = a * b;
	    int l = 2 * (a + b);
	    System.out.println(s + " " + l);
	    scan.close();
	} catch (InputMismatchException e) {
	    System.out.println("??°?????\????????\??????????????????");
	}
    }
}

Measured memory_bytes: 17156
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>s;
    reverse(all(s));
    s+="0000";
    
    n=sz(s);
    fo(i,n)
    {
        lli x=s[i]-'0';
        s[i+1]+=x/10;
        x%=10;
        if(x>5)
        {
            s[i+1]++;
            cnt+=10-x;
        }
        else if(x<5)
            cnt+=x;
        else
        {
            if(s[i+1]-'0'>=5)
            {
                s[i+1]++;
                cnt+=10-x;
            }
            else
                cnt+=x;
        }
    }

    cout<<cnt<<endl;

}   aryanc403();
    return 0;
}


Measured memory_bytes: 1948
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
// vector<vector<int>> A(3, vector<int>(4));
int main() {
  int N;
  cin>>N;
  int ans=0;
  for(int i=1; i<N; i++){
      if(i!=N-i){
          ans++;
      }
  }
  cout<<ans/2<<endl;
}



Measured memory_bytes: 3584
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <math.h>
//const long long mod = 1000000007;
//const long long mod = 998244353;

long long min_times(long long*A, long long*F, long long t, int N) {
	long long res = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] * F[N - i - 1] > t) {
			res += A[i] - t / F[N - i - 1];
		}
	}
	return res;
}

int main() {
	long long N, K;
	scanf("%lld %lld", &N, &K);
	long long*A = new long long[N];
	long long*F = new long long[N];
	for (int i = 0; i < N; i++) {
		scanf("%lld", A + i);
	}
	for (int i = 0; i < N; i++) {
		scanf("%lld", F + i);
	}
	std::sort(A, A + N);
	std::sort(F, F + N);
	if (min_times(A, F, 0, N) <= K) {
		printf("0");
		return 0;
	}
	long long r = 0;
	for (int i = 40; i >= 0; i--) {
		long long c = r | (1LL << i);
		if (min_times(A, F, c, N) > K)r = c;
	}
	printf("%lld", r + 1);
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;

bool is_integer(double x){
  return lround(x) == x;
}

int main(){
  int n, d;
  cin >> n >> d;
  vector<vector<int> > x(n, vector<int>(d));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++){
      cin >> x.at(i).at(j);
    }
  }
  int count = 0;
  int ans = 0;
  for(int i = 0; i < n-1; i++){
    for(int k = i+1; k < n; k++){
      int l = 0;
      for(int j = 0; j < d; j++){
        l += pow(x.at(i).at(j) - x.at(k).at(j), 2);
      }
      double ls = sqrt(l);
      if(is_integer(ls)) count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mp(x,y) make_pair(x,y)

void solve(){
    int n,k;
    cin>>n>>k;
    int a[n+1]={0};
    for(int i=0;i<k;i++){
        int x; cin>>x;
        for(int j=0;j<x;j++){
            int y; cin>>y;
            a[y]++;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(a[i]==0) ans++;
    }
    cout<<ans<<'\n';
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int tc;
    tc=1;
    while(tc--){
        solve();
    }
return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
	long long h,w,n,x;
	cin>>h;
	cin>>w;
	cin>>n;
	x=max(h,w);
	if (n%x==0)
	{
		cout<<n/x<<endl;
	}
	else
	{
		cout<<n/x+1<<endl;
	}
}

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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int a[] = fs.nextIntArray(n);
		int sum = 0;
		for(int i=0;i<n;i++) {
			sum += a[i];
		}
		int ans = 0;
		int tmp = Integer.MAX_VALUE/2;
		for(int i=0;i<n;i++) {
			int dif = Math.abs(sum - a[i]*n);
			if(tmp > dif) {
				tmp = dif;
				ans = i;
			}
		}
		System.out.println(ans);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

long long n, m;
long long data[2][2] = {0};

long long solve(int x);

int main() {
  cin >> n >> m;
  cout << min(solve(0), solve(1)) << endl;
  return 0;
}

long long solve(int x) {
  long long o = 0, d = 1, cnt = 0, bf;
  data[0][0] = n;
  data[1][0] = m;
  data[0][1] = 0;
  data[1][1] = 0;
  while(data[0][0] > 0 && data[1][0] > 0) {
    data[d][1] += data[o][0];
    if((o + x) % 2) {
      if(data[d][0] < data[d][1]) {
        bf = data[d][1] - data[d][0];
        data[d][0] -= bf;
        data[d][1] = data[d][0];
      }
    }
    else {
      data[d][0] -= data[d][1] / 2;
      data[d][1] %= 2;
    }
    if(data[0][0] <= 0 || data[1][0] <= 0) break;
    swap(o, d);
    ++cnt;
  }
  return cnt;
}



Measured memory_bytes: 3096
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;

int main(int, char**) 
{
    int a, b;
    cin >> a >> b;
    printf("%d %d %.5f\n",(a/b),(a%b),double(a) / double(b));
    //cout << floor( a / b ) << " " << a % b << " " << double(a) / double(b) << endl;
}


Measured memory_bytes: 3160