akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<end
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll x1,x2,y1,y2;
  cin>>x1>>y1>>x2>>y2;
  cout<<x2-y2+y1<<" "<<y2+x2-x1<<" "<<x1-y2+y1<<" "<<y1+x2-x1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	int ans = 0;
	while(x+y > 0){
		if(x > 0 && y > 0){
			ans += min(2*c,a+b);
			--x;
			--y;
		}else if(x > 0){
			ans += min(2*c,a);
			--x;
		}else{
			ans += min(2*c,b);
			--y;
		}

	}
	cout << ans << "\n";
}



Measured memory_bytes: 256
N,M=list(map(int,input().split()))
ans=0
half=0
for i in range(1,N+1):
   if i%M==0:
      ans+=1
if M%2==0:
   for i in range(1,N+1):
      if i%M==M//2:
         half+=1
   print(ans**3+half**3)
else:
   print(ans**3)

Measured memory_bytes: 3060
#include<stdio.h>

#include<stdlib.h>
#include<string.h>
const int n=1000;
int main()
{
    char w[n];
    gets(w);
    int a[26]={0};

    for(int i=0; i<strlen(w); i++)
    {
        if(w[i]=='a')
        {
            a[0]++;
        }
        else if(w[i]=='b')
        {
            a[1]++;
        }
        else if(w[i]=='c')
        {
            a[2]++;
        }
        else if(w[i]=='d')
        {
            a[3]++;
        }
        else if(w[i]=='e')
        {
            a[4]++;
        }
        else if(w[i]=='f')
        {
            a[5]++;
        }
        else if(w[i]=='g')
        {
            a[6]++;
        }
        else if(w[i]=='h')
        {
            a[7]++;
        }
        else if(w[i]=='i')
        {
            a[8]++;
        }
        else if(w[i]=='j')
        {
            a[9]++;
        }
        else if(w[i]=='k')
        {
            a[10]++;
        }
        else if(w[i]=='l')
        {
            a[11]++;
        }
        else if(w[i]=='m')
        {
            a[12]++;
        }
        else if(w[i]=='n')
        {
            a[13]++;
        }
        else if(w[i]=='o')
        {
            a[14]++;
        }
        else if(w[i]=='p')
        {
            a[15]++;
        }
        else if(w[i]=='q')
        {
            a[16]++;
        }
        else if(w[i]=='r')
        {
            a[17]++;
        }
        else if(w[i]=='s')
        {
            a[18]++;
        }
        else if(w[i]=='t')
        {
            a[19]++;
        }
        else if(w[i]=='u')
        {
            a[20]++;
        }
        else if(w[i]=='v')
        {
            a[21]++;
        }
        else if(w[i]=='w')
        {
            a[22]++;
        }
        else if(w[i]=='x')
        {
            a[23]++;
        }
        else if(w[i]=='y')
        {
            a[24]++;
        }
        else if(w[i]=='z')
        {
            a[25]++;
        }
        else if(w[i]=='b')
        {
            a[1]++;
        }
    }
    int flat=1;
    for(int i=0; i<26; i++){
        if(a[i]%2==1){
            flat=0;
            break;
        }
    }
    printf("%s",flat==1?"Yes\n":"No\n");
    return 0;
}

Measured memory_bytes: 128
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int maxn = 52, mod = 1e9 + 7;
long long N, K;

struct mat{
    long long m[maxn][maxn];
    mat(){memset(m, 0, sizeof(m));}
    mat operator *(mat& rhs){
        mat res;
        for(int i = 0; i < N; i++){
            for(int j = 0; j <N; j++){
                for(int k = 0; k <N; k++){
                    res.m[i][j] = (res.m[i][j]+ m[i][k]*rhs.m[k][j])%mod;
                }
            }
        }
        return res;
    }
    
};

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>N>>K;
    mat a,res;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cin>>a.m[i][j];
        }
        res.m[i][i] = 1;
    }
    
    while(K){
        if(K&1)res = res*a;
        a = a*a;
        K>>=1;
    }
    
    int ans = 0;
    for(int i = 0; i<N;i++){
        for(int j = 0; j < N; j++){
            ans = (ans + res.m[i][j])%mod;
        }
    }
    
    cout<<ans<<endl;
    
    
    return 0;
}



Measured memory_bytes: 384
n, l = map(int, input().split())
d = []
for i in range(1, n + 1):
    d.append(l + i - 1)
wa = sum(d)
k = []
for i in range(1, n + 1):
    t = n * l + n * (n - 1) // 2 - (l + i - 1)
    k.append(t)
for i in range(n):
    k[i] = abs(k[i] - wa)
