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

int main(){
  int a, b, c;
  int ans;
  int n1, n2, n3;
  cin >> a >> b >> c;
  
  if( a >= b && a >= c ){
    n1 = a;
    if( b >= c ){
      n2 = b;
      n3 = c;
    }else{
      n2 = c;
      n3 = b;
    }
  }else if( b >= c and b >= a ){
    n1 = b;
    if( a >= c ){
      n2 = a;
      n3 = c;
    }else{
      n2 = c;
      n3 = a;
    }
  }else{
    n1 = c;
    if( a >= b ){
      n2 = a;
      n3 = b;
    }else{
      n2 = b;
      n3 = a;
    }
  }
//  cout << n1 << " " << n2 << " " << n3 << endl;
  if( (n2-n3)%2==0 ){
    ans = (n1-n2)+(n2-n3)/2;
  }else{
    ans = (n1-n2+1)+(n2-n3+1)/2;
  }
   cout << ans << endl;
  return 0;
}
      


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://abc067.contest.atcoder.jp/tasks/arc078_b

"""
import sys
from sys import stdin
from heapq import heappop, heappush
input = stdin.readline


def prepare_graph(edges, N):
    adj = [[] for _ in range(N+1)]
    for a, b in edges:
        adj[a].append([b, 1])
        adj[b].append([a, 1])
    return adj


def dijkstra(adj, s):
    # ダイクストラ法で始点からの距離を計算する
    WHITE, GRAY, BLACK = 0, 1, 2
    color = [WHITE] * len(adj)
    d = [float('inf')] * len(adj)    # 始点からの距離 計算結果
    d[s] = 0                    #  始点から自身までの距離は0
    pq = []
    heappush(pq, (0, s))
    while pq:
        cost, u = heappop(pq)
        color[u] = BLACK
        if d[u] < cost:
            continue
        for v, cost in adj[u]:
            if color[v] == BLACK:
                continue
            if d[v] > d[u] + cost:
                d[v] = d[u] + cost
                heappush(pq, (d[v], v))
                color[v] = GRAY
    return d                    #  計算した距離情報を返す


def solve(edges, N):
    adj = prepare_graph(edges, N)
    f_dist = dijkstra(adj, 1)
    s_dist = dijkstra(adj, N)

    f_point = 0
    s_point = 0
    for f, s in zip(f_dist[1:], s_dist[1:]):
        if f <= s:
            f_point += 1
        else:
            s_point += 1
    if f_point > s_point:
        return 'Fennec'
    else:
        return 'Snuke'


def main(args):
    edges = []
    N = int(input())
    for _ in range(1, N):
        a, b = map(int, input().split())
        edges.append([a, b])
    ans = solve(edges, N)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N,K;
    Scd(N);

    vector<vi> e(N);

    int a,b;

    Rep(i,N-1){
        Scd2(a,b);
        a--,b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    Scd(K);

    static vector<vi> p(1e6+N);
    vi d(N,-1);

    Rep(i,K){
        Scd2(a,b);
        a--;
        p[b].push_back(a);
        d[a] = b;
    }

    bool ans = true;

    for( vi pp : p ){
        for( int from : pp ){
            int dep = d[from];
            for( int to : e[from] ){
                if( d[to] == -1 ){
                    d[to] = dep+1;
                    p[dep+1].push_back(to);
                }else if( d[to] == dep-1 || d[to] == dep+1 ){
                }else{
                    ans = false;
                }
            }
        }
    }

    YesNo(ans);

    if( ans ){
        Rep(i,N) printf ("%d\n", d[i] );
    }


    return 0;
}



Measured memory_bytes: 35328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i, sz(s)) s[i] = 'A' + ((s[i] - 'A' + n) % 26);
  cout << s << endl;
}


Measured memory_bytes: 256
from math import ceil
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
st = t[0]
sc = {"r":p,"s":r,"p":s}
ans = 0

for i in range(k):
    cnt = 0
    for j in range(i,n,k):
        if t[j] != st:
            ans += sc[st]*ceil(cnt/2)
            st = t[j]
            cnt = 1
        else:
            cnt += 1
    else:
        ans += sc[st]*ceil(cnt/2)

print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b+c>21)puts("bust");
  else puts("win");
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>

#define SIZE 100005
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

using namespace std;


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

	printf("%lld", N*N*N);
}


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

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    if(s.size() == 1) {
        cout << 0 << endl;
        return 0;
    }
    rep(i,s.size()-1){
        if(s[i] == s[i+1]) {
            cnt++;
            if(s[i+1] == '0') s[i+1] = '1';
            else s[i+1] = '0';
        }
    }
    cout << cnt << endl;
}

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

int main() {

    int N;
    cin >> N;
    int W[N];
    int sum = 0;

    rep(i, N) {
        cin >> W[i];
        sum += W[i];
    }

    int mini = sum;
    int prefix_sum = 0;

    rep(i, N) {
        prefix_sum += W[i];
        mini = min(mini, abs(prefix_sum - (sum - prefix_sum)));
    }

    cout << mini << endl;

    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long long int li;
const ll MAXN=2e5+51;
ll n,kk,c,t,res,sum;
char ch[MAXN];
ll tag[MAXN];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
} 
int main()
{
	n=read(),kk=read(),c=read();
	scanf("%s",ch+1),t=1,sum=0;
	while(t<=n)
	{
		while(ch[t]=='x'&&t<=n)
		{
			t++;
		}
		if(t>n)
		{
			break;
		}
		tag[t]++,sum++,t+=c+1;
	}
	res=sum,sum=0,t=n;
	while(t)
	{
		while(ch[t]=='x'&&t>0)
		{
			t--;
		}
		if(t<=0)
		{
			break;
		}
		tag[t]++,sum++,t-=c+1;
	}
	res=max(res,sum);
	if(res!=kk)
	{
		return 0;
	}
	for(register int i=1;i<=n;i++)
	{
		if(tag[i]==2)
		{
			printf("%d\n",i);
		}
	}
}

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

using namespace std;

int main(){
int N;cin >> N; string S,T; cin >> S >> T;

  for(int a = N; a >= 1; a--){
    bool flag= true;
    for(int j = 0; j < a; j++){
      if( S[N-a + j] != T[j]){ flag = false; }}
    
    if( flag){ cout << 2 * N - a << endl; return 0;}
  }
  
  cout << 2 * N << endl; return 0;}

Measured memory_bytes: 256
n = int(input())
r_list = []

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

r_list.sort(key= lambda x:x[1], reverse=True)
r_list.sort(key= lambda x:x[0])

for line in r_list:
    print(line[2])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b, k;
    cin >> a >> b >> k;
    int mx   = min(a, b);
    int curr = 0;
    for (int i = mx; i >= 0; --i) {
        if (a % i == 0 && b % i == 0)
            curr++;
        if (curr == k) {
            cout << i << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
 
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
 
const int N = 1e5 + 5;
const int mod = 1e9+7;
const ll INF = (ll)1e18;

int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
 
    set<pii> s;
    int n, m;
    cin >> n >> m;
    vector<int> g[n+1];
    vector<int> deg(n+1, 0);
    while(m--){
        int x, y;
        cin >> x >> y;
        g[x].pb(y);
        deg[y] ++;
    }
    for(int j = 1; j <= n; j++) s.insert({deg[j], j});
    vector<int> dp(n+1, 0);
    while(!s.empty()){
        int cur = s.begin() -> S;
        s.erase(s.begin());
        for(auto i : g[cur]){
            dp[i] = max(dp[i], 1+dp[cur]);
            s.erase({deg[i], i});
            deg[i] --;
            s.insert({deg[i], i});
        }
    }
    int ans = 0;
    for(int j = 1; j <= n; j++) ans = max(ans, dp[j]);
    cout << ans;
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

class union_find{
    vector<int> rank,par;
public:
    union_find(int n){
        REP(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
    };
    int find(int x){
        if(par[x]==x) return x;
        else return par[x]=find(par[x]);
    };
    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]) par[x]=y;
        else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    };
    bool same(int x,int y){
        return find(x)==find(y);
    };
};

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> p(N);
  REP(i,N){
    cin >> p[i]; --p[i];
  }
  vector<int> x(M), y(M);
  REP(i,M) {
    cin >> x[i] >> y[i]; --x[i]; --y[i];
  }

  union_find uf(N);
  REP(i,M) uf.unite(x[i], y[i]);

  int ret = 0;
  REP(i,N) ret += uf.same(i, p[i]);

  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 2428
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int32_t; using i64 = int64_t; using f64 = double_t; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define stepup(a, b, s, i) for (i32 i = (a); i <= (b); i+=(s))
#define stepdown(a, b, s, i) for (i32 i = (a); i >= (b); i-=(s))
#define foreach(xs, x) for (auto &x : (xs))
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define maximum(xs) (*max_element(all(xs)))
#define minimum(xs) (*min_element(all(xs)))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i32 n;
str s;
str ans;

char guess(i32 i) {
    i32 pi = i-1; if (pi < 0) pi += n-1;
    i32 ppi = i-2; if (ppi < 0) ppi += n-1;
    if (ans[pi] == 'S') {
        if (s[pi] == 'o') {
            return ans[ppi] == 'S' ? 'S' : 'W';
        } else {
            return ans[ppi] == 'S' ? 'W' : 'S';
        }
    } else {
        if (s[pi] == 'o') {
            return ans[ppi] == 'S' ? 'W' : 'S';
        } else {
            return ans[ppi] == 'S' ? 'S' : 'W';
        }
    }
}

bool check(i32 i) {
    i32 pi = i-1; if (pi < 0) pi += n;
    i32 ni = i+1; if (ni > n-1) ni -= n;
    if (ans[i] == 'S') {
        if (s[i] == 'o') {
            return ans[pi] == ans[ni];
        } else {
            return ans[pi] != ans[ni];
        }
    } else {
        if (s[i] == 'o') {
            return ans[pi] != ans[ni];
        } else {
            return ans[pi] == ans[ni];
        }
    }
}

i32 main()
{
    cin >> n >> s;

    times(4, i) {
        ans = (i&1)==0 ? "S" : "W";
        ans += (i&2)==0 ? 'S' : 'W';
        range(2, n, j) {
            ans += guess(j);
        }
        bool ok = true;
        times(n, i) {
            ok &= check(i);
        }
        if (ok) {
            cout << ans << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int , input().split()))
x = 1000
k = 0


for i in range(n-1):
    if a[i] < a[i+1]:
        t = x // a[i]
        k += t
        x -= t * a[i]
    else:
        x += k * a[i]
        k = 0
    #print(x,k)
print( x + k * a[-1])

Measured memory_bytes: 61748
A='abcdefghijklmnopqrstuvwxyz'
n=int(input())-1
p=26
d=1
while n>=p:
    n-=p
    p*=26
    d+=1
ans=[None]*d
#print(n)
for i in range(d):
    ans[d-i-1]=A[n%26]
    n//=26
print(*ans,sep='')

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

string s[2010];
int d1[2010][2010];
int d2[2010][2010];
int l[2010],r[2010];

int main(void){
	int h,w;
	cin >> h >> w;
	rep(i,h) cin >> s[i];

	int ans = max(h,w);
	rep(i,h-1)rep(j,w) d1[i][j]=(s[i][j]!=s[i+1][j]);
	rep(i,h-1)rep(j,w-1) d2[i][j] = d1[i][j]^d1[i][j+1];

	/*
	rep(i,h-1){
		rep(j,w-1) cout << d2[i][j];
		cout << endl;
	}
	*/

	vector<int> hist(w-1,1);


	rep(i,h-1){
		//scerr << i << endl;

		rep(j,w-1){
			if(d2[i][j]==0) 
				hist[j]++;
			else
				hist[j]=1;
		}

		//cerr << i << endl;
		stack<int> t;

		rep(k,w-1){
			while(!t.empty() and hist[t.top()]>= hist[k]) t.pop();
			l[k]=(!t.empty()?t.top()+1:0);
			t.push(k);
		}

		//cerr << i << endl;
		while(!t.empty()) t.pop();
		//cerr << "OK" << endl;
		
		rrep(k,w-1){
			while(!t.empty() and hist[t.top()]>= hist[k]) t.pop();
			r[k]=(!t.empty()?t.top():w-1);
			t.push(k);
		}

		rep(k,w-1){
			int cur = hist[k] * (r[k] - l[k]) + hist[k];
			chmax(ans,cur);
		}
	}

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

Measured memory_bytes: 35840
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << "i" << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ld pi = 3.14159265358979;
    ld r; cin >> r;
    cout << r*2.0*pi ;
}

Measured memory_bytes: 3732
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
#define clr0(a) memset(a,0,sizeof(a))
#define clr1(a) memset(a,-1,sizeof(a))
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
main()
{
    timesave;
    string s,s1;
    cin>>s>>s1;
    int cnt=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=s1[i])
            cnt++;
    }
    cout<<cnt<<endl;
}




Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define int ll

void solve();
ll calc(int);


const int MAXC = 100005;

ll n, x, m, pos[MAXC], in[MAXC];
vector<ll> s;

signed main(){
    ios::sync_with_stdio(0), cin.tie(0);
    while (cin >> n >> x >> m)
        solve();
    return 0;
}

void solve() {
    memset(pos, 0, sizeof(pos));

    ll sum = x;
    in[1] = x;
    pos[x] = 1;

    for (ll i = 2; i <= n; ++i) {
        x = (x * x) % m;

        if (pos[x]) {
            s.clear();
            for (ll l = pos[x]; l < i; ++l) s.push_back(in[l]);

            sum += calc(n - i + 1);
            cout << sum  << '\n';
            return;
        } else {
            in[i] = x;
            pos[x] = i;
            sum += x;
        }
    }
    cout << sum << '\n';
}

ll calc(ll len) {
    ll ans = 0, sum = 0;
    ll sz = s.size();

    for (ll i = 0; i < sz; ++i) sum += s[i];
    ans = sum * (len / sz);
    len %= sz;

    for (ll i = 0; i < len; ++i) ans += s[i];

    return ans;
}


Measured memory_bytes: 5048
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
int a[3];
void solve()
{
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout<<a[0]+a[1];
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
	return(0);
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){


int x,y,s;
while(1){
scanf("%d%d%d",&x,&y,&s);
if(x==0&&y==0&&s==0)break;
int X=100+x;int Y=100+y;int max=0;
for(int i=1;i<s;i++)
for(int j=1;j<s;j++)
{if(i*X/100+j*X/100==s&&max<i*Y/100+j*Y/100)max=i*Y/100+j*Y/100;}

printf("%d\n",max);
}
return 0;

}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
  ll N, W;
  cin >> N >> W;
  ll v[N], w[N];
  ll dp[N+1][W+1];
  for(int i=0; i<N+1; i++) for(int j=0; j<W+1; j++) dp[i][j] = 0;
  for(int i=0; i<N; i++) cin >> w[i] >> v[i];
  for(int i=0; i<N; i++){
    for(int j=0; j<=W; j++){
      if(j-w[i] >= 0){
        ll tmp = dp[i][j];
        if(dp[i][j] < dp[i][j-w[i]] + v[i]) tmp = dp[i][j-w[i]] + v[i];
        dp[i+1][j] = tmp;
      }else{
        dp[i+1][j] = dp[i][j];
      }
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 79104
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
char s[105][105];
//int dx[4]={ -1, 1,0, 0 };
//int dy[4]={ 0, 0, -1,  1 };
int ma[4][2] =
{
    { 0, -1 },
    { 0 , 1 },
    { -1 , 0},
    { 1 , 0 },
};
//int ma[4][2]= {{0,1},{0,-1},{-1,0},{0,1}};
char ch ;
int m,n;

void dfs(int x,int y,char tree)
{
    s[x][y]='1';
    for(int i=0; i<4; i++)
    {
        int xn=x+ma[i][0],yn=y+ma[i][1];
        if(xn>=0&&xn<m&&yn>=0&&yn<n)
        {
            if(s[xn][yn]==tree)
            {
                dfs(xn,yn,tree);
//              cout << xn <<" "<<yn<<endl;
            }
        }

    }

}
int main ()
{

    while(cin >> m >> n&&m&&n)
    {
        for(int i=0; i<m; i++)
        {
            for(int j=0; j<n; j++)
            {
                cin >> s[i][j];
            }
        }
        int sum=0;
        for(int i=0; i<m; i++)
        {
            for(int j=0; j<n; j++)
            {
                if(s[i][j]!='1')
                {
//                    ch=s[i][j];


                    dfs(i,j,s[i][j]);
                    sum++;
//                    cout  << i <<" "<< j<<endl;
                }
            }
        }
//        for(int i=0; i<m; i++)
//        {
//            for(int j=0; j<n; j++)
//            {
//                cout <<s[i][j]<<" ";
//            }
//            cout << endl;
//        }
        cout << sum <<endl;
    }
    return 0;
}

Measured memory_bytes: 3468
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;


void calc() {

	Int N, K; std::cin >> N >> K;
	Int num = N % K;
	num = std::min(num, std::abs(num - K));
	std::cout << num;

}


int main() {

	calc();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

int n, m;
int v[MAX];

void solve() {
	cin >> n >> m;
	int sum = 0;
	for(int i=0; i<n; i++) {
		cin >> v[i];
		sum += v[i];
	}
	int ok = 0;
	for(int i=0; i<n; i++) {
		if(v[i] * 4 * m >= sum) ok++;
	}
	if(ok >= m) cout << "Yes\n";
	else cout << "No\n";
}

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

 	solve();

  	return 0;
}



Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
namespace Atcoder_0404
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetInput_int()[0];
            var A_n = GetInput_long();
            Array.Sort(A_n);
            var maxNum = A_n[A_n.Length - 1];
            bool[] dp =new bool[maxNum + 1];
            for (int i = 0; i < dp.Length; i++)
            {
                dp[i] = false;
            }
            for (int i = 0; i < A_n.Length; i++)
            {
                dp[A_n[i]] = true;
            }

            for (int i = 0; i < A_n.Length; i++)
            {
                var target=A_n[i];
                if (dp[target] == false) continue;
                for(long j = target*2; j < dp.Length; j+=target)
                {
                    dp[j] = false;
                }
            }
            //重複しているものを削除
            for(int i = 0; i < A_n.Length-1; i++)
            {
                if (A_n[i] == A_n[i + 1]) dp[A_n[i]] = false;
            }


            var result = dp.Where(x => x == true).Count();
            Console.WriteLine(result);
        }

        #region input


        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        /// <summary>
        /// 最大公約数
        /// </summary>
        public static int GCD(int a, int b)
        {

            /* 自然数 a > b を確認・入替 */
            if (a < b)
            {
                int tmp = a;
                a = b;
                b = tmp;
            }

            /* ユークリッドの互除法 */
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        public static int LCM(int a, int b)
        {
            int x = a * b;
            b = GCD(a, b);
            return x / b;

        }
        #endregion
        
    }
}

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

    typedef long long int ll;

    #define MOD (ll)(1e9+7)
    #define endl "\n"
    #define pb push_back
    #define TEST_CASES  ll t;cin >> t;while(t--)
    #define forn(i,a,n) for (int i = a; i < n; ++i)
    #define f first
    #define s second
    #define all(x) x.begin(), x.end()
    
    ll powD(ll x,ll y){
      ll res = 1;
      while(y > 0){
        if(y & 1)
          res = (res*x)%MOD;
        x = (x*x)%MOD;
        y = y>>1;
      }
      return res;
    }

  
    int main()
    {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL); 
      int a,b,k;
      cin>>k>>a>>b;
      forn(i,a,b+1){
        if(i%k == 0){
          cout<<"OK"<<endl;
          return 0;
        }
      }
      cout<<"NG"<<endl;


    }
    //read the question correctly (ll vs int)


Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <bitset>
using namespace std;

const int N = 4010;
const int mod = 998244353;

inline int deg(const bitset <N> &b) {
  int t = N - 1;
  while (t >= 0 && !b[t]) t --;
  return t + 1;
}

int n;
char buf[N];

inline void read(bitset <N> &b) {
  scanf("%s", buf);
  reverse(buf, buf + strlen(buf));
  for (int i = 0; buf[i]; i ++)
    b[i] = (bool)(buf[i] - '0');
}

bitset <N> X, A[10], oppo, Y;

inline bitset <N> gcd(bitset <N> p, bitset <N> q) {
  int a = deg(p);
  int b = deg(q);
  while (true) {
    if (!a) return q;
    if (!b) return p;
    if (a < b) {
      swap(p, q); swap(a, b);
    }
    p ^= q << (a - b);
    while (a >= 0 && p[a] == 0) a --;
    a ++;
  }
}

int main() {
  scanf("%d", &n);
  read(X);
  for (int i = 1; i <= n; i ++) read(A[i]);
  for (int i = 2; i <= n; i ++)
    A[1] = gcd(A[1], A[i]);
  int ans = 0, j = deg(A[1]);
  for (int i = deg(X) - 1; i >= j - 1; i --) 
    ans = ((ans << 1) + X[i]) % mod;
  Y = X;
  for (int i = deg(X) - 1; i >= j - 1; i --)
    if (X[i]) {
      X ^= A[1] << (i - j + 1);
      oppo ^= A[1] << (i - j + 1);
    }
  for (int i = deg(Y) - 1; ~ i; i --)
    if (oppo[i] != Y[i]) {
      if (oppo[i] > Y[i]) ans --;
      break;
    }
  ans = (ans + 1) % mod;
  printf("%d\n", ans);
  return 0;
}

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

#define rep(i, N) for(int i = 0;i < N;i++)
typedef long long ll;

using namespace std;

int main(void) {
	unsigned long long X, Y; cin >> X >> Y;
	int ans = 0;

	while (X <= Y) {
		X *= 2;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int last = -1;
        int n = scanner.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = scanner.nextInt();
        }
        long ans = 0;
        for (int i = 0; i < n; i++) {
            int cur = nums[i];
            if (cur < last) {
                ans += (last - cur);
            } else {
                last = cur;
            }
        }
        System.out.println(ans);
    }
}


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

namespace Water_Rate
{
    class Program
    {
        static void Main(string[] args)
        {   
            int[] nums = new int[5];

            for (int i = 0; i < 5; i++)
            {
                nums[i] = int.Parse(Console.ReadLine());
            }

            int a = nums[0] * nums[4];
            int b = 0;
            if (nums[4] > nums[2])
            {
                b = nums[1] + (nums[4] - nums[2]) * nums[3];
            }
            else
            {
                b = nums[1];
            }
            
            if (a >= b)
            {
                Console.WriteLine(b);
            }
            else
            {
                Console.WriteLine(a);
            }
        }
    }
}



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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;


int main(){
    int n;
    cin >> n;
    double k = (double)n / 1.08;
    REPN(i, (int)k-10, (int)k+10) {
        if((int)((double)i * 1.08) == n) {
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;

    return 0;
}


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

int main(){
    // input
    int N, Q;
    long long K;
    cin >> N >> K >> Q;
    // base score
    vector<long long> score(N);
    for( int n=0; n<N; n++ ){
        score[n] = K - Q;
    }
    // get correct participant
    int tmp;
    for( int i=0; i<Q; i++ ){
        cin >> tmp;
        score[ tmp-1 ] += 1;
    }
    // output
    bool GoNextStage;
    for( int n=0; n<N; n++ ){
        GoNextStage = ( score[n] > 0 );
        printf( GoNextStage ? "Yes\n" : "No\n" );
    }
} 

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return abs(x-y)/gcd(x,y); }


int main() {
  int n; cin >> n;
  if(n%10==3) { cout << "bon\n"; }
  else if(n%10==0 || n%10==1 || n%10==6 || n%10==8) { cout << "pon\n"; }
  else { cout << "hon\n"; }

  return 0;
}

Measured memory_bytes: 3632
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
ans = [0] * N
x = 1
for j in range(N):
    if x == 1:
        ans[0] += A[j%N]
    else:
        ans[0] -= A[j%N]
    x ^= 1

for i in range(N-1):
    ans[i+1] = (A[i] - ans[i] // 2) * 2

print(" ".join(map(str, ans)))


Measured memory_bytes: 19176
using System;


namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] In = Console.ReadLine().Split(' ');
            int n = int.Parse(In[0]);
            int k = int.Parse(In[1]);
            Fac[0] = 1;
            iFac[0] = 1;
            for (long i = 0; i < 670000; i++)
            {
                Fac[i + 1] = Fac[i] * (i + 1) % M;
                iFac[i + 1] = iFac[i] * MPow(i + 1, M - 2) % M;
            }
            for (int i = 1; i <= k; i++)
            {
                long temp = Comb(k - 1, i - 1) * Comb(n - k + 1, i);
                temp %= M;
                Console.WriteLine(temp);
            }
        }
        static public readonly int M = 1000000007;
        static public long[] Fac = new long[670001];//n!(mod M)
        static public long[] iFac = new long[670001];//k!^(M-2)(mod M)
        static long MPow(long x, long n)//x^n(mod M) 普通のpowと同じだけどあふれ対策
        {
            long ans = 1;
            while (n != 0)
            {
                if ((n & 1) == 1) ans = ans * x % M;
                x = x * x % M;
                n = n >> 1;
            }
            return ans;
        }
        static long Comb(long a, long b)//aCbをmodで計算
        {
            if (a == 0 && b == 0) return 1;
            if (a < b || a < 0) return 0;
            long temp = iFac[a - b] * iFac[b] % M;
            return temp * Fac[a] % M;
        }
    }
}
//Wa
//namespace D
//{
//    class Program
//    {
//        static public int Mod = 1000000007;
//        static void Main(string[] args)
//        {
//            string[] In = Console.ReadLine().Split(' ');
//            int n = int.Parse(In[0]);
//            int k = int.Parse(In[1]);
//            for(int i = 1; i <= k; i++)
//            {
//                long temp = Co(k - 1, i - 1) * Co(n - k + 1, i);
//                temp %= Mod;
//                Console.WriteLine(temp);
//            }
//        }
//        static public long Co(long x, long y)
//        {
//            long temp = 1;
//            for(int i = 0; i < y; i++)
//            {
//                temp *= (x - i);
//            }
//            long ret = Fa(y);
//            if (ret == 0) return x;
//            else return temp / Fa(y);
//        }
//        static public long Fa(long x ,long sum=1)
//        {
//            if (x == 0) return sum;
//            long temp = x;
//            return Fa(x - 1, sum *= temp);
//        }
//    }
//}


Measured memory_bytes: 37868
x=[int(x) for x in input().split()]
if x[0] >x[1]:
    a, b = x[0], x[1]
else:
    a, b = x[1], x[0]
while(True):
    c=a%b
    if c==0:
        print(b)
        break
    a=b
    b=c


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

bool isValid(int n){
    if(n==0) return true;

    bool ret = true;
    if(n%2==0) ret = isValid(n/2);
    else{
        if((n/2)%2==1) ret = false;
        else ret = isValid(n/2);
    }
    return ret;
}

int main(){
    ll mod = 1000000007;
    int H, W, K;  cin >> H >> W >> K;
    vector<vector<ll>> dp;
    dp = vector<vector<ll>>(H+1, vector<ll>(W+1, 0));
    dp[0][1] = 1;
    for(int h=0; h<H; h++){
        for(int w=1; w<=W; w++){
            ll c1 = 0, c2 = 0, c3 = 0;
            int N = (1 << (W - 1));
            for(int i=0; i<N; i++){
                if(!isValid(i)) continue;
                int n = i;
                int j = 0;
                vector<bool> bridge(W+1, false);
                while(n > 0){
                    if(n%2==1) bridge[W-1-j] = true;
                    n/=2;  j++;
                }
                if(!bridge[w] && !bridge[w-1]) c1++;
                if(bridge[w-1]) c2++;
                if(bridge[w]) c3++;
            }
            dp[h+1][w] = c1*dp[h][w]%mod;
            if(w-1>=1) dp[h+1][w] = (dp[h+1][w] + (c2*dp[h][w-1])%mod)%mod;
            if(w+1<=W) dp[h+1][w] = (dp[h+1][w] + (c3*dp[h][w+1])%mod)%mod;
        }
    }

    cout << dp[H][K] << endl;
}


Measured memory_bytes: 256
import java.util.*;

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

    public void run() {
        int Q = in.nextInt();

        boolean[] isPrime = new boolean[100100];
        Arrays.fill(isPrime, true);
        isPrime[0] = isPrime[1] = false;
        for (int i = 2; i < isPrime.length; i++) {
            if (!isPrime[i]) continue;
            for (int j = i + i; j < isPrime.length; j += i) {
                isPrime[j] = false;
            }
        }

        int[] imos = new int[100100];
        for (int i = 2; i < imos.length; i++) {
            imos[i] = (isPrime[i] && isPrime[(i+1)/2]) ? 1 : 0;
        }
        for (int i = 2; i < imos.length - 1; i++) {
            imos[i+1] += imos[i];
        }

        for (int q = 0; q < Q; q++) {
            int l = in.nextInt(), r = in.nextInt();
            System.out.println(imos[r] - imos[l-1]);
        }
    }


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


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

#define vec_range(n1, n2) vec.begin() + n1, vec.begin() + n2

int main() {
	vector<int> vec; int an, tn, fn1, fn2, fn3;
	cin >> an; vec.resize(an);
	for (int i = 0; i < an; i++) cin >> vec[i];
	cin >> tn;
	for (int i = 0; i < tn; i++) {
		cin >> fn1 >> fn2 >> fn3;
		cout << count(vec_range(fn1, fn2), fn3) << endl;
	}
	return 0;
}


Measured memory_bytes: 3116
AGCT = "AGCT"

S = input()

longest = ""
tmpCounter = 0
for i in range(len(S)):
	# print(i, tmpCounter, longest)
	if S[i] in AGCT:
		if tmpCounter >= len(longest):
			longest = S[i - tmpCounter: i  + 1]
		tmpCounter += 1
	else:
		if tmpCounter > len(longest):
			longest = S[i - tmpCounter: i]
		tmpCounter = 0


print(len(longest))

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

var N string

func main() {
	fmt.Scanf("%s", &N)

	cs := []rune(N)

	for i := 0; i < len(cs); i++ {
		c0 := int(cs[i] - '0')
		if i < len(cs)-1 {
			c1 := int(cs[i+1] - '0')
			if (c0-1) + 9 > c0+c1 {
				cs[i] = rune((c0-1) + '0')
				for j := i+1; j < len(cs); j++ {
					cs[j] = '9'
				}
				break
			}
		}
	}

		ans := 0
	for i := 0; i < len(cs); i++ {
		ans += int(cs[i] - '0')
	}

	fmt.Println(ans)
}



Measured memory_bytes: 512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=1;i<=(n);++i)
#define ALL(v) v.begin(), v.end()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

class CBuildStairs {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    in>>N;
	    vector<int> H(N);
	    REP(i, N) in>>H[i];
	    REP(i, N-1){
	        if(H[i]>H[i+1]) {out<<"No"<<endl; return;}
	        else if(H[i]<H[i+1]) H[i+1]--;
	    }
	    out<<"Yes"<<endl;
        return;
	}
};


int main() {
	CBuildStairs solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n; cin >> n; int odd = 0, even = 0;
	rep(i, 0, n) {
		int a; cin >> a;
		odd += a % 2;
	}
	even = n - odd;
	if (odd % 2) {
		cout << "NO" << endl;
	}
	else cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
t = input()

len_s = len(s)
len_t = len(t)

# 一致する位置を探して返す
def search(s, t):
    head = len(s)-len(t)
    tail = len(s)
    for i in range(head+1):
        s_ = s[head:tail]
        # 一致するか確認
        for j in range(len(t)):
            if t[j] != s_[j]:
                if s_[j] != '?':
                    break
        # 正常終了した
        else:
            return head, tail
        head -= 1
        tail -= 1
        continue
    return None, None

# tの文字列分後ろからみて一致したら入れる
if len_s < len_t:
    print('UNRESTORABLE')
else:
    head, tail = search(s, t)
    if head is None:
        print('UNRESTORABLE')
    else:
        s = list(s)
        s[head:tail] = t
        s = "".join(s)
        s = s.replace('?', 'a')
        print(s)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;

namespace aoj {
	struct Save {
		public int now;
		public int stage;
		public int line;
		public Save(int n, int s, int l) {
			now = n; stage = s; line = l;
		}
	}
	class _0069 {
		public static void Main() {
			string str;
			while ((str = Console.ReadLine()) != "0") {
				var ln = int.Parse(str);
				var cn = int.Parse(Console.ReadLine());
				var hn = int.Parse(Console.ReadLine());
				var sn = int.Parse(Console.ReadLine());
				var hls = new string[sn];
				for (int i = 0; i < hls.Length; i++)
					hls[i] = "0" + Console.ReadLine() + "0";

				var nl = cn;
				var cand = new Queue<Save>();
				for (int i = 0; i < hls.Length; i++) {
					if (hls[i][nl - 1] == '1' || hls[i][nl] == '1') {
						nl += (hls[i][nl - 1] == '1') ? -1 : 1;
						continue;
					} else {
						if (1 < nl && hls[i][nl - 2] == '0') cand.Enqueue(new Save(nl, i, nl - 1));
						if (nl < ln && hls[i][nl + 1] == '0') cand.Enqueue(new Save(nl, i, nl));
					}
				}
				if (nl == hn) {
					Console.WriteLine("0");
					continue;
				}

				var found = false;
				while (cand.Count > 0) {
					var c = cand.Dequeue();
					nl = c.now + ((c.line == c.now) ? 1 : -1);
					for (int i = c.stage + 1; i < hls.Length; i++)
						nl += (hls[i][nl - 1] == '1') ? -1 : (hls[i][nl] == '1') ? 1 : 0;
					if (nl == hn) {
						found = true;
						Console.WriteLine((c.stage + 1) + " " + c.line);
						break;
					}
				}

				if (!found)
					Console.WriteLine("1");
			}
		}
	}
}

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

using namespace std;
string s;
ll k,dp[110][4][2];


ll Rec(int i , int k , bool isSmaller){

    if(k < 0)   return 0;
    if(i == s.size())  return (k == 0);

    if(dp[i][k][isSmaller] != -1)  return dp[i][k][isSmaller];

    ll Res = 0;

    for(char j = '0';j<='9';j++){
        if(j <= s[i] || isSmaller) Res+=Rec(i + 1 , j == '0' ? k : k - 1 , j < s[i] ? true : isSmaller);
    }

    return dp[i][k][isSmaller] = Res;
}

int main()
{
    memset(dp , -1 , sizeof(dp));
    cin >> s >> k;
    cout << Rec(0 , k , 0);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    int n,T,minc = 2000;
    cin >> n >> T;
    int c[n],t[n];
    REP(i,n) {
        cin >> c[i] >> t[i];
    }
    REP (i,n) {
        if (t[i] <= T && c[i]<minc) {
            minc = c[i];
        }
    }
    if (minc == 2000) {
        cout << "TLE";
    }else {
        cout << minc;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int coin = 0;
        int day = 1;
        while(true)
        {
            coin += a;
            if(day % 7 == 0)
                coin += b;
            if(coin >= c)
                break;
            day++;
        }
        System.out.println(day);
    }
}


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

n = int(input())
s = [int(input()) for _ in range(n)]

s.sort()
sm = sum(s)

if sm % 10:
    ans = sm
else:
    ans = 0
    for ele in s:
        if ele % 10:
            ans = sm - ele
            break

print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	uint64_t K;
	uint64_t suuretu[50];
	uint64_t amamiyasora;
	uint64_t horieyui;
	uint32_t morikubosyoutarou;
	const uint32_t N = 50;
	uint32_t i, j;
	if (scanf("%" SCNu64, &K) != 1) return 1;
	amamiyasora = (K + N - 1) / N;
	horieyui = amamiyasora * N;
	for (i = 0; i < N; i++) {
		suuretu[i] = N - 1 + amamiyasora;
	}
	morikubosyoutarou = (uint32_t)(horieyui - K);
	for (i = 0; i < morikubosyoutarou; i++) {
		for (j = 0; j < N; j++) {
			if (i == j) suuretu[j] -= N; else suuretu[j]++;
		}
	}
	printf("%" PRIu32 "\n", N);
	printf("%" PRIu64, suuretu[0]);
	for (i = 1; i < N; i++) {
		printf(" %" PRIu64, suuretu[i]);
	}
	putchar('\n');
	return 0;
}

/*
操作1回で数列の合計が1減る
全要素がNの数列を考える
各要素が1回ずつ選ばれ、N減ってN-1増えるので1減る
全要素をN+1にしても同様にN回の操作で1ずつ減る

N=50に固定する
Kが50で割り切れないときは、途中まで操作を進める
*/


Measured memory_bytes: 128