akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N, C; cin >> N >> C;
	//v[i][j]:=(x+y)%3==iのマス目における色jの出現回数
	int v[3][31];
	int cost[31][31];
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 31; ++j) {
			v[i][j] = 0;
		}
	}
	for (int i = 0; i < C; ++i) {
		for (int j = 0; j < C; ++j) {
			cin >> cost[i][j];
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			int x; cin >> x;
			v[((i + 1) + (j + 1)) % 3][x - 1]++;
		}
	}
	int ans = INF;
	for (int i = 0; i < C; ++i) {//%3==0をiに
		for (int j = 0; j < C; ++j) {//%3==1をjに
			if (i == j)continue;
			for (int k = 0; k < C; ++k) {//%3==2をkに
				if (i == k || j == k)continue;
				int ret = 0;
				for (int l = 0; l < 3; ++l) {//%3の値
					int x;
					if (l == 0)x = i;
					else if (l == 1)x = j;
					else if (l == 2)x = k;
					for (int m = 0; m < C; ++m) {
						ret += v[l][m] * cost[m][x];
					}
				}
				ans = min(ans, ret);
			}
		}
	}
	cout << ans << endl;
	return 0;
}



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

void calc(string& s) {
    map<char, char> to;
    char t = 'a';
    for (auto& c : s) {
        if (to.count(c))
            c = to[c];
        else
            c = to[c] = t++;
    }
}

int main() {
    string s, t;
    cin >> s >> t;
    calc(s);
    calc(t);

    if (s == t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 776
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
a = []
b = []
for i in range(n):
    if i % 2 == 0:
        a.append(v[i])
    else:
        b.append(v[i])
c1 = Counter(a).most_common()
c2 = Counter(b).most_common()
if len(set(a)) == len(set(b)) == 1:
    if a == b:
        print(len(a))
    else:
        print(0)
else:
    if c1[0][0] != c2[0][0]:
        print(n - c1[0][1] - c2[0][1])
    else:
        print(min(n-c1[0][1] -c2[1][1],n - c1[1][1] - c2[0][1]))

Measured memory_bytes: 21084
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1000000007;






int main()
{

    int N;cin >> N;
    ll K;cin >> K;
    vl A(N);
    in(N,A);
    ve<ll> B1(40,0);
    ve<ll> B2(40,0);
    rep(i,N){
        for (ll j = 0; j < 40; j++) {
            if((A[i] >> j) & 1) B1[j]++;
            else B2[j]++;
        }
    }
    ll ans = 0;
    
    //outve(B1);
    //outve(B2);
    
    ve<ll> t(40,1);
    reps(i,1,40) t[i] *= t[i-1]*2;
    
    rep(i,40) ans += t[i]*(((K >> i) & 1) ? B2[i]:B1[i]);
    
    
    for (ll i = 0; i < 40; i++) {
        ll res = 0;
        if((K >> i) & 1){
            for (ll j = 0; j < i; j++) {
                res += max(B1[j],B2[j])*t[j];
            }
            res += t[i]*B1[i];
            for (ll j = i+1; j < 40; j++) {
                if((K>>j) & 1){
                    res += t[j]*B2[j];
                }else{
                    res += t[j]*B1[j];
                }
            }
        }
        ans = max(ans,res);
    }
    
    
    out(ans);

    return 0;
}


Measured memory_bytes: 1024
class card:
    """
    suit: S, H, C, D
    number: 1~10
    """
    def __init__(self, card_input):
        self.suit = card_input[:1]
        self.number = int(card_input[1:])
    
    def __str__(self):
        return self.suit + str(self.number)


def print_list(a):
    out = ''
    for ai in a:
        out += str(ai) + ' '
    else:
        out = out[:-1]
    print(out)

def bubble_sort(a, n):
    for i in range(0, n):
        for j in range(n - 1, i, -1):
            if a[j].number < a[j - 1].number:
                tmp = a[j]
                a[j] = a[j - 1]
                a[j - 1] = tmp
    return a
                
def selection_sort(a, n):
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if a[j].number < a[minj].number:
                minj = j
        tmp = a[i]
        a[i] = a[minj]
        a[minj] = tmp
    return a

n = int(input())
input_cards = input().split(' ')
cards = []
for in_card in input_cards:
    cards.append(card(in_card))

bubble = bubble_sort(cards[:], n)
print_list(bubble)
print("Stable")

selection = selection_sort(cards[:], n)
print_list(selection)
if bubble == selection:
    print("Stable")
else:
    print("Not stable")


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int a[7][7]={
    {0,300,500,600,700,1350,1650},
    {6,0,350,450,600,1150,1500},
    {13,7,0,250,400,1000,1350},
    {18,12,5,0,250,850,1300},
    {23,17,10,5,0,600,1150},
    {43,37,30,25,20,0,500},
    {58,52,45,40,35,15,0}
};
    int b;
    while(cin>>b,b){
	int c,d,e,f,g;
	scanf("%d%d%d%d%d",&c,&d,&e,&f,&g);
	c=c*60+d;
	f=f*60+g;
	if(c>=1050&&c<=1170||f>=1050&&f<=1170){
	    if(a[max(b,e)-1][min(b,e)-1]<=40){int o=a[min(b,e)-1][max(b,e)-1]/2;if(o%50)o+=50-o%50;printf("%d\n",o);}
	    else printf("%d\n",a[min(b,e)-1][max(b,e)-1]);
	    }
	    else printf("%d\n",a[min(b,e)-1][max(b,e)-1]);
	}
    }

Measured memory_bytes: 3136
import java.util.*;
public class Main {
	public static void main(String[] args){
		ABD();
	}
	
	public static void ABD() {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		if (num <= 999) {
			System.out.println("ABC");
		}
		else {
			System.out.println("ABD");
		}
	}
}

Measured memory_bytes: 21844
N = int(input())

ls = []

for i in range(N):
    s, p = input().split()
    ls.append([s, int(p), i + 1])

result = sorted(sorted(ls, key = lambda x:x[1])[::-1], key = lambda x:x[0])

for i in range(N):
    print(result[i][2])

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


[A, B] = [int(i) for i in input().split()]

if A % 2 == 0:
    if B % 2 == 0:
        print(int((A+B)/2))
    else:
        print('IMPOSSIBLE')
else:
    if B % 2 != 0:
        print(int((A+B)/2))
    else:
        print('IMPOSSIBLE')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;

#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)


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

ll lcm(ll a, ll b) {
	return a /gcd(a, b) *b;
}
typedef pair<int,int> pii;
const int mod = 1e9+7;
int main() {

   ll n,k;
   cin>>n>>k;

   vector<pii> vpii;

   fo(i,n){
       int l,r;
       cin>>l>>r;
       vpii.pb({l,r});


   }
   sort(vpii.begin(),vpii.end());
   ll cost = 0;
   for(auto x:vpii){
     ll l,r;
     l = x.first;
     r = x.second;
     //cout<<l<<" "<<r;
     //cout<<endl;
      if(k<=0)
        break;
      if(k>=r){
        k-=r;
        cost+= l*r;
      }
      else{
        cost+= k*l;
        k=0;
      }
   }
   cout<<cost;


























    return 0;

      }


Measured memory_bytes: 1400
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str1 = sc.nextLine();
		String str2 = sc.nextLine();
		
boolean flag = false;
for(int i = 0;i < str1.length();++i){
  String sufStr = str1.substring(str1.length() - i, str1.length());
  String preStr = str1.substring(0, str1.length() - i);
  String compareStr = sufStr + preStr;
  if(compareStr.equals(str2))
    flag = true;
}
if(flag)
  System.out.println("Yes");
else
  System.out.println("No");

}
}

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