m = k.index(min(k))
print(n * l + n * (n - 1) // 2 - (l + m))

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

int main(){
  int n;
  cin>>n;
  
  vector<int> A(n);
  for(int i=0;i<n;i++){
    cin>>A.at(i);
  }
  
  long long dai=0;
  
  for(int i=1;i<n;i++){
    if(A.at(i)<A.at(i-1)){
      dai+=A.at(i-1)-A.at(i);
      A.at(i)=A.at(i-1);
    }
  }
  
  cout<<dai<<endl;
  
  return 0;
}

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

int a,b,c,d[10],e,f;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> e;
  cin >> f;
  {
  if(a%10 != 0){
  d[0] = (a/10+1)*10 -a;
  }
  else if(a%10 ==0) {
    d[0] = 0;
  }
  }
  {
    if(b%10 != 0){
  d[1] = (b/10+1)*10 -b;
  }
  else if(b%10 ==0){
    d[1] = 0;
  }
  }
  {
   if(c%10 != 0){
  d[2] = (c/10+1)*10 -c;
  }
  else if(c%10 == 0){
    d[2] = 0;
  } 
  }
  {
  if(e%10 != 0){
  d[3] = (e/10+1)*10 -e;
  }
  else if(e%10 == 0){
    d[3] = 0;
  } 
  }
  {
  if(f%10 != 0){
  d[4] = (f/10+1)*10 -f;
  }
  else if(f%10 == 0){
    d[4] = 0;
  } 
  }
  
  sort(d,d+5,greater<int>());
  
  cout << d[1]+d[2]+d[3]+d[4]+(a+b+c+e+f) << endl;
}
  


Measured memory_bytes: 256
from collections import deque
n = int(input())
a = deque([])
for i in range(n):
  x = int(input())
  a.append(x)
a=sorted(a)
a1 = deque(a)
b = deque([])
b.append(a1.popleft())
i = 0
while a1:
  if i%2 == 1:
    b.append(a1.popleft())
    if a1 == deque([]):
      break
    b.appendleft(a1.popleft())
    i += 1
  else:
    b.append(a1.pop())
    if a1 == deque([]):
      break
    b.appendleft(a1.pop())
    i += 1
ans = 0
for i in range(1,n):
  ans += abs(b[i] - b[i-1])
a = deque(a)
b = deque([])
b.append(a.pop())
i = 0
while a:
  if i%2 == 0:
    b.append(a.popleft())
    if a == deque([]):
      break
    b.appendleft(a.popleft())
    i += 1
  else:
    b.append(a.pop())
    if a == deque([]):
      break
    b.appendleft(a.pop())
    i += 1
ans2 = 0
for i in range(1,n):
  ans2 += abs(b[i] - b[i-1])
ans = max(ans,ans2)
print(ans)

Measured memory_bytes: 10716
#include<iostream>
#include<string>
#include<utility>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;

const int MAX_M = 11;
const int MAX_N = 1e4 + 4;
const int INF = 1 << 30;

char A[MAX_M];
P dp[MAX_N][MAX_M];

int main() {
    int N, M;
    cin >> N >> M;
    map<char, int> MP;
    for (int i = 1; i <= M; i++) {
        cin >> A[i];
        if (A[i] == '1') MP[A[i]] = 2;
        else if (A[i] == '4') MP[A[i]] = 4;
        else if (A[i] == '7') MP[A[i]] = 3;
        else if (A[i] == '8') MP[A[i]] = 7;
        else if (A[i] == '6' || A[i] == '9') MP[A[i]] = 6;
        else MP[A[i]] = 5;
    }
    sort(A + 1, A + M + 1);
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= M; j++) dp[i][j] = P(-INF, 0);
    }
    dp[0][0] = P(0, 0);
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            if (i - MP[A[j]] >= 0) {
                for (int k = 0; k <= M; k++) {
                    if (dp[i][j].first <= dp[i - MP[A[j]]][k].first + 1) {
                        dp[i][j].first = dp[i - MP[A[j]]][k].first + 1;
                        dp[i][j].second = k;
                    }
                }
            }
        }
    }
    string max_ans = "";
    for (int i = 1; i <= M; i++) {
        if (dp[N][i].first > 0) {
            string now_ans = "";
            int prev = i, rest = N;
            while (prev > 0) {
                now_ans.push_back(A[prev]);
                int tmp = prev;
                prev = dp[rest][prev].second;
                rest -= MP[A[tmp]];
            }
            sort(now_ans.begin(), now_ans.end());
            reverse(now_ans.begin(), now_ans.end());
            if (max_ans.length() < now_ans.length()) max_ans = now_ans;
            else if (max_ans.length() == now_ans.length()) max_ans = max(max_ans, now_ans);
        }
    }
    cout << max_ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  if(N < 1000)
    cout << "ABC" << endl;
  else
    cout << "ABD" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 100 + 10;
const int CAP = 1e5 + 10;
int n,cap;
int v[N], w[N];
ll dp[N][CAP];
ll run(int idx, int cur) {
    if(dp[idx][cur] != -1) return dp[idx][cur];
    ll res = 0;
    if(idx == n or cur == 0) res = 0;
    else if(w[idx] > cur) res = run(idx + 1, cur);
    else res = max(
        run(idx + 1, cur),
        run(idx + 1, cur - w[idx]) + v[idx]
    );
    return dp[idx][cur] = res;
}
ll run() {
    for(int i = 1; i <= n; ++i) {
        for(int k = 1; k <= cap; ++k) {
            if(w[i - 1] > k) dp[i][k] = dp[i - 1][k];
            else dp[i][k] = max(
                dp[i - 1][k],
                dp[i - 1][k - w[i - 1]] + v[i - 1]
            );
        }
    }
    return dp[n][cap];
}
int main() {
    scanf("%d %d", &n, &cap);
    for(int i = 0; i < n; ++i) scanf("%d %d", &w[i], &v[i]);
    memset(dp, -1, sizeof dp);
    ll ans = run(0, cap);
    printf("%lld\n", ans);
    return 0;
}


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

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


