akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
	string sa,sb,sc;
	cin >> sa >> sb >> sc;
	int ia = 0,ib = 0,ic = 0;
	char k = ' ',n = 'a';
	while(k == ' ')
	{
		if(n == 'a')
		{
			ia++;
			if(ia > sa.size())
			{
				k = 'A';
				break;
			}
			n = sa.at(ia - 1);
		}
		else if(n == 'b')
		{
			ib++;
			if(ib > sb.size())
			{
				k = 'B';
				break;
			}
			n = sb.at(ib - 1);
		}
		else if(n == 'c')
		{
			ic++;
			if(ic > sc.size())
			{
				k = 'C';
				break;
			}
			n = sc.at(ic - 1);
		}
	}
    cout << k << endl;
}


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

#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for(int i = a; i < b; i++)

#define PB push_back
#define PI 3.141592653589793238462643383279L

#define MOD 1000000007LL
typedef long long ll;
typedef long double ld;

#define LAR(a, b) a=max(a, (b))
#define SQ(x) ((x)*(x))

int main(){
	int m, t_;
	scanf("%d%d", &m, &t_);
	const ld t0 = 2*PI*m/360;
	const ld T = 60*t_;
	const ld ttm = 2500000;
	const ld ttk = 7200;
	const ld R = 380000;
	const ld r = 1900;
	const ld rm = 1800;
	ld ans = 0;
	REP(t, T){
		ld tm = t0 + 2*PI*t/ttm;
		ld tk = PI/2+2*PI*t/ttk;
		ld xm = R*cos(tm),
			 ym = R*sin(tm),
			 zm = 0;
		ld xk = xm + r*cos(tk),
			 yk = ym,
			 zk = zm + r*sin(tk);
		ld u = (xk*xm+yk*ym+zk*zm)/(xk*xk+yk*yk+zk*zk);
		ld xh = u*xk,
			 yh = u*yk,
			 zh = u*zk;
		ld d = sqrt(SQ(xm-xh)+SQ(ym-yh)+SQ(zm-zh));
		if(false){
			printf("%d", t);
			printf("  %.3Lf %.3Lf", tm, tk);
			printf("  M(%.3Lf %.3Lf %.3Lf)", xm, ym, zm);
			printf("  H(%.3Lf %.3Lf %.3Lf)", xh, yh, zh);
			printf("  K(%.3Lf %.3Lf %.3Lf)", xk, yk, zk);
		 	printf("  %.3Lf\n", d);
		}
		if(d < rm && u < 1){
			ans += 1;
		}
	}
	printf("%.10Lf\n", ans / 60);
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std ;
 
#define ll long long
 
 
int main(){
	
	ios::sync_with_stdio(0) ;
	cin.tie(0) ;
	
	map <string,int> m;
	m["AC"]=0;
	m["WA"]=0;
	m["TLE"]=0;
	m["RE"]=0;
	ll n;
	string s;
	
	cin >> n;
	
	for(int i=0;i<n;++i){
		cin >> s;
		m[s]++;
	}
	
	cout << "AC" << " x " << m["AC"] << "\n";
	cout << "WA" << " x " << m["WA"] << "\n";
	cout << "TLE" << " x " << m["TLE"] << "\n";
	cout << "RE" << " x " << m["RE"] << "\n";
	
	
}

Measured memory_bytes: 3672
def know(N, K, A):
    isOK = False
    for i in range(1, N):
        if A[i] + A[i - 1] >= K:
            isOK = True
            first = i

    if not isOK:
        return ["Impossible"]

    ans = [first]
    for i in range(first + 1, N):
        ans.append(i)
    for i in range(first - 1, 0, -1):
        ans.append(i)
    return ["Possible"] + ans[::-1]


if __name__ == "__main__":
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    ans = know(N, K, A)
    print(*ans, sep="\n")


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  vector<int> primes;

  REP (i, 2, 55556) {
    if (i % 5 != 1) continue;

    bool isPrime = true;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) {
        isPrime = false;
        break;
      }
    }
    if (isPrime) primes.eb(i);
  }

  int n;
  cin >> n;

  rep (i, n) cout << (i == 0 ? "" : " ") << primes[i];
  cout << endl;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    ab = [list(map(int, input().split())) for _ in range(n)]
    res = 0
    for i in range(n-1, -1, -1):
        if (ab[i][0]+res) % ab[i][1] == 0:
            continue
        res += ab[i][1] - ((ab[i][0]+res)%ab[i][1])
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 56284
#include <cstdio>

using namespace std;

int p[20000];
int a[20000];
int b[20000];

int main() {
    int n, i;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%d", &p[i]);
    
    for (i = 0; i < n; i++) {
        a[i] = 20000 * (i + 1);
        b[i] = 20000 * (n - i);
    }
    
    for (i = 0; i < n; i++) {
        a[p[i] - 1] += i;
        b[p[i] - 1] += i;
    }
    
    for (i = 0; i < n; i++) {
        if (i > 0) putchar(' ');
        printf("%d", a[i]);
    }
    puts("");
    
    for (i = 0; i < n; i++) {
        if (i > 0) putchar(' ');
        printf("%d", b[i]);
    }
    puts("");
    
    return 0;
}


