akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    Int n;
    cin >> n;
    vector<int> a(n);
    Int s = 0;
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
        s = s xor a[i];
    }

    for (Int i = 0; i < n - 1; i++) {
        cout << (s xor a[i]) << ' ';
    }
    cout << (s xor a.back()) << endl;

    return 0;
}

Measured memory_bytes: 3960
#include <iostream>

using namespace std;

typedef long long ll;

ll mod = 1000000007;


void swap(ll &a, ll &b){
    ll c = a;
    a = b;
    b = c;
}

ll modadd(ll a, ll b){
    return (a+b)%mod;
}

ll modsub(ll a, ll b){
    ll c = (a-b)%mod;
    if(c < 0){
        c += mod;
    }
    return c;
}

ll modmul(ll a, ll b){
    return ((a%mod) * (b%mod)) % mod;
}

ll modinv(ll a) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}

ll moddiv(ll a, ll b) {
    return ((a%mod) * (modinv(b))) % mod;
}


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

ll modcomb(ll a, ll b){
    ll x = 1;
    for(int i=0; i<b; i++){
        x = modmul(x, modsub(a,i));
    }
    ll y = 1;
    for(int i=0; i<b; i++){
        y = modmul(y, modsub(b,i));
    }
    return moddiv(x,y);
}



int main(){
    ll N, K;
    cin >> N >> K;
    

    ll ans = 0;
    for(ll i=K; i<=N+1; i++){
        ll x = moddiv(modmul(i, modadd(N+1, N-i+1+1)),2);
        ll y = moddiv(modmul(i, i+1),2)-1;
        ans = modadd(ans, modsub(x,y));
    }
    cout << ans << endl;
    
    
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<math.h>
int isPrime(int);
int main(){
	int n,i,j=0;
	scanf("%d",&n);
	int A[n];
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	for(i=0;i<n;i++){
		if(isPrime(A[i])==1){
			j++;
		}
	}
	printf("%d\n",j);
}
int isPrime(int x){
	int i;
  if (x == 2)
    return 1;
  if (x < 2 || x%2==0){
    return 0;
   }
  i = 3;
  while( i <= sqrt(x)){ //の平方根
    if (x % i==0) //で割り切れる
      return 0;
    i = i + 2;
	}
 return 1;
 }


Measured memory_bytes: 2084
N = int(input())
S1 = input()
S2 = input()
MOD = 10 ** 9 + 7
ans = 0
i = 0
pre = -1
while i < N:
    if S1[i] == S2[i]:
        if pre == 0:
            ans *= 2
            ans %= MOD
            pre = 0
            i += 1
        elif pre == 1:
            i += 1
            pre = 0
        else:
            i += 1
            ans = 3
            pre = 0
    else:
        if pre == 0:
            ans *= 2
            ans %= MOD
            i += 2
            pre = 1
        elif pre == 1:
            ans *= 3
            ans %= MOD
            i += 2
            pre = 1
        else:
            i += 2
            ans = 6
            pre = 1

print(ans)


Measured memory_bytes: 3064
//============================================================================
// Name        : AOJ1154_maru.cpp
// Author      : mizo0203
// Version     :
// Copyright   : Your copyright free
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<stdio.h>
#include<algorithm>

#define MAX_SIZE 300000

using namespace std;

void set_prime_number(bool* array, int num) {
  fill(array, array + num, true);
  array[0] = false;
  for (int i = 1; i < num; i++) {
    if (!array[i])
      continue;
    if (i % 7 != 1 && i % 7 != 6) {
      array[i] = false;
    }
  }
}

void set_sosu_number(bool* array, int num) {
  array[1] = false;
  for (int i = 2; i < num; i++) {
    if (!array[i])
      continue;

    for (int j = i * 2; j < num; j += i) {
      array[j] = false;
    }

    //for(int j=2;j<i;j++){
    //if(array[j]){
    //if(i%j==0){
    //array[i]=false;
    //}
//}
//}
  }
}

int main(void) {
  bool getudo_number[MAX_SIZE];
  int num;

  set_prime_number(getudo_number, MAX_SIZE);
  /*月曜土曜数設定*/

  set_sosu_number(getudo_number,MAX_SIZE);
  scanf("%d", &num);

  while (num != 1) {
    printf("%d:", num);
    for (int i = 2; i < MAX_SIZE; i++) {
      if (getudo_number[i]) {
        if (num % i == 0) {
          printf(" %d", i);
        }
      }
    }
    printf("\n");
    scanf("%d", &num);
  }

  return 0;
}

Measured memory_bytes: 1320
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]