fn main() {
    loop {
        let mut n:String = read();
        if n == "-" {
            break;
        }
        let m:usize = read();
        for _ in 0..m {
            let h:usize = read();
            n = format!("{}{}", &n[h..], &n[..h]);
        }
        println!("{}",n);
    }
}


Measured memory_bytes: 5024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    int n; cin >> n;
    int ans = 0;
    rep(i,n){
        int a; cin >> a;
        if( i%2 == 0 && a%2 == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <ostream>
#include <vector>

void trace_space(std::vector<int> v) {
	for (std::vector<int>::iterator i = v.begin(); i != v.end(); ++i) {
		std::cout << *i << " ";
	}
	std::cout << std::endl;
}

void trace_endl(std::vector<int> v) {
	for (std::vector<int>::iterator i = v.begin(); i != v.end(); ++i) {
		std::cout << *i << std::endl;
	}
}

void insertion_sort(std::vector<int> &v, int n, int g, int &cnt) {
	for (int i = g; i < n; i++) {
		int t = v[i];
		int j = i - g;
		while (j >= 0 && v[j] > t) {
			v[j + g] = v[j];
			j = j - g;
			cnt++;
		}
		v[j + g] = t;
	}
}

void shell_sort(std::vector<int> &v, int n) {
	std::vector<int> G;
	for (int g = 1; g <= n; g = 3 * g + 1)
		G.push_back(g);
	
	int c = 0;
	for (int i = 0; i < G.size(); i++) {
		insertion_sort(v, n, G[G.size()-i-1], c);
	}
	// 
	std::cout << G.size() << std::endl;
	for (int i = 0; i < G.size()-1; i++) {
		std::cout << G[G.size() - i - 1] << " ";
	}
	std::cout << G[0] << std::endl;

	std::cout << c << std::endl;
}


int main() {
	int n;
	std::cin >> n;
	std::vector<int> a;
	a.resize(n, 0);
	for (int i = 0; i < n; i++) {
		std::cin >> a[i];
	}
	shell_sort(a, n);
	trace_endl(a);
	return 0;
}

Measured memory_bytes: 10820
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
int main() {
//input
int n;
string s;
string t;
cin>>n>>s>>t;
//compute

//output
rep(i,n){
cout<<s[i]<<t[i];
}
	return 0;
}

Measured memory_bytes: 384
code = r"""
# distutils: language=c++
# distutils: include_dirs=[/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
from cython.parallel cimport prange
from libc.stdio cimport getchar, printf
cdef extern from "/opt/atcoder-stl/atcoder/math.hpp" namespace "atcoder" nogil:
    cdef long long floor_sum(long long n, long long m, long long a, long long b)
cdef long long cin() nogil:
    cdef long long b, c = 0
    while 1:
        b = getchar() - 48
        if b < 0: break
        c = c * 10 + b
    return c
cdef int i, t = cin()
cdef long long n, m, a, b
for i in prange(t, nogil=1):
    n = cin()
    m = cin()
    a = cin()
    b = cin()
    printf('%lld\n', floor_sum(n, m, a, b))
"""
import os, sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('solve.pyx', 'w').write(code)
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 8992
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  int a,b;
  cin >> a >> b;
  string ans = ":(";
  if(a <= 8 and b <= 8)ans = "Yay!";
  cout << ans << endl;
}

Measured memory_bytes: 256
//
// Created by Hideaki Imamura on 2020-03-23.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N, M;
vector<ll> a, b;
vector<int> c;
vector<vector<ll>> dp;

int main() {
    cin >> N >> M;
    a.resize(M);
    b.resize(M);
    c.assign(M, 0);
    for (int i = 0; i < M; ++i) {
        cin >> a[i] >> b[i];
        for (int j = 0; j < b[i]; ++j) {
            int tmp;
            cin >> tmp;
            c[i] += 1 << (tmp - 1);
        }
    }

    dp.assign(M + 1, vector<ll>(1 << N, INF));
    dp[0][0] = 0;
    for (int i = 0; i < M; ++i) {
        for (int j = 0; j < (1 << N); ++j) {
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][j | c[i]], dp[i][j] + a[i]);
        }
    }
    cout << (dp[M][(1 << N) - 1] < INF ? dp[M][(1 << N) - 1] : -1) << endl;
    return 0;
}

Measured memory_bytes: 32384
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  if(N == K){
    cout << 1 << endl;
    return 0;
  }
  cout << (N+(K-3))/(K-1) << endl;
  return 0;
}


Measured memory_bytes: 640
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    s = S()
    if int(s[:2]) > 12 or int(s[:2]) == 0:
        mmyy = False
    else:
        mmyy = True
    if int(s[2:]) > 12 or int(s[2:]) == 0:
        yymm = False
    else:
        yymm = True
    ans = ''
    if yymm and mmyy:
        ans = 'AMBIGUOUS'
    if yymm and not mmyy:
        ans = 'YYMM'
    if not yymm and mmyy:
        ans = 'MMYY'
    if not yymm and not mmyy:
        ans = 'NA'
    print(ans)
        