int main(){


int A,B;
cin >>A >>B;

int a,b,c,d,e=0;
int count=0;
int temp;

for(A;A<=B;A++){
  a=0;
  b=0;
    c=0;
    d=0;
    e=0;
  temp=A;

while(temp>=10000){
temp-=10000;
  a++;
  //cout <<a<<endl<<temp<<endl;
}
while(temp>=1000){
temp-=1000;
  b++;
}
while(temp>=100){
temp-=100;
  c++;
}
while(temp>=10){
temp-=10;
  d++;
}
while(temp>=1){
temp-=1;
  e++;
}

if (a==e && b==d){
count++;
}
  

}
  
    cout <<count<<endl;
  
}

Measured memory_bytes: 256
N = int(input())
A = [int(_) for _ in input().split()]

def solve(N, A):
    k = N * (N + 1) // 2
    s = sum(A)
    if s % k > 0:
        return False
    m = s // k
    # print(k, s, m)
    rs = []
    for i in range(N):
        p = A[i - 1]
        q = A[i]
        delta = q - p
        y = m - delta
        # print(p, q, delta, y, N)
        if y % N > 0:
            return False
        x = y // N
        rs.append(x)
    # print("*", rs)
    R = 0
    for i in range(N):
        x = rs[i]
        l = (N - i) % N + 1
        R += l * x
    # print(1, R)
    if R != A[0]:
        return False
    for i in range(1, N):
        R += m - rs[i]
        R -= rs[i] * (N - 1)
        # print(i, R)
        if R != A[i]:
            return False
    return True