Measured memory_bytes: 768
N, Y = gets.strip.split.map(&:to_i)

def fin(i, j, k)
  puts "#{i} #{j} #{k}"
  exit
end

(0..N).each do |i|
  (0..N).each do |j|
    k = N - (i + j)
    if k >= 0 && Y.eql?(i * 10000 + j * 5000 + k * 1000)
      fin(i, j, k)
    end
  end
end

fin(-1, -1, -1)


Measured memory_bytes: 1916
K, A, B = map(int, input().split())

ans = 0
if A >= B:
    ans = K + 1
else:
    if K < A + 1:
        ans = K + 1 # ビスケットから円に替えるだけの試行回数がそもそもない場合叩き続ける
    elif K == A + 1:
        if A+2 > B:
            ans = A+2
        else:
            ans = B
    else:
        K -= A+1
        #この時点でA+2orB枚のビスケット
        if K // 2 == 0:
            ans = max(A+2, B) + 1
        else:
            if B - A > 2:
                ans = max(A+2, B) + (K//2)*(B-A) + K%2
            else:
                ans = max(A+2, B) + K

print(ans)



Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define MAX 200005

using namespace std;

int main() {
    long long x; cin >> x;
    
    long long p = 100, ans = 0;
    
    while(p < x) {
        p += p/100;
        ans++;
    }
    
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    ll a[n], b[n], asum = 0, bsum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        asum += a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        bsum += b[i];
    }

    ll cnt = 0;
    for (int i = 0; i < n; i++) {
        if (b[i] > a[i]) {
            cnt += (b[i] - a[i] + 1) / 2;
        }
    }

    if (cnt <= bsum - asum) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl k;
    cin >> k;
    intl ans = 0;
    queue<intl> q;
    repi(i,1,10){
        q.push(i);
        ans++;
        if(ans == k){
            cout << q.back() << endl;
            return 0;
        }
    }
    while(true){
        intl a = q.front();
        q.pop();
        intl b = a % 10;
        intl c = a * 10 + b;
        if(c % 10){
            q.push(c - 1);
            ans++;
            if(ans == k)break;
        }
        q.push(c);
        ans++;
        if(ans == k)break;
        if(c % 10 != 9){
            q.push(c + 1);
            ans++;
            if(ans == k)break;
        }
    }
    cout << q.back() << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int const MX = 100009;
int N, K, a[MX], dp[MX][2];
// dp[k][p] = can player p win with k stones if so 1 else 2
int const lose = 2, win = 1;
void read_input()
{
    cin >> N >> K;
    for(int i = 1; i <= N; ++i) {
        cin >> a[i];
    }
}


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

    for(int i = 0; i < a[0]; ++i) {
        dp[i][0] = dp[i][1] = 0;
    }

    for(int k = 0; k <= K; ++k) {
        for(int p = 0; p <= 1; ++p) {
            for(int i = 1; i <= N; ++i) {
                int n = a[i];
                if(n > k) {
                    continue;
                }
                if(dp[k - n][1 - p] == lose) {
                    dp[k][p] = win;
                    break;
                }
            }
            if(dp[k][p] == 0) dp[k][p] = lose;
        }
    }
    if(dp[K][0] == win) cout << "First" << endl;
    else cout << "Second" << endl;
}


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

