akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

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

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

long long lcm(long long a, long long b)
{
	return a * b / gcd(a, b);
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	return a.second < b.second;
}


int main()
{
	int n;
	cin >> n;
	vector<pair<int, int>> data;
	for (int i = 0; i < n; i++)
	{
		int tmpa, tmpb;
		cin >> tmpa >> tmpb;
		data.push_back(make_pair(tmpa, tmpb));
	}

	sort(data.begin(), data.end(), compare_by_b);
	long long day = 0;
	for (int i = 0; i < n; i++)
	{
		day += data[i].first;
		if (day > data[i].second)
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}



Measured memory_bytes: 33652
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    A = sorted(LI())
    n = A[-1]
    ix = bisect.bisect_left(A, n / 2)
    '''
    [1, 3, 8, 10, 12] -> bisect_left(A, 12 / 2) = 2
    [1, 2, 3, 8, 10, 12] -> bisect_left(A, 12/2) = 3
    '''
    m, l, r = inf, inf, inf
    # 最大値の半分との距離が最小のものを選ぶ
    if ix < N:
        m = A[ix]
    if 0 < ix <= N:
        l = A[ix - 1]

    m1 = abs(n / 2 - m)
    l1 = abs(n / 2 - l)

    min_val = min(m1, l1)
    if min_val == m1:
        n_ = m
    if min_val == l1:
        n_ = l

    print(n, n_)
main()



Measured memory_bytes: 85100
#include <cstdio>


int main (){
  char day[255];

  scanf("%s",day);

  switch(day[0]){
    case 'S':
      puts("Cloudy");
      break;
    case 'C':
      puts("Rainy");
      break;
    case 'R':
      puts("Sunny");
      break;
    default:
      break;
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mp make_pair
#define pii pair<int,int>
using namespace std;
typedef long long ll;
#define rint register int
const int maxn=1007;
const int inf=(1LL<<29);
int n,m,a[maxn][maxn],d[maxn][maxn];
int xd[4]={1,-1,0,0},yd[4]={0,0,1,-1};
bool check(int x,int y){
    return x>=1&&x<=n&&y>=1&&y<=m;
}
void bfs(){
    queue<pii> q;
    for(int i=1;i<=n;i++)
        for(int k=1;k<=m;k++) if(a[i][k]) q.push(mp(i,k));
    while(!q.empty()){
        pii u=q.front();q.pop();
        for(int i=0;i<4;i++){
            pii v=mp(u.first+xd[i],u.second+yd[i]);
            if(check(v.first,v.second)&&!a[v.first][v.second]&&!d[v.first][v.second]){
                d[v.first][v.second]=d[u.first][u.second]+1;
                q.push(v);
            }
        }
    }
    int mx=0;
    for(int i=1;i<=n;i++){
        for(int k=1;k<=m;k++) mx=max(mx,d[i][k]);
    }
    cout<<mx<<endl;
}
int main(){
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        char s[1007];cin>>s+1;
        for(int k=1;k<=m;k++) if(s[k]=='#') a[i][k]=1;
    }
    bfs();
    return 0;
}


Measured memory_bytes: 14352
package main
import(
  "fmt"
)
func main(){
  var a,b int
  fmt.Scan(&a)
  fmt.Scan(&b)
  if a>b{
    fmt.Println(2*a-1)
  }else if a<b{
    fmt.Println(2*b-1)
  }else{
    fmt.Println(2*a) 
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int a, b, x;

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

  double l = 0, r = M_PI / 2.0 - 1e-7;

  while (r - l > 1e-8) {
    double m = (l + r) / 2;
    double v;
    if (a * tan(m) > b) {
      v = a * b * b / tan(m) * 0.5;
    } else {
      v = a * a * b - a * a * a * tan(m) * 0.5;
    }

    if (v >= double(x)) {
      l = m;
    } else {
      r = m;
    }
  }

  double ans = l / M_PI * 180.0;
  cout << setprecision(7) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

const int infI=1e9+5;
const long long infL=1e16;
const int MOD=1e9+7;
const int MAX=2e5+5;

#define mp make_pair
#define in &
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ll long long
#define pll pair<ll,ll>
#define vvl vector<vector<ll> >
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define eb emplace_back
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define popb pop_back()
#define se second
#define fi first
#define test(t) int t;cin>>t;while(t--)
#define debug(x) cerr<<"=>"<<#x<<" = "<<x<<endl

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    if(b==1){
        return a;
    }
    ll temp=power(a,b/2);
    temp=(temp*temp)%MOD;
    if(b%2){
        temp=(temp*a)%MOD;
    }
    return temp;
}

//only use if mod is prime
ll mod_inv(ll a,ll mod){
    a%=mod;
    return power(a,mod-2);
}

void extended_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return;
    }
    ll x1,y1;
    extended_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-((a/b)*y1);
    return;
}

//TLE can also occur if vectors are not passed by reference
//priority_queue implements max heap by default

int main(){
    fastio;
    // think about edge cases like n=1,n=MAX etc.
    ll n,m,k;
    cin>>n>>m>>k;
    vl a(n),b(m);
    forn(i,0,n){
        cin>>a[i];
    }
    forn(i,0,m){
        cin>>b[i];
    }
    vl pre(m,0);
    pre[0]=b[0];
    ll ans = 0;
    forn(i,1,m){
        pre[i] = pre[i-1]+b[i];
    }
    ans = 1+(upper_bound(pre.begin(),pre.end(),k)-pre.begin());
    if(ans == m+1){
        --ans;
    }
    if(pre[ans-1]>k){
        --ans;
    }
    ll t = 0;
    forn(i,0,n){
        t+=a[i];
        if(t>k){
            break;
        }
        ll temp = upper_bound(pre.begin(),pre.end(),k-t)-pre.begin();
        if(temp == m){
            --temp;
        }
        if(pre[temp]>k-t){
            --temp;
        }
        temp += i+2;
        ans = max(ans,temp);
    }
    cout<<ans;
    return 0;
}

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

int main(){
	int N, A, B, C, X, Y[110];
	
	while(1){
		int count = 0, j = 0, temp;
		cin>>N>>A>>B>>C>>X;
		
		if(N == 0 && A == 0 && B == 0 & C == 0 && X == 0)break;
		
		for(int i = 1; i <= N; i++)cin>>Y[i];
		
		while(1){
			for(int i = 1; i <= N; i++){
				if(Y[i] == X) { count++;  Y[i] = -1; break;}
				else if(Y[i] != -1) break;
			}//cout<<X<<endl;
			if(count == N) break;
			X = (A * X + B)%C;
			j++;
			if(j > 10000){j = -1; break;}
		}
		cout<<j<<endl;
	}
	return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int n,cnt;
int a[500000];

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3);
  cout << a[1]-a[0]+a[2]-a[1] << endl;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

bool check(ll mid, ll k, vector<ll> &pla, vector<ll> &mai){
    ll cou = 0;
    REP(i, pla.size()){
        ll tmp = 0;
        if(pla[i] == 0){
            if(mid >= 0)tmp += pla.size();
            if(mid >= 0)tmp += mai.size();
        }
        else {
            if(mid >= 0)tmp += upper_bound(ALL(pla), mid/pla[i]) - pla.begin();
            if(mid >= 0)tmp += mai.size();
            else tmp += mai.size() - (lower_bound(ALL(mai), (-mid + pla[i] - 1)/pla[i]) - mai.begin());
        }

        if(pla[i] * pla[i] <= mid)tmp--;
        cou += tmp;
        //cout << pla[i] << " " << tmp << endl;
    }
    REP(i, mai.size()){
        ll tmp = 0;
        if(mid >= 0)tmp += upper_bound(ALL(mai), mid/mai[i]) - mai.begin();
        if(mid >= 0)tmp += pla.size();
        else tmp += pla.size() - (lower_bound(ALL(pla), (-mid + mai[i] - 1)/mai[i]) - pla.begin());
        if(mai[i] * mai[i] <= mid)tmp--;
        cou += tmp;
        //cout << -mai[i] << " " << tmp << endl;
    }
    //cout << "cou " << cou/2 << endl;
    return (cou/2) < k;
}

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

    ll n, k;cin >> n >> k;
    vector<ll> pla;
    vector<ll> mai;

    REP(i, n){
        ll a;cin >> a;
        if(a >= 0)pla.PB(a);
        else mai.PB(-a);
    }

    sort(ALL(pla));
    sort(ALL(mai));

    ll l = -LLINF - 10;
    ll r = LLINF + 10;
    while(r - l > 1){
        ll mid = (l + r) / 2;
        //cout << l << " " << r << " " << mid << endl;
        if(check(mid, k, pla, mai))l = mid;
        else r = mid;
    }

    cout << r << endl;

	return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  char S[H][W];
  for (int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> S[i][j];
    }
  }
  
  
  int count = 0;
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      if (S[i][j] == '#') cout << '#';
      if (S[i][j] == '.'){
        for (int k=-1; k<2; k++){
          for (int l=-1; l<2; l++){
            if (i+k>=0 && i+k<H && j+l>=0 && j+l<W){
              if(S[i+k][j+l] == '#') count++;
            }
          }
        }
        cout << count;
        count = 0;
      }
    }
    cout << endl;
  }
}

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