def dfs(i, a, b, c):
    if i == n:
        if a < 1 or b < 1 or c < 1:
            return 10 ** 18
        return abs(A-a) + abs(B-b) + abs(C-c)
    res = dfs(i + 1, a, b, c)
    res = min([res, dfs(i + 1, a + l[i], b, c) + (10 if a > 0 else 0)])
    res = min([res, dfs(i + 1, a, b + l[i], c) + (10 if b > 0 else 0)])
    res = min([res, dfs(i + 1, a, b, c + l[i]) + (10 if c > 0 else 0)])
    return res


print(dfs(0, 0, 0, 0))


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

///Author:Refat(BSMRSTU)///

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e5 + 5;
const int M = 1e9 + 7;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}
int main() {
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);
    int n,res=0,cnt,num;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        num=i;cnt=0;
        while(num>0){
        num/=10;
        cnt++;
        }
        if(cnt%2==1)res++;
    }
    printf("%d\n",res);
    return 0;
}



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

int main() {
  int T, A, B;
  cin >> T >> A >> B;
  
  if((T * A) < B)
    cout << T * A << endl;
  else if((T * A) > B)
    cout << B << endl;
  else
    cout << B << endl;
}

Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    from functools import reduce
    def lcm_base(n1,n2):
        return (n1*n2)//math.gcd(n1,n2)
    def lcm(*numbers):
        return reduce(lcm_base, numbers)
    n,m = LI()
    s = S()
    t = S()
    l1 = lcm(n,m)
    s_unit = l1//n
    t_unit = l1//m
    l2 = lcm(s_unit, t_unit)
    time = (l1-1)//l2+1
    itr = [l2*i for i in range(time)]
    ans = l1

    for i in itr:
        si = i//s_unit
        ti = i//t_unit
        if s[si] != t[ti]:
            ans = -1

    print(ans)

main()            


Measured memory_bytes: 75180
#include <bits/stdc++.h>
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i : c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
using namespace std;
const int dx[] = { 1, -1 , 0 , 0  };
const int dy [] = { 0 ,0 , 1 , -1  };
const int MOD = 1000 * 1000 * 1000 + 7 ;
const int N = 4  ;
const int MAXN = 1000*100 + 5 ;
const int INF = INT_MAX ;
int main ( ){
fast_io();

int t = 1  ;
// cin >> t ;
while (t--){
int  n , r ;
cin >> n >> r ;
if (n >= 10 )
cout << r ;
else
cout << ( r + ( 100 * (10 - n ) )) ;
br  


}
return 0 ;
 
}


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



int main(){
    int N,M;
    int A=0;
    cin >> N >> M;
    vector<int>vec(N,0);
    vector<int>check(N,0);
	vec.at(0) = 1;
    for (int i=0;i<M;i++){
        int S,C;
        cin >> S >> C;
        if(check.at(S-1) == 0 || C == vec.at(S-1)){
            vec.at(S-1) = C;
            check.at(S-1) = 1;
        }
        else{
            A = -1;
            break;
        }
    }
    if(A != -1){
        for(int i=0;i<N;i++){
             A *= 10;
            A += vec.at(i);
        }
    }
    if(N>=2 && vec.at(0) == 0){
			A = -1;
    }
	if(N == 1 && M == 0){
      A = 0;
    }
    cout << A <<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#define LL long long
using namespace std;
const LL mod=1e9+7;
LL n,m,k;
LL fac[20000010],inv[20000010];
void pre()
{
    fac[0]=fac[1]=inv[0]=inv[1]=1;
    for(LL i=2;i<=20000005;i++) fac[i]=fac[i-1]*i%mod,inv[i]=(mod-mod/i)*inv[mod%i]%mod;
    for(LL i=2;i<=20000005;i++) inv[i]=inv[i-1]*inv[i]%mod;
}
LL C(LL m,LL n) {return fac[m]*inv[m-n]%mod*inv[n]%mod;}
int main()
{
	pre();
	scanf("%lld %lld %lld",&n,&m,&k);
	LL sum=0;
	for(LL i=1;i<=k;i++) sum=(sum+(i+1)*C(n+m,n)%mod+i*(i-1)%mod*C(n+m-2,n-1)%mod)%mod;
	printf("%lld",sum*fac[n]%mod*fac[m]%mod*inv[n+m-k]%mod);
}

Measured memory_bytes: 312704
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

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

	Int N, a, b, c;
	cin >> N >> a >> b >> c;

	vector<Int> l(N);
	for (Int i = 0; i < N; i++) {
		cin >> l[i];
	}

	Int mpa = 0;
	Int mpb = 0;
	Int mpc = 0;
	Int lena = 0;
	Int lenb = 0;
	Int lenc = 0;
	Int tempa = 0;
	Int tempb = 0;
	Int tempc = 0;
	Int ans = INF;
	for (Int bita = 1; bita < (1LL << N); bita++) {
		mpa = 0;
		lena = 0;
		for (Int i = 0; i < N; i++) {
			if (bita & (1LL << i)) {
				mpa += 10;
				lena += l[i];
			}
		}
		mpa -= 10;

		for (Int bitb = 1; bitb < (1LL << N); bitb++) {
			if (bita & bitb)continue;
			mpb = 0;
			lenb = 0;
			for (Int i = 0; i < N; i++) {
				if (bitb & (1LL << i)) {
					mpb += 10;
					lenb += l[i];
				}
			}
			mpb -= 10;

			for (Int bitc = 1; bitc < (1LL << N); bitc++) {
				if (bita & bitc)continue;
				if (bitb & bitc)continue;
				mpc = 0;
				lenc = 0;
				for (Int i = 0; i < N; i++) {
					if (bitc & (1LL << i)) {
						mpc += 10;
						lenc += l[i];
					}
				}
				mpc -= 10;

				tempa = mpa;
				tempb = mpb;
				tempc = mpc;
				
				tempa += abs(a - lena);
				tempb += abs(b - lenb);
				tempc += abs(c - lenc);

				ans = min(ans, tempa + tempb + tempc);

			}
		}
	}
	cout << ans << endl;

}

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

