akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

// $ g++ -std=c++11 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
int N;
int f(LL x) {
  int res=0;
  while(x>0) res+=x%10,x/=10;
  return res;
}
int solve() {
  int res=1e4;
  FOR(n,1,N) {
    LL m=N-n;
    SMIN(res,f(n)+f(m));
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N;
  cout<<solve()<<endl;
  return 0;
}


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

int main() {
	int n,m;cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++)  cin>>a[i];
	sort(a,a+n,greater<int>());
	int sum=0;
	for(int i=0;i<n;i++){
	    sum+=a[i];
	}
	int votes=(sum/(4*m));
	if(sum%2!=0){
	    votes=votes+1;
	}
	int cnt=0;
	for(int i=0;i<m;i++)
	{
	    if(a[i]>=votes) 
	   cnt++;
	   
	}
	if(cnt>=m)  cout<<"Yes"<<endl;
	else   cout<<"No"<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
EPS = 10**(-7)
N,K = map(int,input().split())
xyc = [list(map(int,input().split())) for _ in range(N)]

def possible(t):
    res = False
    cand = []
    for i in range(N):
        cand.append(xyc[i][:2])
        x1,y1,c1 = xyc[i]
        r1 = t/c1
        for j in range(i+1,N):
            x2,y2,c2 = xyc[j]
            r2 = t/c2
            d = ((x2-x1)**2+(y2-y1)**2)**0.5
            if abs(r1-r2)+EPS<d<r1+r2-EPS:
                mx = x1+(x2-x1)*(r1**2-r2**2+d**2)/(2*d**2)
                my = y1+(y2-y1)*(r1**2-r2**2+d**2)/(2*d**2)
                l = abs((r1**2-(mx-x1)**2-(my-y1)**2)**0.5)
                nx = (y2-y1)/d
                ny = -(x2-x1)/d
                cand.append([mx+nx*l,my+ny*l])
                cand.append([mx-nx*l,my-ny*l])


    for X,Y in cand:
        n = 0
        for i in range(N):
            x,y,c = xyc[i]
            if c*((X-x)**2+(Y-y)**2)**0.5<t+EPS:
                n += 1
        if n>=K:
            res = True

    return res

ng = 0
ok = 10**6
m = (ng+ok)/2
for i in range(100):
    if possible(m):
        ok = m
    else:
        ng = m
    m = (ok+ng)/2
print(m)

Measured memory_bytes: 63320
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <climits>
#include <iomanip>

using namespace std;

int main() {
	int a, b, c, k;

	cin >> a >> b >> c >> k;

	int ans = 0;

	if (a >= k) {
		ans = k;
	}
	else if (a < k) {
		if (k - a <= b) {
			ans = a + 0 * b;
		}
		else if (k - a > b) {
			ans = a + 0 * b - (k - a - b);
		}
	}
	
	cout << ans << endl;

	return 0;
}

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

int dp[1005][1005] = {0};
string a, b;

int main() {
  cin >> a >> b;
  for(int i = 0; i <= a.size(); ++i) dp[i][0] = i;
  for(int i = 0; i <= b.size(); ++i) dp[0][i] = i;
  for(int i = 1; i <= a.size(); ++i)
    for(int j = 1; j <= b.size(); ++j) {
      dp[i][j] = min(
          dp[i - 1][j] + 1,
          min(dp[i][j - 1] + 1,
              dp[i - 1][j - 1] + !(a[i - 1] == b[j - 1])));
    }
  cout << dp[a.size()][b.size()] << endl;
  return 0;
}


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

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

    for (int i = 0; i < T.size(); i++) {
        if (i == 0 && T[i] == '?') {
            if (T[i + 1] == '?') {
                T[i] = 'P';
            }
            else {
                T[i] = 'D';
            }
        }
        else if (i < T.size()-1 && T[i] == '?') {
            if (T[i - 1] == 'D' && T[i + 1] == 'D') {
                T[i] = 'P';
            }
            else if (T[i - 1] == 'D' && T[i + 1] == '?') {
                T[i] = 'P';
            }
            else if (T[i - 1] == 'P' && T[i + 1] == '?') {
                T[i] = 'D';
            }
            else {
                T[i] = 'D';
            }
        }
        else if (i >= T.size() - 1 && T[i] == '?') {
            T[i] = 'D';
        }
    }


    cout << T << endl;
    return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iterator>
#include <utility>
#include <iomanip>
#include <cmath>
#include <climits>
#include <cassert>
#include <stdio.h>
#include <string.h>

using namespace std;

void solve() {
  std::vector< std::vector<int> > vv(3, std::vector<int>(2));
  for (int _vi = 0; _vi < 3; _vi++) {
    for (int _vj = 0; _vj < 2; _vj++) {
      cin >> vv[_vi][_vj];
    }
  }
  
  std::vector<int> v(4, 0);
  for (auto &tv : vv) {
    v[tv[0]-1]++;
    v[tv[1]-1]++;
  }
  
  auto odd_n = std::count_if( v.begin(), v.end(), [=](decltype(*begin(v)) x) -> bool {
      return x % 2 != 0;
    });
  bool ret = (odd_n == 2);

  std::cout << (ret ? "YES" : "NO") << std::endl;
}

int main(int argc, char *argv[])
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;

int main() {
    int a, b; cin >> a >> b;
    for (int i = 0; i < max(a, b); i++) {
        cout << min(a, b); 
    }
    cout << endl;
}

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

using namespace std;

int main() {
  int n, h, w;
  cin >> h >> w >> n;
  vector<pair<int, int>> p(n);
  for (int i = 0; i < n; i++)
    cin >> p[i].first >> p[i].second;
  sort(p.begin(), p.end(),
       [](const pair<int, int> &l, const pair<int, int> &r) {
         if (l.second == r.second) {
           return l.first < r.first;
         }
         return l.second < r.second;
       });
  int ans = h;
  int c = 0;
  for (int i = 0; i < n; i++) {
    if (p[i].second + c < p[i].first)
      ans = min(ans, p[i].first - 1);
    else if (p[i].second + c == p[i].first)
      c++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll odd_xor(ll a){
    
    ll div = (a+1)/2;
    if (div % 2 == 0){
        return 1;
    }
    else{
        return 0;
    }
}

ll even_xor(ll a){
    return (a+1) ^ (odd_xor(a+1));
}


ll get_xor(ll a){
    if(a%2 ==0){
        return even_xor(a);
    }
    else{
        return odd_xor(a);
    }
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll A, B; cin >> A >> B;
    
    cout << (get_xor(B)^get_xor(A-1)) << endl;
    
}

Measured memory_bytes: 3648
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main{
	public static void main(String args[]) throws Exception {

		
		Scanner sc = new Scanner(System.in);
		int N= sc.nextInt();
		int L= sc.nextInt();
		ArrayList<String> Line = new ArrayList<String>();

		for(int i = 0;i < N +1;i++) {
				Line.add(sc.nextLine());
		}
		Collections.sort(Line)

		;
		for (String line : Line) {
			System.out.print(line);

		}


	}

}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7;

int N;
unordered_set<int> visited;
map<int, vector<int>> edges;
map<int, vector<int>> subtree_sizes;

ll mod_exp(ll x, ll exp) {
    ll ans = 1;
    ll base = x % MOD;
    while (exp > 0) {
        if (exp % 2 == 1) {
            ans = (ans * base) % MOD;
        }
        base = (base * base) % MOD;
        exp /= 2;
    }
    return ans;
}

ll mod_inv_prime(ll x) {
    return mod_exp(x, MOD-2);
}

int dfs(int v) {
    // cout << v << endl;
    visited.insert(v);
    int total_size = 0;
    for (int ne : edges[v]) {
        // cout << "attempt visit " << ne << endl;
        if (!visited.count(ne)) { 
            int subtree_size = dfs(ne) + 1;
            // cout << "subtree size " << subtree_size << endl;
            if (subtree_size > 0) {
                subtree_sizes[v].push_back(subtree_size);
            }
            total_size += subtree_size;
        }
    }
    if (N - 1 - total_size > 0) {
        subtree_sizes[v].push_back(N-1-total_size);
    }
    return total_size;
}

int main() {
    cin >> N;
    for (int i = 0; i < N-1; i++) {
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }

    dfs(0);

    ll ev = 0;
    ll two_inv = mod_inv_prime(2);
    vector<ll> two_inv_pow = {1};
    ll curr = 1;
    for (int i = 0; i < N; i++) {
        curr = (curr * two_inv) % MOD;
        two_inv_pow.push_back(curr);
    }

    for (int i = 0; i < N; i++) {
        if (subtree_sizes[i].size() < 2) continue;
        ll p_all_white = 1;
        for (int subtree_size : subtree_sizes[i]) {
            p_all_white = (p_all_white * two_inv_pow[subtree_size]) % MOD;
        }
        ll p_one_black = 0;
        for (int subtree_size : subtree_sizes[i]) {
            ll p_t_white = two_inv_pow[subtree_size];
            ll p_t_black = (1 - p_t_white + MOD) % MOD;
            ll prob = (p_t_black * mod_inv_prime(p_t_white)) % MOD;
            p_one_black = (p_one_black + prob) % MOD;
        }
        p_one_black = (p_one_black * p_all_white) % MOD;
        ll cond_prob = (1 - ((p_all_white + p_one_black) % MOD) + MOD) % MOD;
        ll total_prob = (two_inv * cond_prob) % MOD;
        ev = (ev + total_prob) % MOD;
    }

    cout << ev << endl;

}


Measured memory_bytes: 68680
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

#define N 1001

using namespace std;

vector <int> par;

void init(int);
int root(int);
void uni(int, int);
bool same(int, int);

int main(){
	int V, d;
	
	while(cin >> V >> d){
		
		init(V);
		vector <int> f(V);
		int temp1, temp2;
		for(int i = 0; i < V; i++){
			if(i == 0)
				f[i] = temp1 = 2;
			else if(i == 1)
				f[i] = temp2 = 3;
			else{
				f[i] = (temp1 + temp2) % N;
				temp1 = temp2;
				temp2 = f[i];
			}
		}
		
		sort(f.begin(), f.end());
		
		for(int i = 0; i < V - 1; i++)
			if(f[i + 1] - f[i] < d)
				uni(i, i + 1);
		
		int count = 1;
		for(int i = 0; i < V - 1; i++)
			if(root(i) != root(i + 1))
				count++;
		
		cout << count << endl;
	}
	
	return 0;
}

//初期化
void init(int n){
	par.resize(n);
	for(int i = 0; i < n; i++){
		par[i] = i;  //最初自分の集合の代表は自分
	}
}

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

//ｘとｙの属する集合を併合
void uni(int x, int y){
	x = root(x);
	y = root(y);
	if(x == y)
		return;
	par[x] = y;
}

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

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define FTEST int testcase;fin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define no {cout<<"NO"<<endl;return;}
#define yes {cout<<"YES"<<endl;}
const int maxn=2e5;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

void solve(){
    string s;
    cin>>s;
    if(s[0]=='R' && s[1]=='R' && s[2]=='R') cout<<3;
    else if(s[1]=='R' && s[2]=='R') cout<<2;
    else if(s[0]=='R' && s[1]=='R' ) cout<<2;
    else if(s[0]=='R' || s[1]=='R' || s[2]=='R') cout<<1;
    else cout<<0;
    return;
}
int main(){
    IO
    //TEST
    solve();



    return(0);
}


Measured memory_bytes: 3652
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

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

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

    int n,avg = 0;
    cin >> n;
    vector<int> a(n+1),b(n+1);
    reps(i,n){
        cin >> a[i];
        b[i] = a[i] - i;
    }

    sort(b.begin()+1,b.end());
    int mid1 = b[n/2],mid2 = b[n/2+1];
    int res1 = 0,res2 = 0;

    reps(i,n){
        res1 += abs(b[i] - mid1);
        res2 += abs(b[i] - mid2);
    }

    cout << min(res1,res2) << '\n';

    return 0;
}


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

int main(){
    ll A,B,C,K;cin>>A>>B>>C>>K;
    if(K%2)cout<<B-A<<endl;
    else cout<<A-B<<endl;
    return 0;
}

Measured memory_bytes: 256
s=input()
q=int(input())
query=[]
for i in range(q):
    query.append(input())
rev=0
bef=""
aft=""
for i in range(q):
    if query[i][0]=="1":
        rev+=1
    else:
        n,f,c=query[i].split()
        if (rev+int(f))%2==0:
            aft=aft+c
        else:
            bef=c+bef
seqfin=bef+s+aft
if rev%2==0:
    print(seqfin)
else:
    print(seqfin[::-1])

Measured memory_bytes: 17236
n=int(input())
lst=list(map(int,input().split()))
lst[0]-=1
for i in range(n-1):
  if lst[i]!=lst[i+1]:
    lst[i+1]-=1
  if lst[i]>lst[i+1]:
    print("No")
    break
else:
  print("Yes")
  

Measured memory_bytes: 14224
import qualified Data.ByteString.Char8 as BC
import Data.IORef
import Control.Monad(when)
import Control.Applicative((*>))
import Data.Foldable(for_)
import Data.Maybe(fromJust)

main :: IO()
main = BC.getLine *> BC.getContents >>= solve.map (fst.fromJust.BC.readInt).BC.lines >>= print

solve :: [Int] -> IO Int
solve (x : y : xs) = do
                a <- newIORef (y - x)
                b <- newIORef (min x y)
                for_ xs $ \z -> do
                    a' <- readIORef a
                    b' <- readIORef b
                    when (z - b' > a') $ writeIORef a (z - b')
                    when (z < b')      $ writeIORef b z
                readIORef a

Measured memory_bytes: 5852
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd (a, b)

a_b = list(map(lambda x: int(x), input().split(" ")))
A = a_b[0]
B = a_b[1]

print(lcm(A, B))


Measured memory_bytes: 2940
///#pragma GCC optimize("O3,unroll-loops")
///#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ull unsigned long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 200005
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007
#define mod 998244353
#define PI acos(-1.0)
#define eps 1e-9
#define mem(a, b) memset(a, b, sizeof(a))
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(ll N, ll pos){return (bool)(N & (1LL<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll fast_exp(ll x, ll n, ll m)
{
    ll res = 1;
    while(n>0)
    {
        if(n%2==1)
            res = (res * x) % m;
        x = (x * x) % m;
        n/=2;
    }
    return res%m;
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet1;

const int N = 1000006;
ll inv[N], cnt[N], ans[N], sum[N], sq[N];

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    FASTIO;
    int n;
    cin>>n;
    int vis[n+5];
    mem(vis, 0);
    for(int i = 0; i < n-1; i++)
    {
        int a;
        cin>>a;
        vis[a]++;
    }
    for(int i = 1; i <= n; i++)
        cout<<vis[i]<<endl;

    //End();
    return 0;
}


Measured memory_bytes: 4396
use std::cmp;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        w: usize,
        v: [(i32, i32); n],
    }
    let mut table:Vec<Vec<i32>> = vec![vec![0; w+1]];
    for i in 0..n{
        table.push(vec![0; w+1]);
        for j in 1..w+2{
            if j as i32 >= v[i].1+1{
                let temp1 = v[i].0;
                let temp0 = table[i][j-(v[i].1+1) as usize]+temp1;
                let temp = cmp::max(temp0, table[i][j-1]).clone();
                table[i+1][j-1] = temp;
            }
            else{
                let temp = table[i][j-1].clone();
                table[i+1][j-1] = temp;
            }
        }
    }
    println!("{:?}",table[n][w]);
}



Measured memory_bytes: 9012
#include <stdio.h>

int abs(int j)
{
    return (j>0) ? j : -j;
}

int main()
{
    int N, M, i, j;
    int a[50], b[50], c[50], d[50];
    int p[50] = {0};

    scanf("%d %d", &N, &M);
    
    for(i=0; i<N; i++)
    {
         scanf("%d %d", &a[i], &b[i]);
    }
    
    for(j=0; j<M; j++)
    {
         scanf("%d %d", &c[j], &d[j]);
    }
    
    for(i=0; i<N; i++)
    {
         for(j=0; j<M; j++)
         {
             if(abs(a[i] - c[j]) + abs(b[i] - d[j]) < abs(a[i] - c[p[i]]) + abs(b[i] - d[p[i]]))
             {
                 p[i] = j;
             }
         }
         printf("%d\n", p[i]+1);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;


int a[220];
int main()
{
    int n;
    scanf("%d", &n);
    n *= 2;
    for(int i = 0; i < n; i++ )
    {
        scanf("%d", &a[i]);
    }

    sort(a, a + n);

    int res = 0;
    for(int i = 1; i < n; i += 2)
    {
        res += min(a[i], a[i - 1]);
    }
    printf("%d\n", res);
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int row, col, n;
	scanf("%d %d %d", &row, &col, &n);
	
	int bucket;
	if (row >= col)
	{
		bucket = row;
	}
	
	else
	{
		bucket = col;
	}
	
	int i = 0, j;
	int count = 0;
	
	while (i < n)
	{
		count++;
		i += bucket;
	}
	
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 1712
#include<stdio.h>

int main(){

    int a, b, maxi=0;

    scanf("%d",&a);
    scanf("%d",&b);


    if((a+b>=a-b)&&(a+b>=a*b)){
        maxi=a+b;
    }
    else if((a-b>=a+b)&&(a-b>=a*b)){
        maxi=a-b;
    }
    else{
        maxi=a*b;
    }
        printf("%d", maxi);

    return 0;
}

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

int main() {
   // freopen( "C:\\Users\\ehab\\Desktop\\problems\\in.txt" , "r" , stdin );

    string s , t;
    cin >> s >> t;

    int len = s.length();
    for ( int i = 0; i < len; i++ ){
        if ( s == t ){
            cout << "Yes";
            return 0;
        }
        t = t.back() + t;
        t.pop_back();
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ACs = [0] * N
wa = 0
ac = 0
for _ in range(M):
    p, s = input().split()
    if s == "WA" and ACs[int(p)-1] <= 0:
        ACs[int(p)-1] -= 1
    if s == "AC" and ACs[int(p)-1] <= 0:
        wa -= ACs[int(p)-1]
        ACs[int(p)-1] = 1
        ac += 1
print("{} {}".format(ac, wa))

Measured memory_bytes: 3828
# -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache

# 1整数
# n = int(input())

# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce

import sys

input = sys.stdin.readline

# N個整数
n, q = list(map(int, input().split()))

s = input()

ans = set()

qq = [''] * q

for i in range(q):
    t, d = input().split()
    qq[i] = t + d


##最初にマスiにいるゴーレムが左に抜けられるかどうか
def hidari(i):
    for qn in range(q):
        if qq[qn][0] == s[i]:
            if qq[qn][1] == 'R':
                i += 1
                if i >= n:
                    return False
            else:
                i -= 1
                if i < 0:
                    return True
    return False


# 右に抜けられるかどうか
def migi(i):
    for qn in range(q):
        if qq[qn][0] == s[i]:
            if qq[qn][1] == 'R':
                i += 1
                if i >= n:
                    return True
            else:
                i -= 1
                if i < 0:
                    return False
    return False


##左に抜けられるかどうかの最大のにぶたんwithめぐる
ok = -1
ng = n
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    #print(mid, hidari(mid))
    if hidari(mid):
        ok = mid
    else:
        ng = mid
n_hidari = ok

##右に抜けられるかどうかの最大のにぶたんwithめぐる
ok = n
ng = -1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
   # print(mid, migi(mid))
    if migi(mid):
        ok = mid
    else:
        ng = mid
n_migi = ok
#print(n_migi,n_hidari)
print(max(0, n_migi - n_hidari-1))


Measured memory_bytes: 19184
#!/usr/bin/env python3


def main():
    S = input()
    S = S[::-1]
    a = ['maerd', 'remaerd', 'esare', 'resare']
    if S.replace(a[3], '').replace(a[2], '').replace(a[1], '').replace(a[0], '') == "":
        print('YES')
    else:
        print('NO')

main()


Measured memory_bytes: 3188
import numpy as np
n, C = map(int,input().split())
cha = [[[0,0]] for _ in range(C+1)]
stc = [list(map(int, input().split())) for _ in range(n)]
stc.sort()
for s, t, c in stc:
    if cha[c][-1][1]==s:
        cha[c][-1][1] = t
    else:
        cha[c].append([s, t])
result = np.zeros(2*10**5)
for i in range(1, C+1):
    for s, t in cha[i]:
        result[s*2-1:t*2] += 1
print(int(max(result)))

Measured memory_bytes: 47476
#include<iostream>
using namespace std;
int main(){
    int tate,yoko,x,y;
    while(1){
        cin >> tate >> yoko;
        if(tate==0 && yoko==0) break;
        for(x=0;x<tate;x++){
            for(y=0;y<yoko;y++){
                if(x==0 || x==tate-1) cout << "#";
                else if (y==0 || y==yoko-1) cout << "#";
                else cout <<".";
            }
            y=0;
            cout << endl;
        }
        x=0;
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let v = read_vec::<u32>();
    let n = v[0];
    let t = v[1];

    let ct = read_vec2::<u32>(n)
        .into_iter()
        .filter(|ref v| v[1] <= t)
        .map(|v| v[0])
        .collect::<Vec<u32>>();
    let ans = ct.into_iter().min();
    match ans {
        None => println!("TLE"),
        Some(a) => println!("{}", a),
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

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

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

using namespace std;
int main(){
    int n,m;cin>>n>>m;
    // key Cj, val =num;
    map<long,long> mp;
    long key;
    long num;
    rep(i,n){
        cin >> key;
        mp[key]++;
    }
    rep(i,m){
        cin >> num>> key;
        if(mp[key] + num >= n) mp[key] = n;
        else mp[key] += num;
    }
    ll ans=0;
    int rest=n;
    for(auto itr = mp.rbegin();itr != mp.rend();itr++){
        //cout << itr->first << " " << itr->second<< endl;
        if(rest >= itr->second){
            ans += itr->first*itr->second;
            rest -= itr->second;
        }else{
            ans += itr->first*rest;
            rest = 0;
        }
        if(rest==0) break;
    }
    //cout << accumulate(A.begin(),A.end(),0LL) << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12800
import sys


class SegTreeMin:
    """
    以下のクエリを処理する
    1.update:  i番目の値をxに更新する
    2.get_min: 区間[l, r)の最小値を得る
    """

    def __init__(self, n, INF):
        """
        :param n: 要素数
        :param INF: 初期値（入りうる要素より十分に大きな数）
        """
        self.n = n
        # nより大きい2の冪数
        n2 = 1
        while n2 < n:
            n2 <<= 1
        self.n2 = n2
        self.tree = [INF] * (n2 << 1)
        self.INF = INF

    def update(self, i, x):
        """
        i番目の値をxに更新
        :param i: index(0-indexed)
        :param x: update value
        """
        i += self.n2
        self.tree[i] = x
        while i > 1:
            self.tree[i >> 1] = x = min(x, self.tree[i ^ 1])
            i >>= 1

    def get_min(self, a, b):
        """
        [a, b)の最小値を得る
        :param a: index(0-indexed)
        :param b: index(0-indexed)
        """
        result = self.INF

        l = a + self.n2
        r = b + self.n2
        while l < r:
            if r & 1:
                result = min(result, self.tree[r - 1])
            if l & 1:
                result = min(result, self.tree[l])
                l += 1
            l >>= 1
            r >>= 1

        return result

    def debug_print(self):
        a = 1
        while a <= self.n2:
            b = a << 1
            print(self.tree[a:b])
            a = b
        print()


INF = 10 ** 18
n, m = map(int, input().split())
segments = [tuple(map(int, line.split())) for line in sys.stdin]
segments.sort()
sgt = SegTreeMin(n, INF)
sgt.update(0, 0)

for l, r, c in segments:
    use_current = sgt.get_min(l - 1, r - 1) + c
    not_current = sgt.get_min(r - 1, r)

    if use_current < not_current:
        sgt.update(r - 1, use_current)

ans = sgt.get_min(n - 1, n)
if ans == INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 25792
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
cin>>N;
map<string,int>m;
vector<string>s(N);
bool b=false;
string name;
for(int i=0;i<N;i++){
    cin>>name;
    m[name]++;
    if(m[name]>1)b=true;
    s[i]=name;
}
if(b){
cout<<"No";
return 0;
}
for(int i=0;i<N-1;i++){
    if(s[i].at((s[i].size())-1)==s[i+1][0])continue;
    cout<<"No";
    return 0;
}
cout<<"Yes";
return 0;
}


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

using namespace std;


int main(void){
  
  
  int N;
  int A[100];
  int mini=1000000000+1;
  int maxi=0;
    
  
  cin >> N;
  
  for (int i=0;i<N;i++){
    cin >> A[i] ;
    
    
    mini=min(mini,A[i]);
    
    
    maxi=max(maxi,A[i]);
  }
  
  cout << maxi-mini << endl;
  
}


  
  
  
  
  
  


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    string a;
    string b;
    string c;
    cin >> a >> b >> c;
    queue<char> za;
    queue<char> zb;
    queue<char> zc;
    for (int i = 0; i < a.size(); i++) {
        za.push(a[i]);
    }
    for (int i = 0; i < b.size(); i++) {
        zb.push(b[i]);
    }
    for (int i = 0; i < c.size(); i++) {
        zc.push(c[i]);
    }
    ll now = 0;
    while (true) {
        if (now == 0) {
            if (za.empty()) {
                cout << "A" << endl;
                break;
            }
            now = za.front() - 'a';
            za.pop();
        }
        else if (now == 1) {
            if (zb.empty()) {
                cout << "B" << endl;
                break;
            }
            now = zb.front() - 'a';
            zb.pop();
        }
        else if (now == 2) {
            if (zc.empty()) {
                cout << "C" << endl;
                break;
            }
            now = zc.front() - 'a';
            zc.pop();
        }
        
        
        
    }
}

Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();
            String T = in.next();
            int cnt = 0;
            for (int i = 0; i < 3; i++) {
                if (S.charAt(i) == T.charAt(i)) {
                    cnt++;
                }
            }
            out.println(cnt);
        }

    }
}



Measured memory_bytes: 21844
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- 整数の入力
    _ <- getLine
    k <- readLn
    -- スペース区切り整数の入力
    l <- map strToInt . words <$> getLine
    -- 出力
    putStrLn . show . sum $ map (\x -> (* 2) $ min x (k - x)) l


Measured memory_bytes: 1020
#include<iostream>
using namespace std;
int main(){
    int m,f,r;
    int i,j;
    while(50){
        cin>>m>>f>>r;
        if(m==-1&&f==-1&&r==-1)break;
        if(m==-1||f==-1){
        cout<<'F'<<endl;
        }else if(m+f>=80){
            cout<<'A'<<endl;
        }else if(m+f>=65){
            cout<<'B'<<endl;
        }else if(m+f>=50||r>=50){
            cout<<'C'<<endl;
        }else if(m+f>=30){
            cout<<'D'<<endl;
        }else{
            cout<<'F'<<endl;
        }       
    }

    return 0;
}


Measured memory_bytes: 3096
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

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

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------


int n,m,a,b;
vpi bridge;
vi inconv;
struct UnionFind {

        vi par;    // x の親ノード
        vi rank;   // 木の高さ
        vi mem;    // メンバの数
        int sz;             // 集合の個数
        int r;

        UnionFind(int n) :
            par(n, -1), rank(n, 0), mem(n, 1), sz(n), r(0) {
            REP(i,n) par[i] = i;
        }
    
    int size() { return sz; }

    // 集合の追加
    void makeset() {
        par.pb(par.size());
        rank.pb(0);
        mem.pb(1);
        sz++;
    }

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

    int member(int x){
        x = find(x);
        return mem[x];
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        // cerr << x << " " << y << " " <<  member(x)<< " " << member(y) << endl;

        if (rank[x] < rank[y]){
            par[x] = y;
            r -= ( mem[y] * (mem[y]-1)/2);
            mem[y] += mem[x];
            r += ( mem[y] * (mem[y]-1)/2) - ( mem[x] * (mem[x]-1)/2); 
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
            r -= ( mem[x] * (mem[x]-1)/2);
            mem[x] += mem[y];
            r += ( mem[x] * (mem[x]-1)/2) - ( mem[y] * (mem[y]-1)/2); 
        }
        sz--;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int conv(){
        return r;
    }
};

signed main(){
    I(n); I(m);
    UnionFind uf(n);
    REP(i,m){
        I(a); I(b);
        a--; b--;
        bridge.eb(a,b);
    }

    REPN(i,m){
        inconv.pb(uf.conv());
        auto p = bridge[i];
        uf.unite(p.first, p.second);
    }
    int maxi = n * (n-1) / 2;
    REPN(i,m){
        auto v = inconv[i];
        printf("%lld\n", maxi-v);
    }
}

Measured memory_bytes: 7024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#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=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

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

int main() {
    ll x, y;
    cin >> x >> y;
    ll d = gcd(x, y);
    ll ans = 1;
    for (ll p = 2; p <= 2000000; p++){
        if (d % p == 0){
            ans++;
            while (d % p == 0) d /= p;
        }
    }
    if (d > 1) ans++;
    cout << ans << endl;

    return 0;
}


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

void sub(long long int *x,long int *k, unsigned long int *d) {
    long long int tmp = *x / *d;

    if(*x % *d == 0) {
        tmp--;
    }

    if(tmp + 1 <= *k) {
        *k -= (tmp + 1);

        *x -= *d * (tmp + 1);
    }
    else {
        *x -= *d * *k;

        *k = 0;
    }
}

void sum(long long int *x, long int *k, unsigned long int *d) {
    *x *= -1;
    long long int tmp = *x / *d;

    if(*x % *d == 0) {
        tmp--;
    }

    *x *= -1;
    
    if(tmp + 1 <= *k) {
        *k -= (tmp + 1);

        *x += *d * (tmp + 1);
    }
    else {
        *x += *d * *k;

        *k = 0;
    }
}

int main() {
    long long int X;
    long int K;
    unsigned long int D;

    std::cin >> X >> K >> D;

    if(X > 0) {
        sub(&X, &K, &D);

        if(K > 0){
            if(K % 2 == 1) {
                X += D;
            } 

        }
    }
    else {
        sum(&X, &K, &D);

        if(K > 0) {
            if(K % 2 == 1) {
                X -= D;
            }
        }
    }

    if(X < 0) {
        X *= -1;
    }

    std::cout << X << std::endl;

    return 0;
}


Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main() {
	int a, b, n, m, k, p, q, r, cost, time, datas[300][300][2];
	while (cin >> n >> m, n || m) {
		for (int y = 0; y < m; ++y)
			for (int x = 0; x < m; ++x)
				datas[y][x][0] = 10000, datas[y][x][1] = 10000;

		for (int x = 0; x < m; ++x)
			datas[x][x][0] = 0, datas[x][x][1] = 0;

		for (int i = 0; i < n; ++i) {
			cin >> a >> b >> cost >> time;
			--a, --b;
			datas[a][b][0] = cost, datas[a][b][1] = time;
			datas[b][a][0] = cost, datas[b][a][1] = time;
		}
		
		for (int i = 0; i < m; ++i)
			for (int j = 0; j < m; ++j)
				for (k = 0; k < m; ++k) {
					if (datas[j][i][0]+datas[i][k][0] < datas[j][k][0])
						datas[j][k][0] = datas[j][i][0]+datas[i][k][0];
					
					if (datas[j][i][1]+datas[i][k][1] < datas[j][k][1])
						datas[j][k][1] = datas[j][i][1]+datas[i][k][1];
				}
		
		cin >> k;
		for (int i = 0; i < k; ++i) {
			cin >> p >> q >> r;
			cout << datas[p-1][q-1][r] << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAXX 100005
#define ll signed long long int
using namespace std;

ll ans = 0, a, b, c[MAXX] ,n , t, k= 0, m, x;
signed main()
{
    FAST;
    string s;
    cin >> n;
    cin >> s;
    for(ll i = 0; i < n-2; i++){
    	if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
    		ans ++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <climits>
#include <utility>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> lbNum(m);
	vector<vector<int>> lb2sws;
	for (int i = 0; i < m; ++i) {
		int k;
		cin >> k;
		lb2sws.emplace_back(vector<int>(k));
		for (auto& lb2sw : lb2sws.back())cin >> lb2sw, lb2sw -= 1;
	}
	for (auto& sn : lbNum)cin >> sn;

	vector<int> swptnNum;
	int count, ptncount = 0;
	bool willAllLit;
	for (unsigned swptn = 0; swptn < ((1 << n)); ++swptn) {
		swptnNum.clear();
		willAllLit = true;
		for (unsigned j = 0; j < n; ++j) {
			if ((swptn & (1 << j)) != 0)swptnNum.push_back(j);
		}
		for (unsigned j = 0; j < m; ++j) {
			count = 0;
			for (unsigned k = 0; k < swptnNum.size(); ++k) {
				if (find(lb2sws[j].begin(), lb2sws[j].end(), swptnNum[k]) != lb2sws[j].end()) {
					++count;
				}
			}
			if (count % 2 != lbNum[j]) {
				willAllLit = false;
				break;
			}
		}
		if (willAllLit)++ptncount;
	}

	cout << ptncount << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int c=0,g,i,j,d,b,m[102][102],h,w;
	char a;
	cin>>h>>w;
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
		{
			cin>>a;
			m[i][j]=-1;
			if(a=='c')
				m[i][j]=0;
		}
	}
	for(i=1;i<=h;i++)
	{
		c=1;
		for(j=1;j<=w;j++)
		{
			if(m[i][j]==0)
			{
				g=j;
				for(d=j;d<=w;d++)
				{
					if(m[i][d]==0)
						c=1;
					else
					{
						m[i][d]=c;
						c++;
					}
				}
			}
		}
	}
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
		{
			if(j!=w)
				cout<<m[i][j]<<" ";
			else
				cout<<m[i][j];
		}
		cout<<endl;
	}	
	return 0;
}

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

int main(){
    int lor = 10;
    int ttime = 0;
    for(int i = 0; i < 5; i++){
        int x;
        scanf("%d", &x);
        ttime += (x-1)/10+1;
        if(x%10 != 0)lor = min(lor, x%10);
    }
    printf("%d", ttime*10-10+lor);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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

int main(){
    string s;
    unsigned long long k;
    cin >> s >> k;
    unsigned long long cnt=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='1') cnt++;
        else{
            if(k<=cnt){
                cout << 1 << endl;
                return 0;
            }
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256