int a, b;
char op;

int main() {
    
    while (1) {
        
    cin >> a >> op >> b;
        
    if (op == '+') {
        cout << a + b << endl;
        
    } else if (op == '-') {
        cout << a - b << endl;
        
    } else if (op == '*') {
        cout << a * b << endl;
        
    } else if (op == '/') {
        cout << a / b << endl;
        
    } else {
        return 0;
        
    }
}
}


Measured memory_bytes: 3080
#include <algorithm>
#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()
#define ll long long
#define INF 1000000000000000000

int main() {
    string s, t;
    cin >> s >> t;
    rep(i, s.size()) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3624
n,m= map(int, input().split())
l = []
for i in range(n):
  l.append(list(map(int, input().split())))

l = sorted(l, key=lambda x: x[0])

c = 0
for i in range(n):
  for j in range(l[i][1]):
    c += l[i][0]
    m -= 1
    if m == 0:
      print(c)
      exit()
  
  

Measured memory_bytes: 29792
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        long a = sc.nextLong();
        long b = sc.nextLong();

        System.out.println(a * b / gcd(a, b));
    }

    private long gcd(long m, long n) {
        long r;
        while (n > 0) {
            r = m % n;
            m = n;
            n = r;
        }
        return m;
    }
}



Measured memory_bytes: 21844
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
long long int modp(lld a,lld p,lld n)
{
   lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

//lld fac[100001]; 
/*
void solve2()
{
   lld p=1000000007;
    fac[0] = 1; 
    for (lld i=1 ; i<=100000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrModPFermat(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


long long int gcd(lld b,lld a)
{
    if(a<b) return gcd(a,b);
    if(a%b==0) return b;
    return gcd(a%b , b);
}
*/
lld p1=1000000007,p2=998244353;
lld l,r,mid,ans;
lld n,m,i,j,k;
lld x,y,n1,a,b,n2,h,z,c;
queue<lld> q;
lld d,p=1000000000;
//vector< vector <lld > > v(100001);
/*
void bfs(lld x , vector<lld>& d)
{
    d[x]=0;
    q.pu(x);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        l=v[x].size();
        for(i=0;i<l;i++)
        {
            y=v[x][i];
            if(d[y]==INF) 
            {
                d[y] = d[x]+1;
                q.pu(y);
            }       
        }
    }

}
/*

lld DFS(lld a ,lld x)
{
    visited[a] =true;
    sub_size[a]=1;
 //   if(a==x) 
   //     cont[a] =true;
    lld l= v[a].size();
    for(lld i=0;i<l;i++)
    {
        if(visited[v[a][i]] == false)
        {
            sub_size[a]+= DFS(v[a][i],b);
//            if(cont[v[a][i]] ==true ) cont[a]=true;
        }
    }
    return sub_size[a];

}
*/

void solve()
{
    cin>>n;
    vector<lld> v,a(n+1);
    for(i=0;i<n;i++)
    {
        cin>>l;
        v.pb(l);
        if(l<=i+1)
        {
            a[i+1-l] +=1;
        }
    }
    ans=0;
  //  for(i=0;i<=n;i++) cout<<a[i]<<" ";
 //   cout<<"\n";
    for(i=0;i<n;i++)
    {
        x=i+1+v[i];
        if(x<=n) ans+=a[x];
        y=i+1-v[i];
        if(y<=n && y>=0) a[y]-=1; 
    }
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
 //   cin>>t;
 //   solve2();
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
        solve();
    //    cout<<"\n";
    }

    return 0;
}

