akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<string>
#include<vector>
using namespace std;

int main() {
	int n;cin>>n;
	string s;cin>>s;
	int lcount=0;
	int rcount=0;
	vector<char> ans;
	for(int i=0;i<n;i++){
		if(s[i]=='('){
			lcount++;
//			ans.push_back('(');
		}else{
			if(lcount){
				lcount--;
//				ans.push_back(')');
			}else{
//				ans.push_back('(');
//				ans.push_back(')');
				rcount++;
			}
		}
	}
//	for(int i=0;i<lcount;i++){
//		ans.push_back(')');
//	}

//	for(int i=0;i<n;i++){
//		if(s[i]=='('){
//			lcount++;
//		}else{
//			rcount++;
//		}
//	}
	for(int i=0;i<rcount;i++){
		ans.push_back('(');
	}
	for(int i=0;i<n;i++){
		ans.push_back(s[i]);
	}
	for(int i=0;i<lcount;i++){
		ans.push_back(')');
	}
	for(int i=0;i<ans.size();i++){
		cout<<ans[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  ll n, m;
  cin >> n >> m;
  ll ans = min(n, m/2);
  m -= ans*2;
  if(m > 0){
    ans += m/4;
  }
  // if(2*n >= m){
  //   ans = n;
  // }else{
  //   ans = n;
  //   m -= ans * 2;
  //   ans += m/4;
  // }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
S = input()
#N = int(input())
#N = list(map(int, input().split()))
# a = list(map(int, input().split()))
# X = [int(input()) for _ in range(N)]

ans = 'YES'
keyence = 'keyence'

for i in range(len(S)):
    if i == 7:
        S = S[0:7]
        break
    if keyence[i] == S[i]:
        continue
    else:
        S = S[0:i] + S[len(S) - 1 - 6 + i :]
        break


if S == keyence:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3060
n = int(input())
town = []
for i in range(n):
    s, p = input().split()
    p = int(p)
    town.append([s, p, i + 1])

town.sort(key=lambda x: x[1], reverse=True)
town.sort(key=lambda x: x[0])

for i in town:
    print(i[2])


Measured memory_bytes: 3060
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	
      	int r = sc.nextInt();
      	
      
  		if(r < 1200) System.out.println("ABC");
      	else if(r < 2800) System.out.println("ARC");
      	else System.out.println("AGC");
        
	}
}


Measured memory_bytes: 35760
N, K = map(int, input().split())
h = [0]*N
for i in range(N):
    h[i] = int(input())
h.sort()
ans = int(1e18)
for i in range(N-(K-1)):
    tmp = h[i+K-1] - h[i]
    ans = min(ans, tmp)
print(ans)


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


int main() {
 int a,b,c;
 cin >> a >> b >> c;
 int cnt=0;
 if(a == b) cnt++;
 if(b== c) cnt++;
 if(a==c) cnt++;

 if(cnt == 1) cout << "Yes" << endl;
 else cout << "No" << endl;
 
 return 0;

}


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

int main(void){
	int a[4][3][10],n,b,f,r,v;//a棟数、階数、部屋番号,n入力件数,b棟数,f階数,r部屋番号,v人数

	for(int i=0;i<4;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<10;k++)a[i][j][k]=0;
		}
	}
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>b>>f>>r>>v;
		a[b-1][f-1][r-1]+=v;
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<10;k++)cout<<" "<<a[i][j][k];
			cout<<endl;
		}
		if(i!=3){
			for(int k=0;k<20;k++)cout<<"#";
			cout<<endl;
		}
		//cout<<endl;
	}	
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

int solve(int l, int r, VI &h) {
  bool flag = true;
  int idx = -1;
  if(r - l > 0 && l > -1) {
    FOR(i, l, r) {
      if(h[i] < 1) {
        flag = false;
        idx = i;
      }
    }
    if(flag) {
      FOR(i, l, r) h[i] -= 1;
      return 1 + solve(l, r, h);
    }
    else {
      return solve(l, idx, h) + solve(idx + 1, r, h);
    }
  }
  else return 0;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI h(n);
  rep(i, n) cin >> h[i];
  int ans = solve(0, n, h);
  out(ans);
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> res(n);
  for (int i = 1; i <= 100; i++){
    for (int j = 1; j <= 100; j++){
      for (int k = 1; k <= 100; k++){
        ll ans = i * i + j * j + k * k;
        ans += i * j + j * k + k * i;
        if(ans <= n) res[ans-1]++;
      }
    }
  }
  rep(i, n){
    cout << res[i] << endl;
  }
}

Measured memory_bytes: 3596
from itertools import accumulate
from collections import Counter
n,m = map(int,input().split())
a = list(map(int,input().split()))
a1 = list(map(lambda x: x % m ,list(accumulate(a))))
b = Counter(a1)
c = 0
for i in b:
    if i == 0:
        c += b[0]
    if b[i] >= 2:
        c += b[i]*(b[i]-1) // 2

print(c)