main()



Measured memory_bytes: 10744
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O2")
// #pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
// #define int ll
#define pb push_back
#define pob pop_back
#define __bp __builtin_popcount
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pdd = pair<ld,ld>;
using vint = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
#define F first
#define S second
const int N = 1e5+5;//(1 << 18) + 5;
//const ll inf = 1e18+7;
const int Inf = 1e9+7;
const ll INF = 1e18+7;
const int Mod = 1e9+7;
const ld eps = 1e-9;
#ifndef M_PI
#define M_PI 3.1415926535
#endif

void io()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//	freopen("sweets.in", "r", stdin);
//	freopen("sweets.out", "w", stdout);
//	cout << setprecision(7) << fixed;
}

int n;

void solve()
{
	cin >> n;
	ll x1 = 1;
	ll x2 = 2;
	ll x3 = 1;
	for (int i = 1; i <= n; ++i)
	{
		x1 *= 10;
		x1 %= Inf;
		x2 *= 9;
		x2 %= Inf;
		x3 *= 8;
		x3 %= Inf;
	}
	cout << (x1 - x2 + x3 + Inf) % Inf;
}

signed main()
{
	io();
	int tt = 1;
//	cin >> tt;
	while (tt--) {
		// solve();
		solve();
//		cerr << '\n';

	}
}

Measured memory_bytes: 3648
input_line=[int(x) for x in input().split()]
[i_N,i_A,i_B]=input_line
if i_A>=i_B:
  o_max=i_B
  o_min=i_B-(i_N-i_A)
else:
  o_max=i_A
  o_min=i_A-(i_N-i_B)
if o_min<0:
  o_min=0
if o_max>i_N:
  o_max=i_N
print("{} {}".format(o_max,o_min))

Measured memory_bytes: 3064
#include<vector>
#include<iostream>
#include<algorithm>
using LL = long long;
using namespace std;

vector<long long> divisor(long long n) {
	vector<long long> ret;
	for (long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end()); // 昇順に並べる
	return ret;
}

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	// 同じ数が出たら消去
	vector<int> new_A(0);

	int daburi = 0;
	vector<int> is_daburi(1000001, false);
	for (int i = 0; i < N-1; i++) {
		if (A[i] == A[i + 1] && is_daburi[A[i]] == false) {
			daburi++;
			is_daburi[A[i]] =true;
		}
	}

	vector<int> B(0);
	vector<bool> is_B(1000001, false);
	for (int n = 0; n < N; n++) {
		bool warikireru = false;
		vector<LL> divs = divisor(A[n]);
		for (int i = 0; i < divs.size(); i++) {
			if (is_B[divs[i]] == true) {
				warikireru = true;
				break;
			}
		}
		if (warikireru == false) {
			B.push_back(A[n]);
			is_B[A[n]] = true;
		}
	}
	int b_size = B.size();
	for (int i = 0; i < B.size(); i++) {
		if (is_daburi[B[i]] == true) {
			b_size--;
		}
	}
	cout << b_size << endl;
	return 0;
}