Measured memory_bytes: 6892
import heapq
x,y,z,t=map(int,input().split())
a,b,c=[sorted(list(map(int,input().split())),reverse=True) for i in range(3)]
heap=[(-a[0]-b[0]-c[0],0,0,0)]
ed=set()
for _ in range(t):
	p,i,j,k=heapq.heappop(heap)
	print(-p)
	if i+1<x and (i+1,j,k) not in ed:
		ed.add((i+1,j,k))
		heapq.heappush(heap,(-a[i+1]-b[j]-c[k],i+1,j,k))
	if j+1<y and (i,j+1,k) not in ed:
		ed.add((i,j+1,k))
		heapq.heappush(heap,(-a[i]-b[j+1]-c[k],i,j+1,k))
	if k+1<z and (i,j,k+1) not in ed:
		ed.add((i,j,k+1))
		heapq.heappush(heap,(-a[i]-b[j]-c[k+1],i,j,k+1))
	

Measured memory_bytes: 5108
#include <iostream>
#include <stdio.h>
using namespace std;

class Dice{
public:
  int value[6];
  void roll(char _order) {
    switch(_order) {
    case 'N':
      swap(value[4], value[0]);
      swap(value[0], value[1]);
      swap(value[1], value[5]);
      break;
    case 'E':
      swap(value[2], value[0]);
      swap(value[0], value[3]);
      swap(value[3], value[5]);
      break;
    case 'S':
      swap(value[1], value[0]);
      swap(value[0], value[4]);
      swap(value[4], value[5]);
      break;
    case 'W':
      swap(value[0], value[2]);
      swap(value[2], value[5]);
      swap(value[5], value[3]);
      break;
    }
  }
  void rotate(void) {
    this->roll('N');
    this->roll('E');
    this->roll('S');
  }
  bool operator==(const Dice other) {
    bool res = true;
    for (int knock=1;knock<=100;knock++) {
      res = true;
      for (int i=0;i<6;i++)
        if (other.value[i] != this->value[i])
          res = false;
      if (res)
        break;
      else {
        if (knock % 5 == 0) {
          if (knock / 5 <= 3) {
            this->roll('N');
          } else if (knock / 5 == 4) {
            this->roll('E');
          } else {
            this->roll('E');
            this->roll('E');
          }
        } else {
          this->rotate();
        }
      }
    }
    return res;
  }
};