int main()
{
	int L,R,d;
	cin >> L >> R >> d;
	int ans = 0;
	for (int i = L; i <= R; ++i)
	{
		if (i % d == 0) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <cstring>
#include <ctype.h>
#include<stdlib.h>

#define flin            freopen("input.txt", "r", stdin); 
#define flout           freopen("output.txt", "w", stdout);
#define ll              long long
#define ull             unsigned long long
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl              '\n'
#define nll             '\0'
#define pb              push_back
#define bdyptb          return 0;
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define mset(a, b)      memset(a, b, sizeof(a));
#define testcase        ll t,tt; cin>>tt; for(t=1;t<=tt;t++)

#define pi acos(-1.00)   
#define mx 1000007

using namespace std;

int main()
{
	fastio;
	int n;
	cin>>n;
	int d1[n], d2[n];

	for(int i=0; i<n; i++)
	{
		cin>>d1[i]>>d2[i];
	}

	int c=0;

	for(int i=0; i<n; i++)
	{
		if(d1[i]==d2[i])
			c++;
		else
			c=0;
		if(c==3) break;
	}

	if(c==3)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	 

    
}

Measured memory_bytes: 3644
N, M = map(int, input().split())
L=[]
R=[]
for _ in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

min_r = min(R)
max_l = max(L)
if max_l>min_r:
    print(0)
else:
    print(min_r-max_l+1)


Measured memory_bytes: 10996
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD ((int)1e9 + 7)
#define atoi(x) ((x)-'0')
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

int dx[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] = { 0, 0, 1, -1, 1, -1, 1, -1 };

int n, m, k, ans;
char arr[10][10];

int main() {
	fastio;
	cin >> n >> m >> k;
	FOR(i, n) FOR(j, m) {
		cin >> arr[i][j];
	}
	for (int i = 0; i < (1 << n); i++) {
		for (int j = 0; j < (1 << m); j++) {
			int cnt = 0;
			FOR(y, n) FOR(x, m) {
				if (arr[y][x] == '#' && (i & (1<<y)) && (j & (1<<x))) cnt++;
			}
			if (cnt == k) ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
#include<math.h>
using namespace std;

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

	return 0;
}

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

vector<int> graph[100005];
bool visit[100005];

vector<int> path;
vector<int> path2;

void dfs(int t)
{
    visit[t] = true;
    path.push_back(t);
    for (int nxt : graph[t])
    {
        if (visit[nxt] == false)
        {
            dfs(nxt);
            return;
        }
    }
}

int main()
{
    cin.sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    dfs(1);
    swap(path, path2);
    dfs(1);

    printf("%zd\n", path.size() + path2.size() - 1);
    for (int i = (int)path2.size() - 1; i >= 1; i--)
    {
        printf("%d ", path2[i]);
    }
    for (int t : path) printf("%d ", t);
    printf("\n");
}


Measured memory_bytes: 9720
#include "bits/stdc++.h"
using namespace std;

void DFS(vector<int> &allNums, int num, set<int> nums) {
    if (nums.size() == 0)allNums.push_back(num);
    for (auto itr = nums.begin(); itr != nums.end(); ++itr) {
        set<int> s = nums;
        s.erase(*itr);
        DFS(allNums, num * 10 + *itr, s);
    }
}

int main() {
    int N;
    cin >> N;
    int P, Q;
    P = Q = 0;
    for (int i = 0; i < N; i++) {
        int num;
        cin >> num;
        P = P * 10 + num;
    }
    for (int i = 0; i < N; i++) {
        int num;
        cin >> num;
        Q = Q * 10 + num;
    }
    vector<int> allNums;
    set<int> nums;
    for (int i = 0; i < N; i++) {
        nums.insert(i + 1);
    }
    DFS(allNums, 0, nums);
    sort(allNums.begin(), allNums.end());
    

    int a = 0;
    int b = 0;
    for (int i = 0; i < allNums.size(); i++) {
        //cout << allNums[i] << endl;
        if (P == allNums[i])a = i;
        if (Q == allNums[i])b = i;
    }
    cout << abs(a - b);
}

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

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

    static class AizuFIbo {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();

            if (n == 0 || n == 1) {
                out.println("1");
            } else {
                long[] a = new long[n + 1];
                a[0] = 1;
                a[1] = 1;

                for (int i = 2; i <= n; i++) {
                    a[i] = a[i - 1] + a[i - 2];
                }

                out.printf("%d\n", a[n]);
            }
        }

    }
}




Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
#define bye ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define Mod (ll)(1e9+7)
#define matrix vector<vector<ll> >
#define fst first
#define snd second
#define all(c) ((c).begin()), ((c).end())
#define double long double
#define PI acos(-1)

ll n,m,k;
ll a[100100],ans,temp;

ll fastpow(ll n,ll po){
    if(!po)
        return 1;
    ll mul = fastpow(n,po/2);
    mul %= Mod;
    mul*=mul;
    mul%=Mod;
    if(po&1)
        mul*=n;
    mul%=Mod;
    return mul;
}

int main()
{
    bye;
    cin >> n >> k;
    for(int i=k;i>=1;i--){
        ll ans = fastpow(k/i,n);
        for(int j=i+i;j<=k;j+=i){
            ans-=a[j];
            ans+=Mod;
            ans%=Mod;
        }
        a[i] = ans;
        temp+=(i*ans)%Mod;
        temp%=Mod;
    }
    cout << temp << "\n";
    return 0;
}


Measured memory_bytes: 4360
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

double dist(ll x1, ll x2, ll y1, ll y2){
    double d = sqrt(pow(x1-x2, 2) + pow(y1-y2, 2));
    return d;
}

int main() {
    int N;
    cin >> N;
    
    vector<vector<ll>> por(N, vector<ll>(2));
    vector<int> nums;
    REP(i, N){
        cin >> por[i][0] >> por[i][1];
        nums.push_back(i);
    }

    double ans = 0, num = 0;
    do {
        num++;
        REP(i, N-1){
            ans += dist(por[nums[i]][0], por[nums[i+1]][0], por[nums[i]][1], por[nums[i+1]][1]);
        }
    } while (next_permutation(nums.begin(), nums.end()));
    ans = ans/num;
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3796
#include <stdio.h>
#define MAX 250
int parent(int );
int left(int );
int right(int );



int main(){
  int i;
  int n;
  int H[MAX+1];

  scanf("%d",&n);

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

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,H[i]);
    if(parent(i) >= 1 )printf("parent key = %d, ",H[parent(i)] );
    if(left(i) <= n )printf("left key = %d, ",H[left(i)] );
    if(right(i) <= n )printf("right key = %d, ",H[right(i)] );
    printf("\n");
  }

  
  return 0;
}


int parent(int i){
  return i/2;
}

int left(int i){
  return i*2;
}

int right(int i){
  return i*2+1;
}



Measured memory_bytes: 2048
#include<stdio.h>

int main(){
	
	long loan = 100000;
	int week, i;
	
	scanf("%d", &week);
	
	for(i = 0; i < week; i++){
		
		loan *= 1.05;
		loan = (loan + 999) / 1000;
		loan *= 1000;
				
	}
	
	printf("%d\n", loan);
	
    return 0;
}

Measured memory_bytes: 592
#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 FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF LLONG_MAX
#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 n; double k; cin >> n >> k;
    double ans = 0;
    FOR(i, 1, n + 1) {
        double num = max((double)0, ceil(log10(k / i) / log10(2)));
        ans += pow((double)1 / 2, num);
    }
    printf("%.12f\n", (double)1 / n * ans);
    return 0;
}

