akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int visited[100];
vector <int> adj[100];
int ans=0;
int nv=0;
int n,m;
void dfs(int s)
{
	visited[s]=1;
	nv++;
	if(nv==n)
		ans++;
	for(int i=0;i<adj[s].size();i++)
	{
		if(!visited[adj[s][i]])
			dfs(adj[s][i]);
	}
	visited[s]=0;
	nv--;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// freopen("input.txt", "r", stdin);  
	cin >> n >> m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs(1);
	cout << ans;
}

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

int main(void) {
  ll n, k;
  cin >> n >> k;

  ll ans = 0;


  for (ll b = n; b >= 1; b--) {
    ll q = n / b;
    ll r = n % b;

    ll sa = (b - 1) - r;

    ans += max(0LL, (b - k) * q) + max(0LL, b - k - sa);
  }

  if (k == 0) ans -= n;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int min(int a,int b){return a<b?a:b;}
int main(void){
    int a,b,count=50;
    scanf("%d%d",&a,&b);
    printf("100 100\n");
    char t[120],s[120]="####################################################################################################",v[120],u[120]="....................................................................................................";
    a--;
    while(a>0){
        strcpy(t,s);
        for (int i=0; i<min(50,a); i++){
            t[i*2]='.';
        }
        printf("%s\n%s\n",t,s);
        a-=50;
        count-=2;
    }
    for (int i=0; i<count; i++){
        printf("%s\n",s);
    }
    b--;
    count=50;
    while(b>0){
        strcpy(v,u);
        for (int i=0; i<min(50,b); i++){
            v[i*2]='#';
        }
        printf("%s\n%s\n",u,v);
        b-=50;
        count-=2;
    }
    for (int i=0; i<count; i++){
        printf("%s\n",u);
    }
    return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for i in range(Q):
  temp = list(map(int, input().split()))
  B.append(temp[0])
  C.append(temp[1])

d = {}
for i in range(N):
  if(A[i] not in d):
    d[A[i]] = 1
  else:
    d[A[i]] += 1
total = sum(A)
for i in range(Q):
  if(B[i] in d):
    num = d[B[i]]
    total += num*(C[i]-B[i])
    d.pop(B[i])
    if(C[i] in d):
      d[C[i]] += num
    else:
      d[C[i]] = num
  print(total)

Measured memory_bytes: 26764
//Wrong answer on test inf.
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define inf 1000000001
#define y1 y1___
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
ll read(){
	char ch=getchar();ll x=0;int op=1;
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') op=-1;
	for (;isdigit(ch);ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
#define N 100005
int n;ll ans[N];pii a[N];
int main(){
	n=read();
	rep (i,1,n) a[i]=pii(-read(),i);
	sort(&a[1],&a[n+1]);
	rep (i,1,n) a[i].fi=-a[i].fi;
	a[n+1]=pii(0,inf);
	int x=inf;
	for (int i=1,j;i<=n;i=j+1){
		j=i;
		while (j<n&&a[j+1].fi==a[i].fi) j++;
		x=min(x,a[i].se);
		ans[x]+=(ll)(a[i].fi-a[j+1].fi)*j;
	}
	rep (i,1,n) printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll h; cin >> h;
    ll cnt = 0;
    ll monster_num = 1;

    while (h > 0) {
        cnt += monster_num;
        h /= 2;
        monster_num *= 2;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right
N = int(input())
unit = [1]
for b in [6,9]:
    u = b
    while u <= N:
        unit.append(u)
        u *= b
unit.sort()
Nu = len(unit)

ans = N
state_pool = [(0, 0, Nu-1)]
while state_pool:
    n, i, pk = state_pool.pop()
    if N - n >= (ans-i)*unit[pk]:
        continue
    sk = bisect_right(unit, N-n, 0, pk+1)
    for k in range(sk):
        u = unit[k]
        c = n + u
        if c == N:
            if i + 1 < ans:
                ans = i + 1
        else:
            state_pool.append((c, i+1, k))
print(ans)

Measured memory_bytes: 3064
results = []

while True:
    N = int(input())
    if N == 0:
        break
       
    tmp = [0 for _ in range(N+1)]
    res = 0
    
    for i in range(N+1):
        tmp[i] = tmp[i-1] + i
        
    for i in range(N-1):
        for j in range(i+2, N+1):
            if tmp[j] - tmp[i] == N:
                res += 1
                
    results.append(res)
            
for result in results:
    print(result)




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

int main() {
    int n, vi;
    cin >> n;
    map<int, int> even, odd;
    for (int i = 1; i <= n; i++) {
        cin >> vi;
        (i & 1 ? odd[vi] : even[vi])++;
    }

    int key_odd_max1, key_odd_max2, key_even_max1, key_even_max2;
    for (auto oddi : odd) {
        if (oddi.second > odd[key_odd_max1]) key_odd_max1 = oddi.first;
    }
    for (auto eveni : even) {
        if (eveni.second > even[key_even_max1]) key_even_max1 = eveni.first;
    }
    for (auto oddi : odd) {
        if (oddi.second > odd[key_odd_max2] && oddi.first != key_odd_max1) key_odd_max2 = oddi.first;
    }
    for (auto eveni : even) {
        if (eveni.second > even[key_even_max2] && eveni.first != key_even_max1) key_even_max2 = eveni.first;
    }

    int ans_odd = n / 2 - odd[key_odd_max1], ans_even = n / 2 - even[key_even_max1];
    if (key_odd_max1 == key_even_max1) {
        if (odd[key_odd_max2] > even[key_even_max2]) {
            ans_odd = n / 2 - odd[key_odd_max2];
        } else {
            ans_even = n / 2 - even[key_even_max2];
        }
    }

    cout << (ans_odd + ans_even) << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    int n;
    cin >> n;
    lint child = 0;
    lint ans = 0;
    vector<lint> a(n + 1);
    vector<lint> f(n + 1);
    REP(i,n + 1) cin >> a[i];
    f[0] = 1;
    if(f[0] < a[0]){
        println(-1);
        return 0;
    }
    REP(i,n){
        if((f[i] - a[i]) <= LINF / 2)
            f[i + 1] = (f[i] - a[i]) * 2;
        else{
            f[i + 1] = LINF;
        }
        if(f[i + 1] < a[i + 1]){
            println(-1);
            return 0;
        }
    }
    REPR(i,n + 1){
        if(i == n){
            ans += a[i];
            child = a[i];
        }else{
            lint res = min(child + a[i],f[i]);
            ans += res;
            child = res;
        }
    }
    println(ans);
    return 0;
}

Measured memory_bytes: 4792
N = int(input())
S = input()

w_side = 0
e_side = 0
for i in range(1, N):
    if S[i] == "E":
        e_side += 1
        
ans = e_side
for i in range(1, N):
    if S[i-1] == "W":
        w_side += 1
    if S[i] == "E":
        e_side -= 1
    ans = min(ans, w_side+e_side)
    
print(ans)

Measured memory_bytes: 3700
def main():
    _ = input()
    A = list(map(int, input().split()))
    cnt = 0
    for i in range(len(A)-2):
        A_sub = sorted(A[i:i+3])
        a = A[i+1]
        if a == A_sub[1]:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>

#define MAX_K (100)

int check_no(int num, int *D, int K) {
  while (num > 0) {
    int dig = num % 10;
    for (int i = 0; i < K; i++) 
      if (dig == D[i])
        return 0;
    num /= 10;
  }
  return 1;
}

int main(int argc, char *argv[]) {
  int N, K, D[MAX_K], ans;
  scanf("%d %d", &N, &K);
  for (int i = 0; i < K; i++)
    scanf("%d", &D[i]);
  for (ans = N; !check_no(ans, D, K); ans++)
    ;
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 128
S = input()
# print("Q=")
Q = int(input())

def problem_gksn(S,Q):
  check_reverse = 0 # 偶数のとき正常, 奇数の時反転
  atama = ""
  oshiri = ""
  for _ in range(Q):
    # print("queryを入力してください")
    query = input().split()
    # print("query= ",query)
    if len(query) == 1: #1の場合
      # print("文字を反転させます")
      check_reverse += 1
      # S = S[::-1]
    else: #2の場合
      # print("文字をくっつけます")
      if int(query[1]) == 2 - check_reverse % 2:
        oshiri += query[2]
      else:
        atama += query[2]
      # print("atama",atama)
      # print("oshiri",oshiri)
  S = atama[::-1] + S + oshiri
  if check_reverse % 2==1:
    S = S[::-1]
  
  return S

print(problem_gksn(S,Q))

Measured memory_bytes: 4172
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String str = S.substring(5, 7);
		sc.close();


		int month = Integer.valueOf(str);
		if(month < 5) {
			System.out.println("Heisei");
		}else {
			System.out.println("TBD");
		}
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define        ll          long long int
#define        sz          200010
#define        fast        ios_base :: sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define        sc1(a)      scanf("%lld",&a)
#define        sc2(a,b)    scanf("%lld %lld",&a,&b)
#define        pb          push_back
#define        pn          printf("No\n")
#define        py          printf("Yes\n")
#define        op(a)       printf("%lld\n",a)

using namespace std;



int main()
{

    string s;

    cin>>s;
    if(s[1]=='B')cout<<"ARC"<<endl;
    else
        cout<<"ABC"<<endl;

    return 0;
}


Measured memory_bytes: 3596
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 3e3 + 10;
char s[N];
int dp[N][N];

int main() {
  int n;
  scanf("%d%s", &n, s);
  dp[n - 1][0] = 1;
  for (int i = n - 2; i >= 0; --i) {
    if (s[i] == '<') {
      int sum = 0;
      for (int j = n - 1 - i; j >= 0; --j) {
        sum = (sum + dp[i + 1][j]) % MOD;
        dp[i][j] = sum;
      }
    } else {
      int sum = 0;
      for (int j = 1; j < n - i; ++j) {
        sum = (sum + dp[i + 1][j - 1]) % MOD;
        dp[i][j] = sum;
      }
    }
  }
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    ret = (ret + dp[0][i]) % MOD;
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 35200
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
long long a[N],l[N],r[N];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	long long d,ret=0;
	cin>>n>>d;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		ret+=a[i];
	}
	ret+=(n-1)*d;
	r[1]=a[1];
	for(int i=2;i<=n;i++)
		r[i]=min(a[i],r[i-1]+d);
	l[n]=a[n];
	for(int i=n-1;i>=1;i--)
		l[i]=min(a[i],l[i+1]+d);
	for(int i=2;i<n;i++)
		ret+=min(l[i],r[i]);
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 4992
N = int(input())

def checkDigit(n):
  a = n % 10
  n = (n-a)//10
  b = n % 10
  c = (n-b)//10
  if a == b and b == c:
    return True
  else:
    return False

for i in range(1000):
  if checkDigit(N):
    print(N)
    break
  N += 1

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,x,y) for(int i=(int)(x);i<(int)(y);++i)
#define FORE(i,x,y) for(int i=(int)(x);i<=(int)(y);++i)
#define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);--i)
#define PB push_back
#define ST first
#define ND second
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=1e4+7;

int ans=0;
int n,m,k,q;
inline int F(int x,int y,int z){
    return x*x+y*y+z*z+x*y+x*z+y*z;
}
int a[MAXN];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    FORE(i,1,n){
        for(int j=1;F(i,j,1)<=n;++j){
            for(int z=1;F(i,j,z)<=n;++z){
                ++a[F(i,j,z)];
            }
        }
    }
    FORE(i,1,n){
        cout<<a[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3620
S = input()
INF = 10 ** 9 + 7

dp = [[0 for _ in range(13)] for _ in range(len(S) + 1)]
index = 1
dp[0][0] = 1
for i in range(len(S)):
    c = S[-i - 1]
    if c == '?':
        for j in range(10):
            for k in range(13):
                dp[i + 1][(j * index + k) % 13] += dp[i][k]
                dp[i + 1][(j * index + k) % 13] %= INF
    else:
        c = int(c)
        for k in range(13):
            dp[i + 1][(c * index + k) % 13] += dp[i][k]
            dp[i + 1][(c * index + k) % 13] %= INF
    index *= 10
    index %= 13

print(dp[len(S)][5])

Measured memory_bytes: 66396
#include "bits/stdc++.h"
#define ll long long
#define inf 1000000007
#define sort(vec) sort((vec).begin(),(vec).end());
#define rever(vec) reverse((vec).begin(),(vec).end());
#define unsort(vec) sort((vec)); rever((vec));
using namespace std;

int main() {
	int n;
	cin>>n;
	vector<string>get(n);
	vector<int>can(n);
	for(int i=0;i<n;i++) {
		string s;
		cin>>s;
		get[i]=s;
	}
	int m;
	cin>>m;
	vector<string>loss(m);
	for(int i=0;i<m;i++) {
		string s;
		cin>>s;
		loss[i]=s;
	}
	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++) {
			if(get[i]==loss[j]) {
				can[i]--;
			}
		}
		for(int j=0;j<n;j++) {
			if(get[i]==get[j]) {
				can[i]++;
			}
		}
	}
	unsort(can);
	if(can[0]>=0) {
		cout<<can[0]<<endl;
	}
	else {
		cout<<"0"<<endl;
	}
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var S string
	var o, e, r int
	fmt.Scan(&S)
	for i, v := range strings.Split(S, "") {
		w := strconv.Itoa(i % 2)
		if v != w {
			o++
		}
		if v == w {
			e++
		}
	}
	if e < o {
		r = e
	} else {
		r = o
	}
	fmt.Println(r)

}

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

int main(){
    int n;
    cin >> n;
    int k;
    cin >> k;
    int l[n];
    for(int i=0;i<n;i++){
        cin >> l[i];
    }
    sort(l, l+n, greater<int>());

    int result = 0;
    for(int i=0;i<k;i++){
        result += l[i];
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N;
int A[1000];

signed main()
{
	cin >> N;
	REP(i, N) cin >> A[i];

	int sum = 0;
	REP(i, N)
	{
		sum += A[i];
	}
	double ave = sum / (double)N;

	double min = DBL_MAX;
	int ans = 0;

	REP(i, N)
	{
		double sub = abs(A[i] - ave);
		if (sub < min)
		{
			min = sub;
			ans = i;
		}
	}

	cout << ans << endl;
}








Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int a,b,c,x,y;
    scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
    if(a+b>2*c){
        int ans1=max(x,y)*2*c;
        int ans2=min(x,y)*2*c;
        if(x>=y) ans2+=(x-y)*a;
        else ans2+=(y-x)*b;
        printf("%d",min(ans1,ans2));
    }else{
        printf("%d",a*x+b*y);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
const int MOD = 1e9 + 7;
long long f[MAXN], inv[MAXN];

long long quick_pow(long long a, long long b){
	long long ans = 1;
	while (b){
		if (b & 1){
			ans = (ans * a) % MOD;
		}
		a = (a * a) % MOD;
		b /= 2;
	}
	return ans;
}

long long C(long long n, long long m){
	long long ans = (f[n] * inv[n - m]) % MOD;
	ans = (ans * inv[m]) % MOD;
	return ans;
}

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	long long n, k;
	cin >> n >> k;
	long long ans = 0;
	f[0] = 1;
	for (int i = 1; i <= n; ++i){
		f[i] = (f[i - 1] * i) % MOD;
	}
	for (int i = 0; i <= n; ++i){
		inv[i] = quick_pow(f[i], MOD - 2) % MOD;
	}
	k = min(k, n - 1);
	for (int i = 0; i <= k; ++i){
		ans = (ans + C(n, i) * C(n - 1, i) % MOD) % MOD;
	}
	cout << ans << "\n";
	return 0;
}



Measured memory_bytes: 3328
import java.util.Scanner;

public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int i = 1;
    do
    {
      int x = i;
      if(x % 3 == 0)
      {
        System.out.print(" "+i);
      }
      else
      {
        while(x != 0)
        {
          if(x % 10 == 3)
          {
            System.out.print(" "+i);
            break;
          }
          x /= 10;
        }
      }     
    }
    while(++i <= n);

    System.out.println();    
  }
}

Measured memory_bytes: 28472
using System;

namespace ABC_076_A_Csharp__ver
{
    class Program
    {
        static void Main(string[] args)
        {
            int R = int.Parse(Console.ReadLine());
            int G = int.Parse(Console.ReadLine());
            if (G == 0)
            {
                Console.WriteLine(-R);
            }
            else
            {
                Console.WriteLine(G * 2 - R);
            }
            Console.ReadKey();
        }
    }
}


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

int main() {
    int n, a, extra;
    cin >> n >> a;
    extra = n % 500;
    if (extra <= a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll a,b,c;
  cin >> a >> b >> c;
  if(a==b)
    cout << c << endl;
  else if(b == c)
    cout << a << endl;
  else
    cout << b << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>

using namespace std;
int a, b;
int num[15];


int bind(int p,int q){
	if(q<10){
		return 10*p+q;
	}
	else return 100*p+q;
}


int main(void){
	while(1){
		cin >> a >> b;
		if(a == 0 && b == 0){
			return 0;
		}
		set <int> S;
		for(int i=0;i<a;i++){
			cin >> num[i];
		}
		for(int i=0;i<a;i++){
			for(int j=0;j<a;j++){
				for(int k=0;k<a;k++){
					for(int l=0;l<a;l++){
						
						if(b==4){
							if(i != j && i != k && i != l && j != k && j != l && k != l){ 
							int c = bind(bind(bind(num[i],num[j]),num[k]),num[l]);
							S.insert(c);
							}
						}
						if(b==3){
							if(j != k && j != l && k != l){
							int c = bind(bind(num[j],num[k]),num[l]);
							S.insert(c);
							}
						}
						if(b==2){
							if(k != l){
							int c = bind(num[k],num[l]);
							S.insert(c);
							}
						}	
					}
				}
			}
		}
		cout << S.size() <<endl;
		S.clear();
	}
}

Measured memory_bytes: 3224
#include <iostream>

int main()
{
    int N, A, B;
    std::cin >> N >> A >> B;

    int cnt=0;

    for(int i=0; i<N+1; i++)
    {
        int fig_sum = i/10000 + (i-(i/10000)*10000)/1000 + (i-(i/1000)*1000)/100 + (i-(i/100)*100)/10 + (i-(i/10)*10);

        if(A <= fig_sum && fig_sum <= B)
            cnt+=i;
    }

    std::cout << cnt << std::endl;
}

Measured memory_bytes: 3524
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

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



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

int main() {
    
    int N;
    cin >> N;
    vector<string> S(N);
    int sb = 0, ea = 0, ba = 0;
    int cnt = 0;
    REP(i, N) {
        cin >> S[i];
        if (S[i].front() == 'B') sb++;
        if (S[i].back() == 'A') ea++;
        if (S[i].front() == 'B' && S[i].back() == 'A') ba++;
        REP(j, S[i].length()-1) {
            if (S[i][j] == 'A' && S[i][j+1] == 'B') cnt++;
        }
    }
    if (sb - ba == 0 && ea - ba == 0 && ba > 1) {
        cout << cnt + ba - 1 << endl;
    } else {
        cout << cnt + std::min(sb, ea) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <algorithm>
#include <string.h>

using namespace std;

int n;
char z[12000];
int cnt;
void work () {
	int i;
	scanf ( "%s" , z + 1 );
	n = strlen ( z + 1 );
	for ( i = 1 ; i <= n ; i++ ) if ( z[i] == 'o' ) cnt++;
	cnt += 15 - n;
	if ( cnt >= 8 ) printf ( "YES\n" );
	else printf ( "NO\n" );
}
int main () {
	work ();
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define vi vector<int>
#define vl vector<long long>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define MOD 1e9+7

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

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

const int MAX_N = 100000;
int S[MAX_N];

int bin_search(int l, int r, int key) {
    while (l < r) {
        int mid = (l+r)/2;
        if (S[mid] == key) {
            return 1;
        } else if (S[mid] < key) {
            l = mid+1;
        } else {
            r = mid;
        }
    }
    return 0;
}
int main() {
    int n;
    cin >> n;
    REP(i, n) {
        cin >> S[i];
    }
    int q;
    cin >> q;
    int ans = 0;
    REP(i, q) {
        int k;
        cin >> k;
        if (bin_search(0, n, k)) ans += 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3376
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

vector<ll>relation[20], money(20, 1);
char s[110][110];
int dp[110][110];

int main() {
	string s;
	cin >> s;
	int n = s.length() + 1;
	vector<ll>a(n);
	rep(i, n-1 ) {
		if (s[i] == '<') {
			a[i + 1] = max(a[i + 1], a[i] + 1);
		}
	}
	for (int i = n - 2;i >= 0;--i) {
		if (s[i] == '>') {
			a[i] = max(a[i], a[i + 1] + 1);
		}
	}
	ll ans = 0;
	rep(i, n) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4740
#include <iostream>
#include <string>
#include <cstring>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define clr(a,v) memset((a),(v),sizeof(a))

int q;
int dp[1001][1001];
std::string s, t;

int rec( int i, int j )
{
  int &ret = dp[i][j];

  if( ~ret )
    return ret;

  if( i == s.size() || j == t.size() )
    return 0;

  ret = 0;

  if( s[i] == t[j] )
    ret = std::max( ret, rec( i+1, j+1 )+1 );

  ret = std::max( ret, std::max( rec( i+1, j ), rec( i, j+1 ) ) );

  return ret;
}

int main()
{
  std::cin >> q;
  while( q-- )
  {
    std::cin >> s >> t;

    clr( dp, -1 );

    std::cout << rec( 0, 0 ) << std::endl;
  }

  return 0;
}

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

    #define ll long long
    #define ff first
    #define ss second
    #define pb push_back
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define MOD 1000000007
    #define pll pair<ll,ll>
    #define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
    int main() {
        fastio;
        int h,a;
        cin>>h>>a;
        if(h%a==0)
            cout<<h/a<<endl;
        else
        {
            cout<<h/a+1<<endl;
        }
    }

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = [0] * 9
for i in range(n):
    for j in range(9):
        if 400 * j <= a[i] <= 400 * (j + 1) - 1 and j != 8:
            b[j] += 1
        elif j == 8 and a[i] >= 400 * j:
            b[j] += 1
m = 0
M = 0
for i in range(8):
    if b[i] != 0:
        m += 1
        M += 1
M += b[8]
if m == 0:
    m = 1
print(m, M)


Measured memory_bytes: 3064
#include<stdio.h>
main(){
  int a[4],b[4];
  int i,k,j;
  int hit,brow;
  while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3])!=EOF){
    scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);
    hit=0;
    brow=0;
    for(i=0;i<4;i++){
      for(j=0;j<4;j++){
	if( a[i] == b[i] ){
	  hit++;
	  break;
	}
	if(a[i]==b[j]){
	  brow++;
	}
      }
    }
    printf("%d %d\n",hit,brow);
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18 
int main(){
    int n ;
    cin >> n ;
    int bd = 200005;
    int ans = 0; 
    rep(i, n){
        int p ;
        cin >> p ;
        if(p < bd){
            ans++ ;
            bd = p ;
        } 
    }
    cout << ans << endl ;

} 

Measured memory_bytes: 3592
#include <stdio.h>
int face[7][7][4] = {
    {{0},{0},{0},{0},{0},{0},{0}},
    {{0},{0},{0,1,2,3},{0,1,3,5},{0,1,4,2},{0,1,5,4},{0}},
    {{0},{0,2,1,4},{0},{0,2,3,1},{0,2,4,6},{0},{0,2,6,3}},
    {{0},{0,3,1,2},{0,3,2,6},{0},{0},{0,3,5,1},{0,3,6,5}},
    {{0},{0,4,1,5},{0,4,2,1},{0},{0},{0,4,5,6},{0,4,6,2}},
    {{0},{0,5,1,3},{0},{0,5,3,6},{0,5,4,1},{0},{0,5,6,4}},
    {{0},{0},{0,6,2,4},{0,6,3,2},{0,6,4,5},{0,6,5,3},{0}}};
int dice[7];
int dice2[7];
int main(){
    int i,j,true=0;
    for(i=1;i<=6;i++) scanf("%d",&dice[i]);
    for(i=1;i<=6;i++) scanf("%d",&dice2[i]);
    
    for(i=1;i<=6;i++)
        for(j=1;j<=6;j++)
            if(dice[face[i][j][1]]==dice2[1]&&
               dice[face[i][j][2]]==dice2[2]&&
               dice[face[i][j][3]]==dice2[3]&&
               dice[7-face[i][j][3]]==dice2[4]&&
               dice[7-face[i][j][2]]==dice2[5]&&
               dice[7-face[i][j][1]]==dice2[6])
                true=1;
    
    if(true)
        printf("Yes\n");
    else
        printf("No\n");
    
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
//#define int ll
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back


void solve()
{
    string s;
    cin>>s;
    int sum = 0;
    for(char c: s)
    {
        sum += c-'0';
    }
    cout << (sum%9==0?"Yes":"No") << '\n';
}
signed main(void)
{
    int T = 1;
    // cout << fixed;
    // cout.precision(44);
    ios_base::sync_with_stdio(0); cin.tie(0);
    //cin >> T;
    while (T--) solve();
    return 0;
}

Measured memory_bytes: 3788
N = int(input())
A = {}
for i in range(N):
    S = list(input())
    S.sort()
    S = ''.join(S)
    A[S] = A.get(S, 0) + 1

ans = 0
for i in A.values():
    if i > 1:
        iL = [j for j in range(i)]
        ans += sum(iL)
    
print(ans)

Measured memory_bytes: 17808
#include<iostream>
#include<vector>
#include<math.h>
#include<complex>

#define EPS 1e-4

#define PI 3.141592
#define EQ(a,b) (abs((a)-(b))<EPS)
using namespace std;

typedef complex<double> P;

vector<P> house;
vector<P> ume,sak,mo;

double cross(P v1,P v2){
	return v1.real()*v2.imag()-v1.imag()*v2.real();
}

bool che(P h,P t,double d,double w,double a){
	P v=h-t;
	if(!(abs(v)<a))return false;
	
	P v1=P(a*cos((w+d/2)/180*PI),a*sin((w+d/2)/180*PI));
	P v2=P(a*cos((w-d/2)/180*PI),a*sin((w-d/2)/180*PI));
	
	if(cross(v1,v)<0 && cross(v2,v)>0)return true;
	else return false;
}

int main(){
	int h,r;
	
	while(cin>>h>>r && h&&r){
		house.clear();
		ume.push_back(P(0,0));
		for(int i=0;i<h;i++){
			int x,y;
			cin>>x>>y;
			house.push_back(P(x,y));
		}
		
		int U,M,S,du,dm,ds;
		cin>>U>>M>>S>>du>>dm>>ds;
		for(int i=0;i<U;i++){
			int x,y;
			cin>>x>>y;
			ume.push_back(P(x,y));
		}
		for(int i=0;i<M;i++){
			int x,y;
			cin>>x>>y;
			mo.push_back(P(x,y));
		}
		for(int i=0;i<S;i++){
			int x,y;
			cin>>x>>y;
			sak.push_back(P(x,y));
		}
		
		
		int data[120];
		for(int i=0;i<120;i++)data[i]=0;
		for(int z=0;z<r;z++){
			int w,a;
			cin>>w>>a;
			
			for(int i=0;i<house.size();i++){
				bool ok=false;
				if(che(house[i],ume[0],du,w,a))ok=true;
				else continue;
				for(int j=1;j<=U;j++){
					if(che(house[i],ume[j],du,w,a))ok=false;
				}
				for(int j=0;j<M;j++){
					if(che(house[i],mo[j],dm,w,a))ok=false;
				}
				for(int j=0;j<S;j++){
					if(che(house[i],sak[j],ds,w,a))ok=false;
				}
				
				if(ok)data[i]++;
			}
		}
		
			int ans=0;
			int tmp=-1;
			for(int i=0;i<h;i++){
				if(ans<=data[i]){
					ans=data[i];
					tmp=i;
				}
			}
			if (ans==0)cout<<"NA"<<endl;
			else {
				for(int i=0;i<h;i++){
					if(i==tmp)cout<<i+1;
					else if(data[i]==ans)cout<<i+1<<" ";
					
				}
				cout<<endl;
			}
			
		
	}
}

Measured memory_bytes: 1220
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;

typedef pair<double,double> pdd;

int calc(int x,int p){
  return p*(100+x)/100;
}

int main(void){

  double x,y;
  int s;

  while(cin >> x >> y >> s){
    if(x==0 && y==0 && s==0)break;

    vector<pdd>v;

    for(int i=1;i<s;i++){
      for(int j=1;j<s;j++){
	int res=calc(x,i)+calc(x,j);
	if(res == s)v.push_back(pdd(i,j));
      }
    }

    int ans=0;
    for(int i=0;i<v.size();i++){
      ans=max(ans,calc(y,v[i].first)+calc(y,v[i].second));
    }

    cout << ans << endl;
  }

  return 0;
}

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

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

    double d,t,s,r;
    cin >> d >> t >> s;

    r = d/s;

    if (r <= t) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 3736
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include <fstream>
#include<unordered_set>
#include<stack>
#include <map>
#include<unordered_map>
#include<time.h>
#include <chrono>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define all(x) x.begin(),x.end()
using namespace std;
#define MAX 1000001 
#define M 998244353
ll inverse(ll n)
{
    ll modu = M;
    ll m = modu;
    ll a = 0, b = 1;
    if (modu == 1)
        return 0;
    while (n > 1)
    {
        ll quo = n / modu;
        ll temp = modu;
        modu = n % modu, n = temp;
        temp = a;
        a = b - (quo * a);
        b = temp;
    }
    if (b < 0)
        b += m;
    return b;
}
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll n, k;
    cin >> n >> k;
    string ans = "";
    f(i, 0, n)
        ans += "a";
    f(i, 0, k)
    {
        ll s;
        char c;
        cin >> s >> c;
        if (ans != "-1")
        {
            if (ans[s - 1] != 'a' && ans[s - 1] != c)
                ans = "-1";
            else
            {
                ans[s - 1] = c;
            }
        }
    }
    if (ans[0] == '0' && n > 1)
        ans = "-1";
    if (ans[0] == 'a' && n > 1)
        ans[0] = '1';
    else if(ans[0] == 'a' && n == 1)
        ans[0] = '0';
    f(i, 0, n)
    {
        if (ans[i] == 'a')
            ans[i] = '0';
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
  int q;
  double x;
  while(1){
    scanf("%d",&q);
    if(q==-1)
      break;
    x=(double)q/2;
    while(fabs(x*x*x-q)>=0.00001*q)
      x=x-(x*x*x-q)/(3*x*x);
    printf("%f\n",x);
  }
  return 0;
}

Measured memory_bytes: 632
#include<stdio.h>

struct X{
   int c, l, r;
};

struct X Y[1000];


void preorder(int num){
   if(num == -1)
      return;
   printf(" %d", num);
   preorder(Y[num].l);
   preorder(Y[num].r);
}

void inorder(int num){
   if(num == -1)
      return;
   inorder(Y[num].l);
   printf(" %d", num);
   inorder(Y[num].r);
}

void postorder(int num){
   if(num == -1)
      return;
   postorder(Y[num].l);
   postorder(Y[num].r);
   printf(" %d", num);
}



int main () {   int n, i, v, l, r, root;

   scanf("%d", &n);
   for(i = 0; i < n; i++){
      Y[i].c = -1;
   }

   for(i = 0; i < n; i++){
      scanf("%d %d %d", &v, &l, &r);
      Y[v].l = l;
      Y[v].r = r;
      if(l != -1)
         Y[l].c = v;
      if(r != -1)
         Y[r].c = v;
   }

   for(i = 0; i< n; i++){
      if(Y[i].c == -1)
         root = i;
   }


   printf("Preorder\n");
   preorder(root);
   printf("\nInorder\n");
   inorder(root);
   printf("\nPostorder\n");
   postorder(root);
   printf("\n");

   return 0;

}

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

int main(){
  string a; cin>>a;
  if(a[0]==a[1] ||a[0]==a[2] || a[1]==a[2]) cout<<"No";
  else cout<<"Yes";
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

A_ = sorted(A)

if len(A_) == 1:
    if A_[0] == 0:
        print(1)
    else:
        print(0)

elif A_[0] == A_[1] == 0:
    print(0)

else:
    ans_ = 2 ** (N // 2)
    ans = ans_ % (10**9 + 7)


    if len(A_) % 2 == 0:
        for i in range(len(A_) // 2):
            if A_[2*i] != A_[2*i+1]:
                print(0)
                exit()

    else:
        if A_[0] != 0:
            print(0)
            exit()

        for i in range(len(A_) // 2):
            if A_[2*i+1] != A_[2*i+2]:
                print(0)
                exit()


    print(ans)


Measured memory_bytes: 14008
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		
		while(stdIn.hasNext()){
			int a = stdIn.nextInt();
			int b = stdIn.nextInt();
			int c = a + b;
			int count = 1;
		
			while(c/10!=0){
				count++;
				c = c/10;
			}
		
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 20436
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
#from bisect import bisect_left as bl, bisect_right as br, insort
#from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write('\n'.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
#from decimal import Decimal
#from fractions import Fraction
#sys.setrecursionlimit(100000)
#INF = float('inf')
mod = int(1e9)+7

n=int(data())
x=data()
c=x.count('1')
t1,t2=1,1
k1=0
k2=0
for i in range(n-1,-1,-1):
    if x[i]=='1':
        k1=(k1+t1)%(c+1)
        if c==1:
            continue
        k2=(k2+t2)%(c-1)
    t1=(t1*2)%(c+1)
    if c != 1:
        t2=(t2*2)%(c-1)
ans=[]
t1,t2=1,1
for i in range(n-1,-1,-1):
    if x[i]=='1':
        if c==1:
            ans.append(0)
            continue
        k=(k2-t2+c-1)%(c-1)
    else:
        k=(k1+t1)%(c+1)
    cnt=1
    while k:
        k=k%(bin(k)[2:].count('1'))
        cnt+=1
    ans.append(cnt)
    t1 = (t1 * 2) % (c + 1)
    if c!=1:
        t2 = (t2 * 2) % (c - 1)
outl(ans[::-1])


Measured memory_bytes: 101720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

using P = pair<double, int>;
int main() {
    init();

    double sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    int n; cin >> n;
    n += 2;
    vector<double> x(n), y(n), r(n);
    x[0] = sx, y[0] = sy;
    x[n - 1] = tx, y[n - 1] = ty;
    FOR(i, 1, n - 1)cin >> x[i] >> y[i] >> r[i];

    vector<vector<P>> g(n);
    FOR(i, 0, n)FOR(j, i + 1, n) {
        double dx = x[i] - x[j], dy = y[i] - y[j];
        double cost = sqrt(dx * dx + dy * dy);
        cost = max(cost - r[i] - r[j], 0.0);
        g[i].emplace_back(cost, j);
        g[j].emplace_back(cost, i);
    }

    vector<double> dis(n, LLINF);
    priority_queue<P, vector<P>, greater<P>> dik;
    dis[0] = 0.0;
    dik.emplace(0.0, 0);
    while (!dik.empty()) {
        double d; int now;
        tie(d, now) = dik.top(); dik.pop();
        if (dis[now] < d)continue;
        for (P next : g[now]) {
            double cost; int to;
            tie(cost, to) = next;
            if (!chmin(dis[to], dis[now] + cost))continue;
            dik.emplace(dis[to], to);
        }
    }

    cout << dis[n - 1] << "\n";
}


Measured memory_bytes: 22548
use std::io::{stdout, Write, BufWriter};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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!{
        n: usize,
    }

    let mut pf_map = vec![1; n-1];
    for num in (2..n+1) {
        let mut tmp = num;
        for (i, x) in (2..n+1).enumerate() {
            while tmp % x == 0 {
                pf_map[i] += 1;
                tmp = tmp / x;
            }
        }
    }

    let ans = &pf_map.iter().filter(|x| **x >= 75).count()
            + &pf_map.iter().filter(|x| **x >= 25).count() * (&pf_map.iter().filter(|x| **x >= 3).count() - 1)
            + &pf_map.iter().filter(|x| **x >= 15).count() * (&pf_map.iter().filter(|x| **x >= 5).count() - 1)
            + &pf_map.iter().filter(|x| **x >= 5).count() * (&pf_map.iter().filter(|x| **x >= 5).count() - 1) * (&pf_map.iter().filter(|x| **x >= 3).count() - 2) / 2;

    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    writeln!(out, "{}", ans).unwrap();
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

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

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





int main() {
    string s,t;
    cin>>s>>t;
    map<char, char>m;
    int n=s.size();
    for(int i=0;i<n;i++){
        if(m.count(s.at(i))==0 or m[s.at(i)]==t.at(i)){
            m[s.at(i)]=t.at(i);
        }
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    map<char, char>m1;
    for(int i=0;i<n;i++){
        if(m1.count(t.at(i))==0 or m1[t.at(i)]==s.at(i)){
            m1[t.at(i)]=s.at(i);
        }
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 904