int main() {
  Dice base, comp;
  for (int i=0;i<6;i++)
    cin >> base.value[i];
  for (int i=0;i<6;i++)
    cin >> comp.value[i];

  if (comp == base)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}



Measured memory_bytes: 3104
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	A := nextInt()
	B := nextInt()

	if B%A == 0 {
		fmt.Println(A + B)
	} else {
		fmt.Println(B - A)
	}

}


Measured memory_bytes: 640
// AOJ ITP 1_3_C
#include<cstdio>
#include<algorithm>

int main()
{
	int x, y;
	while( scanf( "%d%d", &x, &y ), x|y )
		printf( "%d %d\n", std::min(x,y), std::max(x,y) );

	return 0;
}

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

using namespace std;

int main() {
    int n, W;
    cin >> n >> W;
    vector<int> w(n), v(n);
    for (int i = 0; i < n; i++) cin >> w[i] >> v[i];

    vector<long long> dp(W + 1, 0);
    for (int i = 0; i < n; i++) {
        for (int j = W; j >= w[i]; j--) {
            dp[j] = max(dp[j - w[i]] + 1ll * v[i], dp[j]);
        }
    }

    cout << dp[W] << '\n';
}


Measured memory_bytes: 1024
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextLong()
    val a = (0 until n).map { sc.next().toInt() }
    println(problem167d(n, k, a))
}

fun problem167d(n: Int, k: Long, a: List<Int>): Int {
    val visited = hashMapOf<Int, Int>()
    visited[1] = 0
    var loopPoint = -1 to -1
    var current = 1
    for (i in 0 until n) {
        current = a[current-1]
        if (i.toLong() >= k - 1) {
            return current
        }
        if (visited.contains(current)) {
            loopPoint = current to i + 1 - visited[current]!!
            break
        }
        visited[current] = i + 1
    }
    val temp = (k - visited[loopPoint.first]!!) % loopPoint.second
    current = loopPoint.first
    for (i in 0 until temp) {
        current = a[current - 1]
    }
    return current
}


Measured memory_bytes: 67304
#include <iostream>
#include <cctype>
#include <string>
#include <vector>
using namespace std;

int main() {
  while(true){
  	string s;cin>>s;
    if(s=="-") return 0;
  	int n;cin>>n;
    int a,sum=0;
    
    for (int i=0;i<n;i++){
  		  cin>>a;
      	  sum+=a;
    }
    for (int i=0;i<s.size();i++){
  		  cout<<s.at((sum+i)%s.size());
    }
    cout<<endl;
    sum=0;
  }
}	


Measured memory_bytes: 3228
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
signed main() {
	string s; cin >> s;
	if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2])cout << "Yes\n";
	else if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1])cout << "Yes\n";
	else if (s[0] == s[3] && s[1] == s[2] && s[0] != s[1])cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int f(int k){
	if(k%3==0)return 1;
	while(k){
		if(k%10==3)return 1;
		k/=10;
	}
	return 0;
}

int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		if(f(i))printf(" %d",i);
	}
	puts("");
}


Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N;
int A[200000];

int main(){
    int m1=0,m2=0;
    cin>>N;
    rep(i,N){
        cin>>A[i];
        if(A[i]>m1){
            m2=m1;
            m1=A[i];
        }else if(A[i]>m2){
            m2=A[i];
        }
    }

    rep(i,N){
        if(A[i]==m1){
            cout<<m2<<endl;
        }else{
            cout<<m1<<endl;
        }
    }
}

Measured memory_bytes: 2432
if __name__ == '__main__':
    n = int(input())
    setN =set([n])
    count=1
    while True:
        if n %2 ==1:
            n=3*n+1
        else:
            n=n/2
        if n in setN:
            print(count+1)
            break
        else:
            count+=1
            setN.add(n)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long ll;
const int MAXN = 100;

int A[MAXN];