using namespace std;
using ll = long long;

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

bool isMonth(int x) { return 1 <= x && x <= 12; }

bool isYear(int x) { return 0 <= x && x <= 99; }

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

  int yy = 10 * (s[0] - '0') + (s[1] - '0');
  int mm = 10 * (s[2] - '0') + (s[3] - '0');

  if (isMonth(yy)) {
    if (isMonth(mm)) {
      cout << "AMBIGUOUS" << '\n';
      return 0;
    } else if (isYear(mm)) {
      cout << "MMYY" << '\n';
    }
  } else {
    if (isMonth(mm)) {
      cout << "YYMM" << '\n';
      return 0;
    } else {
      cout << "NA" << '\n';
    }
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int num[252521];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, a;
  cin>>n;
  REP(i, n-1){
    cin>>a;
    ++num[a];
  }
  FOR(i, 1, n+1){
    cout<<num[i]<<'\n';
  }
  return 0;
}


Measured memory_bytes: 4328
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
int n,m,a[110];
int dp[100010];
int main() {
	//freopen("1.txt","r",stdin);
	read(m); read(n);
	for (int i=1;i<=m;i++) read(a[i]);
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++)
			if (i>=a[j]&&!dp[i-a[j]]) { dp[i]=1; break; }
	}
	if (dp[n]) printf("First\n");
	else printf("Second\n");
	return 0;
}

Measured memory_bytes: 640
import sys

n, T, A, *h = map(int, sys.stdin.read().split())

def main():
    t = [T - 0.006 * h[i] for i in range(n)]
    d = [(abs(A - t[i]), i+1) for i in range(n)]
    d.sort()
    return d[0][1]

if __name__ == '__main__':
    ans = main()
    print(ans)

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

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

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

int GCD(int a, int b){
    if(b == 0) return a; 
    if(a < b) return GCD(b, a);
    else return GCD(b, a%b);
}

struct Edge{
    int to;
    long cost;
    Edge(int t, long c){
        to = t;
        cost = c;
    }
};
typedef pair<long, int> P;//距離、点

struct Dijkstra{
    int V;
    vector<vector<Edge>> G;
    vector<long> d;
    long inf = 1000000000000000000; // 10^18

    Dijkstra(int vv){
        V = vv;
        G.resize(V);
        d.resize(V);
    }

    void add_data(int a, int b, long c){
        Edge e1(b, c);
        G[a].push_back(e1);
    }

    void calc_dis(int s){
        priority_queue<P, vector<P>, greater<P>> que; //Pのfirstが小さい奴から取り出せる
        REP(i, V) d[i] = inf;
        d[s] = 0l;
        que.push(P(0, s));

        while(!que.empty()){
            P p = que.top(); que.pop();
            int v = p.second;
            if(d[v] < p.first) continue;
            for(int i=0;i<G[v].size();i++){
                Edge e = G[v][i];
                if(d[e.to] > d[v] + e.cost){
                    d[e.to] = d[v] + e.cost;
                    que.push(P(d[e.to], e.to));
                }
            }
        }
    }


};

