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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

constexpr ll BIG = 1000000000000L;

int query(vi& balls) {
    // replace with binary search
    cout << "? ";
    for (auto ball : balls) cout << ball + 1 << " ";
    cout << endl;

    string ans;
    cin >> ans;
    if (ans == "Red") return 0;
    else if (ans == "Blue") return 1;
    else return -1; 
}

int find_trans(int N) {
    vi balls(N);
    for (int j=0;j<N;j++) balls[j] = j;
    int left_val = query(balls);
    
    int left = 0;
    int right = N;

    while (right - left > 1) {
        int mid = (left + right) / 2;
        for (int j=0;j<N;j++) balls[j] = mid+j;
        int cur = query(balls);

        if (cur == left_val) {
            left = mid;
        } else {
            right = mid;
        }
    }
    return right;
}

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

    int N;
    cin >> N;

    int x = find_trans(N);

    vi colors(2*N, -1);

    vi balls(N);
    for (int i=0;i<N-1;i++) balls[i] = x+i;
    for (int i=0;i<2*N;i++) {
        if (i < x || i >= x+N-1) {
            balls[N-1] = i;
            colors[i] = query(balls);
        }
        
    }
    for (int i=0;i<N-1;i++) {
        balls[i] = x-1;
        balls[N-1] = x+N-1;
        colors[x+i] = 1 - query(balls);
        balls[i] = x+i;
    }

    cout << "! ";
    for (auto color: colors) {
        if (color == 0) cout << "R";
        if (color == 1) cout << "B";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 724
/*  ex2_3
      fmuacshai */
 
#include <stdio.h>
 
int main(void){
  //Nは一辺のマスの個数、Aは白のマス目の数、Blackは黒のマスの個数
  int N,A,Black;
  //Nを入力
  scanf("%d",&N);
  //Aを入力
  scanf("%d",&A);
  //黒のマス目の個数の計算
  Black=N*N-A;
  //黒のマス目の個数を出力
  printf("%d\n",Black);
  return 0;
}

Measured memory_bytes: 128
fn main() {
    let v = read_vec::<i32>();
    let (sx, sy) = (v[0], v[1]);
    let (tx, ty) = (v[2], v[3]);
    let y = ty - sy;
    let x = tx - sx;

    for (t, c) in vec![
        (y, 'U'),
        (x, 'R'),
        (y, 'D'),
        (x, 'L'),
        (1, 'L'),
        (y + 1, 'U'),
        (x + 1, 'R'),
        (1, 'D'),
        (1, 'R'),
        (y + 1, 'D'),
        (x + 1, 'L'),
        (1, 'U'),
    ] {
        for _ in 0..t {
            print!("{}", c);
        }
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<stdio.h>

main(){
int N,i,j;
int A[100];

scanf("%d",&N);
for(i=0;i<N;i++)scanf("%d",&A[i]);

trace(A,N);
sort(A,N);

return 0;

}

void trace(int A[],int N){
int i;

for(i=0;i<N;i++){
if(i>0)printf(" ");
printf("%d",A[i]);
}
printf("\n");
}

void sort(int A[],int N){
int i,j,k;

for(i=1;i<N;i++){
k=A[i];
j=i-1;
while(j>=0&&A[j]>k){
A[j+1]=A[j];
j--;
}
A[j+1]=k;
trace(A,N);
}
}

Measured memory_bytes: 600
from operator import itemgetter

n, m = map(int, input().split())

requests = [tuple(map(int, input().split())) for _ in range(m)]
requests = sorted(requests, key=itemgetter(1))

counter = 1
now = requests[0][1]
for request in requests[1:]:
    if request[0] >= now:
        now = request[1]
        counter += 1

print(counter)


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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

int main() {
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	a -= b;
	if (d % 2) {
		a = -a;
	}
	cout << a<< "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long mod=1e9+7;
long long sum,t;
int n;
long long a;
int main()
{
    cin>>n;
    while(n>0)
    {
        cin>>a;
        (sum+=a*t)%=mod;
        (t+=a)%=mod;
        n--;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3612
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 2 * (int)1e5 + 10;
vector < int > g[maxN];
vector < int > f[2];
bool used[maxN];
int p[maxN];
int cnt[3];
vector < int > t[3];
void dfs(int v, int p, int par) {
    f[par].push_back(v);
    for (int to : g[v]) {
        if (to == p) continue;
        dfs(to, v, par ^ 1);
    }
}
void en() {
    for (int i = 1; i <= n; i++) {
        if (!used[i]) {
            for (int j = 0; j < 3; j++) {
                if (!t[j].empty()) {
                    p[i] = t[j].back();
                    t[j].pop_back();
                    break;
                }
            }
        }
    }
    for (int i = 1; i <= n; i++) cout << p[i] << " ";
    exit(0);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n - 1; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1, -1, 0);
    cnt[0] = n / 3;
    cnt[1] = (n + 2) / 3;
    cnt[2] = (n + 1) / 3;
    for (int i = 1; i <= n; i++) t[i % 3].push_back(i);
    for (int p = 0; p < 2; p++) {
        if (cnt[1] + cnt[2] <= f[p].size()) {
            for (int v : f[p]) {
                for (int r = 1; r <= 2; r++) {
                    if (!t[r].empty()) {
                        used[v] = true;
                        ::p[v] = t[r].back();
                        t[r].pop_back();
                        break;
                    }
                }
            }
            en();
        }
    }
    for (int p = 0; p < 2; p++) {
        if (cnt[1] <= f[p].size() && cnt[2] <= f[p ^ 1].size()) {
            for (int v : f[p]) {
                for (int r = 1; r <= 1; r++) {
                    if (!t[r].empty()) {
                        used[v] = true;
                        ::p[v] = t[r].back();
                        t[r].pop_back();
                    }
                }
            }
            for (int v : f[p ^ 1]) {
                for (int r = 2; r <= 2; r++) {
                    if (!t[r].empty()) {
                        used[v] = true;
                        ::p[v] = t[r].back();
                        t[r].pop_back();
                    }
                }
            }
            en();
        }
    }
    assert(false);
    return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int64_t N, K; cin >> N >> K;
  int64_t p = 0;
  if (K % 2 == 0) {
    REP(n, 1, N + 1) {
      if (n % K == K / 2) {
        p++;
      }
    }
  }
  int64_t a = N / K;
  cout << p * p * p + a * a * a << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
using namespace std;
using ll=long long;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

  int N;
  string S;
  int K;
  cin>>N;
  cin>>S;
  cin>>K;

  char s = S[K-1];
  REP(i,S.length()){
    if(S[i]!=s) S[i]='*';
  }

  cout<<S<<endl;
  return 0;
}

Measured memory_bytes: 256
#C
N,T = map(int,input().split())
t = list(map(int,input().split()))

now = -1
ans = 0
for i in range(N):
    if now <= t[i]:
        ans+=T
        now = T+t[i]
    else:
        ans+=T
        ans-=now-t[i]
        now = T+t[i]
        
print(ans)



Measured memory_bytes: 26836
// AOJ 2473 Poor Computer
// 2018.2.1 bal4u

#include <stdio.h>

#define MAX 42

int lim;
long long goal;

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int bitcount64(long long x)
{
	x = ((x & 0xAAAAAAAAAAAAAALL) >>  1) + (x & 0x55555555555555LL);
	x = ((x & 0xCCCCCCCCCCCCCCLL) >>  2) + (x & 0x33333333333333LL);
	x = ((x & 0xF0F0F0F0F0F0F0LL) >>  4) + (x & 0x0F0F0F0F0F0F0FLL);
	x = ((x & 0x00FF00FF00FF00LL) >>  8) + (x & 0xFF00FF00FF00FFLL);
	x = ((x & 0xFF0000FFFF0000LL) >> 16) + (x & 0x00FFFF0000FFFFLL);
	x = ((x & 0xFFFFFF00000000LL) >> 32) + (x & 0x000000FFFFFFFFLL);
	return (int)x;
}

int trailingZero(long long x)
{
	int k = 0;
	while (!(x & 1)) k++, x >>= 1;
	return k;
}

int dfs(long long s, int k)
{
	int i, j, t;
	long long s1, s2;

	if (k + bitcount64(goal & ~s) > lim) return 0;
	if ((goal & s) == goal) return 1;

	for (s1 = s; s1; s1 &= s1-1) {
		i = trailingZero(s1);
		for (s2 = s; s2; s2 &= s2-1) {
			j = trailingZero(s2);
			if (i+j <= MAX && !((s >> (i+j))&1)) {
				if (dfs(s | (1LL << (i+j)), k+1)) return 1;
			}
			t = i-j; if (t < 0) t = -t;
			if (t > 0 && !((s >> t)&1)) {
				if (dfs(s | (1LL << t), k+1)) return 1;
			}
		}
		for (; i <= MAX; i <<= 1) {
			if (!((s >> i) & 1)) {
				if (dfs(s | (1LL << i), k+1)) return 1;
			}
		}
	}
	return 0;
}

int main()
{
	int n, i;
 
	n = in();
	for (i = 0; i < n; i++) goal |= 1LL << in();
	for (lim = n; lim <= MAX; lim++) if (dfs(2LL, 0)) break;
	printf("%d\n", lim);
	return 0;
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
//#define int long long
signed main(){
    int n,m,q;
    cin >> n >> m >>q;
    int s[n+2][m+2]={0};
    string ll;
    for(int i=0;i<=n+1;i++){s[i][0]=0;s[i][m+1]=0;}
    for(int j=0;j<=m+1;j++){s[0][j]=0;s[n+1][j]=0;}
    for(int i=1;i<=n;i++){
        cin >> ll;
        for(int j=1;j<=m;j++){
         s[i][j]=int(ll[j-1])-48;
        }
    }
    int t[n+1][m+1]={0};
    for(int i=0;i<=n;i++)t[i][0]=0;
    for(int j=0;j<=m;j++)t[0][j]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i][j]==1){
                t[i][j]=2-s[i-1][j]-s[i][j-1]-s[i+1][j]-s[i][j+1];
            }
        }
    }
    int hasi[n+1][m+1]={0};
      for(int i=0;i<=n;i++)hasi[i][0]=0;
    for(int j=0;j<=m;j++)hasi[0][j]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            hasi[i][j]=hasi[i-1][j]+hasi[i][j-1]-hasi[i-1][j-1]+t[i][j];
        }
    }
    int ren1[n+1][m+1]={0};
      for(int i=0;i<=n;i++)ren1[i][0]=0;
    for(int j=0;j<=m;j++)ren1[0][j]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            ren1[i][j]=ren1[i][j-1];
            if(s[i][j]==1&&s[i+1][j]==1)ren1[i][j]++;
        }
    }
    int ren2[n+1][m+1]={0};
      for(int i=0;i<=n;i++)ren2[i][0]=0;
    for(int j=0;j<=m;j++)ren2[0][j]=0;
    for(int j=1;j<=m;j++){
        for(int i=1;i<=n;i++){
            ren2[i][j]=ren2[i-1][j];
            if(s[i][j]==1&&s[i][j+1]==1)ren2[i][j]++;
        }
    }
    int x1,y1,x2,y2;
    
    //cout << hasi[3][0]<<ren1[0][0]<<ren2[0][0]<<endl;
    for(int t=0;t<q;t++){
        cin >> x1>>y1>>x2>>y2;
       // cout << ' '<<hasi[x2][y2]<<' '<<hasi[x1-1][y2]<<' '<<hasi[x2][y1-1]<<' '<<hasi[x1-1][y1-1]<<' '<<ren1[x2][y2]<<' '<<ren1[x1-1][y2]<<' '<<ren1[x2][y1-1]<<' '<<ren1[x1-1][y1-1]<<' '<<ren2[x2][y2]<<' '<<ren2[x2][y1-1]<<' '<<ren2[x1-1][y2]<<' '<<ren2[x1-1][y1-1]<<endl;
    
        cout <<(hasi[x2][y2]-hasi[x1-1][y2]-hasi[x2][y1-1]+hasi[x1-1][y1-1]+ren1[x2][y2]+ren1[x1-1][y2]-ren1[x2][y1-1]-ren1[x1-1][y1-1]+ren2[x2][y2]+ren2[x2][y1-1]-ren2[x1-1][y2]-ren2[x1-1][y1-1])/2<<endl;
    }



    return 0;
}