int main() {
	int  N;
	cin >> N;
	rep(i, N)cin >> A[i];
	for (int i = 1; i < N; i++) {
		int v = A[i];
		int j = i - 1;
		rep(k, N) {
			cout << A[k];
			if (k != N - 1)cout << " ";
			else cout << endl;
		}
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
	}
	rep(k, N) {
		cout << A[k];
		if (k != N - 1)cout << " ";
		else cout << endl;
	}
	return 0;
}


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

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using ml = map<ll,ll>;

#define ff first
#define ss second
#define endl '\n'
#define ins insert
#define eb emplace_back
#define sz(c) (ll) c.size()
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define itr(x,c) for(auto &x : c)
#define tc ll t; cin >> t; while(t--)
#define rep(i,a,n) for(ll i = a ; i < n ; ++i)
#define per(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) itr(x,c) cout << x << " "; cout << endl;
#define dm(m) itr(x,m) cout << x.ff << " -> " << x.ss << endl;
#define godspeed cin.tie(0) -> sync_with_stdio(0);

int main() {
    godspeed;
    int temp;
    cin>>temp;
    if(temp>=30)
    	cout<<"\n Yes";
    else
    	cout<<"\n No";
    
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (1LL<<31) - 1;
const ll mod = 1e9 + 7;

ll N;
ll C[4];


int main(){
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;
	FOR(i, 0, N) {
		string S;
		cin >> S;
		if (S == "AC") {
			C[0]++;
		}
		else if (S == "WA") {
			C[1]++;
		}
		else if (S == "TLE") {
			C[2]++;
		}
		else if (S == "RE") {
			C[3]++;
		}
	}
	cout << "AC x " << C[0] << endl;
	cout << "WA x " << C[1] << endl;
	cout << "TLE x " << C[2] << endl;
	cout << "RE x " << C[3] << endl;



}


Measured memory_bytes: 3656
import math

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

if abs(n-m) == 1:
    print((math.factorial(n)*math.factorial(m)) % (10**9+7))
elif n == m:
    print((math.factorial(n)*math.factorial(m)*2) % (10**9+7))
else:
    print(0)


Measured memory_bytes: 5192
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const ll INF = 1ll << 60;

struct Enclosure {
  ll l, r;
  ll len() const { return r - l; }
  Enclosure add(ll v) const { return {min(l, v), max(r, v)}; }
  bool containsLeft(ll L) const { return l <= L; }
  bool containsRight(ll R) const { return R <= r; }
  bool contains(ll L, ll R) const {
    return containsLeft(L) && containsRight(R);
  }
};

int main() {
  int N;
  while (cin >> N) {
    vector<vector<ll>> xy(N, vector<ll>(2));
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < 2; j++) {
        cin >> xy[i][j];
      }
    }
    vector<int> ind(2 * N);
    for (int i = 0; i < 2 * N; i++) ind[i] = i;
    sort(ind.begin(), ind.end(),
         [&](int a, int b) { return xy[a / 2][a % 2] < xy[b / 2][b % 2]; });
    vector<int> order;
    vector<bool> used(N, false);
    for (int i = 0; i < 2 * N; i++) {
      int j = i % 2 == 0 ? i / 2 : 2 * N - i / 2 - 1;
      int g = ind[j] / 2;
      if (!used[g]) {
        order.push_back(g);
        used[g] = true;
      }
    }
    vector<ll> mnmn(N + 1, INF), mnmx(N + 1, 0), mxmn(N + 1, INF),
        mxmx(N + 1, 0);
    for (int i = N - 1; i >= 0; i--) {
      int j = order[i];
      auto p = minmax(xy[j][0], xy[j][1]);
      mnmn[i] = min(mnmn[i + 1], p.first);
      mnmx[i] = max(mnmx[i + 1], p.first);
      mxmn[i] = min(mxmn[i + 1], p.second);
      mxmx[i] = max(mxmx[i + 1], p.second);
    }
    function<ll(int, Enclosure, Enclosure)> dfs =
        [&](int i, const Enclosure& red, const Enclosure& blue) {
          if (i >= N) {
            return red.len() * blue.len();
          }
          ll limL = mnmn[i], limR = mxmx[i], bestR = mnmx[i], bestL = mxmn[i];
          if (red.contains(limL, limR) && blue.containsLeft(limL)) {
            return red.len() * blue.add(bestR).len();
          }
          if (red.contains(limL, limR) && blue.containsRight(limR)) {
            return red.len() * blue.add(bestL).len();
          }
          if (red.containsLeft(limL) && blue.contains(limL, limR)) {
            return red.add(bestR).len() * blue.len();
          }
          if (red.containsRight(limR) && blue.contains(limL, limR)) {
            return red.add(bestL).len() * blue.len();
          }
          int j = order[i];
          ll x = xy[j][0], y = xy[j][1];
          return min(dfs(i + 1, red.add(x), blue.add(y)),
                     dfs(i + 1, red.add(y), blue.add(x)));
        };
    cout << dfs(0, {INF, 0}, {INF, 0}) << endl;
  }
  return 0;
}