def solve(N, A):
    k = N * (N + 1) // 2
    s = sum(A)
    if s % k > 0:
        return False
    m = s // k
    for i in range(N):
        x = A[i - 1] - A[i] + m
        if x < 0 or (x % N) > 0:
            return False
    return True

if solve(N, A):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 14488
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
typedef long long ll;
#define PI 3.14159265
ll exponent(ll x,ll n,ll m)
{  if(n==0)
    return 1;
    if(n%2!=0)
    {
        return (x*exponent(((x%m)*(x%m))%m,(n-1)/2,m))%m;
    }
    else
    return exponent(((x%m)*(x%m))%m,n/2,m);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    for(int j=0;j<n;j++)
        cin>>a[j];
    int cnt=1,mini=a[0];
    for(int j=1;j<n;j++)
    {
        mini=min(a[j],mini);
        if(mini==a[j])
            ++cnt;
    }
    cout<<cnt;

    return 0;
}


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

using ll = long long;

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

    lc = L / 2019;
    rc = R / 2019;
    // printf("lc %lld rc %lld\n",lc, rc);
    int res = 2019;
    if(rc - lc >=1){
        cout << 0 << endl;
        return 0;
    }else{
        ll ld = L % 2019;
        ll rd = R % 2019;

        for(int i = ld; i < rd; i++){
            for(int j =i+1; j<=rd; j++){
                res = min(res, (i*j)%2019);
            }
        }
    }
    cout << res << endl;
    return 0;
}

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

