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

typedef long long ll;

int main(){
  ll n,r,minv=10000000000,maxv=-10000000000; //初期値に十分大きなあたいと十分小さなあたいをとる
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> r; //基準となる数字
    if ( maxv < r-minv ) maxv = r-minv; // maxvよりr-minvのほうが大きい場合
    if ( minv > r ) minv = r; // minvよりrが小さい場合
  }
 
  cout << maxv << endl;
  return 0;
}

Measured memory_bytes: 1156
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
#define MAX_V 100100
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End



#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Graph Start
struct edge {
    int from, to;
    long long cost;
};
/// Graph End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl;
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template



int main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(n,k);
    vector<long long> h(n);
    rep(i,n) cin >> h[i];
    sort(All(h));
    vector<long long> ans;
    rep(i,n-k+1){ 
        ans.push_back(abs(h[i+k-1]-h[i]));
    }
    cout << *min_element(All(ans)) << nn;
    return 0;
}

Measured memory_bytes: 2168
def main():
    q, h, s, d = map(int, input().split())
    n = int(input())
    min_1 = min(q*4, h*2, q*2+h, s)
    min_2 = min(min_1*2, d)

    print((n % 2)*min_1 + (n // 2)*min_2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9132
package main

import (
	"fmt"
	"math"
)

func main() {
	var r float64
	fmt.Scan(&r)

	area := fmt.Sprintf("%.10f", math.Pi*r*r)
	length := fmt.Sprintf("%.10f", 2*math.Pi*r)
	fmt.Println(area, length)
}



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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb emplace_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

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

	int q;
	cin >> q;
	while (q--) {
		ll a, b;
		cin >> a >> b;
		if (a == b) {
			cout << 2 * a - 2 << endl;
		} else {
			ll i = 0, j = 2e9+5, rep = 35;
			while (rep--) {
				ll m = (i + j) / 2;
				if (m * m >= a * b) j = m;
				else i = m;
			}
			j--;

			if (j * (j + 1) < a * b) cout << 2 * j - 1 << endl;
			else cout << 2 * j - 2 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
import fractions
from functools import reduce


def lcm(a, b):
    return (a * b) // fractions.gcd(a, b)


def lcm_list(n):
    return reduce(lcm, n)


n = int(input())
a = list(map(int, input().split()))

mod = 10 ** 9 + 7

L = lcm_list(a)
ans = 0
for i in a:
    ans += L // i

print(ans % mod)


Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D;
  cin >> D;
 
  if (D <= 25) {
    cout << "Christmas";
  }
  if (D <= 24) {
    cout << " Eve";
  }
  if (D <= 23) {
    cout << " Eve";  
  }
  if (D <= 22) {
    cout << " Eve";
  }
  
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list( map(int, input().split()) ) 
count=0
if N%2==1:
    for i in range((N+1)//2):
        if A[2*i]%2==1:
            count=count+1
        else:
            count=count
    print(count)
else:
    for i in range(N//2):
        if A[2*i]%2==1:
            count=count+1
        else:
            count=count
    print(count)

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

using namespace std;

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

	int result = 1;
	// それぞれの基数に対するX以下の最大値を見ていく
	for(int b = 2; b <= 40; b++) {
		int n = b * b;
		if(n > X) {
			break;
		}
		while(true) {
			if(n * b > X) {
				result = (result > n) ? result : n;
				break;
			}
			n *= b;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

inline int read()
{
	int x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}

int n,cnt;

int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		if(read()&1)
			cnt++;
	if(cnt&1)
		puts("NO");
	else
		puts("YES");
	return 0;
}


Measured memory_bytes: 256
a = list(map(int,input().split()))

if a[0] + a[1]>= a[2]:
  if a[2] >= a[0]:
    if a[1] >= a[2] - a[0]:
      print("YES")
    else:
      print("NO")
  else:
    print("NO")
else:
  print("NO")

Measured memory_bytes: 3060
#ifdef  DEBUG
#define MAXN 10
#else
#define MAXN 100007
#endif
#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define pb(c) push_back(c)
#define vii vector<pair<int,int>>
#define vvi vector<vector<int>>
#define ii pair<int,int>
#define mp(i, j) make_pair(i,j)
#define ull unsigned long long int
#define ll  long long int
#define endl '\n'
#define PI  3.141592653589793238
#define MOD (1000000007)
#define INF (2000000000)
#define EPS (0.00000001)

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef DEBUG
    freopen("input", "r", stdin);
#endif
    int n,m,k;
    cin>>n>>m>>k;
    rep (i,0,n+1) {
        int num = k-i*m;
        int deno = n-2*i;
        if (deno!=0 && ((num)%deno) == 0 && (num/deno) >=0 && (num/deno)<=m) {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}





















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

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

int main(){
int n,a;
cin>>n>>a;
n=n-(n/500)*500;
if(n<=a)
cout<<"Yes"<<endl;
else
{
  cout<<"No"<<endl;
}




  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

# B - RGB Boxes
R, G, B, N = map(int, input().split())
ans = 0

for r in range(N + 1):
	for g in range(N + 1):
		b_sum = N - R*r - G*g
		
		if b_sum < 0:
			break
		else:
			if (b_sum / B).is_integer():
				ans += 1

print(ans)



Measured memory_bytes: 2940
#include <iostream>
#include <cmath>

using namespace std;
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;

  int d0 = 0;
  int d1 = 0;

  for (int i = 0; i < s.size(); i++) {
    if (i % 2 == 0) {
      if (s[i] != '0') d0++;
      if (s[i] != '1') d1++;
    } else {
      if (s[i] != '1') d0++;
      if (s[i] != '0') d1++;
    }
  }

  cout << min(d0, d1) << "\n";
  return 0;
}

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

int main(){
	int n,m,count,tmp;
	while(cin >> n >> m && n && m){
		bool flag[n+1];
		count = 0;
		for(int i = 1;i <= n;++i){
			flag[i] = true;
		}
		tmp = m;
		for(int i = 1;i <= n;++i){
			if(count == (n - 1)) break;
			if(flag[i]){
				--tmp;
				if(tmp == 0){
					flag[i] = false;
					count++;
					tmp = m;
				}
			}
			if(i == n) i = 0;
		}
		for(int i = 1;i <= n;++i){
			if(flag[i]){
				cout << i << endl;
			}
		}

	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);
#define int long long
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a,b;
	cin>>a>>b;
	int res = a/(b+b+1);
	if(a%(b+b+1))++res;
	cout<<res<<endl;
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	string s; cin >> s;
	LL ans = 0;
	FOR(i, 0, SZ(s)) {
		string t = s.substr(0, i + 1);
		string u = s.substr(i + 1, i + 1);
		DD(de(t, u))
			if (t == u && 2 * SZ(t) < SZ(s)) {
				ans = max(ans, 2LL * SZ(t));
			}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <sstream>
#include <vector>
using namespace std;

template <class T, class U>
T lexical_cast(const U& from) {
  T to;
  stringstream ss;
  ss << from; ss >> to;
  return to;
}

typedef double D;
const D EPS = 1e-8;

struct P {
  D x, y;
  P() { }
  P(D x_, D y_) : x(x_), y(y_) { }
};

struct C {
  P p; D r;
  C() { }
  C(P p_, D r_) : p(p_), r(r_) { }
};

P operator +(P a, P b) { return P(a.x + b.x, a.y + b.y); }
P operator -(P a, P b) { return P(a.x - b.x, a.y - b.y); }
P operator *(P a, D b) { return P(a.x * b, a.y * b); }
P operator /(P a, D b) { return P(a.x / b, a.y / b); }

int sig(D a, D b) {
  if(a < b - EPS) return -1;
  if(a > b + EPS) return +1;
  return 0;
}

D inp(P a, P b) { return a.x*b.x + a.y*b.y; }
D outp(P a, P b) { return a.x*b.y - a.y*b.x; }
D norm(P p) { return inp(p, p); }
D abs(P p) { return sqrt(norm(p)); }
P rot90(P p) { return P(-p.y, p.x); }

vector<P> cCC(C a, C b) {
  D d = abs(b.p - a.p);
  D x = (d*d + a.r*a.r - b.r*b.r) / (2*d);
  D y = sqrt(a.r*a.r - x*x);
  P v = (b.p - a.p) / d;
  vector<P> res;
  res.emplace_back(a.p + v*x + rot90(v)*y);
  res.emplace_back(a.p + v*x - rot90(v)*y);
  return res;
}

int main() {
  while(true) {
    int N; cin >> N;
    if(N == 0) break;
    vector<C> Cs(N);
    for(int i = 0; i < N; ++i) {
      string S; cin >> S;
      D x = lexical_cast<double>(S.substr(0, S.find(',')));
      D y = lexical_cast<double>(S.substr(S.find(',') + 1));
      Cs[i].p = P(x, y);
      Cs[i].r = 1.0;
    }
    int ans = 1;
    for(int i = 0; i < N; ++i) {
      for(int j = i + 1; j < N; ++j) {
        if(sig(abs(Cs[i].p - Cs[j].p), 2.0) <= 0) {
          vector<P> cross_point = cCC(Cs[i], Cs[j]);
          for(P p : cross_point) {
            int c = 0;
            for(int k = 0; k < N; ++k) {
              if(sig(abs(Cs[k].p - p), 1.0) <= 0) {
                ++c;
              }
            }
            ans = max(ans, c);
          }
        }
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define lli long long int
#define pb(a) push_back(a)
#define forr(a,n) for(lli i=a;i<n;i++)
#define forrr(j,a,n) for(lli j=a;j<n;j++)
#define all(x) x.begin(),x.end()
#define pi2  1.57079632679489661923

using namespace std;
void print(lli a[],lli n){
forr(0,n){cout<<a[i]<<" ";}
cout<<"\n";
}
lli power(lli x){
lli u=0;
while(x%2==0){
    u++;
    x=x/2;
}
return u;
}

lli powM(lli x,lli y,lli m)
{
    if(m==1){return 0;}
    lli ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
int powm(lli a, lli b) {
	lli res = 1;
	while (b) {
		if (b & 1)
			res = (res * a);
		a = (a * a);
		b >>= 1;
	}
	return res;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
/*
vector <lli> adj[100001];
lli vis[100001]={0};
void dfs(lli a){
    vis[a]=1;
    forr(0,adj[a].size()){
    if(vis[adj[a][i]]){continue;}
    else{
        dfs(adj[a][i]);
    }
    }
}
lli level[100001];
void bfs(lli a){
queue <lli> q;
vis[a]=1;
level[a]=0;
q.push(a);
while(!q.empty()){
    lli p=q.front();
    q.pop();
    forr(0,adj[p].size()){
    if(vis[adj[p][i]]==0){
        level[adj[p][i]]=level[p]+1;
        q.push(adj[p][i]);
        vis[adj[p][i]]=1;
    }
    }

}

}

vector <pair<lli,lli> > dj[100001];
lli dist[100001];
vector<lli> ans[100001];
void dijkstra(lli a){
dist[a]=0;
ans[a].pb(a);
multiset<pair<lli,lli> > s;
s.insert({0,a});
while(s.size()!=0){
    lli x=(*s.begin()).second;
    s.erase(s.begin());
    if(vis[x]){continue;}
    vis[x]=1;
    forr(0,dj[x].size()){
    lli e=dj[x][i].first;
    lli we=dj[x][i].second;
    if(dist[x]+we<dist[e]){
        dist[e]=dist[x]+we;
        ans[e].clear();
        ans[e].pb(x);
        s.insert({dist[e],e});
    }
    }
}

}
*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
   cout.tie(0);
   //freopen("outpu.txt","w",stdout);
int t1=1;
//cin>>t1;
lli M =1e9+7;
while(t1--){
  lli x;
  cin>>x;
  lli u;
  if(x<=599 && x>=400){u=8;}
  if(x<=799 && x>=600){u=7;}
  if(x<=999 && x>=800){u=6;}
  if(x<=1199 && x>=1000){u=5;}
  if(x<=1399 && x>=1200){u=4;}
  if(x<=1599 && x>=1400){u=3;}
  if(x<=1799 && x>=1600){u=2;}
  if(x<=1999 && x>=1800){u=1;}
  cout<<u;
}
     return 0;
}


Measured memory_bytes: 3580
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int N,M,A[9],R;
vector<int> ans(9,0),t(9,0);

vector<int>amd()
{
	vector<int>a(N,0);
	for(int i=0;i<N;i++)a[i]=i;
	for(int i=0;i<M;i++)swap(a[A[i]],a[A[i]+1]);
	return a;
}

int calc()
{
	int r=0;
	vector<int>a(N,0),h(N,0);
	for(int i=0;i<N;i++)a[i]=i;
	if(amd()==ans)
	{
		for(int i=0;i<M;i++)
			h[A[i]]=h[A[i]+1]=max(h[A[i]],h[A[i]+1])+1;
		for(int i=r=0;i<N;i++)r=max(r,h[i]);
		return r;
	}
	return 9;
}


int main()
{
	int R=9;
	scanf("%d%d",&N,&M);
	for(int i=0;i<M;A[i++]--)
		scanf("%d",&A[i]);
	ans=amd();
	sort(A,A+M);
	do
	{
		R=min(R,calc());
	}while(next_permutation(A,A+M));
	printf("%d\n",R);
}

Measured memory_bytes: 1072
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll n, k; cin >> n >> k;
    vll a(n);
    ll mx = 0;
    bool b = false;
    set<ll> s;
    rep(i, 0, n){
        cin >> a[i];
        s.insert(a[i]);
        if(a[i] == k){
            b = true;
        }
        chmax(mx, a[i]);
    }
    if(k > mx){
        prtl("IMPOSSIBLE");
        return 0;
    }
    if(b){
        prtl("POSSIBLE");
        return 0;
    }
    sort(a.begin(),a.end());
    ll g = __gcd(a[0], a[1]);
    rep(i, 2, n){
        g = __gcd(g, a[i]);
    }
    if(k%g == 0){
        prtl("POSSIBLE");
    }else{
        prtl("IMPOSSIBLE");
    }
}



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

int main()
{
    int n;
    cin >> n;
    int a[n];
    int max = 0, sum = 0;

    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(max < a[i]){
            max = a[i];
        }
        sum += a[i];
    }
    cout << sum - max / 2 << endl;
}

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

int main() {
  char x, y;
  cin >> x >> y;

  if (x < y) {
    cout << "<" << endl;
  } else if (x == y) {
    cout << "=" << endl;
  } else {
    cout << ">" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <set>
using namespace std;
string s_lefthand = "qwertasdfgzxcvb";
set<char> lefthand(s_lefthand.begin(), s_lefthand.end());
int main () {
	string line;
	while (cin >> line, line != "#") {
		bool prehand = (lefthand.find(line[0]) != lefthand.end());
		int count = 0;
		for (unsigned i = 0; i < line.size(); i++) {
			if ((lefthand.find(line[i]) != lefthand.end()) != prehand) {
				count++;
				prehand = !prehand;
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define for1(i, a, b) for(i = a; i <= b; ++i)
#define for0(i, a, b) for(i = a; i < b; ++i)
#define forw1(i, a, b) for(i = a; i >= b; --i)
#define forw0(i, a, b) for(i = a - 1; i >= b; --i)
#define fora(v, a) for(auto v : a)
#define bp __builtin_popcount
#define bpll __builtin_popcountll

using namespace std;
using cd = complex<double>;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<cd> vcd;
typedef vector<ii> vii;
typedef vector<vector<int> > vvi;

const int modd1 = 1e9 + 7, modd2 = 998244353, maxn = 5010, K = 26, inf = 1e9, infll = 1e18;
const double pi = acos(-1);
int n, town[maxn], fact[maxn], power[maxn], dp[3][maxn], cc[maxn], cnt_edges, cnt_ver;
bool vis[maxn];
vi gr[maxn];

void init(){
	int i, j;
	fact[0] = power[0] = 1;
	for1(i, 1, n){
		fact[i] = (fact[i - 1] * i) % modd1;
		power[i] = (power[i - 1] * (n - 1)) % modd1; //cout << fact[i] << ' ' << power[i] << '\n';
	}
}

void dfs(int src){
	vis[src] = 1; cnt_ver++;
	fora(v, gr[src]){
		cnt_edges++;
		if(vis[v]){
			continue;
		}
		dfs(v);
	}
}

void solve(){
	int i, j, k, l, r; cin >> n;
	for1(i, 1, n){
		cin >> town[i];
		if(town[i] != -1){
			gr[i].pb(town[i]); gr[town[i]].pb(i);
		}
	}
	init();
	int acc = 0, cnt = 0, ans = 0;
	for1(i, 1, n){
		if(!vis[i]){
			cnt_ver = cnt_edges = 0;
			dfs(i);
			cnt_edges /= 2;
			if(cnt_edges == cnt_ver - 1){
				acc++;
				cc[acc] = cnt_ver;
			}
			else{
				cnt++;
			}
		}
	}
	//cout << acc << ' ' << cnt <<'\n';
	dp[0][0] = 1;
	for1(i, 1, acc){
		for1(j, 0, i){
			dp[i & 1][j] = (dp[1 - (i % 2)][j] * (n - 1)) % modd1;
			dp[i & 1][j] = (dp[i & 1][j] + (dp[1 - (i % 2)][j - 1] * cc[i]) % modd1) % modd1;
		}
	}
	ans = (ans + (cnt * power[acc]) % modd1) % modd1; 
	for1(i, 2, n){
		ans = (ans + (dp[acc % 2][i] * fact[i - 1]) % modd1) % modd1;
	}
	for1(i, 1, acc){
		ans = (ans + ((cc[i] - 1) * power[acc - 1]) % modd1) % modd1;
	}
	cnt_ver = ans;
	ans = (power[acc] * n) % modd1;
	ans = (ans + modd1 - cnt_ver) % modd1;
	cout << ans;
}

signed main() {
    //freopen(".INP", "r", stdin);
    //freopen(".OUT", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
}


Measured memory_bytes: 4044
/*B - Count ABC*/
#include <bits/stdc++.h>

using namespace std;

int main(){

	string cad;
	int ans = 0;
	int tam;

	cin >> tam >> cad;

	for (int i = 0; i < tam - 2; ++i)

		if(cad[i] == 'A' and cad[i + 1] == 'B' and cad[i+2] == 'C')
		  ans++;
	

	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
x,y=[],[]
t=10
for i in range(5):
    x.append(int(input()))
    y.append(x[i]%10)
    if 0<y[i]<t:
        t=y[i]
    if x[i]%10!=0:
        x[i]=((x[i]//10)+1)*10
    y[i]=x[i]
print(sum(y)+t-10)

Measured memory_bytes: 9148
#include<stdio.h>
int main (void){
  char s[100];
  int k,i,n;
   scanf("%d",&k);
  scanf("%s",s);
  n=0;
  while(s[n]!='\0'){n++;}  
  if(n<=k){
    for(i=0;i<n;i++){
      printf("%c",s[i]);
    }
    printf("\n");
  }
  else{
    for(i=0;i<k;i++){
      printf("%c",s[i]);
    }
    printf("...\n");
  }
  return 0;
}

Measured memory_bytes: 1644
#include<stdio.h>

int main()
{
  int n;
  
  scanf("%d", &n);
  
  if(n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9)
  {
    printf("hon\n");
  }else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
  {
    printf("pon\n");
  }else if(n % 10 == 3)
  {
    printf("bon\n");
  }
}

Measured memory_bytes: 1648
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int ans;
    if(s=="MON"){
        ans = 6;
    }else if(s=="TUE"){
        ans = 5;
    }else if(s=="WED"){
        ans = 4;
    }else if(s=="THU"){
        ans = 3;
    }else if(s=="FRI"){
        ans = 2;
    }else if(s=="SAT"){
        ans = 1;
    }else{
        ans =7;
    }
    cout<< ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int a, v, b, w, t;
signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> a >> v >> b >> w >> t;
    int dv = v - w;
    if (llabs(b - a) <= dv * t) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll N, M;
ll kosu(ll val, const vector<ll> &A){
	ll res = 0;
	REP(i, N){
		ll tar = val-A[i];
		ll tmp = A.end() - lower_bound(A.begin(), A.end(), tar);
		res += tmp;
	}
	return res;
}

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

    cin >> N >> M;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    sort(A.begin(), A.end());


    ll lb = -1;
    ll ub = 2000001;

    while(ub-lb>1){
    	ll mid = (lb+ub)/2;
    	if(kosu(mid, A)>=M){
    		lb = mid;
    	}else{
    		ub = mid;
    	}
    }
    ll val = ub-1;

    vector<ll> S(N+1, 0);
    REP(i, N) S[i+1] = S[i] + A[i];

    ll res = 0;
    REP(i, N){
    	ll tar = val - A[i];
    	ll idx = lower_bound(A.begin(), A.end(), tar) - A.begin();
    	res += (S[N] - S[idx]);
    	res += (N-idx)*A[i];
    }

    res -= val * (kosu(val, A) - M);
    cout << res << endl;
    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

int main(){
   IOS;

   long int n;
   cin>>n;

   string s;
   cin>>s;

   string ans;
   ans.push_back(s[0]);

   for(long int i = 1; i < n; i++){
   	if(ans.back() == s[i])
   		continue;
   	else
   		ans.push_back(s[i]);
   }	

   cout<<ans.size();
   return 0;
}

Measured memory_bytes: 592
n = int(input())
avg_temparature, kijun_temparature = map(int,input().split())
list_height = [int(i) for i in input().split()]

result_position = 0
for candidate in range(1,len(list_height)):
    a = avg_temparature - (list_height[result_position] * 0.006)
    b = avg_temparature - (list_height[candidate] * 0.006)
    if abs(kijun_temparature - a) > abs(kijun_temparature - b):
        result_position = candidate

print(result_position+1)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N;
  cin>>N;

  ll ans=0;
  for(ll i=1;i<=N;i++){
    if(i%3==0||i%5==0) continue;
    ans+=i;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int INF = 1e9+7;
using ll = long long;
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    ll asum = 0;
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        if(s[i] == 'C')
        {
            asum = 0;
        }
        else if(s[i] == 'A')
        {
            asum++;
        }
        else if(s[i] == 'B' && i < n-1 && s[i+1] == 'C' && asum > 0)
        {
            ans += asum;
            i++;
        }
        else if(s[i] == 'B' && i < n-1 && s[i+1] == 'B')
        {
            asum = 0;
            i++;
        }
        else if(s[i] == 'B' && i < n-1 && s[i+1] == 'A')
        {
            asum = 1;
            i++;
        }
    }
    cout << ans << endl;
}


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

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

using namespace std;
using ll = long long;

void solve();

int main(void){
    ll n, m, d;
    cin >> n >> m >> d;
    double a;
    if(d > 0) a = (double) 2*(n-d)/(n*n);
    else a = (double) 1/n;
    printf("%.10f\n", a*(m-1));
    return 0;
}

void solve(){}

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

using namespace std;

#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<long long, long long> pl;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double EPS = 1e-6;
const int MAX_N = 16;

int N;
ll a[MAX_N][MAX_N];
ll dp[(1 << MAX_N)], pre[(1 << MAX_N)];

void rec(int i, vector<int>& not_taken, ll score_so_far, int mask, int group) {
	if (i == not_taken.size()) {
		dp[mask] = max(dp[mask], score_so_far + pre[group]);
		return;
	}
	rec(i + 1, not_taken, score_so_far, mask, group);
	rec(i + 1, not_taken, score_so_far, mask | (1 << not_taken[i]), group | (1 << not_taken[i]));
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int N; cin >> N;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			cin >> a[i][j];
		}
	}

	for (int mask = 0;  mask < (1 << N); ++mask) {
		for (int i = 0; i < N; ++i) {
			if (mask & (1 << i)) {
				for (int j = i + 1; j < N; ++j) {
					if (mask & (1 << j)) {
						pre[mask] += a[i][j];
					}
				}
			}
		}
	}

	fill(dp, dp + (1 << MAX_N), -INF);
	dp[0] = 0;
	for (int mask = 0; mask < (1 << N); ++mask) {
		vector<int> not_taken;
		for (int i = 0; i < N; ++i) {
			if (!(mask & (1 << i))) {
				not_taken.push_back(i);
			}
		}
		rec(0, not_taken, dp[mask], mask, 0);
	}

	cout << dp[(1 << N) - 1] << '\n';

	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  double R; 
  cin >> R;

  cout << 2*R*PI << "\n";

  return 0;
}


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

using namespace std;

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

  int N; cin>>N;
  vector<long> A(N); for (auto& a : A) cin>>a;

  long sum = 0;
  vector<long> CA;
  for (auto a : A) {
    sum += a;
    CA.push_back(sum);
  }
  double center = double(sum)/2;
  double min_diff = numeric_limits<double>::max();
  for (auto ca : CA) min_diff = min(min_diff, abs(center - ca));
  long res = min_diff*2;
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3956
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  int n,x;
  string count,aa="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  cin>>n>>x;
  for(int i=0;i<n;i++){
    for(int j=0;j<x;j++){
      string name;
      cin>>name;
      count=name;
      if(count=="snuke"){
        cout<<aa[j]<<i+1<<endl;
      }
    }
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(n, s):
    counts = {}
    for c in s:
        if c in counts:
            counts[c] += 1
        else:
            counts[c] = 1
    nums = counts.values()
    ret = 1
    for num in nums:
        ret *= num + 1
        ret %= MOD
    ret -= 1
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		sc.close();

		//テストケースの総数とACされたテストケースが等しいかどうか
		if(N == M) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

int primes[30010];

int main() {
    memset(primes, 0, sizeof(primes));

    primes[0] = primes[1] = 1;
    for(int i=4; i<=30000; i+=2) primes[i] = 1;
    for(int i=3; i*i<=30000; i+=2)
        if(primes[i] == 0)
            for(int j=2; i*j<=30000; ++j)
                primes[i*j] = 1;

    int t;
    while(cin>>t, t) {
        int ans = 0;
        for(int i=2; i<=(t/2)+1; ++i) {
            if(primes[i]) continue;
            for(int j=i; i+j<t && t-i-j>=j; ++j) {
                if(primes[j]) continue;
                int k = t - i - j;
                if(primes[k]) continue;
                if(i+j <= k) continue;
                ans++;
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 980
#include<bits/stdc++.h>
//#define REP(i,n) for (int i = 0; i < n; i++)
//#define REP(j,m) for (int j = 0; j < m; j++)
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define lli long long int
#define INF 1000000000
#define endl '\n'
#define ll 	long long
#define pi acos(-1.0)
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;

using namespace std;

int main()
{
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	
	for(int i=0;i<n;i++)
	{
		cout<<s[i]<<t[i];
	}
	
	
}

Measured memory_bytes: 3628
n = int(input())
a_lis = list(map(int, input().split()))
ans = max(a_lis)
ans_a = n
a_avg = sum(a_lis)/len(a_lis)

for i, a in enumerate(a_lis):
    if abs(a - a_avg) < ans:
        ans = abs(a - a_avg)
        ans_a = i

print(ans_a)

Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define eb emplace_back
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b);
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c);
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n";
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define state tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define Z 505  //check the limits, man
#define N 100001
#define PI 3.141592653589
const ll INF = 1e10;
int main()
{
    int a,b,x,v;
    in3(a,b,x);
    double d;
    v=a*a*b;
    cout << setprecision(12) << fixed;
    if(2*x<=v)
    {
        d=a*b*b;
        d/=2,d/=x;
        d=atan(d);
    }
    else
    {
        d=v-x;
        d*=2;
        d/=a,d/=a,d/=a;
        d=atan(d);
    }
    d=d*180;
    d/=PI;
    llout(d);
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 3000;
int dp[N + 5][N + 5][2];

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

  int n;
  cin >> n;

  vector<int> a(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  
  memset(dp, 0, sizeof dp);
  for (int i = 0; i <= n; ++i) {
    for (int j = 1; j + i <= n; ++j) {
      int l = j, r = i + j;
      if (dp[l+1][r][1] + a[l] > dp[l][r-1][1] + a[r]) {
        dp[l][r][0] = a[l] + dp[l+1][r][1];
        dp[l][r][1] = dp[l+1][r][0];
      } else {
        dp[l][r][0] = a[r] + dp[l][r-1][1];
        dp[l][r][1] = dp[l][r-1][0];
      }
    }
  }
  
  cout << dp[1][n][0] - dp[1][n][1] << '\n';
}

Measured memory_bytes: 144772
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string s;
    cin >> s;

    ll gu_num = 0;
    ll pa_num = 0;

    ll score = 0;

    for(char c : s){
        if(c == 'p'){
            if(pa_num < gu_num){
                pa_num++;
            }else{
                gu_num++;
                score--;
            }
        }else{
            if(pa_num < gu_num){
                pa_num++;
                score++;
            }else{
                gu_num++;
            }
        }
    }

    p(score);
    
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    long long a,b,d=0,e=0,y=0,z=0;
    string s;
    char c;
    cin>>a>>b>>s;
    b-=1;
    c=s[b];
    y = (int)(c);
    z=y+32;
    c = (char) (z);
    s[b]=c;
    cout<<s;
    return 0;
}


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

int main() {
    int len, k;
    string s;
    cin >> s >> k;
    len = s.length();
    for(int i=0;i<len;i++){
        if(s[i] == 'a') continue;
        int dst = 1 + 'z' - s[i];
        if(dst <= k){
            k -= dst;
            s[i] = 'a';
        }
    }
    s[len-1] += k%26;
    if(s[len] > 'z') s[len-1] -= 26;
    cout << s << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=998244353;
const ll maxn=200005;
ll fac[maxn],inv[maxn];
void inverse(int n){
	inv[1]=1;
	for(int i=2;i<=n;i++){
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	}
}
void init(int n){
	fac[0]=1;inv[0]=1;
	inverse(n);
	for(int i=1;i<=n;i++){
		fac[i]=fac[i-1]*i%mod,inv[i]=inv[i-1]*inv[i]%mod;
	}
}
ll c(int n,int m){
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
ll quickp(ll a,ll n){
	ll ans=1;
	while(n){
		if(n&1) ans=ans*a%mod;
		a=a*a%mod;
		n>>=1;
	}
	return ans;
}
int main(){
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	init(n);
	ll p=quickp(m-1,n-1-k);
	ll ans=0;
	for(int i=k;i>=0;i--){
		ans=(ans+c(n-1,i)*m%mod*p%mod)%mod,p=p*(m-1)%mod;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 6848
//https://atcoder.jp/contests/agc019/tasks/agc019_a
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
struct Dat{
    ll cost;
    ll vol;
    ll cost_per_vol=0; //2l(200)の値段
    Dat(ll icos,ll ivol)
        : cost(icos), vol(ivol) 
    {
        cost_per_vol = cost * (200/ivol);
    }
};
int main() {
    ll Q,H,S,D; cin>>Q>>H>>S>>D;
    ll N; cin>>N; N*=100; //1l->100にする
    vector<Dat> tbl;
    tbl.push_back(Dat(Q,25));
    tbl.push_back(Dat(H,50));
    tbl.push_back(Dat(S,100));
    tbl.push_back(Dat(D,200));
    sort(tbl.begin(),tbl.end(),[](const auto& a, const auto&b){ return a.cost_per_vol < b.cost_per_vol; });
    ll ans=0;
    for(const auto& d:tbl){
        ll tmp=N/d.vol;
        ans+=tmp*d.cost;
        N-=tmp*d.vol;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int a, b;
  cin >> a >> b;
  cout << ((a * b % 2 == 1) ? "Odd" : "Even") << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main() {
    long long int N;
    scanf("%lld",&N);

    long long int A[N+1];
    long long int count[N+1];
    long long int ans[N+1];
    long long int ruiseki = 0;
    for(int i = 0; i <= N; ++i){
        A[i] = 0;
        count[i] = 0;
        ans[i] = 0;
    }

    for(int i = 1; i <= N; ++i){
        scanf("%lld",&A[i]);
        count[A[i]]++;
    }

    for(int i = 1; i <= N; ++i){
                ruiseki += (count[i]-1)*count[i]/2;
            }
    for(int i = 1; i <= N; ++i){
        ans[i] = ruiseki - (count[A[i]]-1)*count[A[i]]/2 + (count[A[i]]-2)*(count[A[i]]-1)/2;
        printf("%lld\n",ans[i]);
    }
    return 0;
}

int A(){
    int N,M;
    int ans;
    scanf("%d %d",&N,&M);

    ans = (N-1)*N/2 + (M-1)*M/2;
    printf("%d",ans);

    return 0;
}

int B(){
    char S[100];
    char mae[50]={};
    char ato[50]={};
    char mae_mae[25]={};
    char mae_ato[25]={};
    char ato_mae[25]={};
    char ato_ato[25]={};

    scanf("%s",&S);

    strncpy(mae,S,(strlen(S)-1)/2);
    for(int i = 0; i < (strlen(S)-1)/2; ++i){
        ato[i] = S[(strlen(S)- 1 - i)];
    }
    if(strcmp(mae,ato) != 0){
        printf("No");
        return 0;
    }

    if(strlen(mae)% 2 == 1) {
        strncpy(mae_mae, mae, (strlen(mae) - 1) / 2);
        strncpy(ato_mae, ato, (strlen(ato) - 1) / 2);
        for(int i = 0; i < (strlen(mae)-1)/2; ++i){
            mae_ato[i] = S[(strlen(mae)- 1 - i)];
            ato_ato[i] = S[(strlen(mae)- 1 - i)];
        }

    }
    else {
        strncpy(mae_mae, mae, strlen(mae) / 2);
        strncpy(ato_mae, ato, strlen(ato) / 2);
        for (int i = 0; i < (strlen(mae)) / 2; ++i) {
            mae_ato[i] = S[(strlen(mae)- 1 - i)];
            ato_ato[i] = S[(strlen(mae)- 1 - i)];
        }
    }

    if(strcmp(mae_mae,mae_ato) != 0 || strcmp(ato_mae,ato_ato) != 0){
        printf("No");
        return 0;
    }
    else{
        printf("Yes");
        return 0;
    }
}

int C(){
    int L;
    double x;
    scanf("%d",&L);
    x = L/ 3.0;
    printf("%f",x*x*x);
    return 0;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,m;cin>>n;
    deque<ll> v;
    v.push_back(10000000000ll);
    rep(i, n){
        ll a;cin>>a;
        if(i==0){
            v.push_front(a);
            continue;
        }
        if(a<=v[0]){
            v.push_front(a);
        }else{
            auto itr = lower_bound(all(v), a);
            //if(itr!=v.end())itr--;
            *(itr-1) = a;
        }
    }
    cout << v.size()-1 << endl;
    return 0;
}


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

const int maxn = 1e5 + 10;
int n, m, ans, f[maxn]; vector <int> g[maxn];

int dfs(int u) {
	if (~f[u]) return f[u];
	for (int v : g[u]) {
		f[u] = max(f[u], dfs(v));
	}
	return ++f[u];
}

int main() {
	memset(f, -1, sizeof f);
	scanf("%d %d", &n, &m);
	for (int i = 1, u, v; i <= m; i++) {
		scanf("%d %d", &u, &v), g[u].push_back(v);
	}
	for (int i = 1; i <= n; i++) {
		ans = max(ans, dfs(i));
	}
	printf("%d", ans);
	return 0;
}

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

int main(){
    int K,o = 0;
    cin >> K ;
    int A,B;
    cin >> A >> B;

    for(int i = A; i <= B;i++ ){
        if(i % K == 0){
            o= 1;
        }
    }
    if(o == 1){
        cout << "OK" << endl;
    }if(o == 0){
        cout << "NG" << endl;
    }
}


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    while(n!=0){
        int a[31]={};
        a[1] = 1;
        a[2] = 2;
        a[3] = 4;
        for(int i=4;i<31;i++){
            a[i] = a[i-1] + a[i-2] + a[i-3];
        }
        cout << ((a[n]/10)/365)+1 << endl;
        cin >> n;
    }
}


Measured memory_bytes: 2996
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int n, a;
  cin >> n >> a;
  bool b = false;
  int i = 0;
  int p = n/500+1;
  while(!b) {
    if(i==p) break;
    int x = 500*i;
    int y = (500*i)+a;
    if(x <= n && n <= y) b = true;
    i++;
  }
  yorn(b);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint k;
string s;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> k;
	cin >> s;
	
	if(s.size() <= k) cout << s << endl;
	else cout << s.substr(0, k) + "..." << endl;
	
	return 0;
}

Measured memory_bytes: 3644