Measured memory_bytes: 80640
import numpy as np
n, m = map(int, input().split())
v = [list(map(int, input().split())) for i in range(n)]
ans = 0
op = [-1,1]
for i in range(2):
    for j in range(2):
        for k in range(2):
            sx, sy, sz = op[i], op[j], op[k]
            dp = np.full(m+1, -np.inf, dtype=np.float64)
            dp[0] = 0
            for x, y, z in v:
                x *= sx
                y *= sy
                z *= sz
                dp[1:] = np.maximum(dp[1:], dp[:-1]+x+y+z)
            ans = max(ans, dp[-1])
print(int(ans))

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

int main() 
{ 
    long long int N,i,cont=0,res=0;
    string s;
    vector<string> v;
   
    cin>>N;
    for(i=0;i<N;i++){
      cin>>s;
      //sortString(s);
      sort(s.begin(), s.end());
      //cout<<s<<endl;
      v.push_back(s);
    }

    sort(v.begin(),v.end());

    for(long long int i=0;i<v.size();i++)
    {
      cont++;
      //cout<<v[i]<<endl;
      if(v[i]!=v[i+1]){
        if(cont>1){
          res=res+(cont-1)*cont/2;           
        }
        cont=0;        
      }
      
    }
    cout<<res<<endl;
    return 0; 
} 