Measured memory_bytes: 36980
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <fstream>
#include <cstddef>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
const ll INF = (1<<30);
const ll NEGA=-INF*10000; 


ll ans = 0;
int p[200000];
int n,m;
int cnt=0;

int main() 
{
  string s;
  cin>>s;
  int k;
  cin>>k;
  string koho[25100];
  fill(koho,koho+25100,"{{{");
  int kohosize=0;
  rep(i,s.length()){
    rep(j,5){
      if(s.length()<=i+j) break;
       koho[kohosize++]=s.substr(i,j+1);
    }
  }
  sort(koho,koho+kohosize);
  int p[25000]={0};
  int pp=0;
  rep(i,kohosize){
   if(i) if(koho[i]==koho[i-1]) p[pp++]=i; 
  }
  rep(i,pp){
    koho[p[i]]="{{{";
  }
  sort(koho,koho+kohosize);
  cout<<koho[k-1]<<endl;
	return 0;
}


Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r1 = ReadSplit();
            var x = r1[0].ToInt();
            var y = r1[1].ToInt();
            var a = r1[2].ToDecimal();
            var b = r1[3].ToDecimal();
            var c = r1[4].ToDecimal();
            var r2 = ReadSplit();
            var p = new List<decimal>();
            for (int i = 0; i < a; i++)
            {
                p.Add(r2[i].ToDecimal());
            }
            var r3 = ReadSplit();
            var q = new List<decimal>();
            for (int i = 0; i < b; i++)
            {
                q.Add(r3[i].ToDecimal());
            }
            var r4 = ReadSplit();
            var r = new List<decimal>();
            for (int i = 0; i < c; i++)
            {
                r.Add(r4[i].ToDecimal());
            }

            p.Sort();
            q.Sort();
            r.Sort();

            var ans = new List<decimal>();
            ans.AddRange(p.GetRange(p.Count - x, x));
            ans.AddRange(q.GetRange(q.Count - y, y));
            ans.Sort();
            for (int i = 0; i < c; i++)
            {
                if (ans.Count < i + 1)
                {
                    break;
                }
                if (r.Any() && ans[i] < r[r.Count - 1])
                {
                    ans[i] = r[r.Count - 1];
                    r.RemoveAt(r.Count - 1);
                }
            }
            WriteRead(ans.Sum());
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {   
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 52776
#include <stdio.h>

int max(int s[], int n){
    int m = 0;
    for(int i = 0; i<n; i++){
        if(s[i] > m){
            m = s[i];
        }
    }
    return m;
}

int min(int s[], int n){
    int m = 100000;
    for(int i = 0; i<n; i++){
        if(s[i] < m){
            m = s[i];
        }
    }
    return m;
}
int main(void){
    int N, M;
    scanf("%d%d", &N, &M);
    int L[M];
    int R[M];
    for (int i = 0; i < M; i++){
        scanf("%d%d", &L[i], &R[i]);
    }
    int x1 = max(L, M);
    int x2 = min(R, M);
    int ans = 0;
    if(x2 >= x1){
        ans = x2-x1+1;
    }
    printf("%d\n", ans);
    return 0; 
}


Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    int N;
    cin >> N;
    cout << 800*N-200*(N/15) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
        
        int N;
        int d[50];
 
     
        int total = 0;
 
        
        scanf("%d", &N);
        for (int i = 0; i < N; i++) {
                scanf("%d", &d[i]);
        }
 
        
        for (int i = 0; i < N-1; i++) {
                for (int j = i+1; j < N; j++) {
                        total += d[i] * d[j];
                }
        }
 
        
        printf("%d", total);
 
        return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
int T;
ll a,b,c,d;

ll gcd(ll a,ll b){
    return a%b==0?b:gcd(b,a%b);
}
int main(){
    scanf("%d",&T);
    while(T--){
        scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
        if(a<b){
            printf("No\n");
            continue;
        }
        if(b>d){
            printf("No\n");
            continue;
        }
        if(c+1>=b){
            printf("Yes\n");
            continue;
        }
        ll cxz=gcd(b,d);
        if((a-c-1)/cxz>(a-b)/cxz)
            printf("No\n");
        else
            printf("Yes\n");
    }
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int a[105];
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
	{
		if (a[i] % 2 == 0)
		{
			if (a[i] % 3 != 0 && a[i] % 5 != 0)
			{
				cout << "DENIED\n";
				return 0;
			}
		}
	}
	cout << "APPROVED\n";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  std::vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }

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



  double mixed=(double)(v[0]+v[1])/2;
  for(int i=2;i<n;i++){
    mixed=(double)(mixed+v[i])/2;
  }

  cout<<mixed<<endl;



  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var h = int.Parse(ReadLine());
        var w = int.Parse(ReadLine());
        var n = int.Parse(ReadLine());
        int max = Max(h, w);
        int i = 0;
        for(; i * max < n; i++);
        WriteLine(i);
    }
}