int main()
{   
    int V, E, r; cin >> V >> E >> r;
    Dijkstra ds(V);
    REP(i, E){
        int s, t; cin >> s >> t;
        long d; cin >> d;
        ds.add_data(s, t, d);
    }
    ds.calc_dis(r);
    REP(i, V){
        if(ds.d[i] == ds.inf) cout << "INF" << endl;
        else cout << ds.d[i] << endl;
    }
    
    return 0;
}




Measured memory_bytes: 19360
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1L<<32;
ll fac[MAX], finv[MAX], inv[MAX];

int main(){
  ll w,a,b,ans;cin>>w>>a>>b;
  if(b>a+w){ans=b-a-w;}
  else if(b+w<a){ans=a-b-w;}
  else{ans=0;}
  cout<<ans<<endl;
}




Measured memory_bytes: 3564
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int mn = a*x+b*y;
    for(int i=0; i<=max(x, y); i++) {
        mn = min(mn, (i * 2 * c) + (max(0, x - i) * a) + (max(0, y - i) * b));
    }
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	char x,y;
	scanf("%c %c",&x,&y);
	if(y>x){
		printf("<\n");
	}
	else if(y<x){
		printf(">\n");
	}
	else{
		printf("=\n");
	}
	return 0;
}
	

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

using namespace std;

#define F first
#define S second

const int MAXN = 1e4 + 10;

