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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

class UnionFind {
 public:
     int n;
     std::vector<int> par;
     std::vector<int> num;

     explicit UnionFind(int n) {  // [0 n)のunion find
         this->n = n;
         this->par.resize(n);
         this->num.resize(n, 1);
         for (int i = 0; i < n; i++) {
             this->par[i] = i;
         }
     }

     int root(int i) {
         if (par[i] == i)
             return i;
         else
             return par[i] = root(par[i]);
     }

     bool same(int i, int j) {
         return root(i) == root(j);
     }

     void unite(int i, int j) {
         int t = root(i);
         int k = root(j);

         if (t == k) return;

         par[t] = k;
         num[k] += num[t];
     }

     int size(int i) {
         return num[root(i)];
     }
};

signed main() {
    ll N, M;
    cin>>N>>M;
    UnionFind uf(N);
    rep(i,0,M){
        ll x,y,z;
        cin>>x>>y>>z;
        x--;
        y--;
        uf.unite(x, y);
    }
    auto s = set<ll>();
    rep(i,0,N){
        s.insert(uf.root(i));
    }
    cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 5760
N,A,B,C,D = map(int,input().split())
S = input()
ans = "Yes"
iwa = 0
for i in S[A-1:C]:
    if i == "#":
        iwa += 1
        if iwa > 1:
            ans = "No"
    else:
        iwa = 0
iwa = 0
for i in S[B-1:D]:
    if i == "#":
        iwa += 1
        if iwa > 1:
            ans = "No"
    else:
        iwa = 0
flag = 0
hoge = 0
if D < C:
    for i in S[B-2:D+1]:
        if i ==".":
            hoge += 1
            flag = max(flag,hoge)
        else:
            hoge = 0
    if flag < 3:
        ans = "No"
print(ans)

Measured memory_bytes: 3572
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(n):
    if i+1==p[i]:
        if i+1==n:
            p[i],p[i-1]=p[i-1],p[i]
        else:
            p[i],p[i+1]=p[i+1],p[i]
        ans+=1
print(ans)

Measured memory_bytes: 20512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define read cin >>
#define echo cout <<
#define fin << '\n'
#define _ << ' ' <<
#define in :
#define var auto&&
#define let const auto

signed main ( ) {

    int n;
    read n;
    vector<int> v(n);
    for ( var i in v ) read i;
    int mi = v[0];
    int cnt = 1;
    for ( int i = 1; i < n; i++ ) {
        if ( v[i] <= mi ) cnt++;
        mi = min ( mi, v[i] );
    }

    echo cnt fin;

    return 0;
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

int sz[100001];

int dfs(int v, int p, vector<vector<int>> &G) {
    if (sz[v]) return sz[v];
    int ret = 1;
    for(int i = 0; i < G[v].size(); i++) {
        if (G[v][i] == p) continue;
        ret += dfs(G[v][i], v, G);
    }
    return sz[v] = ret;
}

int hasNmata(int v, int p, vector<vector<int>> &G) {
    if (sz[v] == 1) return 0;
    int ret = 0;
    int cnt = 0;
    for(int i = 0; i < G[v].size(); i++) {
        if (G[v][i] == p) continue;
        if (sz[G[v][i]] % 2 == 1) cnt++;
    }
    ret |= cnt >= 2;

    for(int i = 0; i < G[v].size(); i++) {
        if (G[v][i] == p) continue;
        ret |= hasNmata(G[v][i], v, G);
    }
    return ret;
}

void solve() {
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    dfs(0, -1, G);
    int flag = hasNmata(0, -1, G);
    if (flag || N % 2 == 1) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 6272
#include<iostream>

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

	long long int *p = new long long int[n + 2];
	long long int *size = new long long int[n + 2];

	p[0] = 1;
	size[0] = 1;
	for (int i = 0; i < n + 1; i++) {
		p[i + 1] = 2 * p[i] + 1;
		size[i + 1] = 2 * size[i] + 3;
	}

	long long int ans = 0;
	for (int i = n; i >= 0; i--) {
		if (x == 0)break;
		if (x == size[i]) {
			ans += p[i];
			break;
		}
		if (x == 1)break;

		if (x >= size[i - 1] + 2) {
			ans += p[i - 1] + 1;
			x -= size[i - 1] + 2;
		}
		else {
			x--;
		}
	}

	printf("%lld", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}

const int MAXN = 2e5 + 100;
int n;
LL arr[MAXN], T;

int main() {
  ios_base::sync_with_stdio(false);
	cin >> n >> T;
	for(int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	assert(arr[1] == 0);
	LL res = 0;
	for(int i = 1; i <= n; i++) {
		if(i == n) {
			res += T;
		} else {
			if(arr[i+1] - arr[i] > T) {
				res += T;
			} else {
				res += arr[i+1] - arr[i];
			}
		}
	}
	cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

vector<vi> e;
int v[1000010];
int rec(int c){
	if(v[c] == -1){
		cout << -1 << endl;
		exit(0);
	}
	else if(v[c]) return v[c];
	
	v[c] = -1;
	int res = 0;
	for(int i : e[c]) res = max(res, rec(i));
	return v[c] = res + 1;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	e.resize(n * n);
	auto node = [n](int a, int b){
		return min(a, b) * n + max(a, b);
	};
	
	rep(i, n){
		vi v(n - 1);
		rep(j, n - 1) cin >> v[j], v[j]--;
		rep(j, n - 2){
			//(i, v[j]) => (i, v[j + 1])
			e[node(i, v[j + 1])].pb(node(i, v[j]));
		}
	}
	int ans = 0;
	rep(i, n) rep(j, i) ans = max(ans, rec(node(j, i)));
	if(ans == inf) ans = -1;
	cout << ans << endl;
	
	return 0;
}

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

#define INF (1<<29)
#define D(x) cout << #x " is " << (x) << endl
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()

using namespace std;

int dp[16][(1<<16)];

int main(void){

  int n;
  string s,t;

  while(cin >> n,n){
    cin >> s >> t;

    fill(dp[0],dp[n],INF);
    int tmp=0;
    for(int i=0;i<n;i++){
      if(s[i]==t[i])tmp|=(1<<i);
    }
    for(int i=0;i<n;i++)dp[i][tmp]=0;
    
    int ans=INF;
    for(int r=0;r<4;r++){
      for(int i=0;i<n;i++){
	if(!(tmp>>i&1)){
	  for(int k=0;k<n;k++){
	    for(int j=0;j<n;j++){
	      if(s[j]!=s[k]){
		for(int S=0;S<(1<<n);S++){
		  if(!(S>>j&1) && !(S>>k&1)){
		    int next=S;
		    next|=(1<<j)|(1<<k);
		    if(dp[k][next]>dp[i][S]+abs(j-i)+abs(k-j))
		      dp[k][next]=dp[i][S]+abs(j-i)+abs(k-j);
		  }
		}
	      }
	    }
	  }
	}
	ans=min(ans,dp[i][(1<<n)-1]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main() {

	string S, T;
	cin >> S >> T;

	sort(S.begin(), S.end());
	sort(T.begin(), T.end());

	vector<int> s(256, 0);
	vector<int> t(256, 0);

	for (int i = 0; i < (int)S.size(); i++)
	{
		int index_s = S[i] - '0';
		int index_t = T[i] - '0';

		s[index_s]++;
		t[index_t]++;
	}
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());

	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] != t[i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;


	return 0;
}

Measured memory_bytes: 776
import itertools

N, M, X = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(N)]


kakaku = 9999999
combinations = []
for n in range(1, N+1):
    combinations += list(itertools.combinations(range(N), n))

for pair in combinations:
    hantei = True
    for m in range(M):
        total = 0
        for i in pair:
            total += CA[i][m+1]
        if X <= total:
            continue
        else:
            hantei = False
            break
    if hantei:
        kingaku = 0
        for i in pair:
            kingaku += CA[i][0]
        kakaku = min(kakaku, kingaku)
    else:
        continue

if kakaku == 9999999:
    print(-1)
else:
    print(kakaku)

Measured memory_bytes: 68592
//2718 佐々木 稜平 問4
import java.util.Scanner;
public class Main{
    
    public void solve(){
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int hozon=1;
        int ichi=0;
        while(n!=0){
            for(int cnt=0;cnt<n;cnt++){
           int k=sc.nextInt();
                if(k>=2){
                   hozon++;
                }else if(k==1){
                   ichi++;
          }
      }
        if(hozon>=2){
            System.out.println(hozon+ichi);        
              }else{
                 System.out.println("NA");
                    }
                hozon=1;
                ichi=0;
                n=sc.nextInt();
                }
            }
    public static void main(String[] args){
       Main obj = new Main();
       obj.solve();
    }
}

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010, M = 2 * N;

int n, m, k;
int d[N];
int p[N], size[N];
int res[N];

int find(int x)
{
	if (x != p[x]) p[x] = find(p[x]);
	return p[x];
}

int main()
{
	for (int i = 0; i < N; i ++ ) p[i] = i, size[i] = 1;
	
	scanf("%d%d%d", &n, &m, &k);
	
	for (int i = 0; i < m; i ++ )
	{
		int a, b;
		scanf("%d%d", &a, &b);
		d[a] ++ , d[b] ++ ;
		
		int aa = find(a), bb = find(b);
		if (aa == bb) continue;
		size[aa] += size[bb];
		p[bb] = aa;
	}
	
	for (int i = 1; i <= n; i ++ )
	{
		res[i] = size[find(i)];
		res[i] -= d[i];
		res[i] -- ;
	}
	
	for (int i = 0; i < k; i ++ )
	{
		int a, b;
		scanf("%d%d", &a, &b);
		
		int aa = find(a), bb = find(b);
		if (aa != bb) continue;
		res[a] -- , res[b] -- ;
	}
	
	for (int i = 1; i <= n; i ++ ) printf("%d ", res[i]);
	return 0;
}

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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
	int a, b;
	cin >> a >> b;
	a -= 1;
	b -= 1;
	cout << (b + a - 1) / a;
	return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop


def solve(string):
    n, m, *a = map(int, string.split())
    while m > 0:
        a.sort(reverse=True)
        if a[0] == 0:
            break
        b = a[0] // 2
        for i, _a in enumerate(a):
            if m == 0 or _a <= b:
                break
            a[i] //= 2
            m -= 1
    return str(sum(a))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 15172
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;
//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


void solve(){
	string s,t;
	cin >> s >> t;
	int r,b;
	cin >> r >> b;
	string u;
	cin >> u;
	if(u==s){
		r--;
	}
	else if(u==t)
		b--;
	cout << r << " " << b << endl;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 3636
/**
 *	author:   fractal
 *	timus:    288481RF
 *	created: 08/17/20 17:08:41
**/

#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define szc(x) (int)strlen(x)
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound 
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 1e6 + 2;
const int M = 1e6;
const int mod = 998244353;
const int inf = 1e9 + 3;
const ld INF = 1e16;

struct line {
	ll k, b;
} t[5 * N];

struct li_chao {
	
	ll value(line a, ll x) {
		return a.k * x + a.b;
	}
	
	void init(int v = 1, int tl = 1, int tr = M) {
		t[v].k = 0.0;
		t[v].b = INF;
		if (tl == tr)
			return;
		int tm = tl + tr >> 1;
		init(v * 2, tl, tm);
		init(v * 2 + 1, tm + 1, tr);
	}
	
	void add_line(line val, int v = 1, int tl = 1, int tr = M) {
		int tm = tl + tr >> 1;
		bool l = value(val, tl) < value(t[v], tl);
		bool m = value(val, tm) < value(t[v], tm);
		if (m)
			swap(t[v], val);
		if (tl == tr)
			return;
		if (l != m)
			add_line(val, v * 2, tl, tm);
		else
			add_line(val, v * 2 + 1, tm + 1, tr);
	}
	
	ll get(ll pos, int v = 1, int tl = 1, int tr = M) {
		if (tl == tr)
			return value(t[v], pos);
		int tm = tl + tr >> 1;
		if (pos <= tm + 0.0)
			return min(value(t[v], pos), get(pos, v * 2, tl, tm));
		else
			return min(value(t[v], pos), get(pos, v * 2 + 1, tm + 1, tr));
	}
} tree;

int n;
ll h[N];	
ll c;

int main() {	
	scanf("%d %lld", &n, &c);
	tree.init();
	ll ans;
	for (int i = 1; i <= n; ++i)
		scanf("%lld", &h[i]);
	tree.add_line({-2LL * h[1], h[1] * h[1]});
	for (int i = 1; i <= n; ++i) {
		ans = h[i] * h[i] + c + tree.get(h[i] + 0.0);
		line val = {-2LL * h[i], ans + h[i] * h[i]};
		tree.add_line(val);
	}
	printf("%lld", ans);
	
}


Measured memory_bytes: 38064
#include <iostream>
#include <math.h>
#include <string> 
using namespace std;
#define MAX 200000

int main(){
    char a[2501],b='#';
    int h,w,i,sum,up,down,r,l;
    cin>>h>>w;
    for(i=0;i<h*w;i++)cin>>a[i];
    for(i=0;i<h*w;i++){
        up=down=r=l=1;
        sum=0;
        if(a[i]=='#')cout<<'#';
        else if(a[i]!=b){
            if((i+1)%w==0)r=0;
            if((i%w)==0)l=0;
            if((i-w+1)<0)up=0;
            if((i+w+1)>h*w)down=0;
            
            if(up){
                if(r && a[i-w+1]==b)sum++;
                if(l && a[i-w-1]==b)sum++;
                if(a[i-w]==b)sum++;
            }
            if(down){
                if(r && a[i+w+1]==b)sum++;
                if(l && a[i+w-1]==b)sum++;
                if(a[i+w]==b)sum++;
            }
            if(r && a[i+1]==b)sum++;
            if(l && a[i-1]==b)sum++;           

            cout<<sum;
        }
        
        if((i+1)%w==0)cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
s = len(S)
t = len(T)
L = [""]*(s-t+2)
match = [0]*(s-t+1)


for p in range(s-t+1):
    for q in range(t):
        L[p] += S[p+q]

for r in range(s-t+1):
    for s in range(t):
        if L[r][s] == T[s]:
            match[r] += 1

print(t-max(match))




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

using namespace std;

int abs(int num){
	return ((num < 0) ? -num : num);
}

int main(){
	int n, k;
	cin >> n >> k;
	int h[n];
	int dp[n];
	for (int i = 0; i < n; i++){
		cin >> h[i];
	}

	dp[0] = 0;

	for (int i = 1; i < n; i++){
		int min = dp[i-1] + abs(h[i] - h[i-1]);
		for (int j = i - 2; j >= 0 && j >= i - k; j--){
			int t = dp[j] + abs(h[i] - h[j]);
			if (t < min){
				min = t;
			}
		}
		dp[i] = min;
	}
	cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 1024
from collections import deque
def MI(): return map(int, input().split())
N,Q=MI()
graph=[[] for i in range(N)]
Point=[0]*N
for i in range(N-1):
  a,b=MI()
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)
for i in range(Q):
  p,x=MI()
  Point[p-1]+=x
que=deque([])
que.append(0)
check=[0]*N
while que:
  v=que.pop()
  check[v]=1
  for u in graph[v]:
    if check[u]!=1:
      #continue
      Point[u]+=Point[v]
      que.append(u)
print(*Point)

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


using namespace std;

const int MAXN = (int) 50;

int dl[] = {-1, -1, -1, 0, 0, 1, 1, 1}, dc[] = {-1, 0, 1, -1, 1, -1, 0, 1};

string str[MAXN + 1];

int ans[MAXN + 1][MAXN + 1];

int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int i, j, n, m;
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for(i = 1; i <= n; i++) {
        cin >> str[i];
        str[i] = " " + str[i];
    }
    for(i = 1; i <= n; i++) {
        for(j = 1; j <= m; j++) {
            for(int p = 0; p < 8; p++) {
            int l = i + dl[p];
            int c = j + dc[p];
            if(l > 0 && l <= n && c > 0 && c <= m && str[l][c] == '#')
               ans[i][j]++;
            }
        }
    }
    for(i = 1; i <= n; i++) {
        for(j = 1; j <= m; j++) {
            if(str[i][j] == '#')
                cout << str[i][j];
            else
                cout << ans[i][j];
        }
        cout << endl;
    }
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null) {
			BigDecimal a, b, dec;
			String decstr;
			int n, sum = 0;

			n = Integer.parseInt(line.split(" ")[2]);
			a = new BigDecimal(line.split(" ")[0]).setScale(n + 1);
			b = new BigDecimal(line.split(" ")[1]).setScale(n + 1);

			dec = a.divide(b, n + 1, RoundingMode.HALF_UP);
			decstr = dec.toString().split("\\.")[1];

			for (int i = 0; i < n; i++) {
				sum += (decstr.charAt(i) - 48);
			}
			System.out.println(sum);
		}
	}
}

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

int main()
{
    int n;
    cin >> n;
    vector<char> s(n);
    int ans = 0;
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    for(int j=0;j<n;j++){
        if(s[j] == 'Y'){
            ans++;
            break;
        }
    }
    if(ans == 0){
        cout << "Three" << endl;
    }
    else{
        cout << "Four" << endl;
    }
    return 0;
}

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

const long long int MOD = 1e9 + 7;

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

	int n;
	long long int t;
	int count[64][2];

	memset(count,0,sizeof(count));

	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		for(int j=0;j<63;j++)
		{
			if(t&(1LL<<j))
			{
				count[j][1]++;
			}
			else
			{
				count[j][0]++;
			}
		}
	}

	long long int res = 0;
	long long int base = 1;
	for(int i=0;i<60;i++)
	{
		res += (((count[i][0]%MOD)*(count[i][1]%MOD)%MOD)*(base%MOD)%MOD);
		res%=MOD;
		base*=2;
	}

	cout << res << '\n';

	return 0;
}


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

int main(void)
{
	ios_base::sync_with_stdio(false);    
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll n,w;
	cin>>n>>w;
	vector<ll> dp(w+1,0);
	
	ll weight,value;
	for(int i=0;i<n;i++)
	{
		cin>>weight>>value;
		for(int j=w-weight;j>=0;j--)
		{
			dp[j+weight]=max(dp[j+weight],dp[j]+value);
		}
	}
	
	ll m=0;
	for(int i=0;i<=w;i++)
		m=max(m,dp[i]);
		
	cout<<m<<"\n";

	return 0;
}

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

int main() {
  int N, R;
  cin >> N >> R;

  if (N >= 10)
    cout << R << endl;
  else
    cout << R + 100 * (10 - N) << endl;
  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s=="abc"||s=="acb"||s=="bac"||s=="bca"||s=="cab"||s=="cba"){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define LL long long
using namespace std;
const LL N=101;
LL i,n,m,sum;
LL a[N];
int main()
{
	scanf("%lld%lld",&n,&m);
	for (i=1;i<=n;++i)
	{
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	if (m<sum)
	{
		sort(a+1,a+n+1);
		for (i=1;i<=n;++i)
			if (m-a[i]<0)
				break;
			else
				m-=a[i];
		printf("%lld",i-1);
	}
	else
		printf("%lld",n-(m>sum));
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <numeric>
#include <ios>
#include <iomanip>

using namespace std;


int main() {
	int n;
	while (cin >> n, n != 0) {
		vector<vector<int>> vec(n + 1);

		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				int temp;
				cin >> temp;
				vec[i].push_back(temp);
			}
			int sum = accumulate(vec[i].begin(), vec[i].end(), 0);
			vec[i].push_back(sum);
		}
		for (int j = 0; j < n + 1; ++j) {
			int sum = 0;
			for (int i = 0; i < n; ++i) {
				sum += vec[i][j];				
			}
			vec[n].push_back(sum);
		}
		for (auto& a : vec) {
			for (auto& ans : a) {
				cout << setw(5) << right << ans;
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using ll = long long;


int main() {
	int n; std::cin >> n;
	if (n % 10 == 7 || n / 10 % 10 == 7 || n / 100 % 10 == 7) std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
	return 0;
}


Measured memory_bytes: 3632
import math
ans=[]
while True:
  n=int(input())
  if n==0:
    break
  S=list(map(int,input().split(' ')))
  mean=0

  for i in range(n):
    mean+=S[i]
  mean/=n

  a2=0
  for i in range(n):
   a2+=(S[i]-mean)**2

  a2/=n
  a=math.sqrt(a2)
  ans.append(a)


for i in range(len(ans)):
  print(ans[i])



Measured memory_bytes: 5700
#include<iostream>
#include<vector>
#include <algorithm>
#include <cstring>

#define MAX_V 10000
#define INF 1000000000

void add_edge(int,int);
bool dfs(int);
int bipartite_matching(int);
void warshall_floyd(int);

using namespace std;

vector<int>G[MAX_V];
bool used[MAX_V];
int match[MAX_V],d[MAX_V][MAX_V];



int main(void){
  int n,m,l,p[MAX_V],t[MAX_V];

  while(scanf("%d %d %d",&n,&m,&l),n,m,l){
    for(int i=0;i<MAX_V*2;i++)G[i].clear();
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	  d[i][j]= i==j ?0:INF;

      for(int i=0;i<m;i++){
	  int a,b,c; 
	  scanf("%d %d %d",&a,&b,&c);
	  d[a][b]=d[b][a]=c;
	}
      warshall_floyd(n);

      for(int i=0;i<l;i++)
	scanf("%d %d",&p[i],&t[i]);

      for(int i=0;i<l;i++){
	for(int j=0;j<l;j++){
	  if(i==j)continue;
	  else if(t[i]+d[p[i]][p[j]]<=t[j])
	    add_edge(i,j+l);
	}
      }

      cout << l-bipartite_matching(2*l) << endl;
    }
  return 0;
}

void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v){
  used[v]=true;
  for(int i=0;i < G[v].size();i++){
    int u= G[v][i],w=match[u];
    if(w < 0 || !used[w] && dfs(w)){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}


int bipartite_matching(int V){
  int res = 0;
  memset(match,-1,sizeof(match));
  for(int v=0; v<V; v++){
    if(match[v]<0){
      memset(used, 0, sizeof(used));
      if(dfs(v))res++;
    }
  }
  return res;
}

void warshall_floyd(int V){
  for(int i = 0; i < V; i++){
    for(int j = 0; j < V; j++){
      for(int k = 0; k < V; k++){
	d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
      }
    }
  }
}

Measured memory_bytes: 9996
#include<stdio.h>

int main()
{
    int a,b,c,x,y,bill1,bill2,bill3;

    scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);

    bill1=x*a+y*b;


    if(x>y)
    {
        bill2 =2*y*c+(x-y)*a;
    }
    else
    {
        bill2 =2*x*c+(y-x)*b;
    }


    if(x>y)
    {
        bill3 =2*c*x;
    }
    else
    {
        bill3 =2*c*y;
    }

    if(bill1<=bill2&&bill1<=bill3)
        printf("%d\n",bill1);
    else if(bill2<=bill1&&bill2<=bill3)
        printf("%d\n",bill2);
    else if(bill3<=bill2&&bill3<=bill1)
        printf("%d\n",bill3);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>

using namespace std;
using ll = long long;

int main()
{
	int H, W;
	int h, w;
	cin >> H >> W >> h >> w;

	cout << (H*W)-(h*W + (H-h)*w) << endl;
}



Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

W,H,x,y = map(int,read().split())

W,H,x,y

bl = (W == 2*x and H == 2*y)
area = W*H/2
print(area,1 if bl else 0)

Measured memory_bytes: 3060
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        return 2.0 * (double)n * Math.PI;
    }
}


Measured memory_bytes: 27524
N = int(input())
h = list(map(int, input().split()))

dp = [float('inf') for _ in range(N)]
dp[0] = 0

for i in range(N):
    if i - 1 >= 0:
        if dp[i - 1] + abs(h[i] - h[i - 1]) < dp[i]:
            dp[i] = dp[i - 1] + abs(h[i] - h[i - 1])
    if i - 2 >= 0:
        if dp[i - 2] + abs(h[i] - h[i - 2]) < dp[i]:
            dp[i] = dp[i - 2] + abs(h[i] - h[i - 2])
print(dp[N-1])

Measured memory_bytes: 13776
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    WS = list(map(int, input().split()))
    ans = float('inf')
    for i in range(N):
        ans = min(ans,abs(sum(WS[:i+1])-sum(WS[i+1:])))
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3828
A,B=map(int,input().split())

def XOR(x):
    if x%4==1 or x%4==2:
        l="0"
    else:
        l="1"
    i=2
    while x>=(2**(i-1)):
        k=x%(2**i)
        if k<=2**(i-1)-1:
            l+="0"
        else:
            if k%2==0:
                l+="1"
            else:
                l+="0"
        i+=1    
    l=l[::-1]
    return(int(l,2))

print(XOR(B)^XOR(A-1))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int w, h;
	while (cin >> w >> h) {
		if (w == 0)break;
		int wall[32][32][32][32] = {};
		for (int i = 1; i <= w; i++) {
			wall[i][0][i][1] = 1;
			wall[i][h][i][h + 1] = 1;
		}
		for (int i = 1; i <= h; i++) {
			wall[0][i][1][i] = 1;
			wall[w][i][w + 1][i] = 1;
		}
		int c;
		for (int i = 1; i <= 2 * h - 1; i++) {
			if (i % 2) {
				for (int j = 1; j <= w-1; j++) {
					cin >> c;
					if (c) {
						wall[j][i / 2 + 1][j + 1][i / 2 + 1] = 1;
					}
				}
			}
			else {
				for (int j = 1; j <= w; j++) {
					cin >> c;
					if (c) {
						wall[j][i / 2][j][i / 2 + 1] = 1;
					}
				}
			}
		}
		vector<P> v; v.push_back({ 1,1 });
		int d[32][32];
		for (int i = 0; i <= 31; i++) {
			for (int j = 0; j <= 31; j++) {
				d[i][j] = (int)MOD;
			}
		}
		d[1][1] = 1;
		while (!v.empty()) {
			int len = v.size();
			for (int i = 0; i < len; i++) {
				int x = v[0].first; int y = v[0].second; v.erase(v.begin());
				if (d[x + 1][y] > d[x][y] + 1 && wall[x][y][x+1][y] == 0) {
					d[x + 1][y] = d[x][y] + 1;
					v.push_back({ x + 1,y });
				}
				if (d[x - 1][y] > d[x][y] + 1 && wall[x-1][y][x][y] == 0) {
					d[x - 1][y] = d[x][y] + 1;
					v.push_back({ x - 1,y });
				}
				if (d[x][y+1] > d[x][y] + 1 && wall[x][y][x][y+1] == 0) {
					d[x][y+1] = d[x][y] + 1;
					v.push_back({ x,y+1 });
				}
				if (d[x][y-1] > d[x][y] + 1 && wall[x][y-1][x][y] == 0) {
					d[x][y-1] = d[x][y] + 1;
					v.push_back({ x,y-1 });
				}
			}
		}
		if (d[w][h] == (int)MOD) {
			cout << 0 << endl;
		}
		else {
			cout << d[w][h] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 7152
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]
cost = []
for i in range(n + 1):
    cost.append(abs(a[i + 1] - a[i]))
cost_t = [0]
for i in range(n + 1):
    cost_t.append(cost[i] + cost_t[i])
for i in range(n):
    ans = abs(a[i + 2] - a[i])
    ans += cost_t[i] + cost_t[-1] - cost_t[i + 2]
    print(ans)

Measured memory_bytes: 16072
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  vector<long> vec(N);
  for(int i=0;i<N;i++)
    cin>>vec.at(i);
  int count=0;
  int ans=0;
  for(int i=0;i<N;i++){
    count=0;
  	while(true){
      if(vec.at(i)%2==0){
        count++;
        vec.at(i)=vec.at(i)/2;
      }
      else{
        ans+=count;
        break;
      }
    }
  }
  cout<<ans<<endl;
}

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

int main() {
    int a, b;
    while(1) {
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        if(a > b) swap(a, b);
        cout << a << " " << b << "\n";
    }
}


Measured memory_bytes: 3112
import math
from itertools import permutations

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

ls = permutations(range(1, N+1), N)

Ns = []

for l in ls:
    s = ''.join([str(n) for n in l])
    Ns.append(int(s))

p = ''.join(map(str, P))
q = ''.join(map(str, Q))

a = Ns.index(int(p)) + 1
b = Ns.index(int(q)) + 1

print(abs(a-b))



Measured memory_bytes: 10508
#include <iostream>
#include <string>
#include <set>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    s = "ABC";
    if(n >= 1200) s = "ARC";
    if(n >= 2800) s = "AGC";
    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1, typename T2>
inline bool cmn (T1& a, T2 b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
inline bool cmx (T1& a, T2 b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  long long n;
  cin >> n;
  constexpr int sz = 3;
  vector<int> a(sz), b(sz);
  for (int i = 0; i < sz; i++) cin >> a[i];
  for (int i = 0; i < sz; i++) cin >> b[i];
  auto cal = [] (int W, vector<int>&w, vector<int>&v) {
    int tz = w.size();
    if (tz == 0) return 0LL;
    if (tz == 1) return (long long)(W / w[0]) * v[0];
    if (tz == 2) {  
      long long ret = 0;
      for (int t = 0; t < 2; t++) {
        for (int i = 0; i <= min(W / w[0], w[1]); i++) {
          int j = (W - w[0] * i) / w[1];
          cmx(ret, (long long)i * v[0] + (long long)j * v[1]);
        }
        swap(w[0], w[1]);
        swap(v[0], v[1]);
      }
      return ret;
    }
    vector<long long> dp(W + 1, -1);
    dp[0] = 0;
    for (int i = 0; i < tz; i++) {
      if (v[i] < 0) continue;
      for (int j = 0; j <= W; j++) {
        if (dp[j] == -1) continue;
        for (int k = 0; j + w[i] * k <= W; k++) {
          cmx(dp[j + w[i] * k], dp[j] + v[i] * k);
        }
      }
    }
    return *max_element(dp.begin(), dp.end());
  };
  for (int t = 0; t < 2; t++) {
    vector<int> w, v;
    for (int i = 0; i < sz; i++) {
      if (a[i] < b[i]) {
        w.push_back(a[i]);
        v.push_back(b[i] - a[i]);
      }
    }
    n += cal(n, w, v);
    swap(a, b);
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

//FILE * in = freopen("input.txt", "r", stdin);

int cnt = 1;
int data[1000][11][21];

void init(){
	int i, j, k;
	for(i = 1; i < 1000; i++) {
		for(j = 1; j <= 10; j++){
			int mon = 19 + (j&1);
			if(i%3==0)mon = 20;
			for(k = 1; k<= mon; k++) {
				data[i][j][k] = cnt++;
			}
		}
	}
}

int main() {
	int n, x, y, z;
	init();
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d%d%d", &x, &y, &z);
		printf("%d\n", cnt - data[x][y][z]);
	}
	return 0;
}

Measured memory_bytes: 1908
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s,t;
	cin >> s >> t;

	cout << t << s << endl;
	return 0;
}



Measured memory_bytes: 256
n, m = map(int, input().split())

wa, ac = [0]*n, [0]*n

for i in range(m):
    p, s = input().split()
    p = int(p)
    if s=="AC": ac[p-1] = 1
    else:
        if ac[p-1]==0: wa[p-1] += 1
wac = 0
for i in range(n): wac += wa[i] * ac[i]
print(sum(ac), wac)


Measured memory_bytes: 4596
import sys;          from decimal import Decimal
import math;         from numba import njit, i8, u1, b1
import bisect;       from itertools import combinations, product
import numpy as np;  from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)

def Main():
    n, k = read_ints()
    x = read_int_list()
    ans = INF

    for i in range(n - k + 1):
        left = x[i]
        right = x[i + k - 1]
        if left < 0 and right > 0:
            ans = min(ans, min(abs(left), abs(right)) * 2 + max(abs(left), abs(right)))
        else:
            ans = min(ans, max(abs(left), abs(right)))
    
    print(ans)
    
if __name__ == '__main__':
    Main()

Measured memory_bytes: 102736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

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

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int n ; cin >> n;
	string s; cin >> s;	
	int st = int('A');
	rep(i,s.size()){
		if(s[i]-st+n>=26) s[i]-=26;
		s[i] = s[i]+n;
	}
	out(s);
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

const ll MOD = 1e9 + 7;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(c - a + b, 0) << endl;
}

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

bool check(string s) {
    for(int i = 0; i < (int)s.size(); i++)
        if(s[i] != s[0])
            return false;
    return true;
}

int main() {
    //ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s;
    cin >> s;
    int ans = 101;
    for(int c = 'a'; c <= 'z'; c++) {
        string temp = s;
        while (!check(s)) {
            string t = "";
            for(int i = 0; i < (int)s.size() - 1; i++) {
                if(s[i] == c || s[i + 1] == c)
                    t += c;
                else
                    t += s[i];
            }
            s = t;
        }
        ans = min(ans, (int)temp.size() - (int)s.size());
        s = temp;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(x) cout<<x<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,A,B,C,ans=0;
  string s,t="abc";cin>>s;
  vsort(s);
  if(s==t)printyes;
  else printno;
  return 0;
}


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

#define SZ(x) ((int)(x).size())
#define pi 3.141592653589793


using ll = long long;
using ull = unsigned long long;
using namespace std;




int main()
{
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    printf("%.15f\n", sqrt(pow(A, 2.0) + pow(B, 2.0) - 2 * A * B * (cos((5.5 * M - 30 * H) * pi / 180))));
    return 0;
}


Measured memory_bytes: 4200
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    int N;
    cin >> N;

    vector<int> B(N - 1);
    for (int i = 0; i < N - 1; i++)
    {
        cin >> B[i];
    }

    deque<int> A;
    A.push_back(B[0]);

    for (int i = 0; i < B.size() - 1; i++)
    {
        A.push_back(min(B[i], B[i + 1]));
    }
    A.push_back(B.back());

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        // cout << A[i] << " ";
        ans += A[i];
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        list: [u64; n],
    }

    let mut list = list;

    let mut ans = 0;
    while list.iter().all(|&x| x % 2 == 0) {
        list = list.iter().map(|x| x / 2).collect();
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for(int i = 0;i < n;i++){
        ans += i;
    }
    cout << ans << endl;
}




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

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

    vector<bool> kaeru(X+110,false);
    vector<int> items = {100,101,102,103,104,105};

    for(int j=0;j<6;j++) kaeru[items[j]]=true;

    for(int i=1;i<=X;i++){
        if(kaeru[i]){
            for(int j=0;j<6;j++) kaeru[i+items[j]]=true;
        }
    }

    if(kaeru[X]) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 256