int main(){
  int a,m[3];
  cin>>a;
  for(int i=0;i<a;i++){
    cin >>m[0]>>m[1]>>m[2];
    sort(m,m+3);
    if(m[2]*m[2]==m[1]*m[1]+m[0]*m[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> x >> y >> z >> n;

	f = 0;
	rep(i, x+1){
		rep(j, y+1){
			rep(k, z+1){
				if(500*i+100*j+50*k == n) ++f;
			}
		}
	}
	cout << f;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
void bubbleSort(int[], int);

int main() {
	int n, a[110];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	bubbleSort(a, n);
	return 0;
}

void bubbleSort(int a[], int n) {
	bool flag = true;
	int count = 0;
	while (flag) {
		flag = false;
		for (int i = n - 1; i >= 1; i--) {
			if (a[i - 1] > a[i]) {
				int copy = a[i];
				a[i] = a[i - 1];
				a[i - 1] = copy;
				flag = true;
				count++;
			}
		} 
	}
	for (int i = 0; i < n; i++) {
		cout << a[i];
		if (i == n - 1) cout << endl;
		else cout << " ";
	}
	cout << count << endl;

}

Measured memory_bytes: 1164
#include<iostream>
using namespace std;
const int N=1e5+5;
int f[N],ar[N];
int main(){
	int n,k,i,j;
	cin>>n>>k;
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	for(i=1;i<=k;i++){
		for(j=1;j<=n;j++){
			if(i>=ar[j]&&f[i-ar[j]]==0){
				f[i]=1;
				break;
			}
		}
	}
	if(f[k]==1){
		cout<<"First";
	}
	else{
		cout<<"Second";
	}
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

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

  int a,b;
  int count = 0;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    if(a==b){
      count++;
    }
    else{
      count = 0;
    }
    if(count>=3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3656
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())
m = [[0] * W for _ in range(H)]
for h in range(H):
    i = None
    for j in range(W + 1):
        if j < W and S[h][j] == ".":
            if i is None:
                i = j
        else:
            if i is not None:
                for k in range(i, j):
                    m[h][k] += j - i
                i = None
for w in range(W):
    i = None
    for j in range(H + 1):
        if j < H and S[j][w] == ".":
            if i is None:
                i = j
        else:
            if i is not None:
                for k in range(i, j):
                    m[k][w] += j - i
                i = None
ans = 0
for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            continue
        ans = max(ans, m[h][w] - 1)
print(ans)


Measured memory_bytes: 99160
#include "bits/stdc++.h"
using namespace std;
int INF = numeric_limits<int>::max() / 2;
using ll = long long;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n),c(n);
    for(int i = 0; i < n; i++){cin >> a[i]; c[i] = a[i] - (i+1);}
    sort(c.begin(), c.end());
    int b = c[n/2];

    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += abs(a[i] - (b+i+1));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

int main(void) {
    string s;
    cin >> s;

    int minv = INT32_MAX;
    int check = 0;
    for(int i = 0; i < (s.size() - 2) ; ++i) {
        check = abs(753 - stoi(s.substr(i,3)));
        
        if (minv > check) {
            minv = check;
        }
    }

    cout << minv << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;

ll modpow(ll a, ll p, ll m) {
  if (p == 0)
    return 1;
  if (p % 2 == 0) {
    ll d = modpow(a, p / 2, m);
    return d * d % m;
  } else {
    return a * modpow(a, p - 1, m) % m;
  }
}

int main() {
  int n;
  cin >> n;
  vector<ll> c(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  sort(c.begin() + 1, c.end(), greater<ll>());
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += c[i] * (i + 1);
    ans %= MOD;
  }
  ans *= modpow(4, n - 1, MOD);
  ans %= MOD;
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return


ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }


/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////

int main(){

    ll n;
    cin >> n;

    ll sum = 0;
    rep(i,1,n+1){
	if(i % 3 != 0 && i % 5 != 0)sum += i;
    }
    P(sum);
    return  0;
}


Measured memory_bytes: 3612
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

const int MOD = 1000000007;
int dp[10010][102][2];

string S;
vector<int> N;
int D;

int solve(int dig, int m, bool less) {
  if (dig >= N.size()) {
    return (m == 0);
  }
  if (dp[dig][m][less] != -1) return dp[dig][m][less];

  int res = 0;
  for (int d = 0; d < 10; d++) {
    if (less || (d <= N[dig])) {
      res = (res + solve(dig + 1, (m + d) % D, less || (d < N[dig]))) % MOD;
    }
  }

  return dp[dig][m][less] = res;
}

int main() {
  while (cin >> S >> D) {
    N.clear();
    for (int i = 0; i < S.size(); i++) N.push_back(S[i] - '0');

    memset(dp, -1, sizeof(dp));
    int res = solve(0, 0, false);
    res = (res - 1 + MOD) % MOD;

    cout << res << endl;
  }
  return 0;
}


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

const int MAXN = 200005;

int n, k, a[MAXN];

int main(){
	scanf("%d %d", &n, &k);
	for(int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	
	for(int i = k; i < n; i++){
		if(a[i] > a[i - k])printf("Yes\n");
		else printf("No\n");
	}
	
	return 0;
}


Measured memory_bytes: 4540
#include <stdio.h>
int main(){
    int a,b;
    char op;

    while(1){
        scanf("%d %c %d\n",&a,&op,&b);
        if(op == '+'){
            printf("%d\n",a + b);
        }
        else if(op == '-'){
            printf("%d\n",a - b);
        }
        else if(op == '*'){
            printf("%d\n",a * b);
        }
        else if(op == '/'){
            printf("%d\n",a / b);
        }
        else{
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 604
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            String line = sc.nextLine();
            if (line.equals(".")) break;
            System.out.println(isBalanced(line));
        }
    }
    
    public static String isBalanced(String line) {
        Stack<Character> st = new Stack<Character>();
        
        for (int i = 0; i < line.length(); i++) {
            char c = line.charAt(i);
            if (c == '(' || c == '[') {
                st.push(c);
            }
            else if ((c == ')' || c == ']') && st.empty()) {
                return "no";
            }
            else if (c == ')') {
                char t = st.pop();
                if (t != '(') {
                    return "no";
                }
            }
            else if (c == ']') {
                char t = st.pop();
                if (t != '[') {
                    return "no";
                }
            }
        }
        
        if (!st.empty()) return "no";
        
        return "yes";
    }
    
}




Measured memory_bytes: 43384
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	string s;
	cin>>s;
	char c=s[0];
	int ans=1;
	for(int i=1;i<4;++i){
		if(s[i]==c) ++ans;
		else{
			c=s[i];
			ans=1;
		}
		if(ans==3){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>

#define N 2000000
#define K 10000

int A[N + 1], B[N + 1], C[K + 1];
int n, k;

void inputArray() {
	int i;

	scanf("%d", &n);

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

}

void coutingSort() {
	int i, j;

	for (j = 1; j <= n; j++) {
		C[A[j]]++;
	}

	for (i = 1; i <= k; i++) {
		C[i] += C[i - 1];
	}

	for (j = n; j >= 1; j--) {
		B[C[A[j]]] = A[j];
		C[A[j]]--;
	}

}

void displayArray() {
	int i;

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

int main() {

	inputArray();
	coutingSort();
	displayArray();

	return 0;
}

Measured memory_bytes: 16268
import java.util.*;
 
class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    String S = sc.nextLine();
    String T = sc.nextLine();
    
    String[] Sar = S.split("");
    String[] Tar = T.split("");
    
    int c = 0;
    for(int i = 0; i < S.length(); i++){
      if(!Sar[i].equals(Tar[i])){
        c++;
      }
    }
    System.out.print(c);
  }
}

Measured memory_bytes: 65792
import time
st = time.time()

d = int(input())
clist = list(map(int,input().split()))
last_c = [0]*26
select_c = [0]*26
for i in range(26):
    select_c[i] = []

slist = [0] * d
for i in range(d):
    slist[i] = list(map(int,input().split()))

tlist = [0]*d
satisfy = [0]*(d+1)

#貪欲法
for i in range(0,d):
    max = 0
    max_n = 0
    for n in range(26):
        if i > 0:
            curr = slist[i][n] + satisfy[i-1]
        else:
            curr = slist[i][n]
        minus = 0
        for j in range(26):
            if n != j:
                minus -= clist[j] * (i - last_c[j])
        curr += minus
        if curr > max:
            max = curr
            max_n = n
    satisfy[i] = max
    last_c[max_n] = i+1 
    select_c[max_n].append(i+1)
    tlist[i] = max_n+1

import random
import numpy as np

sum = 0
total_c = 0


for i in range(d):
    sum += slist[i][tlist[i]-1]

ct = time.time()

for i in range(len(select_c)):
    start = 1
    c_change = 0
    if select_c[i] == []:
        c_change = np.sum(np.arange(d+1))
    else:
        for j in range(len(select_c[i])):
            end = select_c[i][j]
            if end > start:
                c_change += np.sum(np.arange(end-start+1))
            start = end
        end = d+1
        c_change += np.sum(np.arange(end-start))
        start = end
    total_c += clist[i]*c_change

current_max = sum - total_c

try:

    import bisect
    while ct-st < 1.9:
        change_d = random.randint(1,d)
        change_d_to_c = random.randint(0,len(select_c)-1)
        for x in range(len(select_c)):
            try:
                ind = select_c[x].index(change_d)
                change = x
                s_change = slist[change_d-1][ind]
                select_c[x].remove(change_d)
                break
            except:
                None

        s_change2 = slist[change_d-1][change_d_to_c]

        bisect.insort(select_c[change_d_to_c],change_d)
        #calc
        sum2 = sum - s_change + s_change2
        total_c2 = 0
        for i in range(len(select_c)):
            start = 1
            c_change = 0
            if select_c[i] == []:
                c_change = np.sum(np.arange(d+1))
            else:
                for j in range(len(select_c[i])):
                    end = select_c[i][j]
                    if end > start:
                        c_change += np.sum(np.arange(end-start+1))
                    start = end
                end = d+1
                c_change += np.sum(np.arange(end-start))
                start = end
            total_c2 += clist[i]*c_change

        if sum - total_c < sum2 - total_c2:
            sum = sum2
            total_c = total_c2
            tlist[change_d-1] = change_d_to_c+1
        else:
            bisect.insort(select_c[change],change_d)
            select_c[change_d_to_c].remove(change_d)

        

        ct = time.time()
except:
    None
#remove first
for i in tlist:
    print(i)

Measured memory_bytes: 27572
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<functional>
#include<queue>
using namespace std;
int n, p[100009], x[100009], dp[1009], d[5009], prev_[5009]; vector<int>X[100009]; bool OK = false;
int dfs(int pos) {
	for (int i = 0; i < X[pos].size(); i++) { dfs(X[pos][i]); }
	for (int i = 0; i < 5009; i++) { d[i] = (1 << 30); prev_[i] = (1 << 30); }prev_[0] = 0;
	for (int i = 0; i < X[pos].size(); i++) {
		int U = dp[X[pos][i]]; if (U == (1 << 30))continue;
		for (int j = x[X[pos][i]]; j < 5009; j++) { d[j] = min(d[j], prev_[j - x[X[pos][i]]] + U); }
		for (int j = U; j < 5009; j++) { d[j] = min(d[j], prev_[j - U] + x[X[pos][i]]); }
		for (int j = 0; j < 5009; j++) { prev_[j] = d[j]; d[j] = (1 << 30); }
	}
	int minx = (1 << 30);
	for (int j = 0; j <= x[pos]; j++)minx = min(minx, prev_[j]);
	dp[pos] = minx; if (minx >= (1 << 29))OK = true;
	return minx;
}
int main() {
	cin >> n;
	for (int i = 2; i <= n; i++) { cin >> p[i]; X[p[i]].push_back(i); }
	for (int i = 1; i <= n; i++)cin >> x[i];
	dfs(1);
	if (OK == true)cout << "IMPOSSIBLE" << endl; else cout << "POSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 2816
'use strict'

function main(input) {
	let nums = input.split('\n')[1].split(' ').map(n => parseInt(n, 10));
    
    let count = 0;
  	while(nums.every(num => num % 2 === 0)) { // 全ての配列の数値が偶数かチェック
      count++;
      nums = nums.map(n => n / 2);
    }
  	console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1e18;


void solve(void){
	ll A, B, C, K;
	cin >> A >> B >> C >> K;
	cout << (K & 1 ? B-A : A-B) << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
log = console.log;

var stdin = require("fs").readFileSync("/dev/stdin", "UTF-8");
// var lines = stdin.split("\n");
var N = Number(stdin);
var rootN = Math.ceil(Math.sqrt(N));

answers = [];
for (var A = 1; A <= rootN; A++) {
  if (N % A === 0) {
    var B = N / A;
    var F = Math.max(A.toString().length, B.toString().length);
    answers.push(F);
  }
}

log(Math.min(...answers));


Measured memory_bytes: 21576
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
ll per(ll n,ll x){
    ll ans = 1;
    rep(i,x)ans *= n-i;
    rep(i,x)ans /= i+1;
    ans %= 1000000000+7;
    return ans;
}
int main(){
    int n,k;
    cin >> n >> k;
    ll ans = 0;
    vector<ll>sum(n+1);
    sum[0] = 0;
    rep(i,n)sum[i+1] = sum[i] + i+1;
    for(int i = k;i <= n+1;i++){
        ll big = 0,sma = 0;
        if(n-i < 0)big = sum[n];
        else big = sum[n] - sum[n-i];

        sma = sum[i-1];
        //cout << i << ' ' << big << ' ' << sma << endl;
        ans += big - sma+1;
        ans %= 1000000000+7;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int N, K;
vector<int> h, dp;

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

    cin >> N >> K;

    h.resize(N);
    for (int i = 0; i < N; i++)
        cin >> h[i];

    dp.assign(N, INT_MAX);
    dp[0] = 0;
    for (int i = 1; i < N; i++)
        for (int j = i - 1; j >= 0 && j >= i - K; j--)
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));

    cout << dp[N - 1] << endl;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int64_t> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  vector<int> idx(N);
  iota(idx.begin(), idx.end(), 0);
  sort(idx.begin(), idx.end(), [&](int a, int b) { return B[a] < B[b]; });
  int64_t t = 0;
  for (int i : idx) {
    if (t + A[i] > B[i]) {
      cout << "No" << '\n';
      return 0;
    }
    t += A[i];
  }
  cout << "Yes" << '\n';
  return 0;
}


Measured memory_bytes: 4224
import java.util.Scanner;

fun main(args: Array<String>) {
	val sc = Scanner(System.`in`)
	val x1 = Integer.parseInt(sc.next())
	val y1 = Integer.parseInt(sc.next())
	val x2 = Integer.parseInt(sc.next())
	val y2 = Integer.parseInt(sc.next())
	sc.close()
	val x3 = x2 - (y2 - y1)
	val y3 = y2 + (x2 - x1)
	val x4 = x3 - (y3 - y2)
	val y4 = y3 + (x3 - x2)
	println("" + x3 + " " + y3 + " " + x4 + " " + y4)

}

Measured memory_bytes: 31524
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll M=1e9+7;
char ch[100];
ll power(ll x,ll y){
    ll res=1;
    x=x;
    if(x==0)
        return 0;
    while(y>0){
        if(y&1)
            res=(res*x);
        y=y>>1;
        x=(x*x);
    }
    return res;
}

int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    set<ll>s;
    while(k--){
        ll m;
        cin>>m;
        ll i;
        for(i=0;i<m;i++){
            ll x;
            cin>>x;
            s.insert(x);
        }
    }
    cout<<n-s.size()<<"\n";
}

Measured memory_bytes: 3664
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;

void main(){
  auto F=readln.split.to!(int[]),a=F[0],b=F[1];
  if((a+b)%2==0)writeln((a+b)/2);
  else writeln((a+b)/2+1);
}

Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=3e5+2;
int n,k,p[N],f[N];

template <typename _Tp> inline void IN(_Tp&x) {
    char ch;bool flag=0;x=0;
    while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1 ;
    while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    if(flag) x=-x;
}

struct Segment_Tree {
    #define mid ((l+r)>>1)
    int Mi[N<<2],Mx[N<<2];
    void build(int x,int l,int r) {
        if(l==r) {Mi[x]=Mx[x]=p[l];return;}
        build(x<<1,l,mid),build(x<<1|1,mid+1,r);
        Mi[x]=min(Mi[x<<1],Mi[x<<1|1]),Mx[x]=max(Mx[x<<1],Mx[x<<1|1]);
    }
    int query_Mi(int x,int l,int r,int L,int R) {
        if(L==l&&r==R) return Mi[x];
        if(R<=mid) return query_Mi(x<<1,l,mid,L,R);
        else if(L>mid) return query_Mi(x<<1|1,mid+1,r,L,R);
        else return min(query_Mi(x<<1,l,mid,L,mid),query_Mi(x<<1|1,mid+1,r,mid+1,R));
    }
    int query_Mx(int x,int l,int r,int L,int R) {
        if(L==l&&r==R) return Mx[x];
        if(R<=mid) return query_Mx(x<<1,l,mid,L,R);
        else if(L>mid) return query_Mx(x<<1|1,mid+1,r,L,R);
        else return max(query_Mx(x<<1,l,mid,L,mid),query_Mx(x<<1|1,mid+1,r,mid+1,R));
    }
}T;

int main() {
    IN(n),IN(k);
    for(int i=1;i<=n;++i) IN(p[i]);
    T.build(1,1,n);
    int Mi=T.query_Mi(1,1,n,1,k),Mx=T.query_Mx(1,1,n,1,k),cnt=0;
    f[1]=1;
    bool flag=false;
    for(int i=2;i<=n;++i)
        f[i]=(p[i-1]<=p[i])?f[i-1]+1:1,
        flag|=((f[i]>=k)&&i>k);
    if(flag) ++cnt;
    if((f[k]==k&&!flag)||(f[k]<k)) ++cnt;
    for(int r=k+1;r<=n;++r) {
        int now_Mi=T.query_Mi(1,1,n,r-k+1,r),now_Mx=T.query_Mx(1,1,n,r-k+1,r);
        if(!(Mi==p[r-k]&&now_Mx==p[r])&&f[r]<k) ++cnt;
        Mi=now_Mi,Mx=now_Mx;
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 11264
K = int(input())
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(L[K-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF 100000000
#define MAX 100001
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<ll, ll>
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<< "\n";
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

vi G[100000];
int D1[100000], DN[100000];

void dfs(int* a, int pos, int d){
    if(a[pos] != 0 && a[pos] < d) return;
    a[pos] = d;
    AREP(i, G[pos]) dfs(a, i, d+1);
}

signed main(){ INIT;
    VAR(int, n);
    REP(i, n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(D1, 0, 1);
    dfs(DN, n-1, 1);
    int cnt = 0;
    REP(i, n) cnt += D1[i] <= DN[i];

    if(cnt > n - cnt) {
        OUTL("Fennec");
    } else {
        OUTL("Snuke");
    }
RET;}


Measured memory_bytes: 11264
# -*- coding:utf-8 -*-
s = list(input())
k = int(input())
for tmp in range(len(s)):
    if k == 0:
        break
    a = 26-(ord(s[tmp]) - ord('a'))
    if s[tmp] != 'a' and k >= a: 
        k -= a
        s[tmp] = 'a'
    else:
        pass
if k > 0:
    s[len(s)-1] = chr((ord(s[len(s)-1])+k%26))
print(''.join(s))

Measured memory_bytes: 4152
N = int(input())
X = list(map(int, input().split()))
X = [x//400 for x in X]
min_X = len(set([x for x in X if x < 8]))
max_X = min_X + len([x for x in X if x >= 8])
# この max は気づかないなあ
print(max([min_X, 1]), max_X)


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

int main(void){
	int n;

	while(cin>>n && n){
		int m = 10000000;

		for(int z=0;z*z*z<=n;z++){
			for(int y=0;z*z*z+y*y<=n;y++){
				m = min(z+y+(n-z*z*z-y*y), m);
			}
		}
		cout<<m<<endl;
	}

	return 0;
}

Measured memory_bytes: 868
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

int main()
{
    long N,M;
    std::cin >> N >> M;
    if(N==M){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

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

int main() {
	int n,a,b,c,d;
	cin >> n;
	a = n/1000;
	b = (n - a * 1000)/100;
	d = n % 10;
	c = (n - d) /10 % 10;
	
	if(a+b+c+d==7) cout << a << "+" << b << "+" << c << "+" << d <<"=7" << endl;
	else if(a-b+c+d==7) cout << a << "-" << b << "+" << c << "+" << d <<"=7" << endl;
	else if(a+b-c+d==7) cout << a << "+" << b << "-" << c << "+" << d <<"=7" << endl;
	else if(a+b+c-d==7) cout << a << "+" << b << "+" << c << "-" << d <<"=7" << endl;
	else if(a-b-c+d==7) cout << a << "-" << b << "-" << c << "+" << d <<"=7" << endl;
	else if(a-b+c-d==7) cout << a << "-" << b << "+" << c << "-" << d <<"=7" << endl;
	else if(a+b-c-d==7) cout << a << "+" << b << "-" << c << "-" << d <<"=7" << endl;
	else if(a-b-c-d==7) cout << a << "-" << b << "-" << c << "-" << d <<"=7" << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
suits = ["S", "H", "C", "D"]
cards = []
for suit in suits:
    for i in range(1, 14):
        cards.append("{} {}".format(suit, i))

n = int(input())
for i in range(n):
    g = input()
    if g in cards:
        cards.remove(g)

for card in cards:
    print(card)


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll a,b;cin >>a>>b;
    ll ans=a+b;
    if(ans>=10){
        puts("error");
    }
    else {
        cout <<ans <<endl;
    }
    return 0;
}



Measured memory_bytes: 256
import math
import sys

s = input()
n= len(s)


"""
sが回文かどうかのチェック
"""
end = n
for i in range(end):
  head = s[i]
  tail = s[end-i-1]
  if head != tail:
    print('No')
    sys.exit()
    
"""
2つめチェック
"""
end = int((n-1)/2)
for i in range(end):
  head = s[i]
  tail = s[end-i-1]
  if head != tail:
    print('No')
    sys.exit()

"""
3つめチェック
"""
start=int((n+3)/2)-1
end = n
iteration=0
for i in range(start,end):
  head = s[i]
  tail = s[end-iteration-1]
  iteration+=1
  if head != tail:
    print('No')
    sys.exit()

print('Yes')

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			string s = cin.Next();

			int ans = 0;
			for (int i = 0; i <= 999; i++) {
				char n3 = (char)('0' + (i % 10));
				char n2 = (char)('0' + ((i / 10) % 10));
				char n1 = (char)('0' + ((i / 100) % 10));

				bool ok1 = false;
				bool ok2 = false;
				bool ok3 = false;
				for (int j = 0; j < n; j++) {
					if (ok1 == false) {
						if (s[j] == n1) {
							ok1 = true;
						}
					} else if (ok2 == false) {
						if (s[j] == n2) {
							ok2 = true;
						}
					} else {
						if (s[j] == n3) {
							ok3 = true;
							break;
						}
					}
				}

				if (ok3) {
					++ans;
				}
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

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

int y, m, d;

int conv(){
    if( y < 1868 || (y == 1868 && ( m < 9 || (m == 9 && d < 8) ) ) ){
        cout << "pre-meiji" << endl;
        return 1;
    }
    if( y < 1912 || (y == 1912 && ( m < 7 || (m == 7 && d <= 29) ) ) ){
        cout << "meiji ";
        cout << y-1867 << ' ';
    }else if( y < 1926 || (y == 1926 && ( m < 12 || d <= 24 ))){
        cout << "taisho ";
        cout << y-1911 << ' ';
    }else if( y < 1989 || (y == 1989 && ( m == 1 && d <= 7 ) ) ){
        cout << "showa ";
        cout << y-1925 << ' ';
    }else{
        cout << "heisei ";
        cout << y-1988 << ' ';
    }
    return 0;
}

int main(){
    while( cin >> y >> m >> d ){
        if( conv() ) continue;
        cout << m << ' ' << d << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <stdlib.h>
using namespace std;

void quit(long long x)
{
    cout << x << '\n';
    exit(EXIT_SUCCESS);
}

int main()
{
    unsigned long long A, B, C;
    cin >> A >> B >> C;

    if(A%2 == 0 || B%2 == 0 || C%2 == 0) quit(0);

    if(A > C) swap(A, C);
    if(B > C) swap(B, C);

    quit(A*B);
}

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

CoordinateList1 = []
CoordinateList2 = []
CoordinateList3 = []
CoordinateList4 = []
for i in range(N):
    x,y,a = map(int, input().split())
    if a == 1:
        CoordinateList1.append(x)
    elif a == 2:
        CoordinateList2.append(x)
    elif a == 3:
        CoordinateList3.append(y)
    elif a == 4:
        CoordinateList4.append(y)
# X
a1 = 0
if sorted(CoordinateList1) != []:
    a1 = sorted(CoordinateList1)[-1]
a2 = W
if sorted(CoordinateList2) != []:
    a2 = sorted(CoordinateList2)[0]

# Y
a3 = 0
if sorted(CoordinateList3) != []:
    a3 = sorted(CoordinateList3)[-1]
a4 = H
if sorted(CoordinateList4) != []:
    a4 = sorted(CoordinateList4)[0]

if (int(a2)-int(a1)) > 0 and (int(a4)-int(a3)) > 0:
    print((int(a2)-int(a1))*(int(a4)-int(a3)))
else:
    print(0)

Measured memory_bytes: 3064
#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iomanip>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#define ll long long
#define inf 1000000000
#define mod 1000000007
#define N 100000
using namespace std;
int i;
char ch;
int main()
{
	for (i = 1;i <= 12; i++)
		{
			if (i == 5) cout<<" ";
			ch = getchar(); cout<<ch;
		}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256