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

int main() {
  int n, m, T, P, X, i;
  ll cnt = 0;
  vector<int> t, p, x;
  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> T;
    t.push_back(T);
    cnt += T;
  }
  cin >> m;
  for (i = 0; i < m; ++i) {
    cin >> P >> X;
    p.push_back(P);
    x.push_back(X);
  }
  vector<ll> ans(m, cnt);
  for (i = 0; i < m; ++i) {
    ans[i] = ans[i] - t[p[i] - 1] + x[i];
  }
  for (i = 0; i < m; ++i) {
    cout << ans[i] << "\n";
  }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<ll>ans(1e4+1,0);
  rep(z,1,sqrt(n)+1){
    rep(y,1,z+1){
      rep(x,1,y+1){
        ll f = x*x+y*y+z*z+x*y+y*z+z*x;
        if(f >= ans.size()) continue;
        if(y == z && y == x) ans[f] += 1;
        else if(y == z || y == x) ans[f] += 3;
        else ans[f] += 6;
      }
    }
  }
  rep(i,1,n+1) cout << ans[i] << endl;
}

Measured memory_bytes: 3692
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 2e5 + 10;
int n , m , a[N];
int cnt[N] , vis[N] , err;

void add(int x){
    cnt[x]++;
    int t=x-cnt[x]+1;
    if(t>=1&&++vis[t]==1)
        err--;
}
void del(int x){
    int t=x-cnt[x]+1;
    cnt[x]--;
    if(t>=1&&--vis[t]==0)
        err++;
}

int main(){
    scanf("%d%d",&n,&m);
    err = n;
    rep(i,1,n+1) scanf("%d",a + i) , add(a[i]);
    rep(i,0,m){
        int x,y;
        scanf("%d%d",&x,&y);
        del(a[x]);
        add(a[x]=y);
        printf("%d\n",err);
    }
    return 0;
}