Measured memory_bytes: 512
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


class BIT:
    def __init__(self, size):
        self.bit = [0] * size
        self.size = size
        self.total = 0

    def add(self, i, w):
        x = i + 1
        self.total += w
        while x <= self.size:
            self.bit[x - 1] += w
            x += x & -x
        return

    def sum(self, i):
        if i < 0:
            return 0
        res = 0
        x = i + 1
        while x:
            res += self.bit[x - 1]
            x -= x & -x
        return res

    def interval_sum(self, i, j): # i <= x < j の区間
        return self.sum(j - 1) - self.sum(i - 1)


n = I()
s = list(S())
D = defaultdict(lambda:BIT(n))
for i in range(n):
    D[ord(s[i])].add(i, 1)

q = I()
for j in range(q):
    qi, i, c = LS()
    i = int(i) - 1
    if qi == '1':
        D[ord(s[i])].add(i, -1)
        D[ord(c)].add(i, 1)
        s[i] = c
    else:
        l, r = i, int(c)
        ret = 0
        for k in range(97, 123):
            if D[k].sum(r - 1) > D[k].sum(l - 1):
                ret += 1
        print(ret)


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

int main()
{
ll n , k ;
cin >> n >> k ;
vector<ll> a(n);
vector<ll> b(n);
rep(i, n){
  cin >> a[i] >> b[i];
}
vector<ll> z;
ll mask=0;
if(k==0){
  rep(i,n)if(a[i]==0)ans+=b[i];
  cout << ans << endl;
  return 0;
}
for(ll i=63-__builtin_clzll(k);i>=0;i--){
  ll an=0;
  mask+=(1LL<<i);
  if(((k>>i) & 1LL)==0)continue;
  rep(j,n){
    if((a[j]&mask)==0&&a[j]<=k)an+=b[j];
  }
  mask-=(1LL<<i);
  ans=max(ans,an);
}
ll ann=0;
rep(j,n){
  if((a[j]&mask)==0&&a[j]<=k)ann+=b[j];
}
ans=max(ans,ann);
cout << ans << endl;
return 0;
}


Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();

		//判定
		String ans ="";
		if (a <= 8 && b <= 8) {
			ans = "Yay!";
		} else {
			ans = ":(";
		}

		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>
#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

struct dat{
    int left,cnt;
};

int main(){
    int N,K;
    cin >> N >> K;
    string s;
    cin >> s;
    int pos=0,cnt=0,length_one=0,max_len_one=0;
    vector<dat> vec;

    rep(i,N){
        if(s[i] == '0'){
            cnt++;
            max_len_one = max(max_len_one, length_one);
            length_one=0;
        }else{
            length_one++;
            if(cnt > 0){
                pos = i-1;
                vec.push_back({pos,cnt});
                cnt = 0;
            }
        }
    }
    if(cnt > 0)vec.push_back({N-1,cnt});

    if(K >= vec.size()){
        cout << N << endl;
        return 0;
    }else if(K == 0){
        cout << max_len_one << endl;
        return 0;
    }

    int M = max_len_one;
    M = max(M, vec[K].left - vec[K].cnt + 1);
    reps(i,1,N-K-1){
        if(i+K>vec.size()-1) break;
        M = max(M, vec[i+K].left - vec[i-1].left - vec[i+K].cnt);
    }

    M = max(M,N - (vec[(vec.size()-1) - K].left+1));
    cout << M << endl;

    return 0;
}

Measured memory_bytes: 1020
#include <math.h>
#include <stdio.h>

#define DIV 1000000007
int main() {
    int n;
    scanf("%ld", &n);
    long b[60] = { 0 };
    for (int i = 0; i < n; i++) {
        unsigned long a;
        scanf("%lu", &a);
        for (int j = 0; a > 0; j++) {
            b[j] += a % 2;
            a /= 2;
        }
    }

    unsigned long sum = 0;
    for (int j = 0; j < 60; j++) {
        unsigned long c = (long)pow((double)2, (double)j);
        c %= DIV;
        sum += ((b[j] * ((n - b[j])) % DIV) * c) % DIV;
        sum %= DIV;
    }

    printf("%d\n", (int)sum);
    return 0;
}


Measured memory_bytes: 256
fun main (args : Array<String>) {
	val (num1, num2) = readLine()!!.split(" ").map(String::toInt)
	val app1 = num1.toInt()
	var app2 = num2.toInt()
	app2 += app1 * 3
	var result : Int = (app2 / 2)
	println("${result}")
	
}

Measured memory_bytes: 37940
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

bool con[8][8];