Measured memory_bytes: 13140
n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = float('inf')
for i in range(1<<(n-1)):
    count = 0
    for j in range(n-1):
        if i>>j&1:
            count += 1
    if count < k - 1:
        continue
    minLim = a[0] + 1
    cost = 0
    for j in range(n-1):
        if i>>j&1:
            if a[j+1] < minLim:
                cost += minLim - a[j+1]
                minLim += 1
            else:
                minLim = a[j+1] + 1
        else:
            minLim = max(minLim, a[j+1]+1)
    ans = min(ans, cost)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
#include<chrono>
using namespace std;
typedef long long ll;
ll a[1001];
struct B{
	ll h;//high
	ll a;//number(left)
	ll lb,rb;//?????£???????????????
	ll lc,rc;//?????£??????????????????
	ll lv,rv;//?????´???vector?????????????????´
};
B b[100001];
struct C{
	ll h;//high
	ll b;//number
};
vector<C>c[1001];
ll n,m,h,k;
struct U{
	ll ai,bi;
};
U u[100001];
bool operator<(U a,U b){return a.bi<b.bi;}
int main(){
	while(cin>>n>>m>>h>>k&&n+m+h+k>0){
	for(ll i=1;i<=n;i++){
		cin>>a[i];
		c[i].clear();
	}
	for(ll i=1;i<=m;i++)
		cin>>u[i].ai>>u[i].bi;
	sort(u+1,u+m+1);
	for(ll i=1;i<=m;i++){
		ll ai=u[i].ai,bi=u[i].bi;
		ll io=(ll)c[ai].size(),oi=(ll)c[ai+1].size();
		b[i]=B{bi,ai,-1,-1,-1,-1,io,oi};
		c[ai].push_back(C{bi,i});
		c[ai+1].push_back(C{bi,i});
	}
	ll sum=0;
	for(ll i=1;i<=n;i++){
		ll d=i;
		ll e=0;
		while(e<c[d].size()){
			if(b[c[d][e].b].a==d){
				b[c[d][e].b].lb=i;
				e=b[c[d][e].b].rv;
				d++;
			}
			else{
				b[c[d][e].b].rb=i;
				e=b[c[d][e].b].lv;
				d--;
			}
			e++;
		}
		if(i<=k) sum+=a[d];
	}
	for(ll i=1;i<=n;i++){
		ll d=i;
		ll e=c[d].size()-1;
		while(e>=0){
			if(b[c[d][e].b].a==d){
				b[c[d][e].b].lc=i;
				e=b[c[d][e].b].rv;
				d++;
			}
			else{
				b[c[d][e].b].rc=i;
				e=b[c[d][e].b].lv;
				d--;
			}
			e--;
		}
	}
	ll ans=sum;
	for(ll i=1;i<=m;i++){
		ll sum2=sum;
		if(b[i].lb<=k){
			sum2-=a[b[i].rc];
			if(b[i].lv==(ll)c[b[i].a].size()-1){
				sum2+=a[b[i].a];
			}
			else{
				if(b[c[b[i].a][b[i].lv+1].b].a==b[i].a){
					sum2+=a[b[c[b[i].a][b[i].lv+1].b].rc];
				}
				else{
					sum2+=a[b[c[b[i].a][b[i].lv+1].b].lc];
				}
			}
		}
		if(b[i].rb<=k){
			sum2-=a[b[i].lc];
			if(b[i].rv==(ll)c[b[i].a+1].size()-1){
				sum2+=a[b[i].a+1];
			}
			else{
				if(b[c[b[i].a+1][b[i].rv+1].b].a==b[i].a+1){
					sum2+=a[b[c[b[i].a+1][b[i].rv+1].b].rc];
				}
				else{
					sum2+=a[b[c[b[i].a+1][b[i].rv+1].b].lc];
				}
			}
		}
		ans=min(ans,sum2);
	}
	cout<<ans<<endl;
}
}

Measured memory_bytes: 15168
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
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 main(){
  string s;
  cin>>s;

  if(s.at(3)==s.at(2) && s.at(4)==s.at(5)) cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e9
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
    string s;
    int n,k;
    cin>>s>>k;
    n=s.length();
    map<char,int>m,r;
    int index=0;
    for(char x='a';x<='z';x++){
        m[x]=(++index);
        r[index]=x;
    }
    for(int i=0;i<n;i++){
        if(s[i]=='a')continue;
        else{
            if(k>=27-m[s[i]]){
                k-=27-m[s[i]];
                s[i]='a';
            }
            else continue;
        }
    }
    if(k==0){
        cout<<s<<endl;
        return 0;
    }
    if(k>=26){
        int x=k/26;
        k-=26*x;
    }
    s[n-1]=r[m[s[n-1]]+k];
    cout<<s<<endl;
    return 0;
}

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