Measured memory_bytes: 3712
#include<iostream>
using namespace std ;
int main()
{
	int n;
	cin >> n ;
	if(n>=1&&n<105)  cout << 0 ;
	if(n==105)  cout << 1 ;
	if(n>105&&n<=200) {
		int f,s=0;
		for(int i=107;i<=n;i+=2){
			f=0;
			for(int j=1;j<=i;j++)
				if(i%j==0) f++;
			if(f==8) s++;
		}
		cout << s+1 ;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<iostream>
#include<string>
#include <string.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
#include <map>
using namespace std;
int a[200005];
int main() {
    int n, mx = 0;
    long long ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) {
        if (a[i] > mx) mx = a[i];
        else ans += mx - a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4536
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <random>
#include <stdio.h>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl

bool isPrime(LL N)
{
  if (N < 2) {
    return false;
  }
  else if (N == 2) {
    return true;
  }
  else if (N % 2 == 0) {
    return false;
  }

  LD sqrtNum = sqrt(N);
  for (LL i = 3; i <= sqrtNum; i += 2)
  {
    if (N % i == 0)
    {
      return false;
    }
  }
  return true;
}


void func() {
  LL N;
  cin >> N;
  vector<LL> L(N);
  REP(i, N) {
    cin >> L[i];
  }

  //sort(ALL(L), less<LL>());
  sort(ALL(L), greater<LL>());

  LL cnt = 0;
  for (LL i1 = 0; i1 < N; i1++) {
    for (LL i2 = i1 + 1; i2 < N; i2++) {
      for (LL i3 = i2 + 1; i3 < N; i3++) {
        //fprintf(stderr, "i1=%ld, i2=%ld, i3=%ld\n", L[i1], L[i2], L[i3]); 
        if (L[i1] >= L[i2] + L[i3]) {
          //cerr << "break"<< endl;
          break;
        }
        if ((L[i2] < L[i1] + L[i3]) && (L[i3] < L[i1] + L[i2])) {
          //cerr << "cnt++"<< endl;
          cnt++;
        }
        //cerr << "ao" << endl;

      }
    }
  }

  cout << cnt;
  //PRINTLN(L);
}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

const ll MOD = 998244353 ;
const int MAXN = 55;
//EAZY..PIZZIIEE

void solve(){
    long double L;
    cin >> L;
    long double x = L / 3;
    long double ans = x * x * x;
    cout << fixed << setprecision(7) << ans << '\n';


}

int main(){
    //int t; cin >> t;
    //while(t--)
        solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<string>;
using P =pair<int,int>;
const ll mod=1000000007;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int main(){
    int n;
    cin>>n;
    vector<int> v(n,0);
    rep(i,n)cin>>v[i];
    vector<int> a(100001,0);
    vector<int> b(100001,0);
    rep(i,n){
        if(i%2==0)++a[v[i]];
        else ++b[v[i]];
    }
    int maxa[2]={};
    int maxb[2]={};
    int indexa[2]={};
    int indexb[2]={};

    for(int i=1;i<100001;++i){
        if(a[i]>=maxa[0]){
            maxa[1]=maxa[0];
            indexa[1]=indexa[0];
            maxa[0]=a[i];
            indexa[0]=i;
        }else if(a[i]>=maxa[1]){
            maxa[1]=a[i];
            indexa[1]=i;
        }

        if(b[i]>=maxb[0]){
            maxb[1]=maxb[0];
            indexb[1]=indexb[0];
            maxb[0]=b[i];
            indexb[0]=i;
        }else if(b[i]>=maxb[1]){
            maxb[1]=b[i];
            indexb[1]=i;
        }
    }

    int ans=0;
    if(indexa[0]==indexb[0])ans=max(maxa[0]+maxb[1],maxa[1]+maxb[0]);
    else ans=maxa[0]+maxb[0];

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

Measured memory_bytes: 4500
#include<bits/stdc++.h>
using namespace std;
int main(){
  	std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int a,b,c;
  cin>>a>>b>>c;
  cout<<(c/a)*b<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define MAX 30
#define NIL -1

struct Node{int p, l, r;};
Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].l, d+1);
  setDepth(T[u].r, d+1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if(T[u].l != NIL) h1 = setHeight(T[u].l) + 1;
  if(T[u].r != NIL) h2 = setHeight(T[u].r) + 1;
  return H[u] = max(h1, h2);
}

int getSibling(int u) {
  if(T[u].p == NIL) return NIL;
  if(T[T[u].p].l != u && T[T[u].p].l != NIL) return T[T[u].p].l;
  if(T[T[u].p].r != u && T[T[u].p].r != NIL) return T[T[u].p].r;
  return NIL;
}

void print(int u) {
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "sibling = " << getSibling(u) << ", ";
  int deg = 0;
  if(T[u].l != NIL) deg++;
  if(T[u].r != NIL) deg++;
  cout << "degree = " << deg << ", ";
  cout << "depth = " << D[u] << ", ";
  cout << "height = " << H[u] << ", ";
  if(T[u].p == NIL) cout << "root" << endl;
  else if(T[u].l == NIL && T[u].r == NIL) cout << "leaf" << endl;
  else cout << "internal node" << endl;
}

int main() {
  int v, l, r, root = 0;
  cin >> n;
  for(int i=0; i<n; i++) T[i].p = NIL;
  for(int i=0; i<n; i++) {
    cin >> v >> l >> r;
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }
  for(int i=0; i<n; i++) if(T[i].p == NIL) root = i;
  setDepth(root, 0);
  setHeight(root);
  for(int i=0; i<n; i++) print(i);
  return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=1<<18,INF=1<<30;

int main(){
    
    int N;cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    ll ans=0;
    int out=0;
    for(int i=0;i<N;i++){
        if(A[i]<=out) continue;
        if(A[i]==out+1) out++;
        else{
            if(out==0){
                ans+=A[i]-1;
                out++;
            }else{
                ans+=(A[i]-1)/(out+1);
            }
        }
        //cout<<i<<" "<<ans<<endl;
    }
    
    cout<<ans<<endl;
}


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

int main() {
    int n;
    cin >> n;
    int ans = 1;
    rep(i,3) {
        ans *= n;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int[] num = new int[1000];

			for (int i = 0; i < 1000; i++) {
				num[i] = i + 1;
			}

			for (;;) {

			int n = sc.nextInt();
			int count = 0;

			if (n==0) {
				break;
			}

			for (int i = 0; i < 1000; i++) {
				int sum = num[i];
				for (int j = 1; sum <= n; j++) {
					if ((i+j)>999){
						break;
					}
					sum += num[i + j];
					if (sum == n) {
						count++;
						break;
					}
				}
			}
			System.out.println(count);
		}
	}
}



Measured memory_bytes: 26692
#include<iostream>
using namespace std;
int main(void){
    string s1,s2,s3,s4;
    cin >> s1 >> s2 >>s3;
    s4.push_back(s1[0]);
    s4.push_back(s2[1]);
    s4.push_back(s3[2]);
    cout << s4;
}

Measured memory_bytes: 256
// Problem : B - Between a and b ...
// Contest : AtCoder - AtCoder Beginner Contest 048
// URL : https://atcoder.jp/contests/abc048/tasks/abc048_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a) for (int i=0; i<(a); i++)
#define rep1(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rep(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define imax INT_MAX
#define imin INT_MIN
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	 
	ios_base::sync_with_stdio(0); cin.tie(0); 
	ll a,b,x;
	cin>>a>>b>>x;
	if(a%x==0)
	cout<<b/x-a/x+1<<nl;
	else 
	cout<<b/x-a/x<<nl;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3516
N,X=map(int,input().split())
bg=[1]
l=[1]
for _ in range(N):
    bg.append(bg[-1]*2+1)
    l.append(l[-1]*2+3)

def eat(n,x):#レベル,食べる層の数
    if x<=1: return 0
    if x==l[n-1]+1: return bg[n-1]
    if x==l[n] or x==l[n]-1: return bg[n]
    if x<=l[n-1]: return eat(n-1,x-1)
    return bg[n-1]+1+eat(n-1,x-l[n-1]-2)
print(eat(N,X))
    

Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

int main(){
  int n; cin >> n;
  double ans = 0;
  for(int i=0;i<n;++i){
    double x; string u;
    cin >> x >> u;
    if(u == "JPY") ans += x;
    else ans += x * 380000.0;
  }

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


Measured memory_bytes: 888
#include <cstring>
#include <algorithm>
#include <map>
#include <stack>
#include <cassert>
#include <cmath>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <iostream>
#include <set>
#define MP make_pair
#define F first
#define PB push_back
#define S second
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 50;
const int mod = 1e9 + 7;
const int inf = (1 << 30);

int main(){
    ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a > b)
        swap (a, b);
    if (a <= 0 and b >= 0)
        return cout << "Zero" << endl, 0;
    else if (b < 0){
        if ((a - b + 1) % 2 == 0)
            return cout << "Positive" << endl, 0;
        return cout << "Negative" << endl, 0;
    }
    cout << "Positive" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

int main() {
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b)*h / 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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; }

int ctoi(char c) {
    switch (c) {
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    }
}
char itoc(int c) {
    switch (c) {
    case 0: return '0';
    case 1: return '1';
    case 2: return '2';
    case 3: return '3';
    case 4: return '4';
    case 5: return '5';
    case 6: return '6';
    case 7: return '7';
    case 8: return '8';
    case 9: return '9';
    }
}

int main() {
    string n;
    int k;
    cin >> n >> k;
    vector<char> d(k);
    FOR(i, k)cin >> d[i];
    while (1) {
        bool bad = 0;
        FOR(i, n.length()) {
            FOR(j, k)if (n[i] == d[j])bad = 1;
        }
        if (bad) {
            n = to_string(stoi(n) + 1);
            continue;
        }
        cout << n << endl;
        break;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main (){
    int c[9],saA,saB;
    for(int i=0;i<9;i++){
        cin >> c[i];
        }
    saA=c[3]-c[0];
    saB=c[6]-c[3];
    if(c[4]==c[1]+saA&&c[5]==c[2]+saA&&c[7]==c[4]+saB&&c[8]==c[5]+saB){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
B = Array.new(N + 1,0)
ans = M.times.find do  
  u, v = gets.split.map(&:to_i).sort
  B[v] += 1 if u == 1
  B[u] += 1 if v == N
  B[v] == 2 || B[u] == 2
end
puts ans ? "POSSIBLE" :  "IMPOSSIBLE"


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

const int N = 1e5+7, K = 18;
vector<int> cld[N];
int par[N], level[N], anc[N][K];
bool done[N];

int n, k;
priority_queue<pair<int, int>> pq;

void setup(int u) {
    if (par[u] != u) level[u] = level[par[u]]+1;
    pq.push({level[u], u});
    anc[u][0] = par[u];
    for (int k=1; k<K; k++)     anc[u][k] = anc[anc[u][k-1]][k-1];
    for (int v: cld[u])         setup(v);
}

int getanc(int u, int d) {
    if (d >= N) d = N-1;
    for (int k=0; k<K; k++)
        if (d & (1<<k))
            u = anc[u][k];
    return u;
}

void dfs(int u) {
    if (done[u])    return;
    done[u] = 1;
    for (int v: cld[u])
        dfs(v);
}

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

    cin>>n>>k;
    cin>>par[1];
    int ans = 0;
    if (par[1] != 1)    ans++, par[1] = 1;

    for (int i=2; i<=n; i++) {
        cin>>par[i];
        cld[par[i]].push_back(i);
    }
    setup(1);

    while (pq.size()) {
        int u = pq.top().second;
        int d = pq.top().first;
        pq.pop();
//        cout<<u<<" --> "<<d<<endl;
        if (d <= k)     continue;
        if (done[u])    continue;

        int g = getanc(u, k-1);
        ans++;
        dfs(g);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 23636
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=1e6+10;
const int mod7=1e9+7;
const int mod=998244353;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int n,a,b,c;
char ans[N];
string s[N];
void dfs(int st,int a,int b,int c)
{
    if(st>n)
    {
        puts("Yes");
        for(re int i=1;i<=n;i++) putchar(ans[i]),putchar('\n');
        exit(0);
    }
    if(s[st]=="AB")
    {
        if(a)
        {
            ans[st]='B';
            dfs(st+1,a-1,b+1,c);
        }
        if(b)
        {
            ans[st]='A';
            dfs(st+1,a+1,b-1,c);
        }
    }
    if(s[st]=="AC")
    {
        if(a)
        {
            ans[st]='C';
            dfs(st+1,a-1,b,c+1);
        }
        if(c)
        {
            ans[st]='A';
            dfs(st+1,a+1,b,c-1);
        }
    }
    if(s[st]=="BC")
    {
        if(b)
        {
            ans[st]='C';
            dfs(st+1,a,b-1,c+1);
        }
        if(c)
        {
            ans[st]='B';
            dfs(st+1,a,b+1,c-1);
        }
    }
}
int main()
{
    read(n),read(a),read(b),read(c);
    for(re int i=1;i<=n;i++) cin>>s[i];
    dfs(1,a,b,c);puts("No");
    return 0;
}

Measured memory_bytes: 42764
from bisect import bisect_left
n = int(input())
ans_list = []
flag = True
while flag:
    if n % 26 == 0:
        ans_list.append(26)
        n //= 26
        n -= 1
    else:
        ans_list.append(n % 26)
        n //= 26
    if n == 0:
        flag = False

ans_list = ans_list[::-1]
str_list = []
for x in ans_list:
    str_list.append(chr(x + 96))

print(''.join(str_list))

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;
	vector<vector<bool>> f(n, vector<bool>(10));
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < 10; j++) {
			ll x;
			cin >> x;
			f[i][j] = (x == 1);
		}
	}
	vector<vll> p(n, vll(11));
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < 11; j++) cin >> p[i][j];
	}

	vector<bool> v(10, false);
	v[9] = true;

	ll ans = -1e10;
	for (ll i = 0; i < 1023; i++) {
		ll subans = 0;
		for (ll j = 0; j < n; j++) {
			ll cnt = 0;
			for (ll k = 0; k < 10; k++) {
				if (v[k] && f[j][k]) cnt++;
			}
			subans += p[j][cnt];
		}
		ans = max(ans, subans);

		if (i == 1022) break;
		ll x = 9;
		while (x >= 0 && v[x]) {
			v[x] = false;
			x--;
		}
		v[x] = true;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream&o,const pair<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
template<typename T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 2e3;

int n, k;
ll comb(int a, int b){
  if(b<0 || a<b) return 0;
  return fac[a]*rfac[b]%MOD*rfac[a-b]%MOD;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  setFac(N, MOD);
  cin >> n >> k;
  FOR(i, 1, k+1) cout << comb(k-1, i-1)*comb(n-k+1, i)%MOD << "\n";
}

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

int main() {
  char c;
  cin >> c;
  
  	if(c == 'a'){
    	cout << "vowel" << endl;
    }
  	else if(c == 'u'){
    	cout << "vowel" << endl;
    }  	
  	else if(c == 'e'){
    	cout << "vowel" << endl;
    }  	
  	else if(c == 'i'){
    	cout << "vowel" << endl;
    }  	
  	else if(c == 'o'){
    	cout << "vowel" << endl;
    }
    else if(c == 'u'){
    	cout << "vowel" << endl;
    }
  	else{
    	cout << "consonant" << endl;
    }

  // ここにプログラムを追記
}


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

int main()
{
  int n,a,b;
  string str,ch,p;
  char c;
  cin>>str;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>ch;
    if(ch=="replace"){
      cin>>a>>b>>p;
      for(int j=a,k=0;j<=b;j++,k++)str[j]=p[k];
    }
    if(ch=="reverse"){
      cin>>a>>b;
      for(int j=a,k=b;j<(a+b+1)/2;j++,k--){
	swap(str[j],str[k]);
      }
    }
    if(ch=="print"){
      cin>>a>>b;
      for(int j=a;j<b+1;j++)cout<<str[j];
      cout<<endl;
    }
  }
  return 0;
}

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

int main(){
  double t,x;
  cin>>t>>x;
  cout<<t/x<<endl;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n=int(input())
    l=[0]*(n+1)

    for x in range(1,10**2+1):
        for y in range(1,10**2+1):
            for z in range(1,10**2+1):
                val=x**2+y**2+z**2+x*y+y*z+z*x
                if val<=n:
                    l[x**2+y**2+z**2+x*y+y*z+z*x]+=1
                else: continue
    
    for i in range(1,n+1):
        print(l[i])
    
resolve()

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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const int maxn = 200*1000+10;
int cnt, n, cur, a[maxn], r[maxn];
ll k;
bool mark[maxn];

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i]--;
    }
    while (!mark[cur])
    {
        mark[cur] = 1;
        r[cur] = cnt++;
        cur = a[cur];
    }
    if (k <= r[cur])
    {
        cur = 0;
        for (int i = 0; i < k; i++)
            cur = a[cur];
        cout << cur + 1;
        return 0;
    }
    k -= r[cur];
    k %= cnt - r[cur];
    for (int i = 0; i < k; i++)
        cur = a[cur];
    cout << cur + 1;
	return 0;
}


Measured memory_bytes: 5392
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;
const ll MOD = 1000000007;

ll dp[2][2][67];
//Lより大きいことは確定？,Rより小さいことは確定？,Digit

ll solve(ll L, ll R, int pos) {
	for (int i = 0;i < 67;i++)
		for (int j = 0;j < 2;j++)
			for (int k = 0;k < 2;k++)
				dp[j][k][i] = 0;
	dp[0][0][64 - pos] = 1;
	for (int i = pos - 1;i >= 0;i--) {
		dp[0][0][63 - i] %= MOD;
		dp[1][0][63 - i] %= MOD;
		dp[0][1][63 - i] %= MOD;
		dp[1][1][63 - i] %= MOD;

		if (R & (1LL << i)) {
			if (L & (1LL << i)) {
				//両方不自由
				//L1R1のみ可能
				dp[0][0][64 - i] += dp[0][0][63 - i];

				//Lが自由
				//L0R0は可能
				dp[1][1][64 - i] += dp[1][0][63 - i];
				//L0R1,L1R1は可能、その後はRは不自由
				dp[1][0][64 - i] += dp[1][0][63 - i] * 2;

				//Rが自由
				//L1R1のみ可能
				dp[0][1][64 - i] += dp[0][1][63 - i];

				//LもRも自由
				//L0R0,L0R1,L1R1すべて可能
				dp[1][1][64 - i] += dp[1][1][63 - i] * 3;
			}
			else {
				dp[0][1][64 - i] += dp[0][0][63 - i];
				dp[0][0][64 - i] += dp[0][0][63 - i];
				dp[1][0][64 - i] += dp[0][0][63 - i];

				dp[1][0][64 - i] += dp[1][0][63 - i] * 2;
				dp[1][1][64 - i] += dp[1][0][63 - i];

				dp[0][1][64 - i] += dp[0][1][63 - i] * 2;
				dp[1][1][64 - i] += dp[0][1][63 - i];

				dp[1][1][64 - i] += dp[1][1][63 - i] * 3;
			}
		}
		else {
			if (L & (1LL << i)) {
				//両方不自由はありえない

				//Lが自由 0,0しかありえない
				dp[1][0][64 - i] += dp[1][0][63 - i];

				//Rが自由 1,1しかありえない
				dp[0][1][64 - i] += dp[0][1][63 - i];

				dp[1][1][64 - i] += dp[1][1][63 - i] * 3;
			}
			else {
				//両方不自由
				dp[0][0][64 - i] += dp[0][0][63 - i];

				//Lが自由 0,0しかありえない
				dp[1][0][64 - i] += dp[1][0][63 - i];

				//Rが自由 0,0 0,1だとLは不自由なまま
				dp[0][1][64 - i] += dp[0][1][63 - i] * 2;
				//1,1だとLは自由
				dp[1][1][64 - i] += dp[0][1][63 - i];

				dp[1][1][64 - i] += dp[1][1][63 - i] * 3;
			}
		}
	}
	return (dp[0][0][64] + dp[0][1][64] + dp[1][0][64] + dp[1][1][64]) % MOD;
}

int main() {
	ll L, R;
	cin >> L >> R;

	int lb, rb;
	for (int i = 0;i < 62;i++) {
		if (L & (1LL << i))lb = i;
		if (R & (1LL << i))rb = i;
	}

	ll ans = 0;
	if (lb == rb) {
		ans = solve(L, R, lb);
	}
	else {
		ans = solve(1LL << rb, R, rb) % MOD;
		for (int i = rb - 1;i > lb;i--) {
			ans += solve(1LL << i, (1LL << (i + 1)) - 1, i);
			ans %= MOD;
		}
		ans += solve(L, (1LL << (lb + 1)) - 1, lb);
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;

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

  vector<int> w;
  int s1 = 0, s2 = 0;
  rep (i, n) {
	int tmp;
	cin >> tmp;
	w.push_back(tmp);
	s2 += tmp;
  }

  int res = abs(s1 - s2);
  for (int tmp : w) {
	s1 += tmp;
	s2 -= tmp;
	res = min(res, abs(s1 - s2)); 
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
ll n;
int main()
{
	scanf("%lld",&n);
	for(int a1=1;a1<=3500;a1++)
		for(int a2=a1;a2<=3500;a2++)
		{
			ll fz=-n*a1-n*a2+4*a1*a2,fm=n*a1*a2;
			if(fz>0&&fm>0&&fm%fz==0) {printf("%d %d %lld",a1,a2,fm/fz); return 0;}
			
		}
	return 0;
}

Measured memory_bytes: 256
import string
N = int(input()) - 1
a = list(string.ascii_lowercase)
ans = ''
tmp = 0
m = 0
while True:
    m, v = divmod(N, 26)
    if m == 0:
        N = m
    else:
        N = m - 1
    ans += a[v]
    if N <= 25:
        break
if m != 0:
    ans += a[N]
print(ans[::-1])

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

int main() {
    string S;
    cin >> S;
    string T = "CODEFESTIVAL2016";
    int ans = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) {
            ans++;
        }
    }

    cout << ans << endl;
}

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

int main(){
	int n, p;
  	cin >> n >> p;
  	string s;
  	cin >> s;
  
  	if(10 % p == 0){
    	long long ans = 0;
      	rep(i, n){
        	if((s[i] - '0') % p == 0){
            	ans += i + 1;
            }
        }
      	cout << ans << endl;
       	return 0;
    }
  
  	vector<int> d(n + 1);
  	int ten = 1;
  	for(int i = n - 1; i >= 0;i--){
    	int a = (s[i] - '0') * ten % p;
      	d[i] = (d[i + 1] + a) % p;
      	ten *= 10; ten %= p;
    }
  
  	vector<int> cnt(p);
  	long long ans = 0;
  	for(int i = n; i >= 0; i--){
    	ans += cnt[d[i]];
      	cnt[d[i]]++;
    }
  	cout << ans << endl;
}

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

int main() {
  int n;cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v.at(i);
  sort(v.begin(),v.end());
  int sum = 0;
  rep(i,n-1) sum+=v.at(i);
  sum += v.at(n-1)/2;
  cout << sum << endl;
}

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

int main(){
    int K;
    string s;
    cin>>K>>s;
    
    if(s.size() <= K)cout<<s<<endl;

    else {
        s = s.substr(0,K);
        s += "...";
        cout<<s<<endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;                        // 任意長整数
using Real = mp::number<mp::cpp_dec_float<1024>>;// 仮数部が1024bitの浮動小数点数
#include<bits/stdc++.h>

using namespace std;
//using Bint = long long;


Bint fact(int n) {
	Bint cur = 1;
	for(Bint i = 1; i <= n; i++) {
		cur *= i;
	}
	return cur;
}

int main()
{
	int n, p; cin >> n >> p;
	int a[2] = {};

	for(int i = 0; i < n; i++)  {
		int c; cin >> c; a[c % 2]++;
	}

	Bint odd, aBint, oddans = 0;
	aBint = 1LL<<n;
	odd = 1LL<<(a[0]);


	for(int i = 1; i <= a[1]; i += 2) {
		oddans += odd * (fact(a[1]) / (fact(a[1] - i) * fact(i)) );
		if(oddans < 0) cout << i << endl;
	}
	cout << (p ? oddans : aBint - oddans) << endl;
}

Measured memory_bytes: 384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        ab: f64,
        bc: f64,
        ca: f64,
    }
    let s:f64 = (ab + bc + ca) / 2.;
    println!(
        "{}",
        (s* (s-ab)* (s- bc) * (s- ca)).sqrt()
    );
}


Measured memory_bytes: 4352
using System;
using System.Linq;

namespace Branch_on_Condition
{
    class Circle_in_a_Rectangle
    {
        static void Main(string[] args)
        {
            var token = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var W = token[0];
            var H = token[1];
            var x = token[2];
            var y = token[3];
            var r = token[4];

            if ((x - r < 0) || (x + r > W) || (y - r < 0) || (y + r > H)) Console.WriteLine("No");
            else Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 9420
#include<iostream>
#include<climits>
using namespace std;
int main()
{
  int ans,n,min[100],max[100],student[100][100],hand[100][100]={0};
  int a,t;
  while(cin>>n,n){
    for(int i=0;i<n;i++){
      min[i]=INT_MAX;
      max[i]=INT_MIN;
      for(int j=0;j<n;j++){
	cin>>student[i][j];
      }
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	min[i]=(min[i]<student[i][j]?min[i]:student[i][j]);
	max[i]=(max[i]>student[j][i]?max[i]:student[j][i]);
      }
    }
    ans=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if((student[i][j]==min[i])&&(student[i][j]==max[j]))ans=student[i][j];
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string A,B, C;
	cin >> A >> B >> C;
	cout << char('A' + A[0] - 'a') << char('A' + B[0] - 'a') << char('A' + C[0] - 'a') << endl;
	return 0;
}

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

map<string,int> m;

void change(){
    m["11"] = 'a'; m["12"] = 'b'; m["13"] = 'c'; m["14"] = 'd'; m["15"] = 'e';
    m["21"] = 'f'; m["22"] = 'g'; m["23"] = 'h'; m["24"] = 'i'; m["25"] = 'j';
    m["31"] = 'k'; m["32"] = 'l'; m["33"] = 'm'; m["34"] = 'n'; m["35"] = 'o';
    m["41"] = 'p'; m["42"] = 'q'; m["43"] = 'r'; m["44"] = 's'; m["45"] = 't';
    m["51"] = 'u'; m["52"] = 'v'; m["53"] = 'w'; m["54"] = 'x'; m["55"] = 'y';
    m["61"] = 'z'; m["62"] = '.'; m["63"] = '?'; m["64"] = '!'; m["65"] = ' ';
}

bool judge(string s){
    if(s.size()%2==1) return false;
    
    for(int i = 0 ; i < s.size(); i++){
        if(i%2==1 && !('1' <= s[i] && s[i] <='5')) return false;
        if(i%2==0 && !('1' <= s[i] && s[i] <= '6')) return false;
    }
    return true;
}

int main(){
    string str;
    
    change();
    
    while(cin >> str){
        if(!judge(str)) cout << "NA" << endl;
        else{
            string ans = "";
            for(int i = 0 ; i < str.size() ; i++){
                string k = str.substr(i,2);
                if(i%2==0){
                    ans += m[k];
                }
            }
            cout << ans << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn =1e5+10;
const int mod=20100501;





int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    s.resize(maxn);
    cin>>s;
    string a="dream";
    string b="dreamer";
    string c="erase";
    string d="eraser";
    int n=s.size();
    for(int i=0;i<n;)
    {
        string e=s.substr(i,5);
        string f=s.substr(i,6);
        if(f==d)
        {
            i+=6;
            continue;
        }
        if(e==c)
        {
            i+=5;
            continue;
        }
        if(e==a)
        {
            string g=s.substr(i,7);
            if(g==b)
            {
                if(s[i+7]=='a')
                {
                    i+=5;
                    continue;
                }
                else
                {
                    i+=7;
                    continue;
                }
            }
            else
            {
                i+=5;
                continue;
            }
        }

        cout<<"NO"<<'\n';
        return 0;
    }
    cout<<"YES"<<'\n';




}


Measured memory_bytes: 3760
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
using namespace std;

double Distance(vector<int> vecX, vector<int> vecY, int p)
{
	double dTemp = 0.0;
	double dSum = 0.0;
	for (int i = 0; i < vecX.capacity(); i++)
	{
		dTemp = abs(vecX[i] - vecY[i]);
		dSum += pow(dTemp, p);
	}
	return pow(dSum, 1.0 / p);
}

int main()
{
	int nMax = 0;
	vector<int> vecX, vecY;
	int nCount = 0;
	cin >> nCount;
	int nTemp, g;
	for (int i = 0; i < nCount; i++)
	{
		cin >> nTemp;
		vecX.push_back(nTemp);
	}
	for (int i = 0; i < nCount; i++)
	{
		cin >> nTemp;
		vecY.push_back(nTemp);
		g = abs(vecX[i] - nTemp);
		if (g > nMax)
		{
			nMax = g;
		}
	}
	cout << fixed << setprecision(6) << Distance(vecX, vecY, 1) << endl;
	cout << fixed << setprecision(6) << Distance(vecX, vecY, 2) << endl;
	cout << fixed << setprecision(6) << Distance(vecX, vecY, 3) << endl;
	cout << fixed << setprecision(6) << nMax << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 3464
#include <bits/stdc++.h>
#define gc() getchar()
using namespace std;

int in()
{
    int n = 0, c = 0;
    do {n = 10*n + (c & 0xf); c = gc();} while ('0'<=c && c<='9');
    return n;
}

void ins(string x)
{
    char ch = gc();
    do {x += ch; ch = gc();} while (ch!='\n' && ch!=' ');
}

int main()
{
    int n = in();
    vector<int> count(n, 0);

    int f = 0;
    for (int i=1; i<=n; i++)
    {
        for (int j=i; j<=n; j++)
        {
            for (int k=j; k<=n; k++)
            {
                f = i*i + j*j + k*k + i*j + j*k + k*i;
                if (f > n) break;

                if(i==j && j==k) count.at(f-1)++;
                else if (i==j || j==k) count.at(f-1) += 3;
                else count.at(f-1) += 6;
            }
            //if (f > n) break;
        }
    }

    for (int i=0; i<n; i++)
    {
        printf("%d\n", count.at(i));
    }
}


Measured memory_bytes: 3728
#include <iostream>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <list>
#include <math.h>
#include <map>
using namespace std;
#define REP(i, k, n) for(int i = k;i < n; i++)
#define rep(i, n) REP(i,0,n)
#define ll long long int
int dx[4] = {0,-1,1,0};
int dy[4] = {-1,0,0,1};
#define eps 10e-6
#define mod 1000000007
ll a[100001];
string str[101];
int main(void){
	int h, w;
	cin >> h >> w;
	rep(i,h){
		cin >> str[i];
	}
	rep(i,h){
		cout << str[i] << endl;
		cout << str[i] << endl;
	}
}


Measured memory_bytes: 256
import random
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
ans = 0
a = []
last = [0]*26
for i in range(1,d+1):
    res = -float("inf")
    index = 0
    for k in range(26):
        x = k
        tnplast = last
        tnplast[x] = i
        tnp = 0
        tnp += s[i-1][x]
        for j in range(26):
            tnp -= c[j]*(i-last[j])
        if (tnp > res):
            res = tnp
            index = k+1
    ans += res
    a.append(index)

def rec(t,x,y,ans):
    ans -= s[x-1][t[x-1]-1]
    ans += s[x-1][y-1]
    ma = d+1
    mi = 0
    for j in range(x+1,d+1):
        if (t[j-1]==t[x-1]):
            ma = j
            break
    for j in range(x-1,0,-1):
        if (t[j-1]==t[x-1]):
            mi = j
            break
    ans -= c[t[x-1]-1]*(x-mi)*(ma-x)
    ma = d+1
    mi = 0
    for j in range(x+1,d+1):
        if (t[j-1]==y):
            ma = j
            break
    for j in range(x-1,0,-1):
        if (t[j-1]==y):
            mi = j
            break
    ans += c[y-1]*(x-mi)*(ma-x)
    return ans
    
for i in range(180000):
    x = random.randrange(1,d+1)
    y = random.randrange(1,27)
    t = a
    A = rec(t,x,y,ans)
    if (ans < A):
        t[x-1] = y
        a = t
        ans = A

print(*a ,sep="\n")


Measured memory_bytes: 9688
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = int(lines[0])

    return (n, )

def solve(n):

    if n <= 2:
        return 0
    
    k = (n - 1 ) // 2  
    

    return int(k)
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
#include    <iostream>
#include    <string>

using namespace std;

int main() {
    // まず、mod26上のAと26がお互いに素となるAの値は、
    // {1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25}
    // である。問題で変換したアフィン暗号のパラメータAは、
    // この条件を満たすため、Aはこの範囲で決定できる。
    // 次に、A*(A^) mod 26 = 1となるモジュロ逆数A^は
    // {1, 9, 21, 15, 3, 19, 7, 23, 11, 5, 17, 25}
    // となるが、集合と見た場合はAと一致する。よって、
    // 順序を気にしない全探索の場合はAのパラメータを回すだけでよい
    int n;
    const int palmA[] = {1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25};

    cin >> n;
    cin.ignore();
    for(int i = 0; i < n; i++) {
        string cipher;
        getline(cin, cipher);

        for(auto a : palmA) {
            for(int b = 0; b < 26; b++) {
                string plain;
                // 複合処理
                // 暗号化関数 F(l)=(al+b) mod 26 より
                // 復号化関数 F^(l)=a(l-b) mod 26
                for(auto v : cipher)
                    plain += (v == ' ') ? ' ' : (a*((v-'a')+b) % 26 + 'a');
                if(plain.find("this") != -1 || plain.find("that") != -1) {
                    cout << plain << endl;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int N;
void input()
{
    cin>>N;
}

void solve()
{
    string ans="No";
    while(N>0){
        if(N%10==7){
            ans="Yes"; break;
        }
        N/=10;
    }
    cout<<ans<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3592
#方針: 753数を全列挙
n = gets.to_i

list = ["7","5","3"]
ary = []

(3..9).each do |digit|
  (0..3**digit-1).each do |bit|
    tmp = ""
    (0..bit.to_s(3).rjust(digit,"0").length-1).each do |i|
      tmp += list[bit.to_s(3).rjust(digit,"0")[i].to_i]
    end
    ary << tmp
  end
end

def is_753?(s)
  f7=f5=f3 = false
  s.chars do |c|
    case c
    when "7"
      f7=true
    when "5"
      f5=true
    when "3"
      f3=true
    end
  end
  return f7&&f5&&f3
end

flag = ary.map{|a| is_753?(a)}
  
ans = 0
ary.each_with_index do |a, i|
  if a.to_i <= n && flag[i]
    ans+=1
  end
end

p ans

Measured memory_bytes: 4092
#include<bits/stdc++.h>
using namespace std;
const int P=2019;
int L,R;
int a[P+5],tot;
void solve(){
	if(R-L>=2018)cout<<0;
	else {
		for(int i=L;i<=R;i++)a[++tot]=i%P;
		int minn=1e9;
		for(int i=1;i<=tot;i++)
			for(int j=1;j<=tot;j++){
				if(i==j)continue;
				minn=min(minn,a[i]*a[j]%P);
			}
		cout<<minn;
	}
}
int main(){
	cin>>L>>R;
	solve();
	return 0;
}

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

int main(){
 ll n,k; cin>>n>>k;
  
  cout<< (n+k-3)/(k-1) <<endl;
  
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

int dp[11000];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int H,N;
    cin>>H>>N;
    int A[11000],B[11000];
    for(int i=1;i<=N;i++) cin>>A[i]>>B[i];

    for(int i=0;i<11000;i++){
        dp[i]=MAX;
    }
    dp[H]=0;
    for(int i=H;i>=1;i--){
        for(int j=1;j<=N;j++){
            int a=A[j],b=B[j];
            chmin(dp[max(i-a,0)],dp[i]+b);
        }
    }
    cout<<dp[0]<<endl;
}

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

int main()
{
	int a[10000];
	int n;
	scanf("%d", &n);
	long long sum = 0, maxn = -1000000, minn = 1000000;
	int i;
	for(i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		sum = sum + a[i];
		if(a[i] >= maxn)
		{
			maxn = a[i];
		}
		if(a[i] <= minn)
		{
			minn = a[i];
		}
	}
	printf("%lld %lld %lld\n", minn, maxn, sum);
	return 0;	
}


Measured memory_bytes: 2092