Measured memory_bytes: 17012
use proconio::input;
use proconio::marker::Usize1;

fn dfs(
    ais: &mut Vec<usize>,
    n: usize,
    m: usize,
    abcds: &Vec<(usize, usize, usize, usize)>,
) -> usize {
    if ais.len() == n {
        return abcds
            .iter()
            .map(|&(a, b, c, d)| if ais[b] - ais[a] == c { d } else { 0 })
            .sum();
    }

    let &ai = ais.last().unwrap_or(&1);
    let mut res = 0;
    for aj in ai..=m {
        ais.push(aj);
        res = std::cmp::max(res, dfs(ais, n, m, abcds));
        ais.pop();
    }
    res
}

fn main() {
    input! {
        n: usize,
        m: usize,
        q: usize,
        abcds: [(Usize1, Usize1, usize, usize); q],
    };

    let mut ais = vec![];
    let ans = dfs(&mut ais, n, m, &abcds);
    println!("{}", ans);
}


Measured memory_bytes: 2128
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;


// 入力 // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル


int main() {
    int N; cin >> N;
 long long dp[100010][3];
    long long a[100010][3];
  for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    // 初期化は既に 0 に初期化される
    // 初期条件も既に 0 で OK

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k){
                  continue;
                }
                dp[i+1][k]=max(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    // 答え
    long long res = 0;
    for (int i = 0; i < 3; ++i) res=max(res, dp[N][i]);
    cout << res << endl;
}


Measured memory_bytes: 4992
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var S = Console.ReadLine();
            int ans = 700;
            for(int i = 0; i < 3; i++)
            {
                if (S[i] == 'o')
                {
                    ans += 100;
                }
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define LL long long
#define db double

using namespace std;
const int N=2e5+10,mod=1e9+7,inf=1<<30;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
void ad(int &x,int y){x+=y,x-=x>=mod?mod:0;}
int fpow(int a,int b){int an=1;while(b){if(b&1) an=1ll*an*a%mod;a=1ll*a*a%mod,b>>=1;}return an;}
int ginv(int a){return fpow(a,mod-2);}
vector<int> e[N];
int n,a[N],v1[N],ti,cr[N],st[N],tp,f[N],g[N],b[N],h[N],fac[N],iac[N];
int C(int a,int b){return b<0||a<b?0:1ll*fac[a]*iac[b]%mod*iac[a-b]%mod;}
bool mk[N];
void dfs(int x)
{
    int nn=e[x].size();
    for(int i=0;i<nn;++i)
    {
	int y=e[x][i];
	dfs(y),f[x]=f[x]?-inf:f[y]+1;
    }
}

int main()
{
//iee
    fac[0]=1;
    for(int i=1;i<=N-5;++i) fac[i]=1ll*fac[i-1]*i%mod;
    iac[N-5]=ginv(fac[N-5]);
    for(int i=N-5;i;--i) iac[i-1]=1ll*iac[i]*i%mod;
    n=rd();
    for(int i=1;i<=n;++i) a[i]=rd();
    for(int i=1;i<=n;++i)
	if(!v1[i])
	{
	    ++ti;
	    int x=i;
	    tp=0;
	    while(!v1[x]) v1[x]=ti,st[++tp]=x,x=a[x];
	    if(cr[x]) {mk[x]=1;continue;}
	    if(v1[x]<ti) continue;
	    int cn=0;
	    for(int j=tp;;--j)
	    {
		++cn;
		if(st[j]==x) break;
	    }
	    for(int j=tp;;--j)
	    {
		cr[st[j]]=cn;
		if(st[j]==x) break;
	    }
	    mk[x]=tp>cn;
	}
    ++ti;
    for(int i=1;i<=n;++i)
	if(cr[i]&&v1[i]<ti)
	{
	    int x=i;
	    for(int j=1;j<=cr[i]*2;++j) v1[x]=ti,mk[a[x]]|=mk[x],x=a[x];
	}
    for(int i=1;i<=n;++i)
	if(!cr[i]) e[a[i]].push_back(i);
    int ans=1;
    for(int i=1;i<=n;++i)
	if(cr[i])
	{
	    if(mk[i])
	    {
		int x=i;
		tp=0;
		for(int j=1;j<=cr[i];++j) st[++tp]=x,x=a[x];
		for(int j=1;j<=cr[i];++j) dfs(st[j]);
		for(int j=1;j<=cr[i];++j)
		    if(f[st[j]]<0||f[st[j]]>cr[i]){puts("0");return 0;}
		for(int j=1;j<=cr[i];++j) g[j]=g[j-1]+(bool)f[st[j]];
		for(int j=1;j<=cr[i];++j) g[j+cr[i]]=g[j-1+cr[i]]+(bool)f[st[j]];
		for(int j=cr[i]+1;j<=cr[i]+cr[i];++j)
		{
		    int y=st[j-cr[i]];
		    if(!f[y]) continue;
		    if(cr[i]>1&&g[j-1]-g[j-f[y]]){puts("0");return 0;}
		    ans=1ll*ans*(2-(bool)(g[j-1]-g[j-f[y]-1]))%mod;
		}
	    }
	    else ++b[cr[i]];
	    int x=i,lm=cr[i];
	    for(int j=1;j<=lm;++j) cr[x]=0,x=a[x];
	}
    h[0]=h[1]=1;
    for(int i=2;i<=n;++i) h[i]=1ll*h[i-1]*(2*i-1)%mod;
    for(int i=1;i<=n;++i)
    {
	if(!b[i]) continue;
	int sm=0,dx=1+(i>1&&(i&1));
	for(int j=0;j+j<=b[i];++j)
	    ad(sm,1ll*C(b[i],j+j)*h[j]%mod*fpow(i,j)%mod*fpow(dx,b[i]-j-j)%mod);
	ans=1ll*ans*sm%mod;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 16768
#include <cstdio>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a;
	int flag=1;
	for(int i=0;i<n;i++)
	{
		 cin >> a;
		if(!(a&1))
		{
			if(a%3&&a%5)
				flag=0;
		}
	}
	if(flag)
		cout << "APPROVED";
	else
		cout << "DENIED";

	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] a = new int[2][n];
		int[][] dp = new int[2][n];

		for(int i = 0; i < 2; i++) {
			for(int j = 0; j < n; j++) {
				a[i][j] = sc.nextInt();
			}
		}

		dp[0][0] = a[0][0];
		dp[1][0] = dp[0][0] + a[1][0];


		for(int i = 0; i < 2; i++) {
			for(int j = 1; j < n; j++) {
				dp[i][j] = Math.max(dp[i][j], dp[i][j - 1] + a[i][j]);
				if(i == 1) {
					dp[i][j] = Math.max(dp[i][j], dp[i - 1][j] + a[i][j]);
					dp[i][j] = Math.max(dp[i][j], dp[i][j - 1] + a[i][j]);
				}
			}
		}

		System.out.println(dp[1][n - 1]);

		sc.close();
	}
}