int main() {
    using vi = vector<int>;
    
    int r;
    cin >> r;
    cout << 2 * M_PI * r << endl;
}

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

bool vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
  }
  else { // 発見できなかったとき
    return false;
  }
}

int main(){
  int N;
  cin >> N;
  vector<int> A;
  int ain;
  int aMax = 0;

  for(int i=0;i < N; i++){
    cin >> ain;
    A.push_back(ain);
    if(aMax < ain)
      aMax = ain;
  }
  vector<int> mapA(aMax+1, 0);
  int aLen = A.size();
  
  for(int i=0; i < aLen; i++ ){
    int multiVal = A[i];
    while(multiVal <= aMax){
      mapA[multiVal] += 1;
      multiVal += A[i];
    }
  }

  int passed = 0; 
  for(int i=0; i < aLen; i++){
    if(mapA[A[i]] <=1)
      passed++;  
  }   
  cout << passed << endl;
}


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

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
//const int INF = 0x3f3f3f3f;
//const int mod=1e9+7;
//const double pi=3.14159265359;
//###################################################################
char a[10][10];
int main() {
    int n=D(),m=D(),k=D();
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>a[i][j];

    ll ans=0;
    for(int maskr=0;maskr<(1<<n);maskr++){
        for(int maskc=0;maskc<(1<<m);maskc++){
            ll black=0;
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    if(((maskr>>i)&1)&&((maskc>>j)&1)&&a[i][j]=='#')
                        black++;
                }
            }
            if(black==k)ans++;
        }
    }
    cout<<ans;

}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    bool p;
    if (s[0] == s[1]) p = (s[2] == s[3] && s[1] != s[2]);   // aabb
    else if (s[0] == s[2]) p = (s[1] == s[3] && s[0] != s[1]);  //abab
    else if (s[0] == s[3]) p = (s[1] == s[2] && s[0] != s[1]);  // abba
    else p = false;
    
    cout << (p ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <utility>

using namespace std;
int score[1001][1001];
int main() {
    int H, W;
    cin >> H >> W;
    char A[1001][1001];
    queue<pair<int, int>> q;
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            cin >> A[i][j];
            if (A[i][j] == '#') {
                q.push(make_pair(i, j));
                score[i][j] = 1;
            }
        }
    }
    int number = 1;
    while (!q.empty()) {
        number++;
        int size = q.size();
        for (int i=0; i<size; i++) {
            pair<int, int> p = q.front();
            q.pop();
            int row = p.first;
            int col = p.second;
            if (row-1 >= 0 && score[row-1][col] == 0) {
                score[row-1][col] = number;
                q.push(make_pair(row-1, col));
            }
            if (row+1 < H && score[row+1][col] == 0) {
                score[row+1][col] = number;
                q.push(make_pair(row+1, col));
            }
            if (col-1 >= 0 && score[row][col-1] == 0) {
                score[row][col-1] = number;
                q.push(make_pair(row, col-1));
            }
            if (col+1 < W && score[row][col+1] == 0) {
                score[row][col+1] = number;
                q.push(make_pair(row, col+1));
            }
        }
    }
    int maxVal = -1;
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            if (maxVal == -1 || maxVal < score[i][j]) maxVal = score[i][j];
        }
    }
    cout << maxVal - 1 << endl;
    return 0;
}



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

using namespace std;
int main(){
  long long A,B,C,K;
  cin >> A >> B >> C >> K;
  
  long long ans = A - B;
  if(abs(ans) >= 10000000000000000000) cout << "Unfair" << endl;
  if(K % 2 == 1) ans = -ans;
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n[10];
  for(int i=0;i<10;i++){
    cin>>n[i];
  }
  sort(n,n+10);
  cout<<n[9]<<endl;
  cout<<n[8]<<endl;
  cout<<n[7]<<endl;
}
    

Measured memory_bytes: 3116
# https://atcoder.jp/contests/abc143/tasks/abc143_b
from itertools import combinations
 
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

total = 0
nowrow = 0

for i in range(N):
    #直後に食べる
    if i != 0 and (nowrow + 1) == A[i]:
        total = total + C[nowrow - 1 ]
    #何番目
    nowrow = A[i]
    #食べる満足度
    total = total + B[nowrow - 1]

print(total)


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int n, k;

int main(){
	cin >> n >> k;
	
	cout << n-k+1 << endl;
	
	return 0;
}

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

int sum(int value){
    int ans=0;
    while(value!=0){
        ans+=value%10;
        value /= 10;
    }
    return ans;
}

int main(){
    int n;
    int ans=10000001;
    cin >> n;
    for(int i = 1; i < n; i++){
        int x1 = sum(i);
        int x2 = sum(n-i);
        ans = min(ans,x1+x2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256