int n, k, cnt[200];
set<pair<int, int>>	st;
pair<int, int>	sec[200];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	while (n--){
		string s;	cin >> s;
		cnt[s[0] - 'A']++;
	}
	for (int i = 0; i < 26; i++)
		if (cnt[i])	st.insert({cnt[i], i});

	int ans = 0;
	while (st.size() >= k){
		ans++;
		for (int i = 0; i < k; i++){
			auto it = st.end();	it--;
			sec[i] = *it;
			st.erase(it);
		}
		for (int i = 0; i < k; i++)
			if (sec[i].F > 1)
				st.insert({sec[i].F - 1, sec[i].S});
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


vector<vector<int>> g;

vector<P> edges;
map<P, int> mp;

int cntColor;

void dfs(int current, int last = -1, int lastCol = -1) {
	int curCol = 0;
	REP(i, g[current].size()) {
		int nxNode = g[current][i];
		if (nxNode == last)continue;
		if (curCol == lastCol) curCol++;
		P eg = make_pair(min(current,nxNode), max(current, nxNode));
		if (mp[eg] == -1) {
			mp[eg] = curCol;
		}
		dfs(nxNode, current, curCol);
		curCol++;
	}
	cntColor = max(curCol, cntColor);

}

int main() {
	int N; cin >> N;
	g.assign(N, vector<int>());
	REP(i, N - 1) {
		int a, b; cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
		P qr = make_pair(min(a, b), max(a, b));
		edges.push_back(qr);
		mp[qr] = -1;
	}

	dfs(0);

	print(cntColor);
	REP(i, edges.size()) {
		P qr = make_pair(edges[i].first, edges[i].second);
		print(mp[qr] + 1);
	}




	return 0;
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b)
{
	return b ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void printVec(vector<int> &vec)
{
	for (auto &e : vec)
	{
		cout << e << " ";
	}
	cout << endl;
}

int main()
{
	string al = "abcdefghijklmnopqrstuvwxyz";
	char c;

	cin >> c;

	rep(i, 26)
	{
		if (al[i] == c)
		{
			cout << al[i + 1] << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define debug(aa, a) fprintf(stderr, aa, a)

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {

	string s, t;
	cin >> s >> t;
	cout << t + s << endl;

	Please AC;
}

Measured memory_bytes: 760
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

using ll = long long;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    int same = 0;
    if (a == b) {
        same++;
    }
    if (a == c) {
        same++;
    }
    if (b == c) {
        same++;
    }
    if (same == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
fun gcd(x: Int, d: Int): Int {
    if (d == 0) return x
    if (x == 0) return d
    if (x >= d) return gcd(d, x % d)
    return gcd(x, d % x)
}

fun main(args: Array<String>){
    val (a, b, c) = readLine()!!.split(" ").map(String::toInt)
    if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
        println(0)
        return
    }
    if (a == b && a == c) {
        println(-1)
        return
    }
    var ans = 0
    var difGcd = gcd(gcd(Math.abs(a-b), Math.abs(b-c)), Math.abs(c-a))
    while (difGcd % 2 == 0) {
        difGcd /= 2
        ans++
    }
    println(ans)
}


Measured memory_bytes: 37872
ABC=list(map(int,input().split()))
c=0

for i in range(3):
    while ABC[i]<max(ABC)-1:
        ABC[i]+=2
        c+=1

if ABC.count(max(ABC))==3:
    print(c)
elif ABC.count(max(ABC))==2:
    print(c+2)
else:
    print(c+1)

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

bool check(string s)
{
	int n = s.size();
	for(int i = 0; i < n / 2; i++)
		if(s[i] != s[n - i - 1])
			return false;
	return true;
}

int main()
{
	string s;
	cin >> s;
	
	int n = s.size();
	
	bool fl = check(s) and check( s.substr(0, (n - 1) / 2) ) and check( s.substr(((n + 3) / 2) - 1) );
	
	puts(fl ? "Yes" : "No");

	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
vector<pair<long long, long long>> prime_factorize(long long n) {
    vector<pair<long long, long long>> res;
    for(long long p = 2; p * p <= n; ++p) {
        if(n % p != 0)
            continue; //因数じゃない
        int num = 0;
        while(n % p == 0) {
            ++num;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if(n != 1)
        res.push_back(make_pair(n, 1)); // nが素数だった場合
    return res;
}

int main() {
    ll N;
    ll P;
    cin >> N >> P;
    auto p = prime_factorize(P);
    ll ans = 1;
    for(auto cur : p) {
        /* code */
        if(cur.second >= N) {
            ans *= pow(cur.first, (cur.second / N));
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define fl(i,a,n) for(int i=a; i<n; i++)
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define test()  int tt;  cin>>tt;  while(tt--)
#define nl  cout<<"\n"
#define pii pair<int,int>
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)    {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}
const int mod=1e9+7;
void solve()    {
        int n;  cin>>n;
        string s;       cin>>s;
        map<char,ll> mp;
        fl(i,0,s.size())        {
                mp[s[i]]++;
        }
        ll ans=mp['R']*mp['G']*mp['B'];
        fl(i,0,n-2)     {
                fl(j,i+1,n-1)   {
                        int k=j+(j-i);
                        if(k<n && s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k])    ans--;
                }
        }
        cout<<ans;
}
/*  Integer Overflow  */
int main()  {
    fast;
    //test()
        solve();
}

Measured memory_bytes: 3660
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $ans = [];
  for ($i=0; $i<$n; $i++) {
    list($a) = explode(" ", trim(fgets(STDIN)));
    if(!isset($ans[$a])) {
      $ans[$a] = true;
    }else {
      if($ans[$a]) $ans[$a] = false;
      else $ans[$a] = true;
    }
  }

  $x = 0;
  foreach ($ans as $k => $v) {
    if($v) $x++;
  }

  echo $x;

Measured memory_bytes: 23116
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N, A, B = mi()
S = input()

passed = 0
passedfrgn = 0
for c in S:
  if c=='a':
    if passed<A+B:
      print('Yes')
      passed += 1
    else:
      print('No')
  elif c=='b':
    if passed<A+B and passedfrgn<B:
      print('Yes')
      passed += 1
      passedfrgn += 1
    else:
      print('No')
  else:
    print('No')






Measured memory_bytes: 54104
n , m = map(int,input().split())
war = []
for _ in range(m):
    a , b = map(int,input().split())
    war.append([a,b])
war.sort()
ans = 1
min_right = war[0][1]
max_left = war[0][0]
for i in range(0,m - 1):
    now_left, now_right = war[i][0], war[i][1]
    next_left , next_right = war[i + 1][0] , war[i + 1][1]
    min_right = min(min_right , next_right)
    max_left = max(max_left,next_left)
    if max_left >= min_right:
        ans += 1
        min_right = next_right
print(ans)

Measured memory_bytes: 21708
package main

import (
	"fmt"
)

func main() {
	var N, M, C int
	fmt.Scan(&N, &M, &C)

	B := make([]int, M)
	for x := range B {
		fmt.Scan(&B[x])
	}

	var res, tmp, A int
	for i := 0; i < N; i++ {
		tmp = 0
		for j := 0; j < M; j++ {
			fmt.Scan(&A)
			tmp += (A * B[j])
		}
		tmp += C
		if tmp > 0 {
			res++
		}
	}
	fmt.Println(res)
}

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

const int N = 1e5 + 10;
string s, t;
set<int> st[130];
long long a, b;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> s >> t;
    for (int i = 0, l = s.size(); i < l; i++)
        st[s[i]].insert(i);
    for (int i = 0, l = t.size(); i < l; i++)
    {
        if (st[t[i]].empty())
        {
            cout << -1 << endl;
            return 0;
        }
        if (st[t[i]].lower_bound(b) == st[t[i]].end())
        {
            a++;
            b = 0;
        }
        b = *st[t[i]].lower_bound(b);
        b++;
    }
    cout << a * s.size() + b << endl;
    return 0;
}

Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n; cin>>n;
    vector<ll> x(n);
    rep(i,n) cin>>x[i];
    ll res=10101010101;
    for(ll p=1; p<105; p++){
        ll tmp=0;
        rep(i,n) tmp+=(x[i]-p)*(x[i]-p);
        chmin(res,tmp);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a == b && a != c)
    cout << "Yes" << endl;
  else if(a == c && a != b)
    cout << "Yes" << endl;
  else if(b == c && a != c)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll x; cin >> x;
  if(x%11==0) cout << x / 11 * 2 << endl;
  else if(x%11<=6) cout << x / 11 * 2 + 1 << endl;
  else cout << x / 11 * 2 + 2 << endl;

  return 0;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
import bisect
from functools import reduce
def main():
    def comb(n, r):
        numerator = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])
        denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])
        return numerator * pow(denominator, mod - 2, mod) % mod
    mod = 10 ** 9 + 7
    N, K = MI()
    if K >= N - 1:
        ans = comb(2 * N - 1, N - 1)
        print(ans)
    else:
        N_r = pow(N, mod - 2, mod)
        ans = N * (N - 1) % mod
        add = N * (N - 1) % mod
        for i in range(2, K + 1):
            a = (N - i + 1) % mod
            b = (a - 1) % mod
            c = pow(i, mod - 2, mod)
            d = pow(c, 2, mod)
            add = ((((add * a) % mod * b) % mod) * d) % mod
            ans += add
            ans %= mod
        if K >= 2:
            ans += 1
            ans %= mod
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 102044
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long  ll;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a){
        cout<<k<<endl;
        return 0;
    }else if(k<=a+b){
        cout<<a<<endl;
        return 0;
    }else{
        cout<<a-(k-a-b)<<endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <utility>
#include <functional>
#include <map>
#include <string>
#include <set>
#include <math.h>

using namespace std;

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

  static const long MOD = 1000000007;

  int n, m;
  cin >> n >> m;
  int a[m];
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }

  for (int i = 0; i < m - 1; i++) {
    if (a[i] + 1 == a[i + 1]) {
      cout << 0 << endl;
      return 0;
    }
  }

  long c[n + 1];
  c[0] = 1;
  c[1] = 1;
  for (int i = 2; i <= n; i++) {
    c[i] = (c[i - 1] + c[i - 2]) % MOD;
  }

  long sum = 1L;
  int start = 0;
  int end = n;
  int length;
  for (int i = 0; i < m; i++) {
    end = a[i] - 1;
    length = end - start;

    sum = (sum * c[length]) % MOD;
    start = a[i] + 1;
  }

  length = n - start;
  sum = (sum * c[length]) % MOD;

  cout << sum << endl;
}


Measured memory_bytes: 1280
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [0]*N

for i in range(1, N):
    h_to = h[i]
    dp[i] = min(
        [
            dp_from + abs(h_to - h_from)
            for dp_from, h_from in zip(
                dp[max(0, i-K):i], h[max(0, i-K):i]
            )
        ]
    )

print(dp[-1])

Measured memory_bytes: 13980
def __gcd(a: int, b: int) -> int:
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return __gcd(b, a % b)


def monsters_battle_royale(N: int, A: list) -> int:
    a = A[0]
    for b in A[1:]:
        a = __gcd(a, b)

    return a


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    ans = monsters_battle_royale(N, A)
    print(ans)


Measured memory_bytes: 14252
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
typedef long long ll;
ll n, m, x, y, q, d,z, w = 0, sum = 0, ans = 0;
vector<vector<int>> G;
vector<int> memo;
ll dfs(int i) {
	if (memo[i] != 0)return memo[i];
	ll rec = 0;
	for (int i : G[i]) rec = max(rec, dfs(i)+1);
	return memo[i] = rec;
}
int main(void) {
	cin >> n >> m; G.resize(n);
	memo.resize(n);
	rep(i, m) {
		cin >> x >> y; x--; y--;
		G[x].push_back(y);
	}
	rep(i, n) ans = max(ans, dfs(i));
	cout << ans << endl;
}

Measured memory_bytes: 11052
#include <cstdio>
#include <algorithm>
#include <functional>

int main()
{
  int n, k;
  scanf("%d%d", &n, &k);
  int a[50];
  for (int i = 0; i < n; ++i)
  {
    scanf("%d", a + i);
  }
  std::sort(a, a + n, std::greater<int>());
  int ans = 0;
  for (int i = 0; i < k; ++i)
  {
    ans += a[i];
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
N = int(input())
A = input()
B = input()
C = input()
count = 0
for i in range(N):
    if A[i] == B[i] and B[i] == C[i]:
        continue
    elif A[i] == B[i]:
        C[i] == A[i]
        count += 1
    elif A[i] == C[i]: 
        B[i] == A[i]
        count += 1
    elif B[i] == C[i]:
        A[i] == B[i]
        count += 1
    else:
        B[i] == A[i]
        C[i] == A[i]
        count += 2
print(count)

Measured memory_bytes: 3064
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        h:usize,w:usize,
        hw:[Chars;h],
    }
    let mut v = vec![0usize; 26];
    for r in hw {
        for &c in &r {
            v[charconv(c, 'a')] += 1;
        }
    }
    let mut c = 0;
    if h % 2 == 1 {
        c += w / 2;
    }
    if w % 2 == 1 {
        c += h / 2;
    }
    let mut ret = 0;
    let mut ret2 = 0;
    for i in 0..26 {
        if v[i] % 4 == 2 {
            ret += 1;
        }
        if v[i] % 2 == 1 {
            ret2 += 1;
        }
    }
    if ret > c || ret2 > 1 {
        yn(false);
        return;
    }
    yn(true);
}
pub fn charconv(c: char, base: char) -> usize {
    return (c as u8 - base as u8) as usize;
}
pub fn yn(ans: bool) {
    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

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

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N;
    cin >> N;

    vi a(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];

    vi pref(N);
    for (int i = 0; i + 1 < N; i++)
        pref[i + 1] = __gcd(pref[i], a[i]);

    vi suff(N);
    for (int i = N - 1; i > 0 ; i--)
        suff[i - 1] = __gcd(suff[i], a[i]);

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

    return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ll H, W;
	cin >> H >> W;

	auto result = LLONG_MAX;
	auto S = H * W;
	auto func = [](ll s1, ll s2, ll s3)
	{
		auto minS = min(s1, min(s2, s3));
		auto maxS = max(s1, max(s2, s3));
		return maxS - minS;
	};
	for (auto i = 0ll; i <= H; ++i)
	{
		auto S1 = i * W;
		auto S2 = W / 2 * (H - i);
		auto S3 = S - S1 - S2;
		result = min(result, func(S1, S2, S3));

		S2 = (H - i) / 2 * W;
		S3 = S - S1 - S2;
		result = min(result, func(S1, S2, S3));
	}
	for (auto i = 0ll; i <= W; ++i)
	{
		auto S1 = i * H;
		auto S2 = (W - i) / 2 * H;
		auto S3 = S - S1 - S2;
		result = min(result, func(S1, S2, S3));

		S2 = H / 2 * (W - i);
		S3 = S - S1 - S2;
		result = min(result, func(S1, S2, S3));
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
N=int(input())
def prime_factorization(n):
    p={}
    for i in range(2,int(n**.5)+1):
        x=0
        while n%i==0:
            n//=i
            x+=1
        if x:
            p[i]=x
    if n>1:
        p[n]=1
    return p
p=prime_factorization(N)
x=0
for v in p.values():
    y=0
    while y<v:
        x+=1
        y+=1
        v-=y
print(x)

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);

    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    ll ma_all = 100*a;
    ll ma_melt = 0;
    for(int i=0; i<=30; i++){
        for(int j=0; j<=30; j++){
            if(100*a*i + 100*b*j > f){
                continue;
            }
            for(int k=0; k<=3000; k++){
                for(int l=0; l<=3000; l++){
                    ll melt = c*k + d*l;
                    ll all = 100*(a*i + b*j) + c*k + d*l;

                    if(melt <= e*(a*i + b*j) && all <= f){
                        //printf("%lld %lld %f\n", all, melt, 1.0 * melt / all);
                        if(melt != 0 && ((ma_melt == 0 && ma_all == 0) || ma_melt*all < melt*ma_all)){
                            ma_melt = melt;
                            ma_all = all;
                        }

                    }

                }
            }
        }
    }

    if(ma_all == 0 && ma_melt == 0){
        printf("%d %d\n", 100*a, 0);
    }else{
        printf("%lld %lld\n", ma_all, ma_melt);
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  string s;
  cin >> s;
  cout << (s == "ARC" ? "ABC" : "ARC") << endl;
}

Measured memory_bytes: 3636
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

// i: index, n: size, a: start, b: end
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

// x: container(array, vector etc..)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5

#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main() {
  int a, b;
  cin >> a >> b;

  int count = 1;
  int ans = 0;
  while(count < b) {
    ans++;
    count += a;
    count -= 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>


     
#define INF 1e9
#define LINF 1e19
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define pb push_back
#define sz size()
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

     
const ll MOD = 1e9 + 7;
const ll ZER = 0;



int main(){
    string s;
    cin >> s;
    int cnt = 0;
    rep(i, 4)if(s[i] == '2')cnt++;
    cout << cnt << endl;
}





Measured memory_bytes: 3164
// 反転数の演算
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_N 200000
const int INFTY = 2147483647;

typedef long long llong;

int cmp_count = 0;

llong mergeSort(int A[], int n, int left, int right);
llong merge(int A[], int n, int left, int mid, int right);

int main(void)
{
    llong flip_count;

    int A[MAX_N];
    int n;

    scanf("%d", &n);

    for(int i = 0; i < n; i++)
    {
        scanf("%d", &A[i]);
    }

    // マージソートを実施
    flip_count = mergeSort(A, n, 0, n);

    // 反転数の表示
    printf("%lld\n", flip_count);

    return 0;
}

// マージソートを実施する関数
llong mergeSort(int A[], int n, int left, int right)
{
    llong c1, c2, c3, cnt = 0;

    // 最小単位まで分割する
    if ( left + 1 < right )
    {
        int mid = ( left + right ) / 2;
        c1 = mergeSort(A, n, left, mid);
        c2 = mergeSort(A, n, mid, right);
        c3 = merge(A, n, left, mid, right);

        // 反転数の計算
        cnt = c1 + c2 + c3;
  }

  return cnt;
}

// 分割された要素を並び替える関数
llong merge(int A[], int n, int left, int mid, int right)
{

    // 反転数
    llong flip_count = 0;

    vector<int> L, R;

    int n1 = mid - left;
    int n2 = right - mid;

    // L[0...n1], R[0...n2] を生成
    for(int i = 0; i < n1; i++)
    {
        // 前半部分の配列を作成する
        L.push_back(A[left + i]);
    }

    for(int i = 0; i < n2; i++)
    {
        // 後半部分の配列を作成する
        R.push_back(A[mid + i]);
    }

    // 前半と後半の配列の最後の要素に最大値を入れておく
    // ( 比較時の番兵として使用 )
    L.push_back(INFTY);
    R.push_back(INFTY);

    int i = 0;
    int j = 0;

    for(int k = left; k < right; k++)
    {
        // 前半部分の配列と後半部分の配列を比較する
        if ( L[i] <= R[j] )
        {
            A[k] = L[i++];
        }
        else
        {
            A[k] = R[j++];
            // 反転数の計算
            flip_count += n1 - i;
        }

        cmp_count++;
    }

    return flip_count;
}



Measured memory_bytes: 4640
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  double a[11111];
  int n=0;
  double ans;
  while(cin>>a[n]){
    n++;
  }
  sort(a,a+n);
  ans=a[n-1]-a[0];
  cout<<ans<<endl;
}

Measured memory_bytes: 1300
import sys 
import numpy as np
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, K = map(int, readline().split())
A = [0] + list(map(int,readline().split()))
S = np.cumsum(A)
dic = defaultdict(int)
ans = 0
SS = [0] * (N+1)
for i in range(1,N+1):
    rem = (S[i]-i) % K
    SS[i] = rem

for i in range(N+1):
    if i >= K:
        dic[SS[i-K]] -= 1
    ans += dic[SS[i]]
    dic[SS[i]] += 1
print(ans)

Measured memory_bytes: 62012
#include<bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#define for1(i,l,r) for(int i=(l);i<(r);i++)
#define for2(i,l,r) for(int i=(l);i>(r);i--)
using namespace std;
int n,m,u,v,root,le;
vector<vector<pair<int,int> > > r;
vector<pair<int,int> > ans;
int cnt[100006],vis[100006],out[100006];
void dfs(int u){
	vis[u]=true;
	cnt[u]+=out[u];
	for(int i=0;i<r[u].size();i++){
		int x=r[u][i].first,y=r[u][i].second;
		if(!vis[x]){
			dfs(x);
			cnt[u]+=cnt[x];
			cnt[u]%=2;
			if(cnt[x]%2==1) swap(ans[y].first,ans[y].second);
		}
	}
}
signed main(){
//	freopen(".inp","r",stdin);
//	freopen(".out","w",stdout);
//	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>m;
	r.assign(n+1,vector<pair<int,int> >());
	for(int i=0;i<m;i++){
		cin>>u>>v;
		out[u]++;
		r[u].push_back({v,i});
		r[v].push_back({u,i});
		ans.push_back({u,v});
	}
	for(int i=1;i<=n;i++){
		out[i]%=2;
		if(out[i]) le++;
	}
	if(le%2==1)	cout<<-1;
	else{
		dfs(1);
		for(int i=0;i<m;i++) cout<<ans[i].first<<" "<<ans[i].second<<endl;
	}
}


Measured memory_bytes: 11892