Measured memory_bytes: 4852
import math
n,d = map(int,input().split())
list_x = [[int(i) for i in input().split()] for _ in range(n)]
count = 0
for i in range(n):
    for j in range(i+1,n):
        sum_ = 0
        for k in range(d):
            sum_ += (list_x[i][k] - list_x[j][k])**2
        if math.sqrt(sum_) ==(math.sqrt(sum_))//1:
            count += 1
print(count)

Measured memory_bytes: 3188
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        stdIn.close();
        
        if (N / 100 == 7) {
            System.out.println("Yes");
        } else if ((N % 100) / 10 == 7) {
            System.out.println("Yes");
        } else if (N % 10 == 7) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35760
N = int(input())
H = list(map(int, input().split()))
INF = 10000000000
dp = [INF] * N
dp[0] = 0

for i in range(N-1):
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]))
    if i <= N - 3:
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]))

print(dp[N - 1])

Measured memory_bytes: 52208
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    ll H; cin >> H;
    int N; cin >> N;
    ll sum = 0;
    vector<int> A(N); repp(i,0,N) {
        cin >> A[i];
        sum += A[i];
    }
    if(sum >= H) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
	ll n,res=0;
	cin>>n;
	for(ll i=2;i*i<=n;i++)
	if(n%i==0){
		ll cnt=0;
		while(n%i==0){
			n/=i;
			cnt++;
		}
		ll j=1;
		while(1){
			if(j*(j+1)>2*cnt)
			break;
			res++;
			j++;
		}
	}
	if(n>1)
	res++;
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


Measured memory_bytes: 3644
import numpy as np
D = int(input())
c = np.array(list(map(int,input().split())))
s = np.array([list(map(int,input().split())) for _ in range(D)])
t = np.array([int(input())-1 for _ in range(D)])

last = np.full(26,-1)

S = 0
score = 0;
for i,v in enumerate(t):
    S += s[i][v]
    last[v] = i
    tmp =c*(i - last)
    S -= sum(tmp) 
    score +=max(10**6+S,0)
    print(S)


Measured memory_bytes: 27376
#include <iostream>
#include <vector>

using namespace std;

const int M = 1e9+7;

int n;
vector<int> edge[100005];
long long dp[100005][2]; // 0...White, 1...Black
bool done[100005];