Measured memory_bytes: 21844
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
3 4 6
0 0
0 2
0 3
1 1
2 1
2 3

output:
3
"""

import sys


def dfs(current, matching, visited):
    for target in range(y_num):
        if (not visited[target]) and (target in adj_table[current]):
            visited[target] = True
            ''' Matching[target] = -1: target not assigned to any of x.
            And dfs(matching[target], matching, visited) = True
            indicates that source in x has been already assigned
            to another target in y. '''
            if matching[target] == -1 or dfs(matching[target], matching, visited):
                matching[target] = current
                return True
    return False


def mbm():
    res = 0
    matching = [-1] * y_num
    for source in range(x_num):
        visited = [False] * y_num
        if dfs(source, matching, visited):
            res += 1
    return res


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    x_num, y_num, e_num = map(int, _input[0].split())
    edges = map(lambda x: x.split(), _input[1:])

    adj_table = tuple(set() for _ in range(x_num))
    for edge in edges:
        vx, vy = map(int, edge)
        adj_table[vx].add(vy)
    print(mbm())

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

int main() {
	int N;
	cin >> N;
	int res;
	if(N <= 111) res = 111;
	else if(N <= 222) res = 222;
	else if(N <= 333) res = 333;
	else if(N <= 444) res = 444;
	else if(N <= 555) res = 555;
	else if(N <= 666) res = 666;
	else if(N <= 777) res = 777;
	else if(N <= 888) res = 888;
	else res = 999;
	cout << res << endl;
}


Measured memory_bytes: 256
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.emplace_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.emplace_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  using _pi = pair<int, int>;
  vector<_pi> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<_pi> res(1, _pi(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};
#pragma endregion library

int main(){
    int n; cin >> n;
    vi a(n); rep(i,n) cin >> a[i];
    const int MX = 1000006;
    vector<bool> pr(MX);
    bool flag = true;
    Sieve sv(MX);
    rep(i,n){
        auto vp = sv.factor(a[i]);
        for(auto p: vp){
            if(pr[p.first]) flag = false;
            pr[p.first] = true;
        }
    }
    if(flag){
        cout << "pairwise coprime" << '\n';
        return 0;
    }
    int g = gcd(a[0], a[1]);
    repi(i,2,n){
        g = gcd(g, a[i]);
    }
    if(g == 1){
        cout << "setwise coprime" << '\n';
        return 0;
    }
    cout << "not coprime" << '\n';
    
    
}


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

// ll MOD = 1e9 + 7;
ll MOD = 998244353;

// g = eGCD(a, b, s, t)  --->  sa + tb = g
constexpr ll eGCD(ll a, ll b, ll& s, ll& t) {
  if (a == 0) {
    s = 0;
    t = 1;
    return b;
  }
  ll u = 0;
  ll g = eGCD(b % a, a, t, u);
  s = u - (b / a) * t;
  return g;
}

constexpr ll gcd(ll a, ll b) {
  ll dummy1 = 0;
  ll dummy2 = 0;
  return eGCD(a, b, dummy1, dummy2);
}

struct Fp {
  ll val;

  Fp(ll t = 0) :
    val(t < 0 ? MOD + t % MOD : t >= MOD ? t % MOD : t) {}

  Fp& operator +=(const Fp& t) {
    val += t.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }

  Fp& operator -=(const Fp& t) {
    val -= t.val;
    if (val < 0) val += MOD;
    return *this;
  }

  Fp& operator *=(const Fp& t) {
    val = (val * t.val) % MOD;
    return *this;
  }

  Fp inv() const {
    if (val == 0) {
      cerr << "inv() is called for zero." << endl;
      exit(1);
    }
    ll u = 0;
    ll v = 0;
    eGCD(val, MOD, u, v);
    return Fp(u);
  }

  Fp& operator /=(const Fp& t) {
    return (*this) *= t.inv();
  }

  Fp operator +(const Fp& t) const { return Fp(val) += t; }
  Fp operator -(const Fp& t) const { return Fp(val) -= t; }
  Fp operator *(const Fp& t) const { return Fp(val) *= t; }
  Fp operator /(const Fp& t) const { return Fp(val) /= t; }
  Fp operator -() const { return Fp(-val); }

  bool operator ==(const Fp& t) const { return val == t.val; }
  bool operator !=(const Fp& t) const { return val != t.val; }
  
  operator ll() const { return val; }

};


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N; cin >> N;
  vector<int> cnt(N);
  int dmax = -1;
  for (int i = 0; i < N; i++)  {
    int d; cin >> d;
    if (i == 0) {
      if (d != 0) {
	cout << "0\n";
	return 0;
      }
    }
    cnt.at(d)++;
    dmax = max(dmax, d);
  }
  if (cnt.at(0) != 1) {
    cout << "0\n";
    return 0;
  }
  Fp ans = 1;
  for (int i = 1; i <= dmax; i++) {
    for (int j = 0; j < cnt.at(i); j++) {
      ans *= cnt.at(i-1);
    }
  }
  cout << (int)ans << endl;

  return 0;
}



Measured memory_bytes: 640
H,W = map(int, input().split())

lis = []
whitecol = [0]*W
for i in range(H):
    t = input()
    if '#' in t:
        lis.append(list(t))
        for j in range(len(t)):
            if t[j] == '#':
                whitecol[j] = 1
for i in lis:
    print(''.join([j for j,k in zip(i,whitecol) if k]))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		long amax = 0;
		long bmin = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			long a = sc.nextInt();
			long b = sc.nextInt();
			amax = Math.max(amax, a);
			bmin = Math.min(bmin, b);
		}

		System.out.println(amax + bmin);
	}
}

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

int main(){
	int N,M;
	scanf("%d%d",&N,&M);
	int res[100]={0},a,b;
	for(int i=0;i<M;i++){
		scanf("%d%d",&a,&b);
		res[a]++;
		res[b]++;
	}
	for(int i=1;i<=N;i++){
		printf("%d\n",res[i]);
	}
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
  
#define NIL NULL
  
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
  
typedef struct node * Node;
  
Node root;
  
Node tS(Node,int);
void ins(int);
void pre(Node);
void ino(Node);
 int main(){
  
  int n,i,a;
  char c[20];
  
  scanf("%d", &n);
  
  for(i = 0;i < n;i++){
  
    scanf("%s",c);
  
    if(c[0] == 'f'){
  
      scanf("%d",&a);
  
      if(tS(root,a) != NIL) {
        printf("yes\n");
      }
      else{
        printf("no\n");
      }
    }
  
    else if (c[0] == 'i' ){
      scanf("%d",&a);
      ins(a);
    }
else if (c[0] == 'p' ){
      ino(root);
      printf("\n");
      pre(root);
      printf("\n");
    }
  
  }
  return 0;
}
  
void ino(Node n){
  if(n->left != NIL){
    ino(n->left);
  }
  printf(" %d", n->key);
  if(n->right != NIL){
    ino(n->right);
  }
}
  
void pre(Node n){
  printf(" %d", n->key);
  if(n->left != NIL){
    pre(n->left);
  }
  if(n->right != NIL){
    pre(n->right);
  }
}
void ins(int n){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = n;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else{
    y->right = z;
  }
}
  
Node tS(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key){
      u = u->left;
    }
    else{
      u = u->right;
    }
  }
  return u;
}

Measured memory_bytes: 19364
N, X, Y = map(int, input().split())
X, Y = X - 1, Y - 1

cnt = [0] * N
for i in range(N - 1):
    for j in range(i + 1, N):
        dist = min(j - i, abs(j - Y) + abs(X - i) + 1)
        cnt[dist] += 1

print('\n'.join(map(str, cnt[1:])))



Measured memory_bytes: 9284
#include <bits/stdc++.h>
using namespace std;
map<string, int> X;
int main()
{
    string s;
    int N; cin >> N;
    for(int i=0; i<N; ++i)
    {
        cin >> s;
        X[s] = X[s]+1;
    }
    cin >> N;
    for(int i=0; i<N; ++i)
    {
        cin >> s;
        X[s] = X[s]-1;
    }
    int ans = 0;
    for(auto x:X)
        ans = max(ans, x.second);
    cout<<ans<<endl;
}

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

long long N;
#define MAX_B 39
set<int> S;
int M, F;
deque<int> R;

int main() {
  cin >> N;
  for(int i = 0; i <= MAX_B; ++i) {
    if((N + 1) & (1LL << i)) S.insert(i);
  }
  int M = *S.rbegin(), F = M;
  for(int i = M - 1; i >= 0; --i) R.push_back(i);
  for(int i = M - 1; i >= 0; --i) {
    R.push_back(i);
    if(S.count(i)) {
      R.push_back(F); R.push_front(F); ++F;
    }
  }
  cout << R.size() << endl;
  for(int i = 0; i < (int)R.size(); ++i) {
    cout << (i == 0 ? "" : " ") << R[i] + 1;
  }
  cout << endl;
  return 0;
}


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

#A
def A(s):
    def pri(n, x):
        for i in range(2, int(math.sqrt(n))):
            if n % i == 0 and n // i <= x:
                return [i, n // i]
        return [1, n]
    x = int(math.sqrt(s))
    if s < 10 ** 9:
        print(0, 0, 0, s, 1, 0)
        return
    while 1:
        X = x ** 2
        if X - s < 0:
            x += 1
            continue
        b = pri(X - s, x)
        if b:
            print(0, 0, x, int(b[0]), int(b[1]), x)
            return
        x += 1
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return



#Solve
if __name__ == '__main__':
    A(II())


Measured memory_bytes: 38896
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"sort"
	"strconv"
)

type ByRune []rune

func (r ByRune) Len() int           { return len(r) }
func (r ByRune) Swap(i, j int)      { r[i], r[j] = r[j], r[i] }
func (r ByRune) Less(i, j int) bool { return r[i] < r[j] }

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func SortStringByCharacter(s string) string {
	var r ByRune = StringToRuneSlice(s)
	sort.Sort(r)
	return string(r)
}

func run() {
	n := nextInt()
	counter := make(map[string]int)
	answer := 0
	for i := 0; i < n; i++ {
		s := next()
		ss := SortStringByCharacter(s)
		x, _ := counter[ss]
		answer += x
		counter[ss] = x + 1
	}
	Println(answer)
}

// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695

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

// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024

func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}

func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}

func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}

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

func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}

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

func nextFloats(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = nextFloat()
	}
	return res
}

func nextStrings(n int) []string {
	res := make([]string, n)
	for i := 0; i < n; i++ {
		res[i] = next()
	}
	return res
}

func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}


Measured memory_bytes: 30080
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<cassert>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#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++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

template<int m>
class Prime{
  std::vector<bool> p;
public:
  std::vector<int> ps;
  Prime(){
    p = std::vector<bool>(m,true);
    assert(m>1);
    p[0]=p[1]=false;
    for(int i=4;i<m;i+=2)
      p[i]=false;
    ps.push_back(2);
    for(int i=3;i<m;i+=2){
      if(p[i]){
        ps.push_back(i);
        for(int j=i+i;j<m;j+=i)
          p[j]=false;
      }
    }
  }

  bool isPrime(int n){
    assert(m>n);
    return p[n];
  }

  int operator [] (int n){
    if(n<ps.size()) return ps[n];
    else return 0;
  }

  int size(){
    return ps.size();
  }
};

int main(){
  Prime<1299710> p;
  vector<int> &v = p.ps;

  int n;
  while(scanf("%d",&n), n){
    vector<int>::iterator it = lower_bound(ALL(v), n);
    if(n == 2 || *it == n){
      puts("0");
    }else{
      printf("%d\n",*it - *(it-1));
    }
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int[][][] g = new int[h][w][4];//L,U,R,D
        char[][] s = new char[h][w];
        for (int i = 0; i < h; i++) {
            s[i] = sc.next().toCharArray();
            for (int j = 0; j < w; j++) {
                if(s[i][j] == '.'){
                    g[i][j][0] = 1;
                    g[i][j][1] = 1;
                    if(0 < j) g[i][j][0] += g[i][j-1][0];
                    if(0 < i) g[i][j][1] += g[i-1][j][1];
                }
            }
        }
        int ans = 0;
        for (int i = h-1; i >= 0; i--) {
            for (int j = w-1; j >= 0; j--) {
                if(s[i][j] == '.'){
                    g[i][j][2] = 1;
                    g[i][j][3] = 1;
                    if(j < w-1) g[i][j][2] += g[i][j+1][2];
                    if(i < h-1) g[i][j][3] += g[i+1][j][3];
                }
                ans = Math.max(ans, g[i][j][0] + g[i][j][1] + g[i][j][2] + g[i][j][3] - 3);
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


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

int main(){
  int N;
  int H[21];
  cin >> N;
  H[0]=0;
  for(int i=1; i<=N; i++) cin >> H[i];
  int sum=0;
  for(int i=1; i<=N; i++){
    int add=1;
    for(int j=0; j<i; j++){
      if(H[j]>H[i]) add=0;
    }
    sum+=add;
  }
  cout << sum << endl;
}

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

int main() {
  string ans, T;
  int pd;
  cin >> T;
  
  for (int i = 0; i < T.size(); i++) {
    if (T[i] == '?') {
//      if (T[i - 1] == 'D') {
//        ans += 'P';
//      } else {
        ans += 'D';
//      }
    } else {
      ans += T[i];
    }
  }
  
  cout << ans << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vec;
typedef std::vector<ld> vecld;
typedef std::vector< std::vector<ll> > vecvec;
typedef std::pair<ll, ll> pr;
typedef std::vector< pr > vpr;

#define tin ll t;cin>>t;while(t--)
#define fio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define sz(a) (ll)((a).size())
#define pb push_back
#define trvect(c,i) for(vector<ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define trset(c,i) for(set<ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define trmap(c,i) for(map<ll,ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,a,b) for(ll i=a;i<=b;i++)
#define present(c,x) ((c).find(x) != (c).end())
#define ff first
#define ss second
#define mp make_pair
#define sq(a) (a)*(a)
#define cube(a) (a)*(a)*(a)
#define cnti(x) (__builtin_popcount(x)) //number of set bits in x
#define mod 1000000007
#define N 100005

ll qpow (ll n, ll m) {
	ll ret = 1;
	while (m) {
		if (m & 1) ret = ret * n % mod;
		n = n * n % mod;
		m >>= 1;
	}
	return ret;
}
ll inv (ll a) {
	return qpow(a, mod - 2);
}

// -------------------------------------------------------------------------------- //



int main(){
    
    ll r;
    cin>>r;
    double c = 2*3.14*r;
    cout<<fixed;
    cout<<setprecision(20)<<c<<"\n";
}


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

const int INF = 1e9;

int m, n, K;
vector<string> mat;

int count(int mask) {
	int sol = 0;
	for (int i = 0; i < 12; ++i) {
		if (mask & (1 << i)) ++sol;
	}
	return sol;
}

int cut(int mask) {
	int cnt = 0;
	vector<int> comp(m);
	comp[0] = 0;
	for (int i = 0; i < m - 1; ++i) {
		if (mask & (1 << i)) ++cnt;
		comp[i + 1] = cnt;
	}
	cnt++;
	int sol = 0;
	vector<int> acc(cnt, 0);
	for (int j = 0; j < n; ++j) {
		vector<int> nacc(acc);
		int corte = 0;
		for (int i = 0; i < m; ++i)
			nacc[comp[i]] += mat[i][j] - '0';
		for (int i = 0; i < cnt; ++i) {
			if (nacc[i] > K) {
				if (nacc[i] - acc[i] > K) return INF;
				corte = 1;
			}
		}
		for (int i = 0; i < cnt; ++i)
			acc[i] = nacc[i] - corte * acc[i];
		sol += corte;
	}
	return sol;
}

int main() {
	cin.sync_with_stdio(false); cin.tie(nullptr);
	cin >> m >> n >> K;
	mat = vector<string>(m);
	for (int i = 0; i < m; ++i) cin >> mat[i];
	int mini = INF;
	for (int mask = 0; mask <= (1 << (m - 1)); ++mask)
		mini = min(mini, count(mask) + cut(mask));
	cout << mini << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
const int Maxn = 1e3 + 5;
typedef int arr[Maxn];
//ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n;
char s[Maxn], t[Maxn];
int main()
{
	cin >> n >> s + 1 >> t + 1;
	for (int i = 1; i <= n; i++)
		cout << s[i] << t[i];
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

class UnionFind {
public:
	std::vector<int32> tree;
	//コンストラクタ
	UnionFind(size_t size) :tree(size, -1) {}
	//xの代表ノード
	int32 find(int32 x) {
		if (tree[x] < 0) return x;
		return tree[x] = find(tree[x]);
	}
	//x,yを要素に持つ2集合の併合
	void unite(int32 x, int32 y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (tree[x] > tree[y]) {
			tree[y] += tree[x];
			tree[x] = y;
		}
		else {
			tree[x] += tree[y];
			tree[y] = x;
		}
		return;
	}
	//xを要素に持つ集合の要素数
	size_t size(int32 x) {
		return -tree[find(x)];
	}
	//x,yが同じ集合に属しているか
	bool same(int32 x, int32 y) {
		return find(x) == find(y);
	}
};

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n, m;
	std::cin >> n >> m;
	std::vector<uint32> a(m), b(m);
	rep(i, 0, m)
		std::cin >> a[i] >> b[i];
	uint32 c = 0;
	std::vector<UnionFind> t(m, n + 1);
	rep(i, 0, m) {
		rep(j, 0, m) {
			if (i == j) continue;
			t[i].unite(a[j], b[j]);
		}
		bool f = 1;
		rep(j, 1, n) {
			if (!t[i].same(j, n)) {
				f = 0;
			}
		}
		if (!f) ++c;
	}
	std::cout << c << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort(ALL(c))
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


int main() {
	LL N;
	cin >> N;
	VI b(N);
	REP(i, N) {
		cin >> b[i];
	}

	VI ans;
	for (LL i = N - 1; i >= 0; i--) {
		LL bj = -1;
		for (LL j = i; j >= 0; j--) {
			if (b[j] == (j + 1)) {
				bj = b[j];
				b.erase(b.begin() + j);
				break;
			}
		}
		if (bj == -1) {
			cout << "-1" << endl;
			return 0;
		} else {
			ans.PB(bj);
		}
	}
	REVERSE(ans);
	REP(i, N) {
		cout << ans[i] << endl;
	}
	
    return 0;
}


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

using namespace std;

int defsai[4] = { 3,5,4,2 };
int toplist[200][200];
int takasa[200][200];

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

class sai{
public:
	int top,bot;
	int side[4];

	sai(int t,int f){
		top = 1;
		copy(defsai,defsai+4,side);
		bot = 6;

		if(t == bot){
			mae();
			mae();
		}else if(top != t){
			while(side[0]!=t){
				left();
			}
			usi();
		}
		while(side[0]!=f){
			left();
		}
	}

	void mae(){
		swap(top,side[2]);
		swap(side[2],bot);
		swap(bot,side[0]);
	}

	void usi(){
		swap(top,side[0]);
		swap(side[0],bot);
		swap(bot,side[2]);
	}

	void mleft(){
		swap(top,side[1]);
		swap(side[1],bot);
		swap(bot,side[3]);
	}

	void mright(){
		swap(top,side[3]);
		swap(side[3],bot);
		swap(bot,side[1]);
	}

	void left(){
		rotate(side, side+1, side+4);
	}

	void right(){
		rotate(side, side+3, side+4);
	}

	vector<int> sidelist(){
		vector<int> ans;
		for(int i=6;i>=4;i--){
			int buf = find(side,side+4,i)-side;
			if(buf != 4){
				ans.push_back(buf);
			}
		}
		return ans;
	}
};

int main(){
	while(true){
		int n;
		cin >> n;
		int sx = 100,sy = 100;
		memset(toplist,0,sizeof(toplist));
		memset(takasa,0,sizeof(takasa));
		if(n==0){
			break;
		}
		for(int i=0;i<n;i++){
			int t,f;
			cin >> t >> f;
			sai s(t,f);
		
			int mx = sx,my = sy;
			bool flag = true;
			while(flag){
				vector<int> move = s.sidelist();
				flag = false;
				for(int j=0;j<move.size();j++){
					if(takasa[my][mx] > takasa[my+dy[move[j]]][mx+dx[move[j]]]){
						mx += dx[move[j]];
						my += dy[move[j]];
						flag = true;

						switch(move[j]){
						case 0:
							s.mae();
							break;
						case 1:
							s.mright();
							break;
						case 2:
							s.usi();
							break;
						case 3:
							s.mleft();
							break;
						}
						break;
					}
				}
			}
			takasa[my][mx]++;
			toplist[my][mx] = s.top;
		}

		int anslist[6]={0};
		for(int i=0;i<200;i++){
			for(int j=0;j<200;j++){
				if(toplist[i][j]!=0){
					anslist[toplist[i][j]-1]++;
				}
			}
		}
		for(int i=0;i<6;i++){
			cout << anslist[i] << ((i+1==6) ? '\n' : ' '); 
		}
	}
}

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


bool isprime(long long int val) {
	if (val <= 1)return false;
	for (long long int i = 2; i*i <= val; i++) {
		if (val%i == 0LL)return false;
	}
	return true;
}


bool f[100002];
int q;

int cnt[100002];

int main() {
	cin >> q;
	for (int i = 2; i <= 100001; i++) {
		f[i] = isprime(i);
	}
	for (int i = 1; i <= 100000; i++) {
		if (f[i] && f[(i + 1)/2]) {
			cnt[i] = 1;
		}
		cnt[i] += cnt[i - 1];
	}
	while (q--) {
		int l, r;
		scanf("%d%d", &l, &r);
		int ans = cnt[r];
		ans -= cnt[l - 1];
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;
const int MOD = 1000000007;
const int K_MAX = 1000000;

long long mod(long long a) {
	a %= MOD;
	return a >= 0 ? a : a+MOD;
}

long long pow_mod(long long a, long long n) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = (res * a) % MOD;
		n >>= 1;
		a = (a * a) % MOD;
	}
	return res;
}

long long inverse[K_MAX*2+1];
long long factorial[K_MAX*2+1];
long long factorial_inverse[K_MAX*2+1];

void calc(int n) {
	inverse[1] = 1;
	factorial[0] = factorial[1] = 1;
	factorial_inverse[0] = factorial_inverse[1] = 1;
	for (int i = 2; i <= n; i++) {
		inverse[i] = MOD - inverse[MOD%i] * (MOD/i) % MOD;
		factorial[i] = i * factorial[i-1] % MOD;
		factorial_inverse[i] = inverse[i] * factorial_inverse[i-1] % MOD;
	}
}

long long comb(long long n, long long k) {
	return factorial[n] * (factorial_inverse[k] * factorial_inverse[n-k] % MOD) % MOD;
}

int main() {
	ll k;
	string s;
	cin >> k >> s;
	ll n = s.size();
	ll ans = 0;
	calc(max(n+k, (ll)26));
	for (int i = 0; i <= k; i++) {
		ans = mod(ans + comb(n-1+i, i) * pow_mod(25, i) % MOD * pow_mod(26, k-i) % MOD);
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
  long l, r;
  cin >> l >> r;
  if (l / 2019 != r / 2019) {
    cout << 0 << endl;
    return 0;
  }
  int minimum = 2018;
  for (int i = l % 2019; i < r % 2019; i++) {
    for (int j = i + 1; j <= r % 2019; j++) {
      minimum = min(minimum, i * j % 2019);
    }
  }
  cout << minimum << endl;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
typedef long long ll;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << min(a,b)+min(c,d) << endl;
}


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

public class GFG
{

    public static void Main()
    {
        var ii = Console.ReadLine();

        long n = long.Parse(ii);
        Dictionary<long, char> dic = new Dictionary<long, char>();
        char a = 'a';
        for (int i = 0; i <= 25; i++)
        {
            dic[i] = a;
            a++;
        }

        StringBuilder ans = new StringBuilder();

        while (n > 0)
        {
            n = n - 1;
            ans.Append(dic[n%26]);

            n = n / 26;
        }

        char[] arr = ans.ToString().ToCharArray();
        Array.Reverse(arr);
        Console.Write(new string(arr));
    }

}





Measured memory_bytes: 17916
import math as mt
import sys, string
from collections import Counter, defaultdict
input = sys.stdin.readline

MOD = 1000000007

# input functions
I = lambda : int(input())
M = lambda : map(int, input().split())
Ms = lambda : map(str, input().split()) 
ARR = lambda: list(map(int, input().split()))


def main():
    n = I()
    n -= 400
    print(8 - n//200)

# testcases
tc = 1
for _ in range(tc):
    main()

Measured memory_bytes: 72072
program asakatsu318B
    implicit none
    integer(8)::i,slen,ans
    character(200)::S
    read*,S
    slen=len_trim(S)
    ans=0
    do i=1,slen/2-1
        if(S(1:i)==S(i+1:2*i))ans=max(ans,2*i)
    end do
    print'(i0)',ans
end program asakatsu318B

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
using namespace std;
using P=pair<int,int>;
using ll=long long;
const int MOD = 998244353;
long long fac[510000], finv[510000], inv[510000];
long long MAX = 510000;
bool COMinited = false;
long long COM(int n, int k) {
  if (COMinited == false) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i - 1] * i % MOD;
      inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
      finv[i] = finv[i - 1] * inv[i] % MOD;
    }
    COMinited = true;
  }
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
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 modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); }
int main(){
    int n,m;
    cin>>n>>m;
    int k;
    cin>>k;
    ll ret=0;
    vector<ll> kai(n+1);
    kai[1]=m;
    for(int i=2;i<n+1;i++){
        kai[i]=kai[i-1]*(m-1)%MOD;
    }
    for(int i=0;i<=k;i++){
        ret+=kai[n-i]*COM(n-1,i);
        ret%=MOD;
    }
    cout<<ret<<endl;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(long long i = 0; i < (long long)(n); i++)
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double r;
    if(x <= a * a * b / 2){
        r = atan2(b * b, 2 * (x / a));
    }
    else{
        r = atan2(2 * (a * b - (x / a)), a * a);
    }
    double ans = r / (2 * acos(-1)) * 360;
    cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 4172
n = int(input())
t = 0
h = 0
for i in range(n):
 c = input().lower().split()
 if c[0]>c[1]:
  t = t+3
 elif c[0]<c[1]:
  h = h+3
 else:
  t = t+1
  h = h+1
print(t,h)



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

using namespace std;

int main(void){
    int N, K;
    cin >> N >> K;
    double ans = 0;
    for(int n = 1; n <= N; n++){
        int nn = n;
        double dans = 1.0 / N;
        while(nn < K){
            nn *= 2;
            dans /= 2.0;
        }
        ans += dans;
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	string s;
	vector<int> a(3);
	cin >> s;
	int sum = 0;
	for (int i = 0; i < 3; i++) {
		if (a.at(s.at(i) - 'a') == 0) {
			sum++;
		}
		a.at(s.at(i) - 'a')++;
	}
	ansYes(sum == 3);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		if (N == 1) {
			System.out.println("Hello World");
		}

		if (N == 2) {
			int num1 = sc.nextInt();
			int num2 = sc.nextInt();
			System.out.println(num1 + num2);
		}

		sc.close();

	}

}

Measured memory_bytes: 21204