Measured memory_bytes: 9092
#include <math.h>
#include <bits/stdc++.h>
#include <deque>
#include <string>
#include <vector>
#include <algorithm>
#define ll long long int
#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
#define vali 1000000000000000000
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s1,s2;
    ll cnt=0;
    cin>>s1>>s2;
    for(int i=0;i<s1.length();i++)
    {
        if(s1[i]!=s2[i])
        cnt++;
    }
    cout<<cnt<<endl;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; ++i) cin >> H[i];
    for (int i = N - 2; i >= 0; --i) {
        if (H[i] > H[i+1]) {
            if (H[i] - H[i+1] > 1) {
                cout << "No" << endl;
                return 0;
            }
            --H[i];
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(){
  int N,max_Xi=0;
  cin >> N;
  long long sum=0, minimum=5833000;
  vector<int> Xs(N);
  for(int i=0;i<N;i++) {
    cin >> Xs.at(i);
    max_Xi = max(max_Xi, Xs.at(i));
  }
  
  for(int i=0;i<max_Xi;i++){
    for(int j=0;j<N;j++){
      sum += (Xs.at(j) - i - 1) * (Xs.at(j) - i - 1);
    }
    //cout << "sum = " << sum << endl;
    minimum = min(minimum, sum);
    sum=0;
  }
  cout << minimum << endl;
}

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

ll A,B,C,D;

ll gcd(ll n,ll m){
    if(n%m==0) return m;
    else return gcd(m,n%m);
}

ll res(ll N,ll c,ll d){
    if(d%c==0) return N-N/c;
    else{
        ll l = d/gcd(c,d)*c;
        return N-(N/c+N/d-N/l);
    }
}
int main(){
    cin >> A >> B >> C >> D;
    if(C>D) swap(C,D);
    cout << res(B,C,D)-res(A-1,C,D) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x;
  	cin>>n;
  	x=n%10;
  	if (x==2 || x==4 || x==5 || x==7 || x==9)
      	cout<<"hon"<<endl;
  	else if (x==0 || x==1 || x==6 || x==8)
      	cout<<"pon"<<endl;
  	else
      	cout<<"bon"<<endl;
  	return 0;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

const static double EPS = 1e-10;

struct Obstacle {
  double pos;
  double height;
  Obstacle(double pos,double height) :
    pos(pos), height(height) {}
};

double h(double g,double vix,double viy,double x){
  return -(g / (2.0 * vix * vix)) * x * x + (viy / vix) * x;
}

double compute_viy(double g,double interval,double vi){
  double a = 4.0;
  double b = - 4 * vi * vi;
  double c = interval * interval * g * g;
  if(b * b - 4 * a * c < 0) return -1;

  return sqrt((-b + sqrt(b * b - 4 * a * c)) / (2.0 * a));
}

int main(){
  double distance;
  int num_of_obstacles;
  int bounce_limit;
  while(~scanf("%lf %d %d",&distance,&num_of_obstacles,&bounce_limit)){
    vector<Obstacle> obstacles;
    for(int obstacle_i = 0; obstacle_i < num_of_obstacles; obstacle_i++){
      double pos,height;
      scanf("%lf %lf",&pos,&height);
      obstacles.push_back(Obstacle(pos,height));
    }

    double g = 1.0;
    double res = numeric_limits<double>::max();

    for(int div = 1; div <= bounce_limit + 1; div++){
      double rhs = 10000.0;
      double lhs = 0;
      double interval = distance / div;

      for(int round = 0; round < 50; round++){
        double vi = lhs + (rhs - lhs) / 2.0;
        double viy = compute_viy(g,interval,vi);
        if(viy < 0) {
          lhs = vi;
          continue;
        }

        double vix = sqrt(vi * vi - viy * viy);

        bool isok = true;
        for(int obstacle_i = 0; obstacle_i < num_of_obstacles; obstacle_i++){
          int offset = (int)(obstacles[obstacle_i].pos / (interval + EPS) );
          if(h(g,vix,viy,obstacles[obstacle_i].pos - ((double)offset * interval)) < obstacles[obstacle_i].height){
            isok = false;
            break;
          }
        }
        if(isok){
          rhs = vi;
          res = min(res,vi);
        }
        else{
          lhs = vi;
        }
      }
    }
    printf("%.5lf\n",res);
  }
}

Measured memory_bytes: 1244
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=1e5+4;

int main()
{
	int n,m,x;

	scn(n); scn(m); scn(x);

	int a[n][m],cost[n];

	rep(i,0,n)
	{	
		scn(cost[i]);

		rep(j,0,m)
		scn(a[i][j]);
	}

	int ans=inf;

	rep(i,1,1<<n)
	{
		int fa[m]={0},cost_here=0;

		rep(j,0,n)
		if(i&(1<<j))
		{
			cost_here+=cost[j];

			rep(k,0,m)
			fa[k]+=a[j][k];
		}

		int flag=1;

		rep(j,0,m)
		if(fa[j]<x)
		flag=0;

		if(flag)
		ans=min(ans,cost_here);
	}

	if(ans==inf)
	ans=-1;

	pri(ans);

    return 0;
}


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

int main(){
  int n,k;
  cin >>n >>k;
  int jud[n] = {0};
  rep(i,k){
    int d;
    cin >>d;
    vector<int> a(d);
    rep(j,d) {
      cin >>a[j];
      jud[a[j]-1]++;
    }
  }
  int cnt = 0;
  rep(i,n){
    if(jud[i]==0) cnt++;
  }
  cout << cnt << endl;   
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L+10L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    ll K;
    cin >> N >> K;
    vector<int> P(N);
    REP(i,N) cin >> P[i];
    REP(i,N) P[i]--;
    vector<ll> C(N);
    REP(i,N) cin >> C[i];
    
    vector<bool> ok(N);
    vector<vector<int>> vv;
    REP(i, N){
        if(ok[i]) continue;
        vector<int> v;
        v.pb(i);
        ok[i] = true;
        while(!(v.size()!=1&&P[v.back()]==i)){
            ok[P[v.back()]] = true;
            v.pb(P[v.back()]);
        }
        vv.pb(v);
    }

    int vn = vv.size();
    ll ans = -MAXINF;
    REP(i, vn){
        int n = vv[i].size();
        ll wa = C[vv[i][0]];
        Rep(j, 1, n) wa += C[vv[i][j]];

        REP(j, n){
            //jをスタート位置とした場合の計算
            ll tmp = 0;
            REP(k, n+1){
                tmp += C[vv[i][(j+k)%n]];
                if(k>=K) break;
                ll num = (K-k-1)/n;
                chmax(ans, tmp + (max(0ll, wa) * num));
            }
        }
    }

    pr(ans);
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int a, b, c, d, e, n, m, k;
string s, t, r;
char c1, c2, c3;

int A[200005];
int B[200005];
int C[200005];

int main() {
	cin >>n;
  	cout <<(10000000-n)%1000;
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll K; cin>>K;
    ll sum=0;
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            for(int h=1;h<=K;h++){
                int a=__gcd(i,j);
                int b=__gcd(a,h);
                sum+=b;
            }
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
long long int a,b,c,d[3],e;
int main()
{
	scanf("%lld %lld %lld",&a,&b,&c);
	if(a%2==0||b%2==0||c%2==0)
	{
		e=0;
	} 
	else
	{
		d[0]=a;
		d[1]=b;
		d[2]=c;
		sort(d,d+3);
		e=d[0]*d[1];
	}
	printf("%lld",e);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String[] params = in.nextLine().split(" ");
        int a = Integer.parseInt(params[0]);
        int b = Integer.parseInt(params[1]);

        System.out.println( a <= 5 ? 0 : a <= 12 ? b / 2 : b );

    }

}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

lint gcd(lint p, lint q){
    if(p<q) swap(p, q);
    while(q){
        lint r=p%q;
        p=q;
        q=r;
    }
    return p;
}

int main(){
    int n;
    lint m;
    scanf("%d%lld", &n, &m);
    lint a[n];
    rep(i, n){
        scanf("%lld", &a[i]);
        a[i]/=2;
    }
    lint lcm=1;
    set<int> S;
    rep(i, n){
        lint g=gcd(lcm, a[i]);
        lcm*=a[i]/g;
        if(lcm>m){
            printf("0\n");
            return 0;
        }
        lint t=a[i];
        int cnt=0;
        while(t%2==0){
            t/=2;
            ++cnt;
        }
        S.insert(cnt);
    }
    if(S.size()>1){
        printf("0\n");
        return 0;
    }
    lint ans=(m/lcm+1)/2;
    printf("%lld\n", ans);
}

Measured memory_bytes: 1024
"use strict";
// inputに入力データ全体が入る
const main = (input) => {
  const [a, b, c] = input.trim().split("");
  return a === c ? "Yes" : "No";
};

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 29548
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string ans = "";
        while (N != 0)
        {
            if (N % -2 == 0)
            {
                ans = "0" + ans;
                
            }
            else
            {
                ans = "1" + ans;
                N--;
            }
            N = N/-2;
        }
        if (ans == "") { Console.WriteLine(0); }
        else { Console.WriteLine(ans); }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
       #include <stdlib.h>
       #include <string.h>
int main ()
{
char ss [100];
scanf("%s",&ss);
if (!strcmp(ss,"SAT"))
{
puts("1");

}
else if (!strcmp(ss,"SUN"))
{
    printf("7");

}
else if (!strcmp(ss,"MON"))
{
        printf("6");

}
else if (!strcmp(ss,"TUE"))
{
        printf("5");

}
else if (!strcmp(ss,"WED"))
{
        printf("4");

}
else if (!strcmp(ss,"THU"))
{
        printf("3");

}
else if (!strcmp(ss,"FRI"))
{
        printf("2");

}

return 0;
}


Measured memory_bytes: 128
// ???
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    int m, n;
    cin >> m >> n;
    int a[n];
    for(int i = 0; i < n; i++)  cin >> a[i];
    if(m == 2){
        int ret = 1<<30;
        for(int i = 1; i <= 2; i++){
            int x = i;
            int tmp = 0;
            for(int j = 0; j < n; j++){
                tmp += a[j]!=x;
                x = 3-x;
            }
            ret = min(ret, tmp);
        }
        cout << ret << endl;
        return 0;
    }
    int ret = 0;
    for(int i = 1; i < n; i++){
        if(a[i]==a[i-1]){
            a[i] = -1;
            ret++;
        }
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 3488
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int K = sc.nextInt();
    	int[] ary = new int[K];
    	int[] ary2 = new int[K];
     	for(int i = 0; i < K; i++){
    		ary[i] = sc.nextInt();
    		if(i > 0){
    			if(i <= K-1){
    				ary2[i-1] = ary[i] - ary[i-1];
    			}
    		}
    	}
    	ary2[K-1] = N - ary[K-1] + ary[0];
    	sc.close();
    	int ans = 0;
    	Arrays.sort(ary2);
    	for(int j = 0; j < K-1; j++){
    		ans += ary2[j];
    	}
    	System.out.println(ans);
	}
}

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

int main(){
	int ans = 0;
	char str;
	
	for(int i=0;i<4;i++){
		cin >> str;
		if(str=='+'){
			ans++;
		}else{
			ans--;
		}		
	}
	
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
typedef pair<double,double>d_d;
#define inf 100000000//10^8

/////////////////////////////////


int main(){
    int a,b,c,x;cin>>a>>b>>c>>x;int ans=0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(i*500+j*100+k*50==x)ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n,*a=$<.map &:to_i
a.sort!

def d(b)
  c=(0...b.size).map{|i|(b[i-1]-b[i]).abs}
  c.reduce(:+)-c.min
end

b=(0...n).map{|i|i%2==0 ? a[i/2] : a[n-i/2-1]}
c=(0...n).map{|i|i%2==1 ? a[i/2] : a[n-i/2-1]}
p [d(b),d(c)].max


Measured memory_bytes: 9320
/*
ID: zhaowei10
TASK:
LANG: C++
*/
#include <algorithm>
#include <array>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define pb push_back
#define MOD 1000000007
#define FOR(i, j, k, l) for (s32 i = j; i < k; i += l)
#define RFOR(i, j, k, l) for (s32 i = j; i >= k; i -= l)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(x) x.begin(), x.end()
#define MEAN(a, b) min(a, b) + (abs(b - a) >> 1)
#define FASTIO()    \
  cin.tie(nullptr); \
  ios::sync_with_stdio(false);

typedef int64_t s64;
typedef uint64_t u64;
typedef int32_t s32;
typedef uint32_t u32;
typedef float f32;
typedef double f64;
typedef pair<s32, s32> II;
typedef pair<s64, s64> LL;
typedef vector<s32> VI;
typedef vector<II> VII;
typedef vector<char> VC;
typedef vector<VII> VVII;
typedef priority_queue<s32> PQI;
typedef priority_queue<s32, VI, greater<s32>> PQIA;
typedef priority_queue<s64> PQL;
typedef priority_queue<II> PQII;
typedef priority_queue<II, VII, greater<II>> PQIIA;
typedef priority_queue<LL> PQLL;
typedef unordered_set<s32> USI;
typedef unordered_set<s64> USL;
typedef set<II> SII;
typedef multiset<s32> MSI;

template <typename T, typename U>
inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void amax(T &x, U y) {
  if (x < y) x = y;
}

template <typename T>
inline s32 ndigits(T x) {
  s32 r = 0;
  while (x) {
    x /= 10;
    ++r;
  }
  return r;
}

int main() {
  FASTIO();
  s64 a, b, k;
  cin >> a >> b >> k;

  s64 x = min(a, k);
  a -= x;
  k -= x;
  b -= min(b, k);

  cout << a << ' ' << b;
}

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

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

using namespace std;
#define X first
#define Y second
#define pb push_back
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
string a,b;int n;

int main()
{
	cin>>n>>a>>b;
	for(int i=n;i>=0;i--)
	{
		bool f=true;
		for(int j=n-i;j<=n-1;j++)
			if(a[j]!=b[i+j-n]) f=false;
		if(f) return printf("%d",2*n-i),0;
	}
	return 0;
}

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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <math.h>

int main() {

    long long int n;
    cin >> n;

    long long int ans = 0;

    for ( long long int i = 2; n > 1; i++ ) {
        if ( i > 1000000 ) {
            ans++;
            break;
        }
        long long int cnt = 0;
        while( ( n % i ) == 0 ) {
            cnt++;
            n /= i;
        }
        for ( long long int j = 1; cnt > 0; j++ ) {
            cnt -= j;
            if ( cnt < 0 ) break;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 3632
import collections

N = int(input())
A = sorted(map(int, input().split()))

cnt = collections.defaultdict(int)
for a in A:
    cnt[a] += 1
ans = sum(A)

Q = int(input())
for _ in range(Q):
    B, C = map(int, input().split())
    ans += (C - B) * cnt[B]
    cnt[C] += cnt[B]
    cnt[B] = 0
    print(ans)


Measured memory_bytes: 24128
#include<bits/stdc++.h>
using namespace std;
string s="abcdefghijklmnopqrstuvwxyz";
#define ll long long int
int main()
{
    ll n,x;cin>>n;
    string ans="";
    while(n>0)
    {
        x=(n-1)%26;
        ans= char(x+'a')+ans;
        n= (  n-(x+1) )/26;
    }
    cout<<ans<<endl;
}
/*




*/


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int N,cnt=0,a,b,tmp;
    cin >> N;
  int A[N];
    for(int i=0 ; i<N; i++){
      cin >> A[i];
    }
  for(int i=0 ; i<N-1; i++){
    if(A[i]>A[i+1]){
      ++cnt ;
      if(cnt == 1){
        a = i;
      }
      else if(cnt == 2){
        b = i+1;
      }
    }
  }
  
    if(cnt > 2 ){
      cout << "NO" << endl;
    }
  	else if(cnt == 0)
      cout << "YES" <<endl;
  	else if(cnt == 1){
      tmp=A[a];
      A[a]=A[a+1];
      A[a+1]=A[tmp];
      for(int i=0 ; i<N-1; i++){
    if(A[i]>A[i+1]){
      cout << "NO" << endl;
      break;
    }
      if(i == N-2)
        cout << "YES" <<endl;
      }
    }
      
  	else{
    tmp = A[a];
  	A[a]=A[b];
  	A[b]=A[tmp];
    for(int i=0 ; i<N-1; i++){
    if(A[i]>A[i+1]){
      cout << "NO" << endl;
      break;
    }
      if(i == N-2)
        cout << "YES" <<endl;
    }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

#define MAX 100002

int main() {
	int imos[MAX] = {};
	int N; cin >> N;

	for (int i = 0; i < N; i++) {
		int a, b; cin >> a >> b;
		imos[a]++; imos[b + 1]--;
	}
	imos[0] = 1;
	for (int i = 1; i < MAX; i++) {
		imos[i] += imos[i - 1];
	}
	int ans = 0;
	for (int i = 0; i < MAX; i++) {
		if (imos[i] >= i)ans = max(ans, i - 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1560
//
//  main.cpp
//  Test
//
//  Created by momoc on 2019/8/18.
//  Copyright © 2019年 momoc. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    int a;
    char s[20];
    cin>>a>>s;
    if(a==3200){
        cout<<s<<endl;
    }
    else if(a>3200){
        cout<<s<<endl;
    }
    else{
        cout<<"red"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main(){
  vector<ll> primes;
  const ll mx = 10000000;
  const ll bs_size = ((mx>>1)-1);
  
  vector<ll> first;
  bitset<bs_size> *bs;
  bs =(bitset<bs_size>*)calloc(1,sizeof(bitset<bs_size>));
  for(int i=0; i<bs->size(); i++){
    if(bs->test(i)) continue;
    for(int j=i+(2*i+3); j<bs->size(); j+=2*i+3){
      bs->set(j);
    }
  }
  primes.push_back(2);
  for(int i=0; i<bs->size(); i++){
    if(!bs->test(i)){
      primes.push_back(2*i+3);
    }
  }

  ll N; cin>>N;
  ll ans = N==1 ? 1 : 5;
  vector<ll> fy{2};
  REP(i,3,N+1){
    ll cnt = 1;
    vector<ll>::iterator it;
    // is even
    int j=i;
    ll c=0;
    while(!(j&1)){
      j>>=1;
      c++;
    }
    if(c){
      cnt = fy[(i>>1)-2]/c*(c+1);
      goto last;
    }
    // is prime
    if(bs->test((i-3)>>1)==false){
      cnt=2;
      goto last;
    }
    
    // is odd
    it = primes.begin();
    while(*it <= (i>>1) && it != primes.end()){
      j=i;
      c=0;
      while(j%*it==0){
        j/=*it;
        c++;
      }
      if(c){
        cnt = fy[(i/(*it))-2]/c*(c+1);
        break;
      }
      it++;
    }
    last:
    //cout<<i<<","<<cnt<<endl;
    fy.push_back(cnt);
    ans+=i*cnt;
  }
  std::cout<<ans<<endl;
}

Measured memory_bytes: 140312
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] s = new int[4];
		// AC:0 WA:1 TLE:2 RE:3
		String str;
		for(int i=0; i<n; i++) {
			str = sc.next();
			switch (str) {
			case "AC":
				s[0]++;
				break;
			case "WA":
				s[1]++;
				break;
			case "TLE":
				s[2]++;
				break;
			case "RE":
				s[3]++;
				break;
			}
				
		}

		System.out.println("AC x " + s[0]);
		System.out.println("WA x " + s[1]);
		System.out.println("TLE x " + s[2]);
		System.out.println("RE x " + s[3]);
	}

}


Measured memory_bytes: 58428
import numpy as np

n, m = map(int, input().split())

seikai = np.zeros(n)
matigai1 = np.zeros(n)
matigai2 = np.zeros(n)
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if seikai[p]==1:
        continue
    else:
        if s=='AC':
            seikai[p] = 1
            matigai2[p] = matigai1[p]

        else:
            matigai1[p] += 1

print(int(seikai.sum()), int(matigai2.sum()))

Measured memory_bytes: 14644
#include<stdio.h>

#define MAX 2000001
#define VMAX 10000

void CountingSort(int, int*, int*);
int A[MAX],B[MAX];
int n;

int  main(){
  int i;

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

  CountingSort(VMAX,A,B);
  for(i = 1; i <= n; i++){
    printf("%d",B[i]);
    if(n != i) printf(" ");
  }
  printf("\n");
  return 0;
}

void CountingSort(int k,int *A, int *B ){
  int i,C[VMAX + 1];

  for(i = 0; i <= VMAX; i++){
    C[i] = 0;
  }

  for(i = 1; i <=n; i++){
    C[A[i]]++;
  }

  for(i = 1; i < VMAX+1; i++){
    C[i] += C[i-1];
  }

  for( i = 1; i <= n; i++){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
 return;
}



Measured memory_bytes: 17384
#include<bits/stdc++.h>
using namespace std;
long long a[100010];
long long c[100010];
int main()
{
	int n;
	scanf("%d",&n);
	long long sum=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		c[a[i]]++;
		sum+=a[i];
	}
	int m;
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		long long x,y;
		scanf("%lld %lld",&x,&y);
		sum-=c[x]*x;sum+=c[x]*y;
		c[y]+=c[x];c[x]=0;
		printf("%lld\n",sum);
	}
}

Measured memory_bytes: 5316
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
ll bitpow(ll x,ll n){
    ll ans = 1;
    while(n > 0){
        if(n%2 == 1) ans = ans * x % MOD;
        x = x * x %MOD;
        n = n >> 1;
    }
    return ans;
}
int N = 2005;
int fac[2011];
int inv[2011];
ll COM(ll n,ll k){
    return fac[n]*inv[k]%MOD*inv[n-k]%MOD;
}
    
signed main(){
    fac[0] = 1;
    inv[0] = 1;
    for(int i = 1;i <= N;i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = bitpow(fac[i],MOD-2)%MOD;
    }
    int n,k;
    cin >> n >> k;
    
    for(int i = 1;i <= k;i++){
        if(i-1 > n-k || i > k){
            cout << 0 << endl;
        }else cout << COM(n-k+1,i)*COM(k-1,i-1)%MOD << endl;
    }

    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc132.contest.atcoder.jp/tasks/abc132_b

Measured memory_bytes: 256