void dfs(int u)
{
  done[u] = true;
  dp[u][0] = dp[u][1] = 1;
  for (int v: edge[u]) {
    if (done[v]) continue;
    dfs(v);
    dp[u][0] *= dp[v][0] + dp[v][1];
    dp[u][1] *= dp[v][0];
    dp[u][0] %= M;
    dp[u][1] %= M;
  }
}

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y; cin >> x >> y;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  
  dfs(1);
  
  cout << (dp[1][0] + dp[1][1]) % M << endl;
  return 0;
}

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

int main ()
{
    string str;
    map<int,int> m;
    while (getline(cin, str)) {
        if (str == "") break;
        stringstream ss;
        for (int i = 0;i < str.size(); i++)
            if (str[i] == ',') str[i] = ' ';
        ss << str;
        int n, d;
        ss >> n >> d;
        m[n]++;
    }

    set<int> v;
    while (getline(cin, str)) {
        if (str == "") break;
        stringstream ss;
        for (int i = 0;i < str.size(); i++)
            if (str[i] == ',') str[i] = ' ';
        ss << str;
        int n, d;
        ss >> n >> d;
        if (m.find(n) != m.end()) {
            v.insert(n);
            m[n]++;
        }
    }

    vector<pair<int,int> > p;
    for (auto& i : v) {
        p.push_back(pair<int,int>(i, m[i]));
    }
    sort(p.begin(), p.end());
    for (int i = 0; i < p.size(); i++) {
        cout << p[i].first << " " << p[i].second << endl;
    }

    return 0;
}

Measured memory_bytes: 1232
def dijkstra(g, s)
  def penq(pq, val)
    pq << val
    cd = pq.size
    pr = cd / 2
    until pr.zero? || (pq[pr - 1] <=> pq[cd - 1]) < 0
      pq[pr - 1], pq[cd - 1] = pq[cd - 1], pq[pr - 1]
      cd = pr
      pr = cd / 2
    end
  end
  def pdeq(pq)
    pq[0], pq[-1] = pq[-1], pq[0]
    rs = pq.delete_at(-1)
    unless pq.empty?
      pr = 1
      cd = [pr * 2, pr * 2 + 1].select { |i| pq[i - 1] }.min_by { |i| pq[i - 1] }
      until cd.nil? || (pq[pr - 1] <=> pq[cd - 1]) < 0
        pq[pr - 1], pq[cd - 1] = pq[cd - 1], pq[pr - 1]
        pr = cd
        cd = [pr * 2, pr * 2 + 1].select { |i| pq[i - 1] }.min_by { |i| pq[i - 1] }
      end
    end
    rs
  end

  pq = []
  d = Array.new(g.size) { Float::INFINITY }
  d[s] = 0
  penq(pq, [0, s])
  until pq.empty?
    v_cost, v = pdeq(pq)
    next if d[v] < v_cost
    g[v].each do |e|
      if d[e[:to]] > d[v] + e[:cost]
        d[e[:to]] = d[v] + e[:cost]
        penq(pq, [d[e[:to]], e[:to]])
      end
    end
  end
  d
end

v, e, r = gets.split.map(&:to_i)
g = Array.new(v) { [] }
e.times do
  s, t, d = gets.split.map(&:to_i)
  g[s] << {to: t, cost: d}
end

dijkstra(g, r).each do |sum|
  puts (sum == Float::INFINITY ? 'INF' : sum)
end

Measured memory_bytes: 169720
#include <stdio.h>