int main(){
  int N,M;
  cin >> N >> M;
  rep(i,M){
    int a,b;
    cin >> a >> b;
    a--; b--;
    con[a][b]=1;
    con[b][a]=1;
  }
  vector<int> v(0);
  for(int i=1;i<N;i++){
    v.push_back(i);
  }
  int ans=0;
  do{
    bool flag=true;
    if(con[0][v[0]]==0) flag=false;
    for(int i=0;i<=N-3;i++){
      if(con[v[i]][v[i+1]]==0) flag=false;
    }
    if(flag) ans++;
  }while(next_permutation(all(v)));
  cout << ans << endl;
}

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

using namespace std;

int main(){
  int n,m;
  cin>>n>>m;
  int dp[51][51][9];
  fill(dp[0][0],dp[51][0],-(1<<29));
  dp[0][m][0]=0;
  for(int i=0;i<n;i++){
    int a,b,c;
    cin>>a>>b>>c;
    for(int j=0;j<=m;j++){
      for(int k=0;k<=8;k++){
	for(int l=0;l<=8&&l<=j;l++){
	  for(int p=0;p<=l;p++){
	    for(int o=0;o+p<=8&&o<=k;o++){
	      int nr=j-l;
	      dp[i+1][nr][l]=max(dp[i+1][nr][l],dp[i][j][k]+((!p&&!o)?c:a*p+b*o));
	    }
	  }
	}
      }
    }
  }
  cout<<*max_element(dp[n][0],dp[n+1][0])<<endl;
}

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

const int inf = 1e9 + 13;
const int maxn = 202;

int n;
char s[maxn];
int g[maxn][maxn], clr[maxn];
bool bipartite = 1;

void dfs (int u) {
    for (int v = 0; v < n; ++v) {
        if (g[u][v] == 1) {
            if (clr[v] == clr[u])
                bipartite = 0;
            else if (clr[v] == 0) {
                if (clr[u] == 1)
                    clr[v] = 2;
                else
                    clr[v] = 1;
                dfs(v);
            }
        }
    }
}

signed main () {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%s", &s);
        for (int j = 0; j < n; ++j) {
            if (s[j] == '0')
                g[i][j] = inf;
            else
                g[i][j] = 1;
        }
    }
    clr[0] = 1;
    dfs(0);
    if (!bipartite)
        printf("-1\n");
    else {
        for (int k = 0; k < n; ++k) {
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < n; ++j)
                    g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
        int ans = -1;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j)
                ans = max(ans, g[i][j]);
        }
        printf("%d\n", min(ans + 1, n));
    }
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static int maxVal = 1000000 + 1;
    static int[] arr;
    static void Main(string[] args)
    {
        bool ans = false;
        arr = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        if (ansCheck(0, 1, 2) || ansCheck(1, 2, 0) || ansCheck(0, 2, 1)) ans = true;
        if (ans) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }

    static bool ansCheck(int a , int b , int c)
    {
        if (arr[a] == arr[b] && arr[b] != arr[c]) return true;
        return false;
    }
}

Measured memory_bytes: 18884
#include <bits/stdc++.h>
using namespace std;
int main() {
  int D, N;
  cin >> D >> N;
  if (D == 0 && N == 100) {
    cout << 101 << endl;
  }
  else if (D == 0 && N != 100) {
    cout << N << endl;
  }
  else if (D == 1 && N == 100) {
    cout << 10100 << endl;
  }
  else if (D == 1 && N != 100) {
    cout << N * 100 << endl;
  }
  else if (D == 2 && N == 100) {
    cout << 1010000 << endl;
  }
  else {
    cout << N * 10000 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//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",なんちゃら)
//最大公約数
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);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

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;
}

