akhauriyash/Code-Regression huggingface dataset:
import sys

*I, = map(int, sys.stdin.read().split())
n, m, Q = I[:3]
lr = zip(*[iter(I[3:3+m*2])] * 2)
pq = zip(*[iter(I[3+m*2:])] * 2)

def main():
    res = [[0] * (n + 2) for _ in range(n+2)]
    
    for l, r in lr:
        res[1][r] += 1
        res[1][n+1] -= 1
        res[l+1][r] -= 1
        res[l+1][n+1] += 1
    
    for i in range(n+1):
        for j in range(n+1):
            res[i][j+1] += res[i][j]

    for j in range(n+1):
        for i in range(n+1):
            res[i+1][j] += res[i][j]
    
    for p, q in pq:
        yield res[p][q]

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 57632
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
cntA = Counter(A)

A.sort()
V = set()

ans = 0
mx = max(A)
for a in A:
    if a in V:
        continue
    if cntA[a] == 1:
        ans += 1

    p = a
    while p <= mx:
        V.add(p)
        p += a

print(ans)


Measured memory_bytes: 102440
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#define ll long long
#define vi vector<ll>
#define vs vector<string>
#define fr(i, k, n) for (ll i = k; i < n; i++)
#define rep(i, n) fr(i, 0, n)
#define alll(v) v.begin(), v.end()
#define mp(a, b) make_pair(a, b)
#define rdd(a) ll a; cin >> a
#define rrd rdd(a); rep(i, a)
//min({a,b,c,d})などの記法
using namespace std;
template <class X> void pr(X x) { cout << x << endl; }
template <class X> void prr(X x) { for (auto it : x) { cout << it << endl; } }

int main() {
    string s;
    ll n=0;
    cin>>s;
    string kotae="CODEFESTIVAL2016";
    rep(i, kotae.size()){
        if (kotae[i]!=s[i]) {
            n++;
        }
    }
    pr(n);
    return 0;
}