int main() {
    int input;
    scanf("%d", &input);

    long long result = 0;
    long long tmp1 = 0;

    tmp1 = input % 500;
    result = ((input - tmp1) / 500) * 1000;
    
    result += ((tmp1) / 5) * 5;


    printf("%lld", result);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N,R;
cin >> N >> R;

if(N >= 10) {
    cout << R << endl;
    return 0;
}

cout << R + 100 * (10 - N) << endl;


return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<queue>
#define int long long
using namespace std;
const int N=200010;
int n,m,x,y,z,tot,pool,cnt,ans,A[N],B[N],s[N],f[N],rt[N],first[N],a[N<<1][2];
struct tjm{int node,val;} now;
struct tree{int lc,rc,node,val;} t[N<<1];
struct cmp{
	bool operator () (tjm p,tjm q) {
		return p.val>q.val;
	}
};
priority_queue<tjm,vector<tjm>,cmp> h,hh;
inline int read() {
	int tmp=0, fh=1; char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') fh=-1; c=getchar();}
	while (c>='0'&&c<='9') tmp=tmp*10+c-48, c=getchar();
	return tmp*fh;
}
inline void ins_ed(int x,int y) {
	a[++tot][1]=y;
	a[tot][0]=first[x];
	first[x]=tot;
}
int gf(int x) {return x==f[x]?x:f[x]=gf(f[x]);}
inline int newnode(int x) {
	t[++pool]=(tree){0,0,x,A[x]-B[x]};
	return pool;
}
int merge(int x,int y) {
	if ((!x)||(!y)) return x+y;
	if (t[x].val>t[y].val) swap(x,y);
	t[x].rc=merge(t[x].rc,y);
	swap(t[x].lc,t[x].rc);
	return x;
}
inline void gather(int x,int y) {
	f[y]=x; s[x]+=s[y];
	rt[x]=merge(rt[x],rt[y]);
}
inline void update(int x) {
	while (gf(t[rt[x]].node)==x) rt[x]=merge(t[rt[x]].lc,t[rt[x]].rc);
}
signed main() {
	n=read(); m=read();
	for (int i=1;i<=n;i++) A[i]=read(), B[i]=read();
	for (int i=1;i<=m;i++) {
		x=read(); y=read();
		ins_ed(x,y); ins_ed(y,x);
	}
	for (int i=1;i<=n;i++) hh.push((tjm){i,A[i]-B[i]});
//	for (int i=1;i<=n;i++) if (A[i]<=B[i]) f[i]=i, s[i]=B[i], cnt++;
//	for (int i=1;i<=n;i++) if (f[i]) {
//		x=gf(i);
//		for (int j=first[i];j;j=a[j][0]) {
//			y=a[j][1];
//			if (!f[y]) rt[x]=merge(rt[x],newnode(y));
//			else if (gf(y)!=x) gather(x,gf(y));
//		}
//	}
//	for (int i=1;i<=n;i++) if (f[i]==i) {
//		update(i);
//		h.push((tjm){i,t[rt[i]].val-s[i]});
//	}
	ans=0;
	while (cnt<n) {
		//printf("! %d %d\n",hh.top().node,hh.top().val);
		if (h.empty()||(hh.top().val<=h.top().val)) {
			now=hh.top(); hh.pop();
			x=now.node; if (f[x]) continue;
			//printf(" %d %d\n",x,now.val);
			ans=max(ans,now.val);
			f[x]=x; s[x]=B[x], cnt++;
			for (int i=first[x];i;i=a[i][0]) {
				y=a[i][1];
				if (!f[y]) rt[x]=merge(rt[x],newnode(y));
				else gather(x,gf(y));
			}
			if (rt[x]) {
				update(x); h.push((tjm){x,t[rt[x]].val-s[x]});
			}
			continue;
		}
		now=h.top(); h.pop();
		x=now.node; if (f[x]!=x) continue;
		y=t[rt[x]].node; ans=max(ans,now.val);
		//printf("%d %d %d\n",x,y,now.val);
		rt[x]=merge(t[rt[x]].lc,t[rt[x]].rc);
		f[y]=x; s[x]+=B[y]; cnt++;
		for (int i=first[y];i;i=a[i][0]) {
			z=a[i][1];
			if (!f[z]) rt[x]=merge(rt[x],newnode(z));
			else if (gf(z)!=x) gather(x,gf(z));
		}
		if (rt[x]) {
			update(x);
			h.push((tjm){x,t[rt[x]].val-s[x]});
		}
	}
	for (int i=1;i<=n;i++) ans+=B[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 19056
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <iomanip>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <cassert>
#include <stack>
#include <climits>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <memory>
#include <functional>
#include <cfloat>
#include <numeric>
#include <random>


int main() {
	long long int height, width; std::cin >> height >> width;
	int min_diff = (height % 3 == 0 || width % 3 == 0) ? 0 : std::min(height, width);
	for (auto cut = 1LL; cut < height; ++cut) {
		const auto rest = height - cut;
		const auto a = std::max(rest, cut) * (width >> 1);
		const auto b = std::min(rest, cut) * width;
		const auto c = height * width - a - b;
		min_diff = std::min<long long int>(min_diff, std::max({ a, b, c }) - std::min({ a, b, c }));
	}
	for (auto cut = 1LL; cut < width; ++cut) {
		const auto rest = width - cut;
		const auto a = std::max(rest, cut) * (height >> 1);
		const auto b = std::min(rest, cut) * height;
		const auto c = height * width - a - b;
		min_diff = std::min<long long int>(min_diff, std::max({ a, b, c }) - std::min({ a, b, c }));
	}
	std::cout << min_diff << '\n';
}

Measured memory_bytes: 3596
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=pow(10,9)+7

h,w=map(int,input().split())
s=[input() for i in range(h)]
d=[[1,0],[0,1],[-1,0],[0,-1]]

whitecnt=0
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            whitecnt+=1
grid=[[0]*w for i in range(h)]
grid[0][0]=1
q=deque([[0,0,1]])

while q:
    x,y,dist=q.popleft()
    for xd, yd in d:
        if 0<=x+xd<w and 0<=y+yd<h and grid[y+yd][x+xd]==0 and s[y+yd][x+xd]==".":
            if x+xd==w-1 and y+yd==h-1:
                print(whitecnt-(dist+1))
                exit()

            grid[y+yd][x+xd]=1
            q.append([x+xd,y+yd,dist+1])

print(-1)

Measured memory_bytes: 66412
<?php
fscanf(STDIN, "%d", $N);
$list = fscanf(STDIN, str_repeat("%d", $N));
fscanf(STDIN, "%d", $Q);
$array = [];
$sum = 0;
foreach($list as $value){
    if(!isset($array[$value])){
        $array[$value] = 1;
    }else{
        $array[$value]++;
    }
    $sum += $value;
}

while($Q--){
    [$B,$C] = fscanf(STDIN, "%d%d");
    if(isset($array[$B])){
        $sum -= $B * $array[$B];

        $sum += $C * $array[$B];
        if(!isset($array[$C])){
            $array[$C] = $array[$B];
        }else{
            $array[$C] += $array[$B];
        }
        unset($array[$B]);

    }
    echo $sum.PHP_EOL;


}

Measured memory_bytes: 24516
function main(input) {
  const s = input.trim()
  const l = s.length
 
  let answer = 999
  
  for (let i = 0; i + 3 <= l; i++) {
    const t = Math.abs(parseInt(s.substring(i, i + 3), 10) - 753)
    if (t < answer) {
      answer = t
    }
  }
  console.log(answer)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 29380
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vector <ll> vec
#define pair <ll,ll> pa
#define make_pair mp
#define push_back pb
bool pal(ll i,ll j,string s)
{
	while(i<j)
	{
		if(s[i]!=s[j])
			return false;
		i++;
		j--;
	}
	return true;
}
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	ll len=s.length();
	ll a=(len-1)/2;
	a--;
	ll b=(len+3)/2;
	b--;
	if(pal(0,a,s) && pal(b,len-1,s) && pal(0,len-1,s))
	{
		cout<<"Yes";
	}
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

/*
cin.tie(0);
ios::sync_with_stdio(false);
*/

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(a-b<=1000000000000000000){
    cout<<(k%2==0?a-b:-(a-b))<<endl;
  }else{
    cout<<"Unfair"<<endl;
  }
  return 0;
}


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

int main() {

	int n; cin >> n;
	vector<vector<int>> num(10, vector<int>(10, 0));
	for (int i = 1; i <= n; i++) {
		vector<int> d;
		int tmp_i = i;
		while (0 < tmp_i) {
			d.push_back(tmp_i % 10);
			tmp_i /= 10;
		}
		int a = d[0];
		int b = d[d.size() - 1];
		if (a == 0 || b == 0) continue;
		num[a][b]++;
	}
	int ans = 0;
	for (int a = 1; a <= 9; a++) {
		for (int b = 1; b <= 9; b++) {
			ans += num[a][b] * num[b][a];
		}
	}
	cout << ans << endl;
    return 0;
}

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

int main() {
  string s;
  cin>>s;
  if((s[0]==s[1] && s[2]==s[3]) && s[0]!=s[2]) cout<<"Yes"<<endl;
  else if((s[0]==s[2] && s[1]==s[3]) && s[0]!=s[1]) cout<<"Yes"<<endl;
  else if((s[0]==s[3] && s[1]==s[2]) && s[0]!=s[2]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import sys
from collections import Counter
from collections import deque
import math
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
h=lmp()
for i in range(n-1):
    if h[n-i-2]-h[n-i-1]>=2:
        print("No")
        exit()
    if h[n-i-2]-h[n-i-1]==1:
        h[n-i-2]-=1
print("Yes")


Measured memory_bytes: 14900
#include <iostream>
#include <array>
#include <algorithm>
#include <stack>

const int nmax = 105;
const int NIL = -1;

int n, t;
// state of vertex
// 0: not visited
// 1: visited
// 2: complete search from the vertex
std::array<int, nmax> color, d, f;

std::array<std::array<int, nmax>, nmax> adj;


void dfs_1v(int v)
{
  d[v] = ++t;
  color[v] = 1;

  for (int j=0; j<n; ++j)
    {
      if (adj[v][j] == 1 && color[j] ==0)
        {
          dfs_1v(j);
        }
    }
  f[v] = ++t;
  color[v] = 2;
}

void dfs()
{
  t = 0;
  for (int i=0; i<n; ++i)
    {
      if (color[i] != 2)
        dfs_1v(i);
    }
}

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

  color.fill(0);
  std::for_each(adj.begin(), adj.end(), [](auto x){x.fill(0);});
  for (int i=0; i<n; ++i)
    {
      int u, k;
      std::cin >> u >> k;
      for (int j=0; j<k; ++j)
        {
          int v;
          std::cin >> v;
          adj[u-1][v-1] = 1;
        }
    }

  dfs();

  for (int i=0; i<n; ++i)
    {
      std::cout << i+1 << ' ' << d[i] << ' ' << f[i] << std::endl;
    }

}



Measured memory_bytes: 3128
//02
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f,a|b|c|d|e|f;){
    int x=a+d;
    int y=b+e;
    int z=c+f;
    int xt=(x-1)/3;
    int yt=(y-1)/3;
    int zt=(z-1)/3;
    x-=xt*3;
    y-=yt*3;
    z-=zt*3;
    int ar[]={x,y,z};
    sort(ar,ar+3);
    int ex=max(ar[0],(int)count(ar,ar+3,3));
    cout<<xt+yt+zt+ex<<endl;
  }
  return 0;
}
    

Measured memory_bytes: 1176
<?php
//m,f,r

while(true){
    
fscanf(STDIN, "%d %d %d", $m, $f, $r);
if($m + $f + $r == -3 ){
    break;
}elseif($m == -1 || $f == -1 || $m + $f < 30){
    $grade = "F";
}elseif($m + $f >= 80){
    $grade = "A";
}elseif($m + $f >= 65){
    $grade = "B";
}elseif($m + $f >= 50 or $r >= 50){
    $grade = "C";
}elseif($m + $f >= 30){
    $grade = "D";
}
echo $grade.PHP_EOL;

}

Measured memory_bytes: 15264
//write：Sakura
//id：
//problem：
//note：

#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long ll;

int n,k;
int a[200005];
int t[200005];

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		t[a[i]]++;
	}
	sort(t,t+n+1,greater<int>());
	for(int i=0;i<k;i++){
		n-=t[i];
	}
	printf("%d\n",n);
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>

#define NMAX (10001)

using namespace std;

bool prime[NMAX];

int main() {
	for(int i=0; i<NMAX; i++) prime[i]= true;
	prime[0] = prime[1] = false;
	for(int i=2; i<NMAX; i++) {
		if(prime[i]) {
			int j = i*2;
			while(j<NMAX) {
				prime[j] = false;
				j += i;
			}
		}
	}
	
	for(int i; cin >> i;) {
		int ans = 0;
		for(int j=1; j<i; j++) {
			if(prime[j] && prime[i+1-j]) ans++;
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1168
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val s = scanner.next()!!
    val n = Integer.parseInt(s).toLong()
    val sum = (0..n).reduce { acc, i ->
        acc + when (i % 3 == 0.toLong() || i % 5 == 0.toLong()) {
            true -> 0
            else -> i
        }
    }
    println(sum)
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  ll minusCount = 0;
  vl a(n);
  ll ans = 0;
  REP(i,n){
    cin >> a[i];
    if(a[i]<0) minusCount ++;
    a[i] = abs(a[i]);
    ans += a[i];
  }
  sort(a.begin(),a.end());
  if(minusCount%2==1) ans -= 2*a[0];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int n,k,x,y,sum=0;
	scanf("%d %d %d %d",&n,&k,&x,&y);
	if(n<=k)
	sum+=n*x;
	if(n>k)
	sum+=x*k+(n-k)*y;
	printf("%d",sum);
	
	return 0;
}

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

history = [None] * N

pos = 0
for idx in range(N + 1):
    if history[pos] != None:
        offset = history[pos]
        step = idx - offset
        break
    else:
        history[pos] = idx
        pos = A[pos] - 1

if K >= offset:
    n_step = (K - offset) // step
    n_targ = K - (offset + n_step * step)
    for _ in range(n_targ):
        pos = A[pos] - 1
else:
    pos = 0
    for _ in range(K):
        pos = A[pos] - 1
        
print(pos + 1)

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

int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	int ans;
	ans = (H-h)*(W-w);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3580
h, w = gets.split.map(&:to_i)
n = gets.to_i
a = gets.split.map(&:to_i)
f = Array.new(h).map{Array.new(w)}
r, c = 0, 0
i = 0
while true
  break if i == a.size
  if w - c < a[i]
    f[r].fill(i.succ, c...w)
    a[i] -= w - c
    r += 1
    c = 0
  else
    f[r].fill(i.succ, c...c + a[i])
    c += a[i]
    i += 1
  end
end
f.map.with_index{ |f_, i|
  i.even? ? f_ : f_.reverse
}.each{ |f_|
  puts f_ * ' '
}

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

int main(){
  string s; cin >> s;
  int a[26]={};
  bool check=true;
  for(int i=0; i<s.size(); i++){
    a[s[i]-'a']++;
    if(a[s[i]-'a']>1){
      check=false;
      break;
    }
  }
  cout << (check==true?"yes":"no") << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n, s, cnt;
int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

// ??°???{a} ??? i???????????§?????°?????§????????????.
void dfs(int i, int sum, int depth) {
    if (depth == n && sum == s) { cnt++; }

    if (i == 10 || depth == n || sum > s) return;
    // a[i]???????????´???
    dfs(i + 1, sum + a[i], depth + 1);
    // a[i]?????????????????´???
    dfs(i + 1, sum, depth);
}

int main() {
    while (cin >> n >> s) {
        if (n == 0 && s == 0) { break; }
        cnt = 0;
        dfs(0, 0, 0);
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 2984
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

#define rep1(i,x) for(int i=1;i<=(x);++i)

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

int N, L;
int icicles[100002];
int memo[100002];

int rec(int i)
{
	if (memo[i] >= 0) return memo[i];

	int res = 0;

	if (icicles[i] < icicles[i + 1]) chmax(res, rec(i + 1));
	if (icicles[i] < icicles[i - 1]) chmax(res, rec(i - 1));

	res += L - icicles[i];

	return memo[i] = res;
}

signed main()
{
	memset(memo, -1, sizeof(memo));

	scanf("%d %d", &N, &L);

	rep1(i, N) scanf("%d", &icicles[i]);

	int ma = 0;

	rep1(i, N) chmax(ma, rec(i));

	printf("%d\n", ma);
}

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

int main(){
	int a,b;
	cin >> a >> b;

	cout << max(a+b, max(a-b, a*b)) << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;

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

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

	ll n;
	cin >> n;

	deque<char> ans;
	while(n > 0){
		char c;
		if(n % 26 == 0){
			c = 'z';
		}else{
			c = n % 26 - 1 + 'a';
		}
		ans.push_front(c);
		if(n % 26 == 0){
			n /= 26;
			n--;
		}else{
			n /= 26;
		}
	}

	string ans2;
	for(char c : ans) ans2.push_back(c);
	cout << ans2 << endl;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    string s1,s2,s;
    cin>>n;
    cin>>s;
    if(n%2!=0)
    cout<<"No"<<endl;
    else
    {
        s1=s.substr(0,n/2);
        s2=s.substr(n/2,n/2);
        //cout<<s1<<" "<<s2;
        if(s1==s2)
        cout<<"Yes"<<endl;
        else
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[100001];

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

    for (int i = 0; i < q; ++i)
    {
        int x;
        cin >> x;
        a[x]++;
    }
    for (int i = 1; i <= n; ++i)
        cout << (a[i] > 0 ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include<unordered_map>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	int count4 = 0;
	int count2 = 0;
	int count = 0;
	rep(i, n) {
		int a;
		cin >> a;
		if (a % 4 == 0) {
			count4++;
		}
		else if (a % 2 == 0) {
			count2++;
		}
		else {
			count++;
		}
	}
	bool flag = true;
	int ans = count4 * 2 + max(count2-1,0);
	if (ans < n-1) {
		flag = false;
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,k; cin>>n>>k;
    vector<ll> a(n,0);
    rep(i,n) cin>>a[i];
    ll l=0,r=1e9+1,c;
    while(l!=r){
        ll cnt=0;
        c=(l+r+1)/2;
        rep(i,n) cnt+=(a[i]+c-1)/c-1;
        if(cnt>k) l=c;
        else r=c-1;
    }
    cout<<l+1<<endl;
}


Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    int r;
    cin>>r;
    cout<<3*r*r<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,c,d,e;
    scanf("%d %d %d",&a,&b,&c);
    for(d = a; d <= b; d++){
        if(c % d == 0){
            e++;
        }
    }
    printf("%d\n",e);
    return 0;
}


Measured memory_bytes: 2072
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;
using vi = vector <int>;
using vvi = vector <vi>;

signed main() {
	int n, m;
	while (cin >> n >> m, n) {
		int pear[n], berry[m];
		rep (i, n) {
			cin >> pear[i];
		}
		rep (i, m) {
			cin >> berry[i];
		}

		int mini = INF;
		int outa, outb;
		rep (i, n) {
			rep (j, m) {
				int sum = pear[i] + berry[j];
				swap(pear[i], berry[j]);
				int sumn = 0, summ = 0;
				rep (k, n) sumn += pear[k];
				rep (k, m) summ += berry[k];
				if(sumn == summ && mini > sum) outa = pear[i], outb = berry[j], mini = sum;
				swap(pear[i], berry[j]);
			}
		}
		if (mini == INF) cout << -1 << endl;
		else
			cout << outb << " " << outa << endl;
	}
}


Measured memory_bytes: 3072
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>



using namespace std;




int main(){
	
	string a,b,c;
	cin>>a>>b>>c;
	cout<<a[0]<<b[0]<<c[0]<<endl;;


	return 0;
	

}


	

Measured memory_bytes: 256
from sys import stdin
import math
import fractions
from collections import deque

WHITE = 0
BLACK = 1

N = int(stdin.readline().rstrip())
data = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N-1)]

# 木の繋がりと長さ
connect = [[] for _ in range(N+1)]
for u, v, w in data:
    connect[u].append([v,w])
    connect[v].append([u,w])

# 根から頂点までの距離
# 根は適当な頂点を選べば良いので、u_0とする
dist = [None] * (N+1)
dist[data[0][0]] = 0

que = deque([])
que.append(data[0][0])
is_visited = [False] * (N+1)

# BFSで根からの距離を求めていく
while len(que) != 0:
    u = que.popleft()

    if is_visited[u] == True:
        continue

    is_visited[u] = True

    for v, w in connect[u]:
        que.append(v)
        if dist[v] == None:
            dist[v] = dist[u] + w

# distが偶数の頂点には白で、奇数の頂点には黒で塗ることとする
for i in range(1, N+1):
    if dist[i] % 2 == 0:
        print(WHITE)
    else:
        print(BLACK)

Measured memory_bytes: 124248
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	int temp = b * pow(100, a);
	int hehe = pow(100, a);
	if(b == 100) cout << temp + hehe << '\n';
	else         cout << temp << '\n';
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] p = new int[n];
        for(int i=0;i<n;i++){
            p[i]=-1;
        }
        for(int i=0;i<m;i++){
            int s = sc.nextInt();
            int c = sc.nextInt();
            if(p[s-1]==-1){
                p[s-1]=c;
            }
            else{
                if(p[s-1]==c)continue;
                System.out.println(-1);
                return;
            }
        }


        if(p[0]==-1){
            if(n==1){
                System.out.print(0);
            }
            else{
                System.out.print(1);
            }
        }
        else if(p[0]==0){
            if(n==1){
                System.out.println(0);
                return;
            }
            System.out.print(-1);
            return;
        }
        else {
            System.out.print(p[0]);
        }
        for(int i=1;i<n;i++){
            if(p[i]==-1){
                System.out.print(0);
            }
            else{
                System.out.print(p[i]);
            }
        }

    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <queue>
#include <string.h>
#include <bits/stdc++.h>

using namespace std;

struct guide{
	char name[15];
	int point;
	int idx;
};

bool compareguide(guide g1, guide g2) 
{ 
	if (strcmp(g1.name,g2.name) < 0)
		return true;
	else if(strcmp(g1.name,g2.name) == 0)
    	return (g1.point > g2.point); 
    else
    	return false;
} 

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N;
	cin >> N;
	
	guide rest[110];
	for(int i=0;i<N;i++)
	{
		char tmp[15];
		int p;
		cin >> tmp >> p;
		strcpy(rest[i].name,tmp);
		rest[i].point = p;
		rest[i].idx = i + 1;
	}
	
	int n = sizeof(rest)/sizeof(rest[0]);
	sort(rest,rest+N,compareguide);
	
	for(int i=0;i<N;i++)
	{
	/*	cout << "rest name : " << rest[i].name;
		cout << " point : " << rest[i].point;*/
		cout << rest[i].idx << endl;
	}

	
	return 0;
}

Measured memory_bytes: 256