//long longしか使わない
//素数は1より大きい
int main() {
	string s;
	cin >> s;
	ll n = s.length();
	rep(i, n) {
		if (s[i] == '?')s[i] = 'D';
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3724
from sys import stdin


def get_result(data):
    S = data[0]
    mod_all_bit = [0] * 2019
    mod_all_bit[0] = 1
    # 10**i の mod を漸化式的に事前計算
    # こうすることで計算が効率化できる
    ten_i_mod = [0] * len(S)
    ten_i_mod[0] = 1
    for i in range(len(S)-1):
        ten_i_mod[i+1] = (ten_i_mod[i] * 10) % 2019
    mod = 0
    for i in range(len(S)):
        mod = (mod + ten_i_mod[i] * int(S[-(i+1)])) % 2019
        mod_all_bit[mod] += 1
    ans = 0
    for val in mod_all_bit:
        if val >= 2:
            ans += val * (val-1) * 0.5
    return int(ans)


if __name__ == '__main__':
    data = list(map(str, stdin.readline().rstrip().split(' ')))
    result = get_result(data)
    print(result)


Measured memory_bytes: 16108
N, Y = gets.split.map(&:to_i)

for yukichi in 0..[N, Y/10000].min
	for higuchi in 0..[N-yukichi, (Y-yukichi*10000)/5000].min
		noguchi = N - yukichi - higuchi
		if yukichi*10000 + higuchi*5000 + noguchi*1000 == Y
			print "#{yukichi} #{higuchi} #{noguchi}"
			exit
		end
	end
end

print "-1 -1 -1"

Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>

using namespace std;

int main(){

    int a,b,c,n;
    cin >> a >> b >> c;
    for(int i=a; i<=b; i++){
        if(c%i==0){
            n += 1;
        }
    }
    cout << n <<endl;

    return 0;
}



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

int main(){
    int N;
    cin >> N;
    vector<long long>A(N);
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    if (N % 2 == 0) {
        for (int i = 0; i < N / 2; i++) {
            ans += A.at(N-1-i) * 2;
        }
        cout << ans - A.at(N-1);
    }
    else {
        for (int i = 0; i < N / 2 + 1; i++) {
            ans += A.at(N-1-i) * 2;
        }
        cout << ans - A.at(N-1) - A.at(N-1-N/2);
    }
}

Measured memory_bytes: 4736
#include<iostream>
using namespace std;
string s[9];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
int r;
bool in(int a)
{
	return 0<=a&&a<=4;
}
bool check(int a,int b,int c,int d)
{
	if(!(in(a)&&in(b)&&in(c)&&in(d)))return false;
	if(a==c)
	{
		return s[2*a][b<d?b:d]=='1';
	}
	else
	{
		return s[2*(a<c?a:c)+1][b]=='1';
	}
}
main()
{
	for(int i=0;i<9;i++)cin>>s[i];
	int x=0,y=0;
	while(1)
	{
		for(int dr=3;dr<7;dr++)
		{
			int nr=(r+dr)%4;
			int tx=x+dx[nr],ty=y+dy[nr];
			if(check(x,y,tx,ty))
			{
				r=nr;
				x=tx;
				y=ty;
				break;
			}
		}
		cout<<"RDLU"[r];
		if(x==0&&y==0)break;
	}
	cout<<endl;
}



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

using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	vector<int> dif(n);
	for(int &i:dif){
		scanf("%d",&i);
	}
	sort(dif.begin(),dif.end());
	printf("%d\n",dif[n/2]-dif[n/2-1]);
	return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python
# coding: utf-8

# In[1]:


N,D = map(int, input().split())
ans = 0
for _ in range(N):
    X,Y = map(int, input().split())
    if X**2 + Y**2 <= D**2:
        ans += 1
print(ans)


# In[ ]:






Measured memory_bytes: 9168
//
//  main.cpp
//  D_Insertion
//
//  Created by user1 on 2017/06/10.
//  Copyright © 2017年 user1. All rights reserved.
//
#include <iostream>
#define COLOR  8
int N;
std::string S;

int left = 0;
int right = 0;

void solve(){
    std::cin >> N;
    std::cin >> S;

    for(int sind=0; sind < N; sind++){
        if(S[sind] == '(') left++;
        if(S[sind] == ')'){
            //ペアがいる場合
            if(left>=1){
                left--;
                //ぺあが　いない場合
            }else{
                right++;
                S= "(" + S;
                N++;
                sind++;
            }
        }
    }
    
    if(left >= 1){
        for(int i=0; i<left; i++){
            S = S+")";
            N++;
        }
    }
    
    //printf("%d %d %d\n", left,right,N);
    printf("%s\n", S.c_str());
}

int main(int argc, const char * argv[]) {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll dp[400][400][135],c[405][405],f[405],r[405],rui[405][405][135];
int n,a[405],b[405],pos[405],pos2[405],t[405][405];
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int main(){
	cin>>n;
	repn(i,n){
		cin>>a[i];
		pos[a[i]] = i;
	}
	repn(i,n){
		cin>>b[i];
		pos2[b[i]] = i;
	}
	rep(i,405)rep(j,i+1){
		if(j==0||j==i) c[i][j]=1;
		else c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	}
	f[0] = 1;
	repn(i,400) f[i]=f[i-1]*1LL*i%mod;
	rep(i,401) r[i] = modpow(f[i],mod-2);
	rep(i,n+1){
		rep(j,n+1){
			repn(k,n){
				if(pos[k]<=i || pos2[k]<=j) t[i][j]++;
			}
		}
	}
	//fix start
	dp[0][0][0] = 1;
	for(int k=1;k<=n/3;k++){
		repn(x,n){
			repn(y,n){
				rui[x][y][k] = rui[x-1][y][k]+rui[x][y-1][k]-rui[x-1][y-1][k];
				rui[x][y][k] %= mod;
				if(x<pos[b[y]] && y<pos2[a[x]] && 2*k<=t[x][y] && t[x][y]<=3*k-1);
				else continue;
				dp[x][y][k] = rui[x-1][y-1][k-1];
				dp[x][y][k] += dp[0][0][k-1]*f[3*k-3-t[0][0]]%mod;
				dp[x][y][k] = dp[x][y][k]%mod*r[3*k-3-t[x-1][y-1]]%mod;
				rui[x][y][k] += dp[x][y][k]*f[3*k-t[x][y]]%mod;
				rui[x][y][k] %= mod;
			}
		}
	}
	//fix end
	ll ans = 0;
	rep(i,n+1)rep(j,n+1){
		ll mul = f[n-t[i][j]];
		ans = (ans+dp[i][j][n/3]*mul%mod)%mod;
	}
	rep(i,n){
		if(i%3 != 0) ans = ans*1LL*i%mod;
	}
	cout<<(ans%mod+mod)%mod<<endl;
}

Measured memory_bytes: 341888
from collections import deque
N = int(input())
A = list(map(int, input().split()))

L = [(10**18, 10**18, 10**18)] * (N + 1)
left = 0
right = 0
que = deque([])
for i, a in enumerate(A, start=1):
    right += a
    que.append(a)
    while len(que) > 1 and abs(right - left) > abs((right - que[0]) - (left + que[0])):
        q = que.popleft()
        left += q
        right -= q
    L[i] = (abs(left - right), left, right)

R = [(10**18, 10**18, 10**18)] * (N + 1)
left = 0
right = 0
que = deque([])
for i, a in enumerate(A[::-1], start=1):
    right += a
    que.append(a)
    while len(que) > 1 and abs(right - left) > abs((right - que[0]) - (left + que[0])):
        q = que.popleft()
        left += q
        right -= q
    R[i] = (abs(left - right), left, right)

R = R[::-1]

ans = 10**18
for mid in range(1, N):
    X = [L[mid + 1][1], L[mid + 1][2], R[mid + 1][1], R[mid + 1][2]]
    if min(X) == 0:
        continue
    ans = min(ans, max(X) - min(X))
print(ans)


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

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> P(N), C(N);
  rep(i,N) cin >> P[i];
  rep(i,N) cin >> C[i];
  rep(i,N) P[i]--; // 0始まりに合わせる
  
  ll ans = -1e18; //負にしておく
  rep(si, N){ // 開始位置の変更
    int x = si;
    vector<int> s;
    ll tot = 0; 
    // 周期のカウント
    while(1) {
      x = P[x]; // 移動後の位置
      s.push_back(C[x]); // 周期内のスコア追加
      tot += C[x];
      if (x==si) break;
    }
    int l = s.size();
    ll t = 0; // 累積和
    rep(i,l) { // 1周期分の試行
      t += s[i];
      if (i+1 > K) break;
      ll now = t;
      if (tot > 0) { // totが負になる場合周期を繰り返さない方がいい
        ll e = (K-i-1)/l; // 何周できるか
        now += tot*e;
      }
      ans = max(ans, now);
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#define int long long
using namespace std;

int n;
int a[13];
int b[13];

signed main() {
	int i;
	cin >> n;
	
	a[0] = 1;
	b[0] = 0;
	for (i = 1; i <= 12; i++) {
		a[i] = a[i - 1] * 26;
		b[i] = b[i - 1] + a[i];
	}
	
	for (i = 1; n > b[i]; i++);
	
	int len = i;
	int m = n - b[len - 1] - 1;
	
	//mを26進数で
	string ans;
	for (i = 0; i < len; i++) {
		ans += (char)('a' + m % 26);
		m /= 26;
	}
	
	for (i = ans.length() - 1; i >= 0; i--) cout << ans[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (i = 0; i < n; ++i) 
#define REP(i,k,n) for (i = k; i <= n; ++i) 
#define repr(i,k,n) for (i = k; i >= n; --i) 
#define F first;
#define S second;
#define PB push_back;
#define MP make_pair;
// #define ll long long;
#define show(x) cerr << #x << " is " << x << endl;

using namespace std;

typedef vector<int> vi; 
typedef pair<int, int> pll;
typedef long long ll;
typedef unsigned long long ull;

double dist(vector<int> &a, vector<int> &b){
    double res = (double)sqrt(((a[0] - b[0])*(a[0] - b[0])) + ((a[1] - b[1])*(a[1] - b[1])));
    return res;
}
// typedef std::numeric_limits< double > dbl;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cout.precision(12);
    int n;
    cin >> n;
    vector<vector<int>> v(n);
    for(int i = 0; i < n; ++i){
        int a, b;
        cin >> a >> b;
        v[i].push_back(a);
        v[i].push_back(b);
    }
    vector<long> fact(10, 1);
    for(int i = 2; i < 10; ++i){
        fact[i] = i*fact[i-1];
    }
    double res = 0;
    long s = fact[n-1]*2;
    for(int i = 0; i < n; ++i){
        for(int j = i+1; j < n; ++j){
            double val = dist(v[i], v[j]);
            // cout << val << endl;
            res += val;
        }
    }
    res = (double)res/(double)fact[n];
    // cout << s << endl;
    cout << (res*s) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <time.h>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
    int N; cin >> N;
    vector<int> v(N),v2(N);

    for (int i = 1; i <= N; i++){
        int k; cin >> k;
        v[k-1] = i;
    }
    int q = 0;
    for (int i = N-1; i >= 0; i--){
        q += v[i];
        v2[i] = q;
    } 
    int p = 0; 
    for (int i = 0; i < N; i++){
        p += v[i];
        if (i) cout << " ";
        cout << p;
    }
    cout << endl;
    for (int i = 0; i < N; i++){
        if (i) cout << " ";
        cout << v2[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 768
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int[] cnt = new int[26];
		
		for(int i=0;i<s.length();i++) {
			cnt[s.charAt(i)-'a']++;
		}
		
		System.out.println(found(cnt));
	}
	static String found(int[] cnt) {
		for(int i=0;i<26;i++) {
			if(cnt[i]==0)
				return (char)(i+'a')+"";
		}
		return "None";
	}
}


Measured memory_bytes: 25320
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s,t;
    cin >> s >> t;
    int ans = 0;
    
    for (int i= 0; i<s.length(); i++){
        if (s[i] != t[i]) ans += 1; 
    }
    
    cout << ans << endl;
}


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

int main()
{
    long W, H, x, y;

    cin >> W >> H >> x >> y;

    cout << double(W * H) / 2 << " ";
    if(x == W / 2 && y == H / 2 && W % 2 == 0 && H % 2 == 0){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100010
int a[MAXN],n,f;
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++)
		if(i+1>a[i+1])
		{
			if((a[i]-i)%2) f=1;
			bool c=0;
			for(int j=i+1;a[j]==i&&!f;j++)
				c^=1;
			if(c==1) f=1;
			break;
		}
	if(f) printf("First\n");
	else printf("Second\n");
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<list>
#include<bitset>

using namespace std;

/*
125

125
1 + 25 + 12 + 5
1 + 2 + 5

176

*/

char s[11];

bool bit(int n, int i){
  // From right
  int ret;
  ret = (n >> i) & 1;
  fprintf(stderr, "bit(%d, %d) = %d\n", n, i, ret);
  return ret;
}

long long int pow(int x, int n){
  if(n == 0)
    return 1;

  return x * pow(x, n - 1);
}

long long int calc(int i, int b){
  if(i < strlen(s) - 1){
    int bb = b | (1 << i);
    fprintf(stderr, "bb = %d\n", bb);
    return calc(i + 1, b) + calc(i + 1, bb);
  }

  // Reached to a leaf
  //fprintf(stderr, "--- bitmask = %d ---\n", b);
  cerr << "--- bitmask = " << bitset<10>(b) << "---" << endl;
  long long int ret = 0, a = atoll(s);
  int cnt = 0;
  for(int j = 0; j < strlen(s) - 1; j++){
    if(bit(b, j)){
      long long int d = a % pow(10, cnt + 1);
      ret += d;
      a /= pow(10, cnt + 1);
      cnt = 0;

      fprintf(stderr, "%lld\n", d);
    } else {
      cnt++;
    }
  }
  ret += a;
      fprintf(stderr, "%lld\n", a);
  return ret;
}

int main(){
  scanf("%s\n", s);
  printf("%lld\n", calc(0, 0));

  return 0;
}


Measured memory_bytes: 256
# include <stdio.h>

int main(){
    int A, B;
    scanf("%d %d", &A, &B);
    if(A+B<=16){
        if(A<=8 && B<=8){
            printf("Yay!");
        }
        else{
            printf(":(");
    }
    }
    else{
        printf(":(");
    }
    return 0;
}


Measured memory_bytes: 128
<?php
  list($s) = explode(" ", trim(fgets(STDIN)));


  $a = lcm(360, $s);
  echo ($a / $s);

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

// 最大公倍数（２つ）
function lcm($a, $b){
  return $a*$b/gcd($a, $b);
}

    
    
    

Measured memory_bytes: 16192
#include <bits/stdc++.h>
 
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define f(i,a,b) for(ll i=a;i<b;i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define en '\n'
 
int main()
{
	IOS;
	int t=1;
//	cin>>t;
	while(t--)
	{
		ll n;
      cin>>n;
      ll k,a[n+1];
      set<ll> ms;
      set<ll>::iterator it;
      ll s=0;
      ll mi=0;
      f(i,1,n+1)
      {
        cin>>k;
        a[i]=k-i;
        ms.insert(a[i]);
      }
      vector<int> v(a+1,a+n+1);
      sort(all(v)); 
      ll p=v[v.size()/2];
      f(i,1,n+1)
        mi+=abs(a[i]-p);
      cout<<mi;
	}
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1000000
#define MOD 1000000007
#define rint register int
#define gc() getchar()
inline int read(int r=0,int s=0,int c=gc()){for(;c<48||c>57;s=c,c=gc());for(;c>=48&&c<=57;(r*=10)+=c-48,c=gc());return s^'-'?r:-r;}
inline int fxp(int s, int n=MOD-2){int a=1; for(; n; n&1 ? a = 1ll*a*s%MOD : 0, s = 1ll*s*s%MOD, n >>= 1); return a;}
int fac[MAXN+5], efac[MAXN+5], f[MAXN+5], s[MAXN+5], n, Ans; inline int C(int n, int k){return n<0||k<0||n<k?0:1ll*fac[n]*efac[k]%MOD*efac[n-k]%MOD;}
int main()
{
	n = read(); for(rint i = fac[0] = 1; i <= n; fac[i] = 1ll*i*fac[i-1]%MOD, i++); efac[n] = fxp(fac[n]); for(rint i = n; i; efac[i-1] = 1ll*i*efac[i]%MOD, i--);
	for(rint i = 1; i <= n; f[i] = 1ll*C(i-1,n-i-1)*fac[i]%MOD*fac[n-1-i]%MOD, f[i] = (f[i]+MOD-s[i-1])%MOD, s[i] = (s[i-1]+f[i])%MOD, i++);
	for(rint i = 1; i < n; Ans = (Ans+1ll*i*f[i])%MOD, i++); printf("%d\n",Ans); return 0;
}

Measured memory_bytes: 15872