Measured memory_bytes: 760
#include <stdio.h>
int main(void){
    int tanka,kosu;
    int sum=0;
    int ave=0;
    int count=0;
    while(scanf("%d,%d",&tanka,&kosu)!=EOF){
        sum+=tanka*kosu;
        ave+=kosu;
        count++;
    }
    ave=ave*1.0/count+0.5;
    printf("%d\n",sum);
    printf("%d\n",ave);
    return 0;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
long int solve(long int h){
    if(h==1){
        return 1;
    }
    else {
        return 1+(2*solve(floor(h/2)));
}}
int main(){
	
		long int h;
		cin>>h;
		cout<<solve(h);
		return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

//再帰関数による深さ優先探索
void dfs_visit(int u){
	int v;
	color[u] = GRAY;
	d[u] = ++tt; //最初の訪問
	for(v=0; v<n; v++){
		if(M[u][v] == 0)continue;
		if(color[v] == WHITE){
			dfs_visit(v);
		}
	}
	color[u] = BLACK;
	f[u] = ++tt;//訪問の完了
}

void dfs(){
	int u;
	//初期化
	for(u=0; u<n; u++)color[u] = WHITE;
	tt = 0;
	
	for(u=0; u<n; u++){
		//未訪問のuを始点として深さ優先探索
		if(color[u] == WHITE)dfs_visit(u);
	}
	for(u=0; u<n; u++){
		printf("%d %d %d\n", u+1, d[u], f[u]);
	}
}

int main(){
	int u,v,k,i,j;
	
	scanf("%d", &n);
	for(i=0; i<n; i++){
		for(j=0; j<n; j++)M[i][j] = 0;
	}
	
	for(i=0; i<n; i++){
		scanf("%d %d", &u, &k);
		u--;
		for(j=0; j<k; j++){
			scanf("%d",&v);
			v--;
			M[u][v] = 1;
		}
	}
	dfs();
	
	return 0;
}







Measured memory_bytes: 2144
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int ctoi(const char c) {
    if ('0' <= c && c <= '9') {
        return (c - '0');
        return -1;
    }
}

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

    ll dp[s.size()][13] = {};

    if (s[s.size() - 1] == '?') {
        rep(i, 10) { dp[s.size() - 1][i] = 1; }
    } else {
        int num = ctoi(s[s.size() - 1]);
        dp[s.size() - 1][num] = 1;
    }

    ll m_temp = 1;
    repd(i, 1, s.size()) {
        ll index = s.size() - i - 1;
        m_temp *= 10;
        m_temp %= 13;

        if (s[index] == '?') {
            rep(j, 10) {
                ll m = (j * m_temp) % 13;
                rep(l0, 13) {
                    ll index_temp = l0 - m;
                    if (index_temp >= 0) {
                        dp[index][l0] += dp[index + 1][index_temp];
                    } else {
                        dp[index][l0] += dp[index + 1][13 + index_temp];
                    }
                    dp[index][l0] %= mod;
                }
            }
        } else {
            int num = ctoi(s[index]);
            ll m = (num * m_temp) % 13;
            rep(l0, 13) {
                ll index_temp = l0 - m;
                if (index_temp >= 0) {
                    dp[index][l0] += dp[index + 1][index_temp];
                } else {
                    dp[index][l0] += dp[index + 1][13 + index_temp];
                }
                dp[index][l0] %= mod;
            }
        }
    }

    cout << dp[0][5] << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


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

int main()
{
   ll x, y;
   cin >> x >> y;
   ll ans = 0;
   while(x<= y)
   {
      x = 2*x;
      ans++;
   }
   cout << ans << endl;
   //x 2x 4x 8x 16x 32x ...
   //25 200  8
   //25 50 100 200
   //0 1 2 4
   //2^k * x = y
   //2^k = y/x;
   //log2 y/x = k
   //＊　少数点を切り捨てられてWAになる...
   //ll k = log2(y) -log2(x);
   //cout << k+1 << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
#define MOD 1000000007

vector<int> edge[100001];
int A[100001], B[100001];
int sz[100001] = {};
int c[100001];
LL ans[100001];

int main(){
	int N;
	cin >> N;
	for(int i=0; i<N-1; i++){
		int a, b;
		cin >> a >> b;
		A[i] = a;
		B[i] = b;
		edge[a].PB(b);
		edge[b].PB(a);
		sz[a]++;
		sz[b]++;
	}
	for(int i=0; i<N; i++){
		cin >> c[i];
	}
	sort(c, c+N);
	queue<int> que;
	for(int i=0; i<N; i++){
		if(sz[i+1] == 1) que.push(i+1);
	}
	for(int i=0; i<N; i++){
		ans[que.front()] = c[i];
		for(int j=0; j<edge[que.front()].size(); j++){
			if(sz[edge[que.front()][j]] > 1){
				sz[edge[que.front()][j]]--;
				if(sz[edge[que.front()][j]] == 1) que.push(edge[que.front()][j]);
			}
		}
		que.pop();
	}

	LL sum = 0;
	for(int i=0; i<N-1; i++){
		sum += min(ans[A[i]], ans[B[i]]);
	}
	cout << sum << endl;
	for(int i=0; i<N; i++){
		cout << (i == 0 ? "" : " ") << ans[i+1];
	}
	cout << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>

using namespace std;

// n の k 乗を mod で割った余りを計算
long long power_mod(long long n, long long k, long long mod) {
    long long result = 1;
    // k を右シフトしつつ n を 2 乗していく
    while (k > 0) {
        // k の最下ビットが 1 なら、今の n を答えに掛ける
        if ((k & 1) == 1) result = (result * n) % mod;
        n = n * n % mod;
        k >>= 1;
    }
    return result;
}

// 階乗・組み合わせの mod 逆数
class FactorialMod {
    // 逆元を計算
    void calc_inverse() {
        inverse[0] = 0;
        inverse[1] = 1;
        for (int i = 2; i <= max_num; i++) {
            inverse[i] = mod - ((mod / i) * inverse[mod % i] % mod);
        }
    }

    // i! を mod で割った余りと逆元を計算
    void calc_factorial_inverse() {
        factorial[0] = factorial_inverse[0] = 1;
        for (int i = 1; i <= max_num; i++) {
            factorial[i] = (factorial[i - 1] * i) % mod;
            factorial_inverse[i] = (factorial_inverse[i - 1] * inverse[i]) % mod;
        }
    }

  public:
    int max_num;                         // 扱う最大の値
    int mod;                             // mod の法（素数）
    vector<long long> inverse;           // 逆元
    vector<long long> factorial;         // 階乗
    vector<long long> factorial_inverse; // 階乗の逆元

    FactorialMod(int _max_num, int _mod) {
        max_num = _max_num;
        mod = _mod;
        inverse = vector<long long>(max_num + 1);
        factorial = vector<long long>(max_num + 1);
        factorial_inverse = vector<long long>(max_num + 1);
        calc_inverse();
        calc_factorial_inverse();
    }

    // nCk を mod で割った余りを計算
    long long combination_mod(int n, int k) {
        if (n < 0 || k < 0 || n > max_num || k > max_num || k > n) return 0;
        return (((factorial[n] * factorial_inverse[k]) % mod) * factorial_inverse[n - k]) % mod;
    }

    // nHk を mod で割った余りを計算
    long long multi_choose_mod(int n, int k) {
        return combination_mod(n + k - 1, k);
    }
};

const int MOD = 1000000007;

int main(void) {
    int n, k;
    cin >> n >> k;
    FactorialMod factorial_mod(1999, MOD);
    cout << factorial_mod.multi_choose_mod(k, n) << endl;
    return 0;
}


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

const int N = 110;

int n, a[N], ans;

int main(){
    while(~scanf("%d", &n)){
        ans = 0;
        for(int i=1; i<n; i++){
            scanf("%d", a+i);
            if(i == 1){
                ans += a[i];
            } else {
                ans += min(a[i-1], a[i]);
            }
        }
        ans += a[n-1];
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
#include <cmath>
#include <cstdio>
using namespace std;
typedef pair<double, int>DI;
int N, M;
int X[10010], Y[10010], F[10010];
vector<int>vec[10010];
double ans = 0.0;
int main(){
    cin>>N>>M;
    for(int i=1;i<=N;i++){
        cin>>X[i]>>Y[i];
    }
    for(int i=0;i<M;i++){
        int p, q;
        cin>>p>>q;
        vec[p].push_back(q);
        vec[q].push_back(p);
        ans += hypot(X[p]-X[q], Y[p]-Y[q]);
    }
    for(int i=1;i<=N;i++){
        if(F[i])continue;
        priority_queue<DI>Q;
        F[i] = 1;
        for(int j=0;j<vec[i].size();j++){
            Q.push(DI(hypot(X[i]-X[vec[i][j]], Y[i]-Y[vec[i][j]]), vec[i][j]));
        }
        while(!Q.empty()){
            double cost = Q.top().first;
            int id = Q.top().second;
            Q.pop();
            if(F[id])continue;
            F[id] = 1;
            ans -= cost;
            for(int j=0;j<vec[id].size();j++){
                if(F[vec[id][j]])continue;
                Q.push(DI(hypot(X[id]-X[vec[id][j]], Y[id]-Y[vec[id][j]]), vec[id][j]));
            }
        }
    }
    printf("%.9f\n", ans);
    return 0;
}


Measured memory_bytes: 4360
# include <stdio.h>
int main(){
	long n,c,g=0,k=0;
	int z;
	scanf("%ld",&n);
	long a[n];
	for(c=0;c<n;c++){
		scanf("%ld ",&a[c]);
		if(a[c]%2==1)k++;
	}
	if(k%2==1)printf("NO");
	else if(k%2==0)printf("YES");
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#define BIG_NUM 2000000000
using namespace std;

int N;

void func(){

	int me[N],enemy[N];

    for(int i = 0; i < N; i++)scanf("%d",&me[i]);
    for(int i = 0; i < N; i++)scanf("%d",&enemy[i]);

    sort(me,me+N,greater<int>() );
    sort(enemy,enemy+N,greater<int>());

    int me_index = 0,me_win = 0;
    int ans = BIG_NUM;


    for(int i = 0; i < N; i++){

        while(me_index <= N-1){
            if(enemy[i] >= me[me_index]){
                me_index++;
                break;
            }else{
                me_win++;
                if(me_win >= (me_index+1)/2+1){
                    ans = me_index+1;
                    break;
                }
                me_index++;
            }
        }

        if(me_index >= N || ans != BIG_NUM)break;
    }

    if(ans == BIG_NUM || ans == N){
        printf("NA\n");
    }else{
        printf("%d\n",ans);
    }
}

int main(){

    while(true){
        scanf("%d",&N);
        if(N == 0)break;

        func();
    }

    return 0;
}

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

using namespace std;

int p[1000010];
int factors[1000010];
vector<int> primes;

vector<int> factor(int n){
	int index = 0;
	int pf = primes[0];
    vector<int> ans;
	while(pf*pf <= n){
        int cnt = 0;
		while(n%pf==0){
            cnt++;
			n /= pf;
		}
        
        if(cnt > 0) factors[pf]++;
		pf = primes[++index];
	}
	if(n != 1) {
        ans.push_back(n);
        factors[n]++;
    }
    return ans;
}

int main() {

    for (int i = 2; i * i < 1000010; ++i) {
        for (int j = i + i; j < 1000010; j += i)
            p[j] = 1;
    }

    for (int i = 2; i < 1000010; ++i)
        if(!p[i]) primes.push_back(i);

    int n;
    cin >> n;
    vector<int> v(n);
    
    for (auto &x: v) {
        cin >> x;
        factor(x);
    }


    bool flag = 1;
    int gcd = v[0];

    for (int i = 0; i < n; ++i)
        gcd = __gcd(gcd, v[i]);

    for (int x: primes) {
        flag &= factors[x] <= 1;
    }

    if(flag) return cout << "pairwise coprime\n", 0;
    if(gcd == 1) return cout << "setwise coprime\n", 0;
    cout << "not coprime\n";
    return 0;
}


Measured memory_bytes: 15164
import java.util.*;

public class Main{
	static Scanner s=new Scanner(System.in);
	public static void main(String[] $){
		int[]a={0,0,0,0};
		for(int i=0;i<6;++i)
			++a[s.nextInt()-1];
		System.err.println(Arrays.toString(a));
		Arrays.sort(a);
		System.out.println(Arrays.equals(a,new int[]{1,1,2,2})?"YES":"NO");
	}
}


Measured memory_bytes: 23764
n=int(input())
red=[list(map(int,input().split())) for _ in range(n)]
blue=[list(map(int,input().split())) for _ in range(n)]
res = 0
red.sort(key=lambda x: x[1],reverse=True)
blue.sort()
for i in range(n):
    for j in range(len(red)):
        if red[j][0]<blue[i][0] and red[j][1]<blue[i][1]:
            red.pop(j)
            res += 1
            break
print(res)

Measured memory_bytes: 38768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

char select(char a, char b, char x){
    if(a==x)return a;
    if(b==x)return b;
    return a;
}

int main() {
    string s;cin>>s;
    bool same = true;
    rep(i,s.size()){
        if(s[i] != s[0])same = false;
    }
    if(same){
        cout << 0 << endl;
        return 0;
    }
    int ans = INF;
    for (int i = 0; i < 26; i++){
        char x  = 'a'+i;
        string tmp = s;
        int b = 0;
        while(1){
            b++;
            int cnt = 0;
            string tmp2 = "";
            for(int j = 0;j < tmp.size()-1; j++){
                char c = select(tmp[j], tmp[j+1], x);
                tmp2 += c;
                if(c==x)cnt++;
            }
            if(tmp2.size()==cnt){
                ans = min(ans,b);
                break;
            }
            tmp = tmp2;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
def main():
	a = int(input())
	b = int(input())
	#n,m = map(int,input().split())
	# A = [list(map(int, input().split())) for _ in range(H)]

	l = [1,2,3]
	l.remove(a)
	l.remove(b)

	print(int(l[0]))

	




if __name__ == '__main__':
	main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;

int main()
{
    int n,i,s,d,nr,nrtot;
    scanf("%d",&n);
    nrtot=0;
    for(i=1; i<=n-1; i++)
    {
        s=n-i;
        d=2;
        nr=1;
        while(d*d<=s)
        {
            if(s%d==0)
            {
                int tau=1;
                while(s%d==0)
                {
                    tau++;
                    s/=d;
                }
                nr*=tau;
            }
            d++;
        }
        if(s>1) nr*=2;
        nrtot+=nr;
    }
    printf("%d",nrtot);

    return 0;
}


Measured memory_bytes: 3824
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,max,min;
    cin>>a>>b>>c;
    max=a;
    min=a;
    if(max<b)   max=b;
    if(max<c)   max=c;
    if(min>b)   min=b;
    if(min>c)   min=c;
    cout<<min<<" "<<max;
    cout<<endl;
}



Measured memory_bytes: 3104
#include <iostream>
#include <cstring>
#include <cstdio>
#include<algorithm>
#include <queue>
#include <cmath>
#include <limits>
#include <map>
using namespace std;
int main(){
 int n;
 cin >> n;
 int ans = 0;
 if(n<10) ans = n;
 if(n<100 && n>=10) ans = 9;
 if(n<1000 && n>=100) ans = (n - 99) + 9;
 if(n<10000 && n>=1000) ans = 900 + 9;
 if(n<100000 && n>=10000) ans = (n - 9999) + 900 + 9;
 if(n==100000) ans = 90909;

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
string = list(raw_input())
q = input()
List = [0]*q
for i in range(q):
	List[i] = raw_input().split()
	List[i][1:3] = map(int,List[i][1:3])
	if List[i][0] == 'print' :
		print '%s' %"".join(string[List[i][1]:List[i][2]+1])
	elif List[i][0] == 'reverse':
		s = [0] * (List[i][2]-List[i][1])
		s = reversed(string[List[i][1]:List[i][2]+1])
		string[List[i][1]:List[i][2]+1] = s
	else :
		string[List[i][1]:List[i][2]+1] = list(List[i][3])

Measured memory_bytes: 6452
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
inline int in(){ int x; scanf("%d",&x); return x;}

int res;

void dfs(int n, int s, vector<int> used){
  int x,i;

//  cout << n << " " << s << endl;
//  rep(i,used.size()) cout << used[i] << " "; cout << endl;
  if(n == 0 && s == 0) res++;
  rep(x,10){
    bool f = false;
    rep(i,used.size()) if(x == used[i]) f = true;
    if(f) continue;
    if(0 <= s-x && 0 <= n-1){
      used.push_back(x);
      dfs(n-1,s-x,used);
    }
  }
}

int main(){
  int i,j,k;
  int n,s;

  while(scanf("%d %d",&n,&s)){
    if(n == 0 && s == 0) break;
    vector<int> used;

    res = 0;
    dfs(n,s,used);
    printf("%d\n",res);
  }

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
using namespace std;
int main()
{
	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//string s[1001];
	int n;
	int D[31][31] = {};
	int C[501][501] = {};
	int T[4][31] = {};
	cin >> n;
	cin >> c;
	for (a = 1; a <= c; a++)
	{
		for (b = 1; b <= c; b++)
		{
			cin >> D[a][b];
		}
	}
	for (a = 1; a <= n; a++)
	{
		for (b = 1; b <= n; b++)
		{
			cin >> C[a][b];
		}
	}
	for (a = 1; a <= n; a++)
	{
		for (b = 1; b <= n; b++)
		{
			if ((a + b) % 3 == 0)
			{
				T[1][C[a][b]]++;
			}
			else if ((a + b) % 3 == 1)
			{
				T[2][C[a][b]]++;
			}
			else if ((a + b) % 3 == 2)
			{
				T[3][C[a][b]]++;
			}
		}
	}
	ans = 10000000000;
	/*for (a = 1; a <= c; a++)
	{
		for (b = 1; b <= c; b++)
		{
			for (d = 1; d <= c; d++)
			{
				e = 0;
				if (a != b&&b != d&&a != d)
				{
					for (f = 1; f <= n; f++)
					{
						for (g = 1; g <= n; g++)
						{
							if ((f + g) % 3 == 0 && C[f][g] != a)
							{
								e += D[C[f][g]][a];
							}
							else if ((f + g) % 3 == 1 && C[f][g] != b)
							{
								e += D[C[f][g]][b];
							}
							else if ((f + g) % 3 == 2 && C[f][g] != d)
							{
								e += D[C[f][g]][d];
							}
						}
					}
					ans = min(ans, e);
				}
			}
		}
	}*/
	for (a = 1; a <= c; a++)
	{
		for (b = 1; b <= c; b++)
		{
			for (d = 1; d <= c; d++)
			{
				if (a != b&&b != d&&a != d)
				{
					e = 0;
					for (f = 1; f <= c; f++)
					{
						for (g = 1; g <= 3; g++)
						{
							if (g == 1&&f!=a)
							{
								e += D[f][a] * T[g][f];
							}
							if (g == 2 && f != b)
							{
								e += D[f][b] * T[g][f];
							}
							if (g == 3 && f != d)
							{
								e += D[f][d] * T[g][f];
							}
						}
					}
					ans = min(ans, e);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD=1e9+7;
const int MAX=1e5+100;

int main() {
  ll A,B,K;cin>>A>>B>>K;

  if (A>=K) {
    cout<<A-K<<' '<<B<<endl;
  } else {
    cout<<0<<' '<<max(0LL,B-(K-A))<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		List<String> listACTG = new ArrayList<String>();
		listACTG.add("A");
		listACTG.add("C");
		listACTG.add("G");
		listACTG.add("T");
		Scanner scanner = new Scanner(System.in);
		String line = scanner.next();
		int maxCount = 0;
		int tmpCount = 0;
		for (int i = 0 ; i < line.length() ; i++) {
	        if(listACTG.contains(line.substring(i,i+1))) {
	        	tmpCount ++;
	        }else {
	        	tmpCount = 0;
	        }
			if(tmpCount >=maxCount) {
				maxCount = tmpCount;
			}
		}
		System.out.println(maxCount);
		scanner.close();
	}
}

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

#define ll long long
#define pll pair<ll,ll>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define vvi vector<vi>
#define P_Q priority_queue<ll>
#define p_q priority_queue<ll,vi,greater<ll>>
#define loop(i,x,y,z) for(int i=x; i<=y; i+=z)
#define loopR(i,x,y,z) for(int i=x; i>=y; i-=z)
#define all(x) begin(x), end(x)
#define allR(x) rbegin(x), rend(x)
#define watch(x) cout<<(#x)<<" is "<<x<<'\n'
#define display(v,c) for(auto x:v) cout<<x<<c;
#define endl "\n"

int main(){
	IOS
	// do magic here
	ll n,k;
	cin>>n>>k;
	vi heights(n);
	for(auto &x:heights) cin>>x;
	vi dp(n,0);
	loop(i,1,n-1,1){
		ll x = i-1;
		ll ans = LLONG_MAX;
		while (x >= max(0LL,i-k)){
			ans = min(ans,abs(heights[x]-heights[i]) + dp[x]);
			x--;
		}
		dp[i]=ans;
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 4784
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u64,
        b: u64,
        c: u64,
    }
    println!("{}",
        if a == b && b == c { 1 }
        else if a == b || a == c || b == c { 2 }
        else { 3 }
    );
    
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define F first  
#define S second
#define ll long long
#define pb push_back
#define pr pair<ll,ll>

const ll N=2e5+9,mod=1e9+7,inf=1e18;

int BITree[N],n;
int getSum(int index) 
{ 
    int sum = 0; 
  
   
  
  
    while (index>0) 
    { 
       
        sum += BITree[index]; 
  
        
        index -= index & (-index); 
    } 
    return sum; 
} 
  

void updateBIT( int index) 
{ 
    
  
   
    while (index <= n) 
    { 
  
    BITree[index] += 1; 
  
    index += index & (-index); 
    } 
} 

int main(int argc, char const *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
   cin>>n;
   int cnt=0;
   int p=n;
   while(p--)
   {
   	int x;cin>>x;
   	if(getSum(x)==0)cnt++;
   	updateBIT(x);
   }
   

	cout<<cnt<<"\n";
	
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<cmath>

using ll = long long;

int main(){
    ll n;
    std::cin >> n;
    ll th = std::sqrt(n);

    ll minCost = 1e13;
    for(ll i = 1; i <= th; i++){
        if(n % i == 0){
            ll j = n / i;
            minCost = std::min(minCost, i + j - 2);
        }
    }

    std::cout << minCost << std::endl;
    return 0;
}


Measured memory_bytes: 256
*> AtCoder My Practice
       *> author: Leonardone @ NEETSDKASU
       *>
       IDENTIFICATION DIVISION.
       PROGRAM-ID. Answer.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
              FUNCTION ALL INTRINSIC.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
              01 Answer-Values.
                     05 fst    PIC AAA.
                     05 snd    PIC AAA.
                     05 trd    PIC AAA.
       PROCEDURE DIVISION.
       AnswerMain SECTION.
       000-Start.
       
              ACCEPT fst.
              ACCEPT snd.
              ACCEPT trd.
      
      	      DISPLAY fst(1:1) snd(2:1) trd(3:1).
              
       END PROGRAM Answer.


Measured memory_bytes: 384
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect

N, M = list(map(int, input().split()))
s = [[] for _ in range(M)]
for i in range(M):
    s[i] = list(map(int, input().split()))
p = list(map(int, input().split()))

# 全探索だ
ans = 0
for switch in list(itertools.product([0, 1], repeat=N)):
    ok = 0
    for denkyu in range(M):
        tmp = 0
        for i in s[denkyu][1:]:
            tmp += switch[i-1]
        if(tmp % 2 == p[denkyu]):
            ok += 1
    if (ok == M):
        ans += 1

print(ans)


Measured memory_bytes: 13232
using System;
using System.Linq;

namespace AtCoderBeginner120
{
    class Program
    {
        static void Main()
        {
            string str = Console.ReadLine();
            var zero = str.Where(x => x == '0').Count();
            var one = str.Where(x => x == '1').Count();
            Console.WriteLine(Math.Min(zero, one) *2);
        }
    }
}


Measured memory_bytes: 11360
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int n;
int cnt=0;
string s;
string t="753";
int c[3];

void dfs(){
	if(s.size()>=10)return;
	if(s.size()&&stoi(s)<=n&&c[0]&&c[1]&&c[2]){
		cnt++;
	}
	rep(i,3){
		s+=t[i];
		c[i]++;
		dfs();
		c[i]--;
		s.pop_back();
	}
}
int main(){
	cin>>n;
	dfs();
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

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

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin>>n;
    map<ll,ll> mp;
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    
    for(ll i=1;i<=n;i++){
        ll sum=i;
        for(ll j=2;j<=sum;j++){
            while(sum%j==0){
                mp[j]++;
                sum/=j;
            }
            if(sum==1) break;
        }
    }
    ll ans=1;
    for(auto p:mp){
        ans*=(p.second+1);
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


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

const int N=5000005;

int n,Q;
char s[N];
set<int> Set[30];//Set[i]集合中记录第i个字母出现的位置 
set<int>::iterator it;

void init()
{scanf("%d",&n);
 scanf("%s",s+1);
 for (int i=0;i<26;i++)
   Set[i].insert(n+1);
 for (int i=1; i<=n; i++)
   Set[s[i]-'a'].insert(i); 
}

void work()
{int type,i,l,r,ans;
 char c;
 scanf("%d",&Q);
 for (int j=1;j<=Q;j++)
   {scanf("%d",&type);
    if (type==1)//替换操作 
      {scanf("%d %c",&i,&c);
       Set[s[i]-'a'].erase(i); 
	   Set[c-'a'].insert(i); 
	   s[i]=c;
	  }
	else//查询操作 
	  {scanf("%d %d",&l,&r);
	   ans=0;
	   for (int k=0;k<26;k++) 
	     {it=Set[k].lower_bound(l); 
		  if (*it<=r) ans++; 
		 }
	   printf("%d\n",ans);
	  }
   }
}
 
int main()
{
 init();
 work();
 return 0;
}


Measured memory_bytes: 26240
#if defined(_WIN32)
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

using ulong = unsigned long;
using ll = long long;
using ull = unsigned long long;

using namespace std;

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

	ll a;
	cin >> a;

	cout << 48 - a << endl;
	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b;
    cin>>a>>b;
    if((a*b)%2==0)cout<<"Even"<<endl;
    else cout<<"Odd"<<endl;

    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<vector>
    #include<array>
    #include<deque>
    #include<queue>
    #include<map>
    #include<cmath>
    #include<stdio.h>
     
    using std::cout;
    using std::cin;
    using std::setw;
    using std::setfill;
    using std::string;
    using std::pair;
    using std::make_pair;
    using std::vector;
    using std::array;
    using std::queue;
    using std::deque;
    using std::priority_queue;
    using std::multimap;
    using std::next_permutation;
    //using std::iota;
    using std::sort;
    using std::greater;
    using std::max;
    using std::min;
    using std::sin;
    using std::cos;
    using std::log;
     
    using lli = long long int;
    using ulli = unsigned long long int;
     
    #define INF 999999999;
    #define MOD 1000000007;
    #define PI 3.141592653589793;
     
    //#define EVEL 1
     
    #ifndef EVEL
    #define dbug(X) std::cout << #X << ":" <<X<<" " ;
    #define dbugf(s) std::cout << s << " ";
    #define dbugln std::cout<<"\n";
    #else
    #define dbug(X) {}
    #define dbugf(s) {}
    #define dbugln {}
    #endif
     
    int N;
    /*約数が8->27*素数or125*素数or素数3つの積*/
     
    int main(void){
    	cin.tie(0);
    	std::ios::sync_with_stdio(false);
     
    	cin >> N;
    	if(N < 105){
    		cout << 0;
    	}else if(N < 135){
    		cout << 1;
    	}else if(N < 165){
    		cout << 2;
    	}else if(N < 189){
    		cout << 3;
    	}else if(N < 195){
    		cout << 4;
    	}else{
    		cout << 5;
    	}
     
    	return 0;
    }

Measured memory_bytes: 256
// AtCoder Grand Contest 018
// C - Coins

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;


const int MAX_N = 100000;

struct person {
    ll x, y, z;
};

int N;
int X, Y, Z;
person p[MAX_N];
ll ms[2][MAX_N + 1];

int main() {

    auto comp0 = [](person p1, person p2) { return (p1.y - p1.z) > (p2.y - p2.z); };
    auto comp1 = [](person p1, person p2) { return (p1.x - p1.z) > (p2.x - p2.z); };
    priority_queue<person, vector<person>, decltype(comp0)> q0(comp0);
    priority_queue<person, vector<person>, decltype(comp1)> q1(comp1);
    ll ans;

    cin >> X >> Y >> Z;
    N = X + Y + Z;
    for (int i = 0; i < N; i++) {
        cin >> p[i].x >> p[i].y >> p[i].z;
    }
    sort(p, p + N, [](person p1, person p2) { return (p1.x - p1.y) < (p2.x - p2.y); });

    ms[0][Y] = 0;
    for (int i = 0; i < Y; i++) {
        q0.push(p[i]);
        ms[0][Y] += p[i].y;
    }
    for (int k = Y; k < Y + Z; k++) {
        q0.push(p[k]);
        ms[0][k + 1] = ms[0][k] + p[k].y;
        person pr = q0.top(); q0.pop();
        ms[0][k + 1] += -pr.y + pr.z;
    }
    ms[1][Y + Z] = 0;
    for (int i = N - 1; i >= Y + Z; i--) {
        q1.push(p[i]);
        ms[1][Y + Z] += p[i].x;
    }
    for (int k = Y + Z - 1; k >= Y; k--) {
        q1.push(p[k]);
        ms[1][k] = ms[1][k + 1] + p[k].x;
        person pr = q1.top(); q1.pop();
        ms[1][k] += -pr.x + pr.z;
    }

    ans = 0;
    for (int k = Y; k <= Y + Z; k++) {
        ans = max(ans, ms[0][k] + ms[1][k]);
    }
    cout << ans << endl;

    return 0;

}





Measured memory_bytes: 7796
#include<cstdio>
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	if(n>m)n^=m^=n^=m;
	if(n==1&&m==1)puts("1");
	else if(n==1)printf("%d",m-2);
	else printf("%lld",1LL*(n-2)*(m-2));
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt() - 1;
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 0; i < n - 1; i++) {
            c[i] = sc.nextInt();
        }
        int ans = 0;
        ans += b[a[0]];
        for (int i = 1; i < n; i++) {
            if (a[i - 1] + 1 == a[i]) {
                ans += c[a[i - 1]];
            }
            ans += b[a[i]];
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


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

int main() {
  int n;
  cin >> n;
  if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9) cout << "hon" << endl;
  else if(n%10==3) cout << "bon" << endl;
  else cout << "pon" << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<=(int)(n); i++)
#define reprange(i, a) for(int i : vector<int>a)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;
typedef vector<ll> vl;
const ll inf=1LL << 60;
const ll mod=1e9+7;

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

  int k, s, ans=0;
  cin >> k >> s;
  rep(i, k+1)rep(j, k+1)if(s-(i+j)<=k&&s-(i+j)>=0)ans++;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3584
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順

using namespace std;
using ll = long long int;

int main(){
    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    
}

Measured memory_bytes: 3624
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: String Transformation
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_L = 200008;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

char s[MAX_L], t[MAX_L];
int sts[26], tss[26];

/* subroutines */

/* main */

int main() {
  scanf("%s%s", s, t);

  memset(sts, -1, sizeof(sts));
  memset(tss, -1, sizeof(tss));

  for (char *spt = s, *tpt = t; *spt; spt++, tpt++) {
    int sc = *spt - 'a', tc = *tpt - 'a';
    if (sts[sc] != tc) {
      if (sts[sc] < 0 && tss[tc] < 0)
	sts[sc] = tc, tss[tc] = sc;
      else {
	puts("No");
	return 0;
      }
    }
  }
  puts("Yes");
  return 0;
}


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

int main(){

    int n;
    cin >> n;
    vector<int> h(n);
    for(int i=0; i<n; i++) {
        cin >> h.at(i);
    }

    string ans="Yes";
    h.at(0)--;
    if(n>=2){
        if(h.at(0)>h.at(1)) ans="No";
        for(int i=1; i<n-1; i++){
            if(h.at(i-1)!=h.at(i)) h.at(i)--;
            if(h.at(i)>h.at(i+1)) ans="No";
        }
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 3716
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
//int dp[3001][3001];
void lcs(string s,string t,int m,int n)
{
    int dp[m+1][n+1]; 

   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         dp[i][j] = 0; 
       else if (s[i-1] == t[j-1]) 
         dp[i][j] = dp[i-1][j-1] + 1; 
       else
         dp[i][j] = max(dp[i-1][j], dp[i][j-1]); 
     } 
   } 

   int index = dp[m][n]; 

   char lcs[index+1]; 
   lcs[index] = '\0';

   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      if (s[i-1] == t[j-1]) 
      { 
          lcs[index-1] = s[i-1];
          i--; j--; index--;    
      } 

      else if (dp[i-1][j] > dp[i][j-1]) 
         i--; 
      else
         j--; 
   } 
    cout<<lcs<<endl;
}
void solve()
{
     string s,t;
     cin>>s>>t;
     int m = s.length();
     int n = t.length();
     for(int i=0;i<3001;i++)
     {
         for(int j=0;j<3001;j++)
         {
             //dp[i][j] = -1;
         }
     }
     lcs(s,t,m,n);
     //cout<<res<<endl;
}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

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

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

        int l = s.size(), inr = true, cnt = 0, gath;
        std::vector<int> ans(l, 0);
        s += 'R';
        for(int i=0; i<=l; i++){
                if(inr){
                        if(s[i]=='R') cnt++;
                        else{
                                gath = i-1;
                                ans[gath] += (cnt+1)/2;
                                ans[gath+1] += cnt/2;
                                cnt = 1;
                                inr = false;
                        }
                }else{
                        if(s[i]=='L') cnt++;
                        else{
                                ans[gath] += cnt/2;
                                ans[gath+1] += (cnt+1)/2;
                                cnt = 1;
                                inr = true;
                        }
                }
        }

        for(int i=0; i<l; i++) printf("%d ", ans[i]);
        return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
using namespace std;
                   
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    double xa,ya,ra,xb,yb,rb;
    cin>>xa>>ya>>ra>>xb>>yb>>rb;
    double d=sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
    if(d>ra+rb){
      cout<<0<<"\n";
    }else if(abs(ra-rb)<=d && ra+rb>=d){
      cout<<1<<"\n";
    }else{
      cout<<(ra>rb?"":"-")<<2<<"\n";
    }
  }
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

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

int main() {
  ll x,y;
  cin>>x>>y;
  ///////////
  ll a=x;
  ll ans=1;
  while(a<=y){
    
    a*=2;
    if(a<=y){
    ans++;}
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256