akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    int c[9] = {0};
    repi(i, n, 0)
    {
        int a;
        cin >> a;
        if (a >= 3200)
        {
            c[8]++;
        }
        else if (a >= 2800)
        {
            c[7]++;
        }
        else if (a >= 2400)
        {
            c[6]++;
        }
        else if (a >= 2000)
        {
            c[5]++;
        }
        else if (a >= 1600)
        {
            c[4]++;
        }
        else if (a >= 1200)
        {
            c[3]++;
        }
        else if (a >= 800)
        {
            c[2]++;
        }
        else if (a >= 400)
        {
            c[1]++;
        }
        else
        {
            c[0]++;
        }
    }
    int ans = 0;
    repi(i,8,0){
        if(c[i] > 0)ans++;
    }
    cout << max(ans,1) << " " << ans + c[8]<< endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int mod = 1e9 + 7;
const int inf = 1e18;
const int N = 8005;

int i,a,b,c,k;

void solve(){
    cin>>a>>b>>c>>k;
    if(k<=a)
        cout<<k;
    else if(k<=a+b)
        cout<<a;
    else
        cout<<a-(k-a-b);
}

signed main(){
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
#! env/bin/local python3
# -*- coding:utf-8 -*-

# -- submit ----

import math

# --- fetch input ---
inputs: list = []
while True:
    try:
        inputs.append(input().strip('\n'))
    except EOFError:
        break

# --- write code below ---


x = int(inputs[0])
bill = 100
years = 0

while True:
    years += 1
    temp = bill * 1.01
    bill = math.floor(temp)
    if bill >= x:
        print(years)
        break


Measured memory_bytes: 9172
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define ll long long
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll a,b,n;
    cin>>a>>b>>n;
    ll x=min(b-1,n);
    ll ans=(a*x)/b;
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
const int mod=1e9+7;

int main(){
	int n;
	string s;
	cin >> n >> s;
	int ans=0;
	for(int i=0; i<s.size()-1; i++){
		vector<int> a(26);
		for(int j=0; j<=i; j++){
			a[s[j]-'a']++;
		}
		vector<int> b(26);
		for(int j=i+1; j<s.size(); j++){
			if(a[s[j]-'a'])
				b[s[j]-'a']++;
		}
		int sum=0;
		for(int j=0; j<26; j++){
			if(b[j])
				sum++;
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
	return 0;
}

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

ll sx, sy, tx, ty;

int main()
{
    cin >> sx >> sy >> tx >> ty;
        for(int i = 0; i < ty - sy; i++){
            printf("U");
        }
        for(int i = 0; i < tx - sx; i++){
            printf("R");
        }
        for(int i = 0; i < ty - sy; i++){
            printf("D");
        }
        for(int i = 0; i < tx - sx; i++){
            printf("L");
        }
        printf("L");
        for(int i = 0; i <= ty - sy; i++){
            printf("U");
        }
        for(int i = 0; i <= tx - sx; i++){
            printf("R");
        }
        printf("DR");
        for(int i = 0; i <= ty - sy; i++){
            printf("D");
        }
        for(int i = 0; i <= tx - sx; i++){
            printf("L");
        }
        printf("U");

    return 0;
}


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

int main()
{
    int W, H, N;
    cin >> W >> H >> N;
    vector<tuple<int, int, int>> B(N);
    for (int i = 0; i < N;++i){
        int x, y, a;
        cin >> x >> y >> a;
        B[i] = make_tuple(x, y, a);
    }
    vector<vector<int>> A(W, vector<int>(H, 0));

    for (int i = 0; i < N;++i){
        if(get<2>(B[i]) == 1){
            for (int x = 0; x < get<0>(B[i]); ++x){
                for (int y = 0; y < H; ++y){
                    A[x][y] = 1;
                }
            }
        }
        else if (get<2>(B[i]) == 2)
        {
            for (int x = get<0>(B[i]); x < W; ++x)
            {
                for (int y = 0; y < H; ++y)
                {
                    A[x][y] = 1;
                }
            }
        }
        else if (get<2>(B[i]) == 3)
        {
            for (int x = 0; x < W; ++x)
            {
                for (int y = 0; y < get<1>(B[i]); ++y)
                {
                    A[x][y] = 1;
                }
            }
        }
        else if (get<2>(B[i]) == 4)
        {
            for (int x = 0; x < W; ++x)
            {
                for (int y = get<1>(B[i]); y < H; ++y)
                {
                    A[x][y] = 1;
                }
            }
        }
    }
    int ans = 0;
    for (int y = 0; y < H; ++y)
    {
        for (int x = 0; x < W; ++x){
            if(A[x][y] ==0)
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <tuple>
# include <functional>
# include <utility>
# define INF 1000000000
# define MOD 1000000000+7
using namespace std;

char islands[15][15];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

void dfs(int h, int w) {
	islands[h][w] = '0';
	for (int i = 0; i < 4; i++) {
		if (h + dx[i] >= 0 && h + dx[i] <= 12 && w + dy[i] >= 0 && w + dy[i] <= 12 && islands[h + dx[i]][w + dy[i]] == '1') {
			dfs(h + dx[i], w + dy[i]);
		}
	}
}
int main() {
	string a;
	while (cin>>a) {
		for (int i = 0; i < 12; i++) {
			for (int j = 0; j < 12; j++) {
				islands[i][j] = a[j];
			}
			if(i!=11)cin >> a;
		}
		int ans = 0;
		for (int i = 0; i < 12; i++) {
			for (int j = 0; j < 12; j++) {
				if (islands[i][j] == '1')dfs(i, j), ans++;
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3172
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
typedef long long ll;

int main(void) {
  int x, y;
  cin >> x >> y;
  cout << x + y/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;
using pis = std::pair<int, std::string>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
namespace mp = boost::multiprecision;

template<typename T>
constexpr T _gcd(T m, T n) noexcept {
	T g = 1;

	while (m != 0) {
		if (m < n) std::swap(m, n);

		if (m & 1) {
			if (n & 1) m = (m - n) >> 1;
			else n = n >> 1;
		}
		else {
			if (n & 1) {
				m = m >> 1;
			}
			else {
				n = n >> 1;
				m = m >> 1;
				g = g << 1;
			}
		}
	}

	return g * n;
}

template<typename T>
constexpr T _lcm(T m, T n) noexcept {
	return (m * n) / gcd(m, n);
}

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

	int n;
	cin >> n;
	ll* a = new ll[n];
	rep(i, n) cin >> a[i];

	ll maxA = a[0];
	ll t = a[0];
	REP(i, 1, n) {
		t = _gcd(t, a[i]);
		maxA = max(maxA, a[i]);
	}

	if (t == 1) {
		ll* d = new ll[maxA + 1];
		memset(d, 0, sizeof(ll)*(maxA + 1));
		d[1] = 1;
		REP(i, 2, maxA + 1) {
			if (d[i] == 0) {
				d[i] = i;
				for (int j = 2; i*j < maxA + 1; ++j) {
					d[i*j] = i;
				}
			}
		}

		set<ll> x;
		while (a[0] != 1) {
			x.insert(d[a[0]]);
			a[0] /= d[a[0]];
		}

		REP(i, 1, n) {
			while (a[i] != 1) {
				if (x.find(d[a[i]]) != x.end()) {
					cout << "setwise coprime" << "\n";
					return 0;
				}
				else {
					x.insert(d[a[i]]);
					ll p = d[a[i]];
					while (a[i] % p == 0) {
						a[i] /= p;
					}
				}
			}
		}

		cout << "pairwise coprime" << "\n";
	}
	else {
		cout << "not coprime" << "\n";
	}

	return 0;
}


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

using namespace std;

int N, X, Y, minW, minW2, whatC, fac[200009], inv[200009];
vector < int > v[200009], h;
const int mod = 1e9 + 7;

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int subtract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}
void adto (int &x, int y) {x += y; if (x >= mod) x -= mod;}

int power (int a, int b)
{
    int p = 1;
    for (int i=0; (1<<i) <= b; i++)
    {
        if (b & (1 << i)) p = mul (p, a);
        a = mul (a, a);
    }
    return p;
}

void Prec (int lim){fac[0] = inv[0] = 1;for (int i=1; i<=lim; i++)fac[i] = mul (fac[i - 1], i);
inv[lim] = power (fac[lim], mod - 2);for (int i=lim - 1; i>=1; i--)inv[i] = mul (inv[i + 1], i + 1);}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d %d", &N, &X, &Y), Prec (N);
for (int i=1; i<=N; i++)
{
    int c, w;
    scanf ("%d %d", &c, &w);
    v[c].push_back (w);
    if (w < minW || i == 1)
        whatC = c, minW = w;
}
for (int i=1; i<=N; i++)
    sort (v[i].begin (), v[i].end ());
for (int i=1; i<=N; i++)
    if (whatC != i && (!v[i].empty ()) && v[i][0] + minW <= Y)
    {
        if (v[i][0] < minW2 || minW2 == 0)
            minW2 = v[i][0];
        int prefixSize = -1;
        for (int j=0; j<v[i].size (); j++)
        {
            if (v[i][j] + minW > Y && v[i][j] + v[i][0] > X) break;
            prefixSize = j + 1;
        }
        h.push_back (prefixSize);
    }
if (minW2 == 0)
{
    printf ("1\n");
    return 0;
}
int prefixSize = -1;
for (int i=0; i<v[whatC].size (); i++)
{
    if (v[whatC][i] + minW2 > Y && v[whatC][i] + v[whatC][0] > X) break;
    prefixSize = i + 1;
}
h.push_back (prefixSize);
int M = 0, ans = 1;
for (auto sz : h)
    M += sz, ans = mul (ans, inv[sz]);
ans = mul (ans, fac[M]);
printf ("%d\n", ans);
return 0;
}


Measured memory_bytes: 11520
#include <stdio.h>
int main()
{
  int a,b,sum,cou;
  while( scanf("%d %d",&a,&b)!=EOF ){
    //printf("%d%d",a,b);//
    sum=a+b;
    cou=0;
    while(1){
      if(sum<10)break;
      sum=sum/10;
      cou++;
    }
    printf("%d\n",cou+1);
  }
  return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXN = 10010, MAXP = 1231;
bool p[MAXN] = {1, 1};
int num[MAXP + 10];
int sum[MAXP + 10];

int main()
{
    REP(MAXN)if(!p[i])for(int j = i*2;j<MAXN;j+=i)p[j] = 1;
   
    int cnt = 0;
    REP(MAXN)if(!p[i]){num[cnt] = i; cnt++; }

    REP(cnt)sum[i+1] = sum[i] + num[i];

    int n;
    while(cin >> n && n)
    {
        int ans = 0;

        REP(cnt)for(int j = i + 1;j < cnt+1;j++)if(sum[j] - sum[i] == n) ans++;

        cout << ans << endl;
    }

    return 0;
}

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

int main()
{
    int n;
    double n2;

    cin >> n;

    n2 = n;
    int bit[n];
    int selection[n];

    for( int i = 0; i < n; i++ )
    {
        bit[i] = i;
        selection[i] = 0;
    }
    
    for( int i = 0; i < pow( 2, n2 ); i++ )
    {
        int x = i;
        int j = 0;
        while( x > 1 )
        {
            selection[j] = x % 2;
            j++;
            x = x / 2;
        }
        selection[j] = x;

        cout << i << ":";
        for( int k = 0; k < n; k++ )
            if( selection[k] == 1 )
                cout << " " << bit[k];
        cout<< endl;
    }
    return 0;
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n, k;
	cin >> n >> k;
	vector<int> h(n + 1);
	for (int i = 1; i - 1 < n; ++i) cin >> h[i];

	vector<int> dp(n + 1, (int) 1e9);

	dp[1] = 0;
	for (int i = 2; i <= n; ++i) {
		for (int j = 1; j <= k; ++j) {
			if (i - j >= 0) {
				dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
			}
		}
	}

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



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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  if (m == 0) {
    cout << 1LL * n * n << endl;
    return 0;
  }
  long long ans = 0;
  for (int a = m; a <= n; ++a) {
    ans += n - a;
  }
  for (int b = m + 1; b <= n; ++b) {
    int t = n / b;
    ans += 1LL * (t - 1) * (b - m);
    if (b * t + m <= n) {
      ans += n - (b * t + m) + 1;
    }
  }
  cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);

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

    cin>>vec.at(i);
  }
  sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());

    int a=vec.at(0);

    for (int i=1; i<N; i++){
    if (i%2==0)
    a+=vec.at(i);
    else
    a-=vec.at(i);
}

  cout<<a<<endl;
  
}

Measured memory_bytes: 3564
N, M, X = [int(i) for i in input().split()]
AS = [int(i) for i in input().split()]

cnt1 = 0
for i in range(0, X):
  if i in AS:
    cnt1 += 1

cnt2 = 0
for i in range(X+1, N+1):
  if i in AS:
    cnt2 += 1

print(cnt1 if cnt1 < cnt2 else cnt2)


Measured memory_bytes: 9084
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
int s[12][12];

int main(){
   int n,m;
   cin>>n>>m;
   vector<int> k(m),p(m);
   for(int i=0;i<m;i++){
       cin>>k[i];
       for(int j=0;j<k[i];j++)cin>>s[i][j];
   }
   for(int i=0;i<m;i++)cin>>p[i];


   int ans=0;
   for (int bit = 0; bit < (1<<n);bit++){
       bool flag=true;
       for(int i=0;i<m;i++){
           int cnt=0;
           for(int j=0;j<k[i];j++){
               if (bit & (1<<(s[i][j]-1))){
                   cnt++;
               }
           }
           if(cnt%2!=p[i]){
               flag=false;
               break;
           }
       }
       if(flag){
           ans++;
       }
   }
   cout<<ans<<endl;
}

   


Measured memory_bytes: 256
//Badwaper gg
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define pb push_back
#define re register ll
#define fr first
#define sd second
#define FOR(i,a,b) for(re i=a;i<=b;i++)
#define REP(i,a,b) for(re i=a;i>=b;i--)
#define lowbit(x) (x&(-x))
#define Z(x) (x>=mod?x-mod:x)
#define N 21
#define M 200010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
const int mod=1e9+7;
int fac[M],inv[M],n,m,a[N],P[N];
int f[1<<16],ans,bit[1<<16];
inline int C(int n,int m){if(n<m)return 0;return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),m=read();int t=(1<<n);
	FOR(i,1,m)a[i]=read();
	fac[0]=1;
	FOR(i,1,t)fac[i]=1LL*fac[i-1]*i%mod;f[0]=1;
	inv[0]=inv[1]=1;
	FOR(i,2,t)inv[i]=1LL*inv[mod%i]*(mod-mod/i)%mod;
	FOR(i,2,t)inv[i]=1LL*inv[i-1]*inv[i]%mod;
	REP(i,m,1)
	{
    	REP(S,(1<<n)-1,0)FOR(j,1,n)
    	{
    		int p=1<<(j-1);if(S&p||(t-a[i]-S)<p-1)continue;
//     		cout<<"WTF:"<<S<<" "<<p<<" "<<f[S]<<" "<<C(t-a[i]-S,p-1)<<" "<<fac[p]<<" "<<t-a[i]-S<<" "<<p-1<<endl;
    		f[S|p]=Z(f[S|p]+1LL*f[S]*C(t-a[i]-S,p-1)%mod*fac[p]%mod);
    	}
	}
//	FOR(i,1,(1<<n)-1)cout<<"WTF:"<<i<<" "<<f[i]<<endl;
	FOR(i,1,(1<<n)-1)bit[i]=bit[i>>1]+(i&1);P[0]=1;
	FOR(i,1,n)P[i]=1LL*P[i-1]*(mod-1)%mod;
	int ans=fac[t];
	FOR(i,1,(1<<n)-1)ans=Z(ans+1LL*P[bit[i]]*f[i]%mod*fac[t-i-1]%mod*t%mod);
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;
#define FIX(a) ((a)%MOD+MOD)%MOD

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

    string ans;
    if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9) ans = "hon";
    else if(n%10==0 || n%10==1 || n%10==6 || n%10==8) ans ="pon";
    else ans ="bon";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3668
# https://atcoder.jp/contests/abc081/tasks/arc086_a
# C - Not so Diverse
import collections
N, K = list(map(int, input().split()))
a_list = list(map(int, input().split()))

c = collections.Counter(a_list)

# 数がすくないやつから使う
c_list = sorted([v for k, v in c.items()])
ans = sum(c_list[:-K])
print(ans)


Measured memory_bytes: 32568
#define LOCAL
#include <iostream>
#include <map>
#include <iterator>
#include <bits/stdc++.h>
#include <stdbool.h>
#include <math.h>
#define io() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define show(x)     cout << (#x) << ":" << x << endl;
#define show2(x,y)  cout << (#x) << ":" << x << " " << (#y) << ":" << y << endl;
#define ll long long
#define ld long double
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define en "\n"
#define rep(i,a,b) for(int (i)=(a);(i) < (b); (i)++)
using namespace std;

template<class T> ostream& operator<<(ostream &os, vector<T> V){os << "[ "; for(auto v  : V) os << v << " "; return os << "]";}
template<class T> ostream& operator<<(ostream &os, set<T> V){os << "[ "; for(auto v  : V) os << v << " "; return os << "]";}
template<class T , class R > ostream& operator<<(ostream &os, map<T , R> V){os << "[ "; for(auto v  : V) os << "(" << v.first << ":" << v.second << ")"; return os << "]";}
template<class T , class R > ostream& operator<<(ostream &os, pair<T , R> V){return os << "(" << V.first << "," << V.second << ")";}
 
#define cerr cout
#ifdef LOCAL
    #define TRACE
#endif
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){cerr << "T->";cerr << name << " : " << arg1 << endl;}
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){cerr << "T->";const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | "; __f(comma+1, args...);}
    clock_t clk=clock();
    #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
    #define trace(...);
    #define checktime();
#endif

#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<"\n"
#define d2(x,y) cout<<(x)<<" "<<(y)<<"\n"
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<"\n"
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<"\n"
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<"\n"
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<"\n"
#define print(a) for(auto x:a) cout<<x<<" "; cout<<"\n"; 
// Use max({a,b,c,d,....}) instead
// #define max3(a,b,c) max(max((a),(b)),(c))
// #define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))

const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MOD1 = 998244353;


void solve(){
    int x;
    cin>>x;
    if(x>=30)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

int main() {
    io();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //int t;
    //#pragma comment(linker, "/STACK:2000000")
    //cin>>t;
    //rep(i,0,t){
        solve();
    //}
    //h=1;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

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

	if(N / 100 == N % 10){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


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

int main() {
  int A, B, C, X, Y;
  scanf("%d%d%d%d%d", &A, &B, &C, &X, &Y);

  int A_NUM = 0;
  int B_NUM = 0;
  int ans = 0;
  if (A + B > 2 * C) {
    if (X > Y) {
      ans += 2 * C * Y;
      A_NUM += Y;
      B_NUM += Y;
      if (A_NUM >= X) {
        printf("%d", ans);
        return 0;
      }
    } else if (X == Y) {
      ans += 2 * C * X;
      printf("%d", ans);
      return 0;
    } else if (X < Y) {
      ans += 2 * C * X;
      A_NUM += X;
      B_NUM += X;
      if (B_NUM >= Y) {
        printf("%d", ans);
        return 0;
      }
    }
  }

  if (A > 2 * C) {
    ans += 2 * C * (X - A_NUM);
  } else {
    ans += A * (X - A_NUM);
  }
  if (B > 2 * C) {
    ans += 2 * C * (Y - B_NUM);
  } else {
    ans += B * (Y - B_NUM);
  }

  printf("%d", ans);
  return 0;
}

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

int main(){
		int n;scanf("%d",&n);
		char str[n];
		scanf("%s",str);
		int count=0;
		for(int i=0;i<=n-1-2;i++){
				if(str[i]=='A'){
						if(str[i+1]=='B'){
								if(str[i+2]=='C'){
										count++;
									}
							}
					}
			}
		printf("%d",count);	
	}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
signed main(){
    int n;
    int d[105];
    int s=0;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>d[i];
    }
    sort(d,d+n);

    for(int i=0; i<n; i++){
    if(i!=0&&d[i]==d[i-1]){
      continue;
    }
    s++;
    }
    cout<<s<<"\n";
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll A,B;
    cin >> A >> B;
    ll ans = -1;
    repe(i,1,10005){
        if((ll)(i*0.08)==A&&(ll)(i*0.1)==B){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	s, _ := r.ReadString('\n')
	s = strings.TrimRight(s, " \t\n")
	slice := strings.Split(s, " ")
	x := string(slice[0])
	y := string(slice[1])
	X, _ := strconv.Atoi(x)
	Y, _ := strconv.Atoi(y)

	fmt.Println(X + Y/2)

}


Measured memory_bytes: 1776
import java.util.Scanner;
class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			long[] primeList = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};
			long N=Long.parseLong(sc.next());
			long cnt=1;
			for(long prime:primeList){
				if(prime<=N)cnt=(cnt*(1+calc(N,prime)))%(1000000007);
			}
			System.out.println(cnt);
		}
	}
	public static long calc(long N, long prime){
		long cnt=0;
		
		for(long pow=prime;pow<=N;pow*=prime){
			cnt+=N/pow;
			}
		return cnt;
	}
}


Measured memory_bytes: 21972
def lscan;gets.split.map(&:to_i);end

s = gets.chomp

l = s[0..1]
r = s[2..3]

yymm = (1..12).cover?(r.to_i)
mmyy = (1..12).cover?(l.to_i)

if yymm && mmyy
  puts "AMBIGUOUS"
elsif yymm
  puts "YYMM"
elsif mmyy
  puts "MMYY"
else
  puts "NA"
end

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

namespace ARC061_D___すぬけ君の塗り絵
{
    class Program
    {
        static void Main(string[] args)
        {
            var HWN = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            var H = HWN[0];
            var W = HWN[1];
            var N = HWN[2];
            long MOD = 1000000007;

            var colored = new HashSet<long>();
            for (int i = 0; i < N; i++)
            {
                var ab = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                colored.Add(ab[0] + ab[1] * MOD);
            }

            var checking = new HashSet<long>();
            foreach (long p in colored)
            {
                var h = p % MOD;
                var w = p / MOD;
                for (long a = h - 1; a <= h + 1; a++)
                {
                    for (long b = w - 1; b <= w + 1; b++)
                    {
                        if (a <= 1 || a >= H || b <= 1 || b >= W) continue;
                        checking.Add(a + b * MOD);
                    }
                }
            }

            var result = new long[10];
            foreach (long p in checking)
            {
                var count = 0;
                var height = p % MOD;
                var width = p / MOD;
                for (long h = height - 1; h <= height + 1; h++)
                {
                    for (long w = width - 1; w <= width + 1; w++)
                    {
                        if (colored.Contains(h + w * MOD)) count++;
                    }
                }
                result[count]++;
            }

            result[0] = (H - 2) * (W - 2);
            for (int i = 1; i < 10; i++) result[0] -= result[i];
            for (int i = 0; i < 10; i++) Console.WriteLine(result[i]);
        }
    }
}


Measured memory_bytes: 66872
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,a,b,c,d = list(map(int, input().split()))
dp = [0]*(n+1)
dp[0] = 1
M = 10**9+7
### 素数の逆元とCombination
N = n+10 # 必要なテーブルサイズ

g1 = [None] * (N+1) # 元テーブル
g2 = [None] * (N+1) #逆元テーブル
inverse = [None] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 

for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 

def cmb(n, r, M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return (g1[n] * g2[r] * g2[n-r]) % M

for i in range(a, b+1):
    for j in range(n, 0, -1):
        val = 1
        for k in range(c):
            val *= cmb(j-i*k, i, M)
            val %= M
        for k in range(c,d+1):
            if j-i*k>=0:
                dp[j] += dp[j-i*k] * val * g2[k]
                dp[j] %= M
                val *= (cmb(j-i*k, i, M))
                val %= M
            else:
                break
#     print(dp)
print(dp[n]%M)

Measured memory_bytes: 79556
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<std::string> s(N);
  std::queue<std::string> BA, B, A, X;
  for (auto& si: s) {
    char buf[16];
    scanf("%s", buf);
    si = buf;

    if (si[0] == 'B' && si.back() == 'A') {
      BA.push(si);
    } else if (si[0] == 'B') {
      B.push(si);
    } else if (si.back() == 'A') {
      A.push(si);
    } else {
      X.push(si);
    }
  }

  std::string t;
  if (!A.empty()) {
    t += A.front();
    A.pop();
  }
  // if (!A.empty()) {
  //   t += A.front();
  //   A.pop();
  // } else if (!BA.empty()) {
  //   t += BA.front();
  //   BA.pop();
  // } else if (!X.empty()) {
  //   t += X.front();
  //   X.pop();
  // } else {
  //   t += B.front();
  //   B.pop();
  // }

  while (!BA.empty()) {
    t += BA.front();
    BA.pop();
  }
  while (!A.empty() && !B.empty()) {
    t += B.front();
    B.pop();
    t += A.front();
    A.pop();
  }
  while (!A.empty()) {
    t += A.front();
    A.pop();
  }
  while (!B.empty()) {
    t += B.front();
    B.pop();
  }
  while (!X.empty()) {
    t += X.front();
    X.pop();
  }

  int res = 0;
  for (size_t i = 1; i < t.length(); ++i) {
    if (t[i-1] == 'A' && t[i] == 'B') ++res;
  }
  printf("%d\n", res);
}


Measured memory_bytes: 1408
//in the name of god
#include <bits/stdc++.h>

using namespace std;

int n, ans;

int main()
{   
    cin >> n;
    for(int i = 1; i < n; i ++)
    {
        ans += (n - 1) / i;
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm> // min()
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <tuple>

#include <climits> // INT_MAX
#include <cmath> // ceil()
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define b2e(vec) vec.begin(), vec.end()

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;


int main() {
	char x;
	cin >> x;
	if (isupper(x)) {
		cout << 'A' << endl;
	}
	else {
		cout << 'a' << endl;
	}

}

Measured memory_bytes: 3632
#include <stdio.h>

#define MAX 100000

int binarySearch(int*,int,int);

int main(){

  int n,s[MAX],q,t[MAX],i,j,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&t[i]);

  for(i=0;i<q;i++){

    if(binarySearch(&s[0],n,t[i])==1) count++;

  }

  printf("%d\n",count);

  return 0;


}

int binarySearch(int A[], int n, int key){

  int left,right,mid;

  left=0;
  right=n;

  while(left<right){
    mid=(left+right)/2;
    if(A[mid]==key) return 1;
    else if(key<A[mid]) right=mid;
    else left=mid+1;
  }

  return 0;

}


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

using namespace std;
using ll = long long;

int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i = 0;i < n;++i) {
        cin>>a[i];
    }
    for(int i = 0;i < n;++i) {
        for(int j = i+1;j < n;++j) {
            if(abs(a[i]-a[j])%(n-1)==0){
                cout<<a[i]<<" "<<a[j]<<endl;
                return 0;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int a[100010];
 
int main() {

int n,x;
cin>>n>>x;
for(int i=1;i<=n;i++){

	cin>>a[i];
	}

	long long ans=0;
if(a[1]>x) {ans+=a[1]-x;
a[1]=x;}
for(int i=2;i<=n;i++){
if(a[i]+a[i-1]>x){
		ans+=a[i]+a[i-1]-x;
		a[i]-=a[i]+a[i-1]-x;
	}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)

const ll mod = 1000000007LL;


int main() {
	int n, m;
	cin >> n >> m;

	vector<P> ba;


	set<int> d;
	rep(i, n) {
		int a,b;

		cin >> a >> b;
		ba.push_back(mkp(b,a));


	}

	rep(i, m) {
		d.insert(i);
	}


	sort(ba.rbegin(), ba.rend());

	ll ans = 0;
	for(auto b : ba) {
		if (d.empty()) {
			break;
		}
		int cur = m - b.second;
		//cout << "*** money:" << b.first << " day:" << b.second << " cur:" << cur << endl; 
		decltype(d)::iterator it = d.lower_bound(cur);

		//cout << "*it:" << *it << endl;
		if (*it != cur) {
			if (it == d.begin()) {
				continue;
			}
			it--;
		}


		d.erase(it);
		//cout << "money:" << b.first << " day:" << b.second << " d.size():" << d.size() << " ";
		//for(auto dd: d) {
		//	cout << "," << dd;
		//}
		//cout << endl;
		ans += b.first; 
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 8324
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int count = 0;
        while(true){
            String in = sc.next();
            if(in.equals("END_OF_TEXT")) break;
            String lower_in = in.toLowerCase();
            if(lower_in.equals(s)) count++;
        }
        System.out.println(count);
        sc.close();
    }
}


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

using namespace std;

int main()
{
    string s;
    int k;
    cin >> k >> s;
    if (s.size()<=k) {cout << s; return 0;}
    for (int i = 0; i < k; i++)
    {
       cout << s[i];


    }

    cout << "...";



}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  std::string s;
	cin >> s;
	if (s.find("A") != std::string::npos && s.find("B") != std::string::npos) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import Control.Monad

main = do
    n  <- read <$> getLine
    xu <- forM [1..n] $ \i -> do
        [x, u] <- words <$> getLine
        return (read x, u)
    putStrLn $ show $ solve n xu

solve :: Int -> [(Double, String)] -> Double
solve n xu = sum [if u == "JPY" then x else x * 380000 | (x, u) <- xu]


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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	vector<long> sam(b);
	for(int i=0; i<b; i++){
		sam.at(i)=((i+1)*a)%b;
	}
	bool judge=false;
	for(int i=0; i<b; i++){
		if(sam.at(i)==c){
			judge=true;
			break;
		}
	}
	if(judge) cout << "YES" << endl;
	else cout << "NO" << endl;
}



Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func solve(n int64, a int64, b int64) int64 {
	if a == 0 {
		return 0
	}
	if b == 0 {
		return n
	}
	ret := (n / (a + b)) * a
	aa := (n % (a + b))
	if a < aa {
		aa = a
	}
	return ret + aa
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n := nextInt()
	a := nextInt()
	b := nextInt()
	res := solve(n, a, b)
	fmt.Fprintln(out, res)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextStringAsBytes(n int64) []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


Measured memory_bytes: 640
s = gets.chomp
l = s.length
if s.index('0') && s.index('1')
  if l % 2 == 0 && %w(01 10).include?(s[l / 2 - 1, 2])
    puts l / 2
  else
    c = s[l / 2]
    (0..((l - 1) / 2)).each do |i|
      if s[(l - 1) / 2 - i] != c || s[l / 2 + i] != c
        puts l / 2 + i
        break
      end
    end
  end
else
  puts s.length
end

Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout<< abs(a-b)+abs(b-c)+abs(c-a)-max(max(abs(a-b),abs(b-c)),abs(c-a)) <<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

struct barrier {
    double x, y, r;
    barrier(double _x, double _y, double _r) : x(_x), y(_y), r(_r) {}
};

struct edge {
    int to;
    double cost;
    edge(int t, double c) : to(t), cost(c) {}
};

using pid = pair<int, double>;
void dijkstra(int s, vector<double> &d, vector<vector<edge>> &G) {
    priority_queue<pid, vector<pid>, greater<pid>> que;
    fill(All(d), (double)1e18);
    d[s] = 0;
    que.push(make_pair(0, s));

    while(!que.empty()) {
        pid p = que.top();
        que.pop();
        int v = p.second;
        if(d[v] < p.first)
            continue;
        for(auto e : G[v]) {
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(make_pair(d[e.to], e.to));
            }
        }
    }
}

int main() {
    double sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int N;
    cin >> N;
    vector<barrier> bs(N, barrier(0, 0, 0));
    for(int i = 0; i < N; i++) {
        double x, y, r;
        cin >> x >> y >> r;
        bs[i] = barrier(x, y, r);
    }
    vector<vector<edge>> G(N + 2, vector<edge>());
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            double d = sqrt((bs[i].x - bs[j].x) * (bs[i].x - bs[j].x) +
                            (bs[i].y - bs[j].y) * (bs[i].y - bs[j].y));
            d -= bs[i].r + bs[j].r;
            d = max((double)0.0, d);
            G[i].pb(edge(j, d));
            G[j].pb(edge(i, d));
        }
    }
    for(int j = 0; j < N; j++) {
        double d = sqrt((sx - bs[j].x) * (sx - bs[j].x) +
                        (sy - bs[j].y) * (sy - bs[j].y));
        double d2 = sqrt((tx - bs[j].x) * (tx - bs[j].x) +
                         (ty - bs[j].y) * (ty - bs[j].y));
        d -= bs[j].r;
        d2 -= bs[j].r;
        d = max((double)0.0, d);
        d2 = max((double)0.0, d2);
        G[N].pb(edge(j, d));
        G[j].pb(edge(N + 1, d2));
    }
    G[N].pb(edge(N + 1, sqrt((sx - tx) * (sx - tx) + (sy - ty) * (sy - ty))));

    vector<double> dist(N + 2);
    dijkstra(N, dist, G);
    cout << fixed << setprecision(10) << dist[N + 1] << endl;
    return 0;
}

Measured memory_bytes: 23780
import java.util.*;

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

        int N = sc.nextInt();
        int Q = sc.nextInt();
        String S = sc.next();

        int  [] list = new int [N + 1]; 
        int cnt = 0;
        
        for (int i = 0; i < N - 1; i++) {
            if ( S.substring(i, i + 2).equals("AC") ) cnt++;
            list[i + 2] = cnt; 
        }

        for (int q = 0; q < Q; q++ ) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int ans = list[r] - list[l];

            System.out.println( ans ); 
        }
    }
}

Measured memory_bytes: 75244
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#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 per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N; cin >> N;
	ll X = 0;
	V<ll> A(N);
	rep(i,N){
		cin >> A[i];
		X ^= A[i];
	}
	const int D = 60;
	ll mask = ((1LL<<D)-1)^X;

	V<ll> B(D);
	auto add = [&](ll x){
		per(i,D){
			if(B[i] == 0 && x&1LL<<i){ // add to base
				B[i] = x;
				return;
			}else if(x&1LL<<i){
				x ^= B[i];
			}
		}
	};
	rep(i,N) add(A[i]&mask);

	ll now = 0;
	per(d,D) chmax(now,now^B[d]);
	cout << now+(now^X) << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n); for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
typedef pair<int, int> P;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
 int N,M;cin>>N>>M;
  vi k(M);vvi s(M,vi(N));vi p(M);
  rep(i,M){
    cin>>k[i];
    rep(j,k[i]){
      cin>>s[i][j];
      s[i][j]--;
    }
  }
  rep(i,M)cin>>p[i];
  int ans=0;
  for(int tmp=0 ; tmp<(1<<N);tmp++){
    bitset<10> st(tmp);
    bool ok=true;
    
    rep(i,M){
      int cnt=0;
      rep(j,k[i]){
        if(st.test(s[i][j]))cnt++;
      }
      if(cnt%2!=p[i])ok=false;
    }
    if(ok)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256