akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int i, j;
	int n;
	
	cin >> n;
	int c = n%10;
	if(c == 2 || c == 4 || c == 5 || c == 7 || c== 9)
	{
		cout << "hon";
	}
	else if(c == 0 || c == 1 || c == 6 || c == 8)
	{
		cout << "pon";
	}
	else
	{
		cout << "bon";
	}
}
		
		


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int N = scan.nextInt();
			
			int ok = 0;
			
			
			for(int i = 1;i<=9;i++) {
				
				
				if(N%i==0) {//割り切れるとは二つの席で表せる
					String s = String.valueOf(N/i);
					if(s.length()==1) {//さらにもう一つの席が人桁かどうか
						ok=1;
						break;
					}
					
				}
			}
			
			
			System.out.println(ok==1?"Yes":"No");
			
			
			
			
			
			
			
		}
		
		
	}
		

}


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

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================

vpll prime_factor;
void div_prime(ll n)
{
	for (ll i = 2; i * i <= n; i++)
	{
		ll count = 0;
		while (n % i == 0)
		{
			count++;
			n /= i;
		}
		if (count)
		{
			pair<ll, ll> temp = { i, count };
			prime_factor.emplace_back(temp);
		}
	}
	if (n != 1)
	{
		pair<ll, ll> temp = { n, 1 };
		prime_factor.emplace_back(temp);
	}
}

// テーブルを作る前処理
ll comb_const = 200005;
vll fac(comb_const), finv(comb_const), inv(comb_const);
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < comb_const; 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(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	ll N, M;
	cin >> M >> N;

	div_prime(N);
	COMinit();

	ll prime = 1;

	ll origin = N;

	vll fact;
	for (int i = 0; i < prime_factor.size(); i++)
	{
		fact.emplace_back(prime_factor[i].second);
	}


	ll ans = 1;

	for (ll i = 0; i < fact.size(); i++)
	{
		ll com = COM(fact[i] + (M - 1), fact[i]) % MOD;
		ans *= com;
		ans %= MOD;
	}

	cout << ans << endl;

}





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

using namespace std;

int main()
{
  int q1, b, c1, c2, q2;
  while(cin >> q1, q1){
    cin >> b >> c1 >> c2 >> q2;
    int aizu = min(q2, b/c1);
    int money = b - aizu*c1;
    int tori = max(money/c2, 0);
    money -= tori*c2;
    int up = 0;
    while(aizu > 0 && (money < 0 || aizu + tori < q1)){
      //cout << aizu << " " << tori << " " << money << endl;
      aizu--;
      money += c1;
      up = max(money/c2, 0);
      money -= up*c2;
      tori += up;
    }
    if(aizu != 0 && aizu + tori >= q1) cout << aizu << " " << tori << endl;
    else cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <complex>
#include <algorithm>
#include <cmath>

using namespace std;

typedef double D;
typedef complex<D> P;

const D eps = 0.0001;

int N;
P ps[300];

bool get_centre(P a, P b, P& r1, P& r2) {
    if (norm(a - b) > 4) { return false; }
    P m = (a + b) / 2.0 - a;
    D l = sqrt(1 * 1 - norm(m));
    P c = m * P(0, 1);
    P cl = c / abs(c) * l;
    r1 = a + m + cl;
    r2 = a + m - cl;
    return true;
}

int solve() {
    int ans = 1;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            P r1, r2;
            if (!get_centre(ps[i], ps[j], r1, r2)) { continue; }

            int r1_cnt = 0;
            int r2_cnt = 0;

            for (int k = 0; k < N; k++) {
                if (norm(ps[k] - r1) <= 1 + eps) { r1_cnt++; }
                if (norm(ps[k] - r2) <= 1 + eps) { r2_cnt++; }
            }

            ans = max(ans, r1_cnt);
            ans = max(ans, r2_cnt);
        }
    }
    return ans;
}

int main() {
    for (;;) {
        scanf("%d", &N);
        if (!N) { break; }
        for (int i = 0; i < N; i++) {
            D x, y;
            scanf("%lf%lf", &x, &y);
            ps[i] = P(x, y);
        }
        printf("%d\n", solve());
    }
    return 0;
}

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

int ma;
int n;

vector<int> graph2[300];
vector<int> graph1[300];
vector<int> graph3[300];

vector<int> vs;
bool used[300];
int cmp[300];

void dfs(int v){
    used[v] = true;

    for(int i = 0;i < graph1[v].size();i++){
        if(!used[graph1[v][i]]) dfs(graph1[v][i]);
    }

    vs.push_back(v);
}

void rdfs(int v, int k){
    used[v] = true;
    cmp[v] = k;
    for(int i = 0;i < graph2[v].size();i++){
        if(!used[graph2[v][i]]) rdfs(graph2[v][i], k);
    }
}

int memo[300];

bool dfs3(int idx){
    if(idx == cmp[n-1]){
        return true;
    }

    if(graph3[idx].size() == 0){
        return false;
    }

    if(memo[idx] != -1){
        return memo[idx];
    }

    bool ans = true;
    for(int i = 0;i < graph3[idx].size();i++){
        ans = (ans && dfs3(graph3[idx][i]));
    }

    return memo[idx] = ans;
}


int scc(){
    memset(used, 0, sizeof(used));
    memset(cmp, 0, sizeof(cmp));
    vs.clear();

    for(int i = 0;i < n;i++){
        if(!used[i]) dfs(i);
    }

    memset(used, 0, sizeof(used));

    int k = 0;
    for(int i = vs.size()-1;i >= 0;i--){
        if(!used[vs[i]]) rdfs(vs[i], k++);
    }

    return k;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin >> ma, ma != 0){
        cin >> n;

        int a[310] = {};

        for(int i = 0;i < n;i++){
            cin >> a[i+1];
        }
        n+=2;
        for(int i = 0;i < n;i++){
            graph1[i].clear();
            graph2[i].clear();
            graph3[i].clear();
        }

        for(int i = 0;i < n;i++){
            for(int j = i+1;j < min(i+ma+1, n);j++){
                int tmp = min(n-1, max(j+a[j], 0));
                graph1[i].push_back(tmp);
                graph2[tmp].push_back(i);
            }
        }

        scc();
        for(int i = 0;i < n;i++){
            for(int j = i+1;j < min(i+ma+1, n);j++){
                int tmp = min(n-1, max(j+a[j], 0));
                if(cmp[i] != cmp[tmp]){
                    graph3[cmp[i]].push_back(cmp[tmp]);
                }
            }
        }


        memset(memo, -1, sizeof(memo));

        if(dfs3(cmp[0])){
            cout << "OK" << endl;
        }else{
            cout << "NG" << endl;
        }

    }

    return 0;
}





Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	// your code goes here
	ll n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	k--;
	s[k]=s[k]-'A'+'a';
	cout<<s;
	return 0;
}

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


int main() {
  long long N;
  cin>>N;
  long long sum=0;
  for(int i=0;i<N;i++){
    long long a;
    cin>>a;
    sum+=a;
  }
  cout<<sum-N<<endl;
    
  
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 100000000
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)

int main(){
    int N, M,sum;
    cin >> N >> M;
    vector<int> A(N,0);
    rep(i,0,M) cin >> A[i];
    sum = accumulate(A.begin(),A.end(),0);
    if (sum >N) cout << "-1" << endl;
    else cout << N-sum << endl;

}

Measured memory_bytes: 7224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int k = scn.nextInt();
		scn.close();
		System.out.println((k == 1) ? "0" : n - k);
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int a, b, c, cnt = 0;
    cin >> a >> b >> c;
    if(a > b)swap(a, b);
    if(b > c)swap(b, c);
    if(a > b)swap(a, b);
    for(; a+2 <= c; a+=2)cnt++;
    for(; b+2 <= c; b+=2)cnt++;
    if(a!=b)cout << cnt + 2 << endl;
    else if(a==c)cout << cnt << endl;
    else cout << cnt + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m,ans,x,y;
struct Node{long long x,y;}a[100010];
long long maxn;
bool cmp(Node a,Node b)
{
	return a.x<b.x || a.x==b.x && a.y<b.y;
}
int main()
{
	cin>>n>>m;
	for (int i=1; i<=m; ++i)
		cin>>a[i].x>>a[i].y;
	sort(a+1,a+m+1,cmp);
	maxn=a[1].y; ans=0;
	for (int i=2; i<=m; ++i)
	{
		if (a[i].x>=maxn)
		{
			maxn=a[i].y;
			ans++;
		}
		else
			maxn=min(maxn,a[i].y);
	}
	ans++;
	cout<<ans;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

typedef long long ll;
const int MAXN = 4000 + 10;
const int MAXM = 2e5 + 10;
const int Mod = 1e9 + 7;
int N;
int A[MAXM], B[MAXM];
int S[MAXN][MAXN], C[MAXN][MAXN];
int ans;

int main() {
	register int i, j;
	scanf( "%d", &N );
	for( i = 1; i <= N; ++i )
		scanf( "%d%d", A + i, B + i ),
		++S[2005 - A[i]][2005 - B[i]];
	for( i = 1; i <= 4009; ++i )
		C[i][0] = C[0][i] = 1;
	for( i = 1; i <= 4009; ++i )
		for( j = 1; j <= 4009; ++j )
			S[i][j] = ( S[i - 1][j] + S[i][j - 1] + S[i][j] ) % Mod,
			C[i][j] = ( C[i - 1][j] + C[i][j - 1] ) % Mod;
	for( i = 1; i <= N; ++i )
		ans = ( ans + S[2005 + A[i]][2005 + B[i]] ) % Mod;
	for( i = 1; i <= N; ++i )
		ans = ( ans + Mod - C[A[i] * 2][B[i] * 2] ) % Mod;
	ans = (ll) ans * 500000004ll % Mod;
	printf( "%d\n", ans );
	return 0;
}

Measured memory_bytes: 127360
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, a = II(), II()
    print(n * n - a)
    return

#B
def B():
    _ = II()
    k = II()
    x = LI()
    ans = 0
    for xi in x:
        ans += min(xi, k - xi)
    print(ans * 2)
    return

#C
def C():
    a, b, c, d, e, F = LI()
    ans = [min(a,b)*100, 0]
    for ai in range(F // (100 * a) + 1):
        for bi in range((F - 100 * ai * a) // (100 * b) + 1):
            if ai == bi == 0:
                continue
            ab = ai * 100 * a + bi * 100 * b
            for ci in range((F - ab) // c + 1):
                for di in range((F - ab - ci * c) // d + 1):
                    if (ai * a + bi * b) * e < ci * c + di * d:
                        continue
                    if ans[1] / ans[0] < (ci * c + di * d) / (ab + ci * c + di * d):
                        ans = [ab + ci * c + di * d, ci * c + di * d]
    print(*ans)
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 39792
#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000009;
const int N = 102;
int n,g,p[N],c[N],f[N][1003];
int main(){
	scanf("%d%d",&n,&g);
	for (int i = 1; i <= n; i++)
		scanf("%d%d",&p[i],&c[i]);
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= 1000; j++)
			f[i][j] = -inf;
	f[0][0] = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 0; j <= 1000; j++)
			if (f[i - 1][j] != -inf)
				for (int k = 0; k <= p[i]; k++)
					f[i][j + k] = max(f[i][j + k], f[i - 1][j] + k * i * 100 + c[i] * (k == p[i]));
	int ans;
	for (int i = 0; i <= 1000; i++)
		if (f[n][i] >= g){
			ans = i;
			break;
		}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define P 1000000007
using namespace std;
int n,a[200005],b[200005],f[4005][4005],fac[8005],ifa[8005];long long ans;
int ksm(int a,int b){int res=1;for(;b;b>>=1,a=1ll*a*a%P) if(b&1) res=1ll*res*a%P;return res;}
int C(int a,int b){if(a<b) return 0;return 1ll*fac[a]*ifa[b]%P*ifa[a-b]%P;}
int main()
{
	fac[0]=1;for(int i=1;i<=8001;i++) fac[i]=1ll*fac[i-1]*i%P;
	ifa[8001]=ksm(fac[8001],P-2);for(int i=8000;~i;i--) ifa[i]=1ll*ifa[i+1]*(i+1)%P;
	scanf("%d",&n);for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]),f[2001-a[i]][2001-b[i]]++;
	for(int i=1;i<=4001;i++) for(int j=1;j<=4001;j++) f[i][j]=((f[i][j]+f[i-1][j])%P+f[i][j-1])%P;
	for(int i=1;i<=n;i++) ans=(ans+f[a[i]+2001][b[i]+2001]-C(2*(a[i]+b[i]),2*a[i])+P)%P;
	printf("%lld\n",1ll*ans*500000004%P);
}

Measured memory_bytes: 64512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, count = 0;
    cin >> n;
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }
    sort(data.begin(), data.end());

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                int a = data[i], b = data[j], c = data[k];
                if(a+b>c) count++;
            }
        }
    }
    cout << count << endl;
}



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

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

    static class D2017LikeNumber {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            boolean[] primes = new boolean[100_001];
            Arrays.fill(primes, true);
            primes[0] = primes[1] = false;
            for (int i = 2; i < 320; i++) {
                for (int j = 2 * i; j < 100_001; j += i) {
                    primes[j] = false;
                }
            }

            boolean[] likes = new boolean[100_001];
            for (int i = 1; i <= 50000; i++) {
                if (primes[i] && primes[2 * i - 1]) {
                    likes[2 * i - 1] = true;

                }
            }

            int[] counts = new int[100_001];
            for (int i = 1; i <= 100_000; i++) {
                counts[i] = counts[i - 1] + (likes[i] ? 1 : 0);
            }

            int q = in.nextInt();
            for (int i = 0; i < q; i++) {
                int l = in.nextInt(), r = in.nextInt();
                out.println(counts[r] - counts[l - 1]);
            }
        }

    }
}



Measured memory_bytes: 67288
n,q = gets.split.map(&:to_i)
s = gets.chomp
l = []
r = []
for i in 1..q do
  l[i], r[i] = gets.split.map(&:to_i)
end

a = [0, 0]
count = 0

for i in 2..n do
  if s[i-1] == "C" && s[i-2] == "A"
    count += 1
  end
  a[i] = count
end

for i in 1..q do
  puts a[r[i]] -a[l[i]]
end


Measured memory_bytes: 4976
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

int32_t main(){
	int n,t;
	cin>>n;
	while(n--){
		cin>>t;
		unless(t&1){
			if((t%3) && (t%5)){
				cout<<"DENIED";
				return 0;
			}
		}
	}
	cout<<"APPROVED";
}


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

using namespace std;

// long gcd(long a, long b){
//     if(a > b)return gcd(b, a);
//     else if(a == 0) return b;
//     else return gcd(b - a*(b/a), a);
// }

int main(void) {
    long long A,B,C,D;cin>>A>>B>>C>>D;

    cout<<B-A+1 - B/C + (A-1)/C -B/D + (A-1)/D + B/(C*D/__gcd(C,D)) - (A-1)/(C*D/__gcd(C,D))<<endl;
    // cout<<b-a+1-(b/c-(a-1)/c+b/d-(a-1)/d)+b/(c*d/gcd(c,d))-(a-1)/(c*d/gcd(c,d));
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
#include <math.h>
#include <cctype>
using namespace std;
#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)

const int mod = 1e9 + 7;
int32_t main() {
    ios::sync_with_stdio(false);
    string k;
    int d;
    cin >> k;
    cin >> d;
    vector<vector<int>>dp( k.size() + 15, vector<int>(d + 10,0));
    dp[0][0] = 1;
    for(int i = 0; i < k.size(); i++){
        for(int j = 0; j <  d; j++){ // текущий остаток
            for(int ij = 0; ij <= 9; ij++){
                dp[i + 1][(j + ij)%d] += dp[i][j];
                dp[i + 1][(j + ij)%d] %= mod;
            }
        }
    }
    int ans = 0;
    int sum = 0;
    for (int i = 0; i < k.size(); i++) {
        for (int j = 0; j < k[i] - '0'; j++) {
            ans += dp[k.size() - i - 1][(2 * d - sum - j % d) % d];
            ans %= mod;
        }
        sum += k[i] - '0';
        sum %= d;
    }
    if (sum == 0) {
        ans += 1;
    }
    ans += mod - 1;
    ans %= mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12016
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
     Scanner sc = new Scanner(System.in);
     int i,j,k,l,m,n,x,y,z;
     x=sc.nextInt();
     y=sc.nextInt();
     z=sc.nextInt();
     System.out.println(z+" "+x+" "+y);
     
    }
}

Measured memory_bytes: 19796
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

/*
 * １太郎勝ち　２花子勝ち　０同点
 */
int duel(string tarou, string hanako) {
	int tlength = tarou.length();
	int hlength = hanako.length();

	int minlength;
	if (tlength < hlength)minlength = tlength;
	else minlength = hlength;

	for (int i = 0; i < minlength; i++) {
		if (tarou[i] > hanako[i])return 1;
		if (tarou[i] < hanako[i])return 2;
	}

	if (tlength > hlength)return 1;
	if (tlength < hlength)return 2;
	return 0;
}

int main(){

	string tarou;
	string hanako;
	int size;
	cin >> size;

	int tscore = 0;
	int hscore = 0;

	for (int i = 0; i < size; i++) {
		cin >> tarou >> hanako;
		int kekka = duel(tarou, hanako);
		
		if (kekka == 1)tscore += 3;
		else if (kekka == 2)hscore += 3;
		else if (kekka == 0) {
			tscore++;
			hscore++;
		}
		else cout << "ha?";
	}

	cout << tscore << " " << hscore << endl;
	//system("pause");
    return 0;
}




Measured memory_bytes: 3208
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();

	    if (a >= k) {
	        System.out.println((a - k) + " " + b);
	      } else if (b >= (k - a)) {
	        System.out.println("0 " + (b - (k - a)));
	      } else {
	        System.out.println("0 0");
	      }
	    }
	  }


Measured memory_bytes: 23508
import math
n = int(input())
a = [int(i) for i in input().split()]
mi = 2
ma = 2
for b in a[::-1]:
  mi = math.ceil(mi/b)*b
  ma = math.ceil((ma+1)/b)*b-1
  if ma < b or mi > ma:
    print(-1)
    exit()
print(mi,ma)

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl

const int N=2e5+5;

int32_t main()
{
   IOS;
   int x, y;
   cin>>x>>y;
   int max1=y/x;
   int ans=1;
   int cur=1;
   while(cur<=max1)
   {
      cur*=2;
      ans++;
   }
   ans--;
   cout<<ans;
   return 0;
}

Measured memory_bytes: 256
import unittest


class TestA(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(2, 16), '9')

    def test_2(self):
        self.assertEqual(think(0, 3), 'IMPOSSIBLE')

    def test_3(self):
        self.assertEqual(think(998244353, 99824435), '549034394')


def solve():
    a, b = read()
    result = think(a, b)
    write(result)


def read():
    return read_int(2)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a, b):
    if abs(a - b) % 2 == 0:
        return str(min(a, b) + abs(a - b) // 2)
    return 'IMPOSSIBLE'


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 5728
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<char,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
const double PI=acos(-1);
const ll INF=1000000;
using namespace std;

int main() {
    ll N;
    cin>>N;
    string A;
    cin>>A;
    map B,C;
    rep(i,0,N) {
        B[A[i]]+=1;
    }
    
    rep(i,0,B['R']) {
        C[A[i]]+=1;
    }
    cout<<C['W']<<endl;





}

Measured memory_bytes: 3764
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int N;cin>>N;
  vector<int> T(N);
  for(auto& t : T) {
    cin >> t;
  }

  int M; cin>>M;
  vector<int> P(M), X(M);
  for(int i = 0; i < M; i++) {
    cin >> P[i] >> X[i];
  }

  for(int i = 0; i < M; i++) {
    int t_idx = P[i] - 1;
    int ans = 0;
    for(int j = 0; j < N; j++) {
      if(j == t_idx) {
        ans += X[i];
      } else {
        ans += T[j];
      }
    }
    cout << ans << endl;
  }
}


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

using namespace std;

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

int main() {
  size_t N;
  cin >> N;

  vector<size_t> P;
  for (size_t i = 0; i<N; i++) {
    size_t p;
    cin >> p;
    P.emplace_back(p);
  }

  if (P.size() == 1) {
    cout << 1 << endl;
    return 0;
  }

  if (P.size() == 2) {
    if (P[0] >= P[1]) {
      cout << 2 << endl;
    } else {
      cout << 1 << endl;
    }
    return 0;
  }

  size_t result = 1;
  size_t cur_min = P[0];
  for (size_t i = 1; i < N; i++) {
    if (cur_min < P[i]) {
      // nop
    } else {
      cur_min = P[i];
      result++;
    }
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 2420
#include <stdio.h>
#include <string.h>

int main(void)
{
  char s[100001], head[200001], tail[200001];
  char *h = head;
  char *t = tail;
  int q;
  scanf("%s%d", s, &q);
  int flag = 1;
  for (int i = 0; i < q; i++) {
    int n, f;
    char c;
    scanf("%d", &n);
    if (n == 1) {
      flag = 1 - flag;
      continue;
    }
    scanf("%d %c", &f, &c);
    if (flag ^ --f) {
      *h++ = c;
    } else {
      *t++ = c;
    }
  }
  *h = '\0';
  *t = '\0';
  if (flag) {
    while (--h >= head) putchar(*h);
    printf("%s%s\n", s, tail);
  } else {
    while (--t >= tail) putchar(*t);
    char *p = s + strlen(s);
    while (--p >= s) putchar(*p);
    puts(head);
  }
}


Measured memory_bytes: 768
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>a>>b>>c;
    if(a==b&&b==c){

    }else if(a==b||b==c||a==c){
        Yes;
        return 0;
    }
    No;
    return 0;
}


Measured memory_bytes: 3656
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
#if DEBUG
            ReadLine();
#endif
        }

        void Solve(ConsoleInput cin)
        {
            int n = cin.ReadInt;

            long[] a_n = cin.ReadLongArray(n);

            Console.WriteLine(a_n.Sum() - n);
        }

        class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;

            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }

            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }

            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 13408
#include <iostream>  
#include <cstring>  
#include <algorithm> 
using namespace std; 
int main()
{
	char a[100];
	int i,j;
	while(cin>>a)
	{
		for(i=0;i<100;i++)
	{
		if(a[i]=='\0')
		{break;}
	}
	for(j=0;j<i/2;j++)
	{
		if(a[j]!=a[i-j-1])
		{
			cout<<"No"<<endl;
			break;
		}
	}   if(a[j]==a[i-1-j])
	    cout<<"Yes"<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

lst = inputs[1]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p lst
end

if lst.size == 1
  puts "Yes"
  exit
end

for i in 0..lst.size-2
  if i == 0
    lst[i] -= 1
  else
    if lst[i - 1] < lst[i]
      lst[i] -= 1
    end
    if lst[i + 1] < lst[i]
      puts "No"
      exit
    end
  end
  pd lst
end

puts "Yes"


Measured memory_bytes: 9620
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

string s[444];

bool dist[444][444];
int n,m,d[]={1,0,-1,0,1};

ll bfs(int sx,int sy){
    dist[sx][sy]=true;
    queue<pint> que;
    que.emplace(sx,sy);
    ll cnt1=1,cnt2=0;
    while(que.size()){
        int x=que.front().first,y=que.front().second;
        que.pop();
        rep(i,4){
            int nx=x+d[i],ny=y+d[i+1];
            if(nx<0||nx>=n||ny<0||ny>=m)continue;
            if(s[nx][ny]!=s[x][y]&&!dist[nx][ny]){
                dist[nx][ny]=1;
                if(s[nx][ny]=='#')++cnt1;
                else ++cnt2;
                que.emplace(nx,ny);
            }
        }
    }
    return cnt1*cnt2;
}

int main(){
    cin>>n>>m;
    rep(i,n)cin>>s[i];
    ll ans=0;
    rep(i,n)rep(j,m){
        if(s[i][j]=='#'&&!dist[i][j])ans+=bfs(i,j);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
    int N, d[100];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> d[i];

    int num[101] = {0};
    for (int i = 0; i < N; ++i) {
        num[d[i]]++;
    }

    int ans = 0;
    for (int i = 1; i <= 100; ++i) {
        if (num[i]) {
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  string a;
  int b,c;
  cin>>b>>a>>c;
  if(a=="+"){
    cout<<b+c<<"\n";
    return(0);
  }
  if(a=="-"){
    cout<<b-c<<"\n";
    return(0);
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	vector<int> ans(n);
	int cnt=0;
	for(ll i=n-1;i>=0;i--){
		if(a.at(i)){
			ans.at(i)=1;
			cnt++;
			for(ll j=1;j*j<=i+1;j++){
				if((i+1)%j==0){
					if((i+1)/j==j) a.at(j-1)^=1;
					else{
						a.at(j-1)^=1;
						a.at((i+1)/j-1)^=1;
					}
				}
			}
		}
	}
	cout << cnt << endl;
	bool flg=true;
	rep(i,n){
		if(ans.at(i)){
			if(flg){
				cout << i+1;
				flg=false;
			}
			else cout << " " << i+1;
		}
	}
	if(cnt>0) cout << endl;
}


Measured memory_bytes: 2560
(* log(n) (m >= 2) *)
let rec is_divisible n m c =
  if c = 0 then
    true
  else
    if n mod m = 0 then
      is_divisible (n / m) m (c - 1)
    else
      false

(* O(√p * log(p)) *)
let solve n p =
  if n = 1 then
    p
  else (* n >= 2 *)
    let m = int_of_float (floor (sqrt (float_of_int p))) in
    let rec loop sofar g =
      if g > m then (* n >= 2 では g <= m (∵ 指数関数の単調増加性より) *)
        sofar
      else
        loop
          (if is_divisible p g n then g else sofar)
          (g + 1)
    in
      loop 1 2

let _ = Scanf.scanf "%d %d" (fun n p -> solve n p |> string_of_int |> print_endline)

Measured memory_bytes: 2432
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   long[] A = new long[N];
   long max = 0;
 	for(int i = 0 ; i < N ; i++)
    {
      A[i] = sc.nextLong();
      max += A[i];
    }
   long half =0;
   int count =0;
   while(max - half > half)
   {
      half+=A[count]; 
      count++;
   }
   if (Math.abs(max - 2* half) >= Math.abs(max - 2*half + 2*A[count-1]))
   {
     System.out.println(Math.abs(max - 2*half + 2*A[count-1]));
   }
   else System.out.println(Math.abs(max - 2* half));
 }
}

Measured memory_bytes: 87172
#include<iostream>
#include<string>
#include<vector>
using ll = unsigned long long;
using namespace std;

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

    // solve
    size_t out=0;
    for(size_t i = 1; i < s.size(); ++i) {
        if(s[i-1] == s[i]) {
            if(s[i]=='1'){
                s[i] = '0';
            } else {
                s[i] = '1';
            }
            out++;
        }
    }
    
    cout << out << endl;

    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int stricmp(char* ch1,char* ch2){
	int ch1_length = 0,ch2_length = 0,div;
	for(int i = 0; ch1[i] != '\0';i++) ch1_length++;
	for(int i = 0; ch2[i] != '\0';i++) ch2_length++;
	if(ch1_length != ch2_length) return -1;
	for(int i = 0; ch1[i] != '\0';i++)
	{
		div = ch1[i] -ch2[i];
		if(div != 0 && div != 32 && div != -32)
			return -1;
	}
	return 0;
}

int main(){
	char W[11],T[1001];
	int count = 0;
	scanf("%s",W);
	while(true){
		scanf("%s",T);
		if(strcmp("END_OF_TEXT",T) == 0) break;
		if(stricmp(T, W) == 0) count++;
	}
	printf("%d\n",count);
}



Measured memory_bytes: 2736
def solve():
    N, A = map(int, input().split())
    x = [int(i) for i in input().split()]
     
    lim = sum(x)
    dp = [[0]*(lim + 1) for i in range(N + 1)]
     
    dp[0][0] = 1
     
    for i in range(N):
        for k in range(N, 0, -1):
            for v in range(lim, -1, -1):
                if v - x[i] < 0:
                    break
                dp[k][v] += dp[k - 1][v - x[i]]
     
    ans = 0
     
    for k in range(1, N + 1):
        if k*A > lim:
            break
        ans += dp[k][k*A]
     
    print(ans)
 
if __name__ == '__main__':
    solve()

Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int n1=n;
	int cnt=0;
	do{
		cnt+=(n1%10);
		n1/=10;
	}while(n1>0);
//	cout<<cnt<<endl; 
	if(n%cnt==0)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;
ll dp[10005]; // dp[i] := HPをi減らす時の最小の魔力消費量
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll H,N;
    cin >> H >> N;
    vector<ll> A(N),B(N);
    rep(i,N){
        cin >> A[i] >> B[i];
    }
    rep(i,1e4+5)dp[i] = 1e18;
    dp[0] = 0;
        for(int j=0;j<=1e4;j++){
            rep(i,N){
                if(j-A[i]>=0)dp[j] = min(dp[j],dp[j-A[i]]+B[i]);
                else if(j<=A[i]) dp[j] = min(dp[j], dp[0] + B[i]);
            }
        }

    cout << dp[H] << endl;
}


Measured memory_bytes: 384
// finish date: 2018/01/28
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;


int main() {
    int N;
    cin >> N;
    vvi A(2, vi(N));
    rep(i, 2) {
        rep(j, N) {
            cin >> A[i][j];
        }
    }
    rep(i,2){
        rep(j,N){
            if(i>0 && j>0) A[i][j] += max(A[i-1][j],A[i][j-1]);
            else if(i>0) A[i][j] += A[i-1][j];
            else if(j>0) A[i][j] += A[i][j-1];
        }
    }
    cout<<A[1][N-1]<<endl;


    return 0;
}



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

struct SCC {
  struct csr {
    vector<int> start, elist;
    csr(int n, const vector<pair<int, int>> &edges)
      : start(n+1), elist(edges.size()) {
        for(pair<int, int> e:edges) {
          start[e.first+1]++;
        }
        for(int i = 1; i <= n; i++) {
          start[i] += start[i-1];
        }
        vector<int> counter = start;
        for(pair<int, int> e:edges) {
          elist[counter[e.first]++] = e.second;
        }
    }
  };
  int n;
  vector<pair<int, int>> edges;
  SCC(int n_) : n(n_) {}
  void add(int from, int to) {edges.emplace_back(from, to);}
  pair<int, vector<int>> scc_ids() {
    csr g(n, edges);
    int now_ord = 0, group_num = 0;
    vector<int> used, low(n), ord(n, -1), ids(n);
    used.reserve(n);
    auto dfs = [&](auto self, int v)->void {
      low[v] = ord[v] = now_ord++;
      used.push_back(v);
      for(int i = g.start[v]; i < g.start[v+1]; i++) {
        int to = g.elist[i];
        if(ord[to] == -1) {
          self(self, to);
          low[v] = min(low[v], low[to]);
        }
        else {
          low[v] = min(low[v], ord[to]);
        }
      }
      if(low[v] == ord[v]) {
        while(true) {
          int u = used.back();
          used.pop_back();
          ord[u] = n;
          ids[u] = group_num;
          if(u == v) break;
        }
        group_num++;
      }
    };
    for(int i = 0; i < n; i++) {
      if(ord[i] == -1) dfs(dfs, i);
    }
    for(int &x:ids) {
      x = group_num - 1 - x;
    }
    return {group_num, ids};
  }
  vector<vector<int>> scc() {
    pair<int, vector<int>> ids = scc_ids();
    int group_num = ids.first;
    vector<int> counts(group_num);
    for(int x:ids.second) counts[x]++;
    vector<vector<int>> groups(group_num);
    for(int i = 0; i < group_num; i++) {
      groups[i].reserve(counts[i]);
    }
    for(int i = 0; i < n; i++) {
      groups[ids.second[i]].push_back(i);
    }
    return groups;
  }
};

//scc is needed

struct two_sat {
  int n;
  vector<bool> boolean_val;
  SCC scc;
  two_sat():n(0), scc(0) {}
  two_sat(int n_):n(n_), boolean_val(n_), scc(n_<<1) {}

  void add(int i, bool ii, int j, bool jj) {
    scc.add(i + (ii?0:n), j + (jj?n:0));
    scc.add(j + (jj?0:n), i + (ii?n:0));
  }
  bool satisfiable() {
    vector<int> id = scc.scc_ids().second;
    for(int i = 0; i < n; i++) {
      if(id[i] == id[i+n]) return false;
      boolean_val[i] = id[i] < id[i+n];
    }
    return true;
  }
};


#define N 1010


int n, d;
int x[2][N];

int main() {
  scanf("%d%d", &n, &d);
  two_sat TS(n);
  for(int i = 0; i < n; i++) scanf("%d%d", x[0]+i, x[1]+i);
  for(int i = 0; i < n; i++) for(int k = 0; k < 2; k++) {
    for(int j = 0; j < i; j++) for(int l = 0; l < 2; l++) {
      if(abs(x[k][i] - x[l][j]) < d) {
        TS.add(i, !k, j, !l);
      }
    }
  }
  if(TS.satisfiable()) {
    vector<bool> &u = TS.boolean_val;
    printf("Yes\n");
    for(int i = 0; i < n; i++) {
      printf("%d\n", x[(int)u[i]][i]);
    }
  }
  else printf("No\n");
}

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

int main(){
  long long N;
  long long K;
  long long ans=1;
  cin >> N;
  cin >> K;
  ans = K;
  for(int i=0; i < N-1; i++) ans *= K-1;
  cout << ans << endl;
}


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

public class Hello{
    public static void Main(){
        var n = Int32.Parse(Console.ReadLine());
        var ret = 0;
        for(var i = 1; i <= n; ++i){
            for(var j = 1; j <= n; ++j){
                for(var k = 1; k <= n; ++k){
                    ret += gcd(i, j, k);
                }
            }
        }

        Console.WriteLine(ret);
    }
    
    public static int gcd(int i, int j, int k){
        return gcd(gcd(i, j), k);
    }

    public static int gcd(int i, int j){
        if (j == 0) return i;

        return gcd(j, i % j);
    }
}


Measured memory_bytes: 17612
n=int(input())
tmp=0
flag=0
for i in range(n):
    x,y=map(int,input().split())
    if(x==y):
        tmp+=1
    else:
        tmp=0
    if(tmp==3):
        flag=1
        break
if(flag):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  vector<int> vec2(N);
  int sum = 0;
  rep(i, N) {
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  rep(i, N) {
    if(i == 0) {
      vec2.at(i) = sum - vec.at(i);
    }
    else {
      vec2.at(i) = vec2.at(i - 1) - vec.at(i);
    }
  }
  int MI = 10000;
  rep(i, N) {
    MI = min(abs(vec2.at(i) - (sum - vec2.at(i))), MI);
  }
  cout << MI << endl;
}

Measured memory_bytes: 3552
#include<iostream>

using namespace std;

int main() {
	int train[200000] = { 0 }, junban[200000] = { 0 }, a = 0, n, i;	
	while (cin >> n) {
		if (n == 0) {
			for (i = 0; train[i] != 0; i++) {}
			junban[a] = train[i - 1];
			train[i - 1] = 0;
			a++;
		}
		else {
			for (i = 0; train[i] != 0; i++) {}
			train[i] = n;
		}
	}
	for (i = 0; junban[i] > 0; i++) {
		cout << junban[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 2732
import sys
sys.setrecursionlimit(20000000)

def dfs(node, distance):
    for next_node, edge_size in G[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((distance + edge_size) % 2)
            dfs(next_node, distance + edge_size)

N = int(input())

G = [[] for i in range(N)]
for i in range(N - 1):
    u, v, w = map(int, input().split())
    G[u - 1].append([v - 1, w])
    G[v - 1].append([u - 1, w])

ans = [-1] * N
dfs(0, 0)
print(*ans, sep='\n')

Measured memory_bytes: 87100
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

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

  ll MOD=1000000007;
  ll n10=1,n9=1,n8=1;

  for(int i=0;i<N;++i){
    n10*=10; n10%=MOD;
    n9*=9; n9%=MOD;
    n8*=8; n8%=MOD;
  }

  ll ans=n10+n8-2*n9;
  ans%=MOD;
  if(ans<0) ans+=MOD;

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


Measured memory_bytes: 3632
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] f=br.readLine().split(" ");
        int n=Integer.parseInt(f[0]);
        int m=Integer.parseInt(f[1]);
        int l=Integer.parseInt(f[2]);
        String[][] A=new String[n][m];
        String[][] B=new String[m][l];
        for(int ni=0;ni<n;ni++) A[ni]=br.readLine().split(" ");
        for(int mi=0;mi<m;mi++) B[mi]=br.readLine().split(" ");
        
    	StringBuilder sb = new StringBuilder();
        for(int ni=0;ni<n;ni++){
        	for(int li=0;li<l;li++){
        		long b=0;
            	for(int mi=0;mi<m;mi++){
            		b+=Integer.parseInt(A[ni][mi])*Integer.parseInt(B[mi][li]);
            	}
            	sb.append(b);
            	if(li!=l-1) sb.append(" ");
        	}
        	sb.append("\n");
        }
    	System.out.print(sb);
	}
}

Measured memory_bytes: 30640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	ll l=0,r=0;
	rep(i,n)r+=in[i];
	ll out=inf;
	rep(i,n){
		l+=in[i];
		r-=in[i];
		if(i<n-1)out=min(out,abs(r-l));
	}
	cout<<out<<endl;
}








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

int findsum(int n){
    int sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(){
    int N, A, B,total;
    cin >> N >> A >> B;
for (int i = 0; i <= N; i++){
    int sum = findsum(i);
    if (sum >= A && sum <= B){
        total += i;
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

void solve() {
  static const int MAXN = 2e3;
  static vi adj[MAXN];
  static bool inq[MAXN];
  static int d[MAXN], q[MAXN * 2], cnt[MAXN];

  int n, x, y;
  cin >> n >> x >> y;
  --x, --y;
  adj[x].push_back(y);
  adj[y].push_back(x);
  for (int i = 1; i < n; ++i) {
    adj[i].push_back(i - 1);
    adj[i - 1].push_back(i);
  }

  memset(cnt, 0, sizeof(int) * n);
  for (int i = 0; i < n; ++i) {
    int head = 0, tail = 0;
    memset(d, 63, sizeof(int) * n);
    d[i] = 0;
    q[tail++] = i;
    while (head < tail) {
      int u = q[head++];
      inq[u] = false;
      for (int v : adj[u]) {
        if (d[v] <= d[u] + 1) continue;
        d[v] = d[u] + 1;
        if (!inq[v]) {
          q[tail++] = v;
          inq[v] = true;
        }
      }
    }
    for (int j = i + 1; j < n; ++j) ++cnt[d[j]];
  }

  for (int i = 1; i < n; ++i) cout << cnt[i] << "\n";
}

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int o_o = 1;
  if (!o_o) cin >> o_o;
  for (; o_o; --o_o) solve();
  return 0;
}


Measured memory_bytes: 384