akhauriyash/Code-Regression huggingface dataset:
from collections import deque

s = input()

q = int(input())

d = deque(list(s))

inversed = -1

for i in range(q):
    query = list(input().split())
    if int(query[0]) == 1:
        inversed *= -1
    else:
        if int(query[1]) == 1:
            if inversed < 0:
                d.appendleft(query[2])
            else:
                d.append(query[2])
        else:
            if inversed < 0:
                d.append(query[2])
            else:
                d.appendleft(query[2])

if inversed < 0:
    print(''.join(list(d)))
else:
    print(''.join(list(d)[::-1]))


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

using namespace std;

typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pi;

#define fi first
#define se second

int read() {
  int res = 0, w = 1; char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') c = getchar(), w = -1;
  while (isdigit(c)) res = (res << 1) + (res << 3) + c - '0', c = getchar();
  return res * w;
}

const int N = 2e5 + 10;

int a[N], b[N], n, vis[N]; 
priority_queue <pi> Heap;

int main() {
  int n = read();
  ll ans = 0;
  for (int i = 1; i <= n; i++) b[i] = read();
  for (int i = 1; i <= n; i++) a[i] = read(), Heap.push(make_pair(a[i], i));
  while (!Heap.empty()) {
    pi tmp = Heap.top(); Heap.pop();
    if (b[tmp.second] == tmp.first) continue;
    if (b[tmp.second] > tmp.first) { puts("-1"); return 0; }
    int dis = tmp.first - b[tmp.second];
    int sum = a[tmp.second - 1] + a[tmp.second + 1];
    if (tmp.second == 1) sum += a[n];
    if (tmp.second == n) sum += a[1];
    if (sum > dis) { puts("-1"); return 0; }
    int add = dis / sum; ans += add;
    a[tmp.second] -= add * sum;
    tmp.first = a[tmp.second];
    Heap.push(tmp);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int a,b; cin >> a >> b;

	cout << a*b-a-b+1 << endl;

	return 0;

}


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

int main()
{
   int i1, i2;
   cin >> i1;
   cin >> i2;
   if (i1 - i2 < 0)
   {
      cout << 0 << endl;
   }
   else
   {
      cout << i1 - i2 << endl;
   }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pb emplace_back

main()
{
    //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    
    int a,b,c;
    cin>>a>>b>>c;

    int s=a+b+c;
    int m=max({a,b,c});

    cout<<m*10+s-m;
}

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

int main() {
  int a,b;
  cin >> a;
  cin >> b;
  if ((a==1&&b==2)||(a==2&&b==1)) cout << 3 << endl;
  else if ((a==1&&b==3)||(a==3&&b==1)) cout << 2 << endl;
  else cout << 1 << endl;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void readin(T &x) {
    x = 0;
    T fh = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
    x *= fh;
}
inline void d_read(double &x) {
    x = 0.0;
    int fh = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
    if (ch == '.') {
        double num = 1.0;
        ch = getchar();
        for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
    }
    x *= fh;
}
template <typename T>
inline void wt(T x) {
    if (x > 9) wt(x / 10);
    putchar(x % 10 + 48);
}
template <typename T>
inline void writeln(T x, char c) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    wt(x);
    putchar(c);
}
int main() {
    long long d, t, s;
    readin(d); readin(t); readin(s);
    if (d > t * s) puts("No");
    else puts("Yes");
    return 0;
}

Measured memory_bytes: 3632
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define MAXN 110
typedef long long ll;

int a[MAXN];

int main(void) {
    int n;
    while (cin >> n) a[n]++;
    int ma = 0;
    for (int i = 0; i <= 100; i++) ma = max(ma, a[i]);
    vector<int> ans;
    for (int i = 0; i <= 100; i++) {
        if (a[i] == ma) ans.push_back(i);
    }
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
# 写経しましたが、何もわかっていません。

def floor_sum(n, m, a, b):
    "Return sum( floor( (A * i + B) / M ) for i in range(N) )"
    ret = 0
    while True:
        ret += ((n - 1) * n) // 2 * (a // m)
        a %= m
        ret += n * (b // m)
        b %= m
        y_max = (a * n + b) // m
        x_max = y_max * m - b
        if y_max == 0:
            return ret
        ret += (n - (x_max + a - 1) // a) * y_max
        n, m, a, b = y_max, a, m, -x_max % a
    
    return ret

def main():
    import sys
    input = sys.stdin.buffer.readline

    ans = []
    T = int(input())
    for _ in range(T):
        N, M, A, B = map(int, input().split())
        ans.append(floor_sum(N, M, A, B))

    print('\n'.join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 79408
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

int main(){
    int n, m;
    cin >> n >> m;
    vector<P> vec(m);
    for(int i = 0; i < m; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        vec[i] = P(b, a);
    }
    sort(vec.begin(), vec.end());
    int ans = 0;
    int broken = -1;
    for(P x : vec){
        int l = x.second;
        int r = x.first;
        if(broken < l || r <= broken){
            broken = r-1;
            ans++;
        }
    }
    cout << ans << endl;
    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 lint=long long;

template<class T>
class sparse_table{
	vector<vector<T>> st;
	vector<int> h;
public:
	sparse_table(const vector<T> &a){
		int n=a.size();
		h.assign(n+1,0);
		for(int i=2;i<=n;i++) h[i]=h[i>>1]+1;
		st.resize(h[n]+1);
		st[0]=a;
		for(int i=1;i<h[n]+1;i++){
			st[i].resize(n-(1<<i)+1);
			rep(j,n-(1<<i)+1) st[i][j]=max(st[i-1][j],st[i-1][j+(1<<(i-1))]);
		}
	}
	T query(int l,int r)const{
		int i=h[r-l];
		return max(st[i][l],st[i][r-(1<<i)]);
	}
};

int main(){
	int n;
	lint L; scanf("%d%lld",&n,&L);
	vector<lint> x(n),v(n);
	rep(i,n) scanf("%lld%lld",&x[i],&v[i]);

	vector<lint> score_l(n+1),score_r(n+1);
	rep(i,n){
		score_l[i+1]=score_l[i]+v[i];
		score_r[i+1]=score_r[i]+v[n-i-1];
	}
	rep(i,n){
		score_l[i+1]-=x[i];
		score_r[i+1]-=L-x[n-i-1];
	}
	sparse_table<lint> Sl=score_l,Sr=score_r;

	lint ans=max(Sl.query(0,n+1),Sr.query(0,n+1));
	rep(i,n-1){
		ans=max(ans,score_l[i+1]-x[i]+Sr.query(0,n-i));
		ans=max(ans,score_r[i+1]-(L-x[n-i-1])+Sl.query(0,n-i));
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 28800
import sys, collections
file = sys.stdin
H,W = map(int, file.readline().split())
C = [list(map(int,i.split())) for i in file.readlines()]
prev = [0 for i in range(W)]
def height(C):
    global prev
    P = []
    for i in range(W):
        if C[-1][i] == 1:
            p = 0
        else: p = prev[i] + 1
        P.append(p)
    prev = P[:]
    return P

def square(C):
    P = height(C)
    G = []
    L = collections.deque()
    for i,v in enumerate(P):
        if not L:
            L.append((i, v))
            continue
        if v > L[-1][1]:
            L.append((i, v))
        elif v < L[-1][1]:
            k = i - 1
            while L and v < L[-1][1]:
                a = L.pop()
                G.append((k - a[0] + 1) * a[1])
            L.append((a[0], v))
    while L:
        a = L.pop()
        G.append((len(P) - a[0]) * a[1])
    return max(G)

def ans(C):
    ans = []
    for i in range(H):
        currentC = C[:i+1]
        ans.append(square(currentC))
    return str(max(ans))
print(ans(C))

Measured memory_bytes: 29412
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define PPC(x) __builtin_popcount((x))
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
using namespace std;

const int maxN = 100042;

int T[maxN];
vector <pair <int, int> > res;

int main()
{
	int n;
	scanf ("%d", &n);
	
	FOR(i, 0, n)
		scanf ("%d", T+i);
	sort(T, T+n);
		
	int i;
	for (i=1; T[i]<0; i++)
		res.pb({T[n-1], T[i]}), T[n-1] -= T[i];
	for (; i<n-1; i++)
		res.pb({T[0], T[i]}), T[0] -= T[i];
	res.pb({T[n-1], T[0]});
	T[n-1] -= T[0];
	
	printf("%d\n", T[n-1]);
	for (auto p : res)
		printf("%d %d\n", p.first, p.second);
	
	return 0;
}


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

#include <bits/stdc++.h>

using namespace std;

class agc029_b {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<int> A(N);
        for (int i = 0; i < N; ++i) {
            in >> A[i];
        }
        /*map<int, int> id;
        vector<int> B(A);
        for (int i = 0, cur = 0; i < N; ++i) {
            if (id.count(B[i])) {
                B[i] = id[B[i]];
            } else {
                id[B[i]] = cur;
                B[i] = cur;
                ++cur;
            }
        }*/
        sort(begin(A), end(A));
        reverse(begin(A), end(A));
        constexpr int MXT = 30;
        int res = 0;
        map<int, set<int>> ind;
        for (int i = 0; i < N; ++i) {
            ind[A[i]].insert(i);
        }
        multiset<int> seen;
        for (int i = 0; i < N; ++i) {
            if (A[i] >= 1) {
                for (int shift = MXT; shift >= 0; --shift) {
                    int val = (1 << shift);
                    int need = val - A[i];
                    auto it = seen.find(need);
                    if (it != end(seen)) {
                        seen.erase(it);
                        ind[A[i]].erase(i);
                        A[*ind[need].begin()] = 0;
                        ind[need].erase(ind[need].begin());
                        A[i] = 0;
                        ++res;
                        break;
                    }
                }
            }
            if (A[i] >= 1) {
                seen.insert(A[i]);
            }
        }
        out << res << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	agc029_b solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 38528
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int n,max_num = -1000001,min_num = 1000001,tmp;
    long long int sum = 0;
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%d",&tmp);
        sum += tmp;
        max_num = max(max_num,tmp);
        min_num = min(min_num,tmp);
    }
    printf("%d %d %lld\n",min_num,max_num,sum);
}



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

using namespace std;

void srch(int *vote, int &fst_p, int &snd_p)
{
    fst_p = (vote[0]>=vote[1]) ? 0 : 1;
    snd_p = (vote[0]>=vote[1]) ? 1 : 0;
    for(int j=2; j<26; j++)
    {
        if(vote[j]>vote[snd_p])
        {
            if(vote[j]>vote[fst_p])
            {
                snd_p = fst_p;
                fst_p = j;
            }
            else
            {
                snd_p = j;
            }
        }
    }

}

int main()
{
    int n;
    while(cin >> n, n)
    {
        int hyou[n];
        for(int i=0; i<n; i++)
        {
            string chr;
            cin >> chr;
            hyou[i] = chr[0] - 'A';
        }
        int vote[26];
        for(int i=0; i<26; i++) vote[i] = 0;
        bool finished = false;
        int winner, f_time;
        for(int i=0; i<n; i++)
        {
            int rest = n - i - 1;
            vote[hyou[i]]++;

            int fst_p, snd_p;
            srch(vote, fst_p, snd_p);
            int dif = vote[fst_p] - vote[snd_p];
            if(dif > rest)
            {
                finished = true;
                f_time = i + 1;
                winner = fst_p;
                break;
            }
        }
        if(!finished)
        {
            f_time = n + 1;
            int fst_p, snd_p;
            srch(vote, fst_p, snd_p);
            if(vote[fst_p]==vote[snd_p])
            {
                winner = -1;
            }
            else
            {
                winner = fst_p;
            }
        }
        if(winner==-1)
        {
            cout << "TIE" << endl;
        }
        else
        {
            cout << char(winner + 'A') << " " << f_time << endl;
        }
    }
}

Measured memory_bytes: 3156
#include<iostream>

using namespace std;

int main(void){
	int hyo[101][101],tate,yoko;
	cin>>tate>>yoko;
	int i,x;
	//??¨?????????????????????
	for(i = 0;i < 101;i++){
		for(x = 0;x < 101;x++){
			hyo[i][x] = 0;
		}
	}
	//??¨???????????£??\
	for(i = 0;i < tate;i++){
		for(x = 0;x < yoko;x++){
			cin>>hyo[i][x];
		}
	}
	//?¨?????¨?????¨????
	for(i = 0;i < tate;i++){
		for(x = 0;x < yoko;x++){
			hyo[i][yoko] = hyo[i][yoko] + hyo[i][x];
		}
	}
	//???????¨?????¨????
	for(i = 0;i < yoko;i++){
		for(x = 0;x < tate;x++){
			hyo[tate][i] = hyo[tate][i] + hyo[x][i];
		}
	}
	//??????????¨?????¨????
	for(i = 0;i < tate;i++){
		hyo[tate][yoko] = hyo[tate][yoko] + hyo[i][yoko];
	}
	//??¨??????????????¨???
	for(i = 0;i < tate + 1;i++){
		for(x = 0;x < yoko + 1;x++){
			cout << hyo[i][x];
			if(x < yoko){
			cout << " ";
			}
		}
		cout << "\n" ;
	}
	return 0;
}

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

using namespace std;

unsigned long long int a = 0, b = 0, c =0, d = 0, e = 9999, n = 0, maxy = 0, mini = 9999, ans = 0, counter = 0, sur = 0;
std::vector<unsigned long long int> vec{};
std::vector<std::string>str{};
std::vector<std::string>str2{};

int arraykun[2300] = {}, nyan[1001] = {}, koji[50][50];
std::string output, output2, input,nyahhoi;
int kakunou[50][50] = { 53 }, moji[50];

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
int dp(int i, int j) {
	bool okada = true;
	if (i == 0 || j == 0) {
		okada = false;
		return 0;
	}
	if (koji[i][j] == -1) {
		okada = false;
		return 0;
	}
	if (i == 1 && j == 1) {
		okada = false;
		return 1;
	}
	if (okada) {
		return dp(i - 1, j) + dp(i, j - 1);
	}

}
int main()
{

	cin >> a;

	for (int i = 0; i < a; i++) {
		cin >> b;
		vec.push_back(b);
}

	std::sort(vec.begin(),vec.end());
		vec.push_back(0);
	for (int i = 0; i < vec.size()-1; i++) {
		counter++;
		if (vec[i] != vec[i + 1]&&counter%2!=0) {
			ans++;
			counter = 0;
		}
	}
	cout << ans << endl;
}






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

int main(){
    int a,b,c,x,z,n=0;
	cin >> a >> b >> c; 
    for (int x = a; x <= b; x++)
    {
    	z = c % x;
    	if ( z == 0 )
    	{
    		n = n + 1;
    	}
    }
    cout << n << endl;
}
    

Measured memory_bytes: 1164
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

i32 main(void){
    i64 ap=0LL,bp=0LL;
    i64 d;
    for(i64 i=0LL;i<4LL;++i){
        scanf("%lli%*c",&d);
        ap+=d;
    }
    for(i64 i=0LL;i<4LL;++i){
        scanf("%lli%*c",&d);
        bp+=d;
    }
    printf("%lli\n",ap>=bp?ap:bp);
    return 0;
}



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

int main(void){
    int a, b;
    cin >> a >> b;
    
    
    cout << fixed << setprecision(5) << a / b << " " << a % b << " " << static_cast<double>(a) / static_cast<double>(b) << endl;
    
    return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
const int MOD = 1000000007;
int dp[100005][2];
int main()
{
    string s;
    cin >> s;

    int n = s.size();
    dp[0][0] = 1;
    REP(i, n)
    {
        {
            if (s[i] == '0')
            {
                dp[i + 1][0] = dp[i][0];
                dp[i + 1][1] = dp[i][1];
            }
            else
            {
                dp[i + 1][1] = (dp[i][0] + dp[i][1]) % MOD;
            }
        }
        {
            if (s[i] == '0')
            {
                (dp[i + 1][1] += dp[i][1] * 2 % MOD) %= MOD;
            }
            else
            {
                (dp[i + 1][0] += dp[i][0] * 2 % MOD) %= MOD;
                (dp[i + 1][1] += dp[i][1] * 2 % MOD) %= MOD;
            }
        }
    }
    int ans = (dp[n][0] + dp[n][1]) % MOD;
    cout << ans << endl;
    return 0;
}


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

N = int(input())

tc = 0
xc = 0
yc = 0
ok_flg = 1
for n in range(N):
    t, x, y = map(int, input().split())
    t_diff = tc - t
    x_diff = abs(x - xc)
    y_diff = abs(y - yc)
    xy_diff = x_diff + y_diff
    if t%2 == 0:
        if xy_diff <= t and xy_diff%2 ==0:
            continue
        else:
            ok_flg = 0
    else:
        if xy_diff <= t and xy_diff%2 ==1:
            continue
        else:
            ok_flg = 0
if ok_flg == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const ll A = (ll)1e10;

int n;
map <ll, ll> cnt, com;

ll sq(ll x){
    ll ret = sqrt(x);
    while(ret * ret < x) ret++;
    while(ret * ret > x) ret--;
    if(ret * ret == x) return ret;
    return -1;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    int ans = 0;
    vector <ll> all;
    for(int i = 0 ; i < n ; i++){
        ll x;
        cin >> x;
        ll a = 1, b = 1;
        for(ll i = 2 ; i * i * i <= A ; i++){
            if(x % i) continue;
            int ex = 0;
            while(x % i == 0){
                x /= i;
                ex++;
            }
            ex %= 3;
            for(int j = 0 ; j < ex ; j++){
                a *= i;
            }
            for(int j = 0 ; j < (3 - ex) % 3 ; j++){
                b *= i;
                if(b > A) b = 0;
            }
        }
        a *= x;
        ll p = sq(x);
        if(x <= 1000000){
            b *= x;
            if(b > A) b = 0;
            b *= x;
            if(b > A) b = 0;
        }
        else if(p != -1){
            b *= p;
            if(b > A) b = 0;
        }
        else b = 0;
        if(b == 0) ans++;
        else{
            cnt[a]++;
            com[a] = b;
            all.push_back(a);
        }
    }
    if(cnt.count(1)){
        ans++;
        cnt.erase(1);
    }
    for(auto &i : all){
        if(!cnt.count(i)) continue;
        if(!cnt.count(com[i])){
            ans += cnt[i];
            cnt.erase(i);
            continue;
        }
        ans += max(cnt[i], cnt[com[i]]);
        cnt.erase(i);
        cnt.erase(com[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 11508
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    size_t N;
    long long A, B;
    scanf("%zu %lld %lld", &N, &A, &B);

    vector<long long> X(N);
    for (size_t i=0; i<N; ++i)
        scanf("%lld", &X[i]);

    long long res=0;
    for (size_t i=1; i<N; ++i) {
        long long d=X[i]-X[i-1];
        res += min(d*A, B);
    }

    printf("%lld\n", res);
    return 0;
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
   fast;
   int n;
   cin >> n;
   map<char , int>m;
   int ans = 0;
   string t = "MARCH";
   f(i,0,n){
      string s;
      cin >> s;
      if(t.find(s[0]) == -1) continue;
      f(j,0,5) if(t[j] != s[0]) f(k,j+1,5) if(t[k] != s[0]) ans += m[t[j]] * m[t[k]];

      m[s[0]]++;
   }

   cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string n;
    cin >> n;
    for(int i=0;i<n.size();i++){
        if(n.substr(i,1) == "1"){
            cout << "9";
        }else{
            cout << "1";
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
import static java.util.Arrays.sort;
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ary = new int[n];
        for(int i = 0;i < n;i++){
            ary[i] = sc.nextInt();
        }
        sort(ary);
        long max = ary[n-1];
        long min = 0;
        int flag = 0;
        OUTER:
        for (int i = n-2; i >= 0; i--) {
            switch (flag) {
                case 0:
                    {
                        long tmp = max;
                        max = ary[i];
                        if(max == tmp){
                            flag++;
                        }       
                        break;
                    }
                case 1:
                    //if(max == ary[i])continue;
                    min = ary[i];
                    flag++;
                    break;
                default:
                    {
                        long tmp = min;
                        min = ary[i];
                        if (min == tmp) {
                            flag++;
                            break OUTER;
                        }
                        break;
                    }
            }
        }
        if(flag != 3)min = 0;
        long ans = max*min;
        System.out.print(ans);
    }
    
}


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

bool is_square(int n)
{
    for (int i = 0; i <= n; i++)
    {
        if (i * i == n)
        {
            return true;
        }
    }
    return false;
}

int main()
{
    string s, t;
    cin >> s >> t;
    for (size_t i = 0; i < s.length(); i++)
    {
        string ss = "";
        ss += s[s.length() - 1];
        for (size_t j = 0; j < s.length() - 1; j++)
        {
            ss += s[j];
            /* code */
        }
        if (ss == t)
        {
            cout << "Yes" << endl;
            return 0;
        }
        s = ss;
    }
    cout << "No" << endl;

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; i++)  cin >> v[i];
    
    for(int i=n-1; i>0; i--){
        if(v[i] +1 == v[i-1]) v[i-1]--;
        else if(v[i] +1 < v[i-1]){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N;
        cin >> N;
        string S;
        cin >> S;

        vector<ll> cnt(26);
        for(int i = 0; i < N; ++i){
            cnt[S[i] - 'a']++;
        }

        ll ans = 1ll;
        for(int i = 0; i < 26; ++i){
            ans *= (cnt[i] + 1);
            ans %= MOD;
        }
        ans--;

        cout << ans << endl;


    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 1144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            bool isAlice = true;
            int alicePoint = 0;
            int bobPoint = 0;
            var points = Console.ReadLine().Split(' ').Select(int.Parse).OrderByDescending(x => x).ToArray();

            for (int i = 0; i < N; i++)
            {
                int tmpPoint = points[i];
                if (isAlice)
                {
                    alicePoint += tmpPoint;
                    isAlice = false;
                }
                else
                {
                    bobPoint += tmpPoint;
                    isAlice = true;
                }
            }
            Console.WriteLine(alicePoint - bobPoint);
        }
    }
}

Measured memory_bytes: 13396
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
ss = set(s)
sl = Counter(s)
tl = Counter(t)
goukei=[]
for i in ss:
  goukei.append(sl[i]-tl[i])
  
if max(goukei) > 0:
  print(max(goukei))
else:
  print(0)

Measured memory_bytes: 3316
public class Main {


  private static void solve() {
    int n = ni();
    long[] a = nal(n);
    int mod = (int) 1e9 + 7;

    long[] sum = new long[n + 1];
    long f = 1;
    for (int i = 0; i < n; i++) {
      sum[i + 1] = (sum[i] + invl(i + 1, mod)) % mod;
      f = f * (i + 1) % mod;
    }

    long ret = 0;
    for (int i = 0; i < n; i++) {
      ret += (sum[i + 1] + sum[n - i] - 1) * a[i] % mod;
      ret %= mod;
    }
    System.out.println(ret * f % mod);
  }

  public static long invl(long a, long mod) {
    long b = mod;
    long p = 1, q = 0;
    while (b > 0) {
      long c = a / b;
      long d;
      d = a;
      a = b;
      b = d % b;
      d = p;
      p = q;
      q = d - c * q;
    }
    return p < 0 ? p + mod : p;
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 39780
//Tue Dec 22 22:01:34 JST 2009
#include<set>
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define mp make_pair
int dx[]={0,1,1,0,-1,-1};
int dy[]={-1,-1,0,1,1,0};
#define CONNECT true
#define UNCONNECT false
#define CANMOVE true
#define CANNOTMOVE false

class state{
public:
  int len;
  int x[8],y[8];
  int cnt;
  int path[8];

  bool is_connected(int me,int you){
    if ( x[me]==x[you]){
      if ( y[me]-1 == y[you] || y[me]+1 == y[you] || y[me]==y[you])return CONNECT;
    }else if ( x[me]+1 == x[you]){
      if (y[me] ==y[you] || y[me]-1==y[you])return CONNECT;
    }else if ( x[me]-1==x[you]){
      if (y[me] ==y[you] || y[me]+1 == y[you])return CONNECT;
    }

    return UNCONNECT;
  }

  bool can_good_pos(int cur){
    rep(i,cur-1){
      if ( is_connected(cur,i)==CONNECT)return false;//©ªÌOÈOÌâÂÆÂÈªÁÄ¢éÌÅ¾ßB
    }
    if (cur==0 ||  is_connected(cur,cur-1)==CONNECT)return true;//©ªÆOÌâÂÆÂÈªÁÄ¢éÌÅ¨
    return false;
  }
  
  void make_next(int now,queue<state>&Q,set<state>&S,bool flag,set<pair<int,int> > & NG){
    if ( now == len){
      if ( S.find((*this))==S.end()){
	cnt++;
	S.insert(*this);
	Q.push(*this);
	cnt--;
      }
      return;
    }

    //don't move
    
    if (can_good_pos(now) ){
      path[now]=-1;
      make_next(now+1,Q,S,CANMOVE,NG);
    }

    if ( flag == CANNOTMOVE)return;//OÌª®¢Ä½ç©ªÍ®¯È¢

    rep(i,6){
      x[now]+=dx[i];
      y[now]+=dy[i];

      path[now]=i;

      if (NG.find(mp(x[now],y[now])) == NG.end() && can_good_pos(now)){
	make_next(now+1,Q,S,CANNOTMOVE,NG);//©ªª®¢½çÌÍ®¯È¢B
      }
      x[now]-=dx[i];
      y[now]-=dy[i];
    }
        
  }
  
  bool operator<(const state & a)const{
    rep(i,len){
      if ( x[i]!=a.x[i])return x[i]<a.x[i];
      if ( y[i]!=a.y[i])return y[i]<a.y[i];
    }
    return false;
  }
  
};



int bfs(state ini,int dx,int dy,set<pair<int,int> > &NG){
  queue<state> Q;
  set<state> S;
  Q.push(ini);
  S.insert(ini);
  while(!Q.empty()){
    state now = Q.front();
    Q.pop();
    if ( (max(now.x[0],dx)-min(now.x[0],dx)+max(now.y[0],dy)-min(now.y[0],dy))/2+now.cnt>20)continue;
    if ( now.x[0]==dx && now.y[0]==dy){
      return now.cnt;
    }
    now.make_next(0,Q,S,CANMOVE,NG);
  }
  return -1;
}


main(){
  int n,m,dx,dy;
  while(cin>>n && n){
    state ini;
    set<pair<int,int> > NG;
    
    ini.len=n;
    ini.cnt=0;
    rep(i,n)cin>>ini.x[i]>>ini.y[i];
    cin>>m;
    rep(i,m){
      int f,s;
      cin>>f>>s;
      NG.insert(mp(f,s));
    }
    cin>>dx>>dy;
    cout << bfs(ini,dx,dy,NG)<<endl;
  }
  return false;
}

Measured memory_bytes: 17000
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int m=1000000007;
bool cmp2(int n,pii p)
 {return n<p.f;}
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int ar(int n)
{
    return n*n;
}
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int n;
cin>>n;
double d[n][2];string x;
for(int i=0;i<n;i++)
{
cin>>d[i][0]>>d[i][1];
x+=(char)('0'+i);
}
sort(x.begin(),x.end());
//cout<<x<<"\n";
double count=1;
double dis=0;
 for(int i=1;x[i];i++)
    {
        int posn=x[i]-'0',posp=x[i-1]-'0';
        dis+=sqrt(ar(d[posn][0]-d[posp][0])+ar(d[posn][1]-d[posp][1]));
    }
while(next_permutation(x.begin(),x.end()))
{
double dt=0;
    for(int i=1;x[i];i++)
    {
        int posn=x[i]-'0',posp=x[i-1]-'0';
        dt+=sqrt(ar(d[posn][0]-d[posp][0])+ar(d[posn][1]-d[posp][1]));
    }
    dis+=dt;
    count++;
}
cout<<setprecision(10)<<dis/count;
}

Measured memory_bytes: 256
import sys

n, m, p = map(int, sys.stdin.readline().split())

abc = []
# edge = [[] for _ in range(n)]
rev_edge = [[] for _ in range(n)]

for _ in range(m):
	a, b, c = map(int, sys.stdin.readline().split())
	abc.append((a-1, b-1, p-c))
	rev_edge[b-1].append(a-1)

def dfs(e, s):
	v_set = {s, }
	stack = [s]

	while stack:
		v = stack.pop()
		for next_v in e[v]:
			if not next_v in v_set:
				stack.append(next_v)
				v_set.add(next_v)
	return v_set

def bellman_ford(sub_abc, n):
	dist = [float('inf')]*n 
	dist[0] = 0

	for _ in range(n):
		updated = False
		for ele in sub_abc:
			a, b, d = ele
			if dist[a] + d < dist[b]:
				dist[b] = dist[a] + d 
				updated = True
		if not updated:
			break
	else:
		return -1

	return max(-dist[n-1], 0)

use = dfs(rev_edge, n-1)
print(bellman_ford([(a, b, c) for a, b, c in abc if a in use and b in use], n))

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

int main() {
    int n,k;
    cin >> n >> k;
    vector<int>v(n);
    int count;
    rep(i, 0, k){
        int d;
        cin >> d;
        rep(j, 0, d){
            vector<int> v2(d);
            cin >> v2[j];
            v[v2[j]-1]++;
        }
    }
    rep(k,0,n){
        if(v[k] == 0) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String... nui) {

		Scanner sc = new Scanner(System.in);

		String a = sc.next();
		String b = sc.next();
		
		System.out.println(a.charAt(0) == b.charAt(2) && a.charAt(1) == b.charAt(1) && a.charAt(2) == b.charAt(0) ? "YES" : "NO");
		
	}

}


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

int main(){
    int A,B,K;
    cin >> A >> B >> K;
    for(int i = min(A, B);i > 0;i--){
        if(A % i == 0 && B % i == 0){
            K--;
            if(K == 0){
                cout << i << endl;
                break;
            }
        }
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;


int main() {
	int n= 0,a =0;
	cin >> n;
	vector<vector<int>>candy(2, vector<int>(n));
	int ans = 0;
	int sum = 0;
	rep(i, 2) {
		rep(j, n) {
			cin >> a;
			candy[i][j] = a;
		}
	}

	rep(i, n) {
		sum = 0;
		for (int j = 0; j <= i; j++) {
			sum += candy[0][j];
		}
		for (int k = i; k < n; k++) {
			sum += candy[1][k];
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  st s;
    ci(s);
  ll k;
    ci(k);
  vll A(0);
  ll n=s.sz;
  ll count=1;
  ll ans=0;
  if(n==1){
    co(k/2)
  }
  
  else{    
  FOR(i,1,n){
    if(s[i-1]==s[i]){
      count++;
    }
    else{
      A.push_back(count);
      count=1;
    }
  }
  if(count!=1){
    A.push_back(count);
  }
  
  ll a=A.sz;
  
  FOR(i,1,a-1){
    ans+=A[i]/2*k;
  }
  
  if(s[0]==s[n-1]){
    if(a!=1){
    ans+=(A[0]+A[a-1])/2*(k-1);
    ans+=A[0]/2;
    ans+=A[a-1]/2;
    }
    else{
    ans+=k*A[0]/2;
    }
  }
  else{
    ans+=A[0]/2*k;
    ans+=A[a-1]/2*k;
  }
  
  co(ans)
  }
}

Measured memory_bytes: 1024
<?php
$list = array_fill_keys(range("a","z"),0);
$input = str_split(file_get_contents('php://stdin'));

foreach($input as $v){
    if(! ctype_alpha($v)){ continue; }
    $list[strtolower($v)]++;
}
foreach($list as $key => $value){
    printf("%s : %d%s",$key,$value,PHP_EOL);
}

Measured memory_bytes: 15180
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

n=int(input())
arr=list(map(int,input().split()))
while len(arr)>1:
    a=arr.pop()
    b=arr[-1]
    arr[-1]=gcd(a,b)
print(arr[0])


Measured memory_bytes: 14252
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	a := nextInt()
	b := nextInt()

	if a == 0 {
		fmt.Println(0)
		return
	}

	if n <= a {
		fmt.Println(n)
		return
	}

	if n <= a+b {
		fmt.Println(a)
		return
	}

	base := a * (n / (a + b))
	amari := n % (a + b)
	if a <= amari {
		amari = a
	}

	fmt.Println(base + amari)
}

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


Measured memory_bytes: 640
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    n <- readLn
    abs <- fmap (sortBy (\a b -> fst b `compare` fst a)) . replicateM n $ do
        [a, b] <- fmap read . words <$> getLine :: IO [Int]
        return (a, b)
    let (c, d) = head abs
    print $ c + d

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

long long dp[110][100010];

int main(){
    int N,W; cin>>N>>W;
    vector<int> w(N),v(N);
    for(int i=0;i<N;++i){
        cin>>w[i]>>v[i];
    }
    memset(dp,0,sizeof(dp));

    for(int i=1;i<=N;++i){
        for(int j=0;j<=W;++j){
            dp[i][j]=dp[i-1][j];
            if(j-w[i-1]>=0) dp[i][j]=max(dp[i][j],dp[i-1][j-w[i-1]]+v[i-1]);
        }
    }
    cout<<dp[N][W]<<endl;
	return 0;
}



Measured memory_bytes: 86144
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>


#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}


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

const int MOD = 1e9 + 7;
int main(){
    int n;
    cin >> n;
    vector<P> p;
    rep(i, n){
        int a;
        cin >> a;
        p.emplace_back(a, i+1);
    }
    sort(ALL(p));
    for(auto x : p){
        cout << x.second << " ";
    }
}

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



int main(void)
{
	int k, n;
	int max = 0, m = 0;
	int a[200000] = { 0 };
	int b[200001] = { 0 };

	cin >> k >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < n; i++) {
		if (i == 0)
			b[i] = a[i];
		else
			b[i]= a[i]-a[i-1];

		if (max <= b[i]) {
			max =b[i];
			m = i;
		}
	}

	b[n] = a[0] + (k - a[n-1]);
	if (max <= b[n])
		m = n;

	cout << k - b[m] << "\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;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int w, h, n; cin >> w >> h >> n;
	vector<pi> v;
	rep(i, n){
		int x, y; cin >> x >> y;
		v.emplace_back(x, y);
	}
	sort(all(v));
	
	int ans = w - 1, mx = 0;
	for(int i = w - 1, j = n - 1; i >= 0; i--){
		ans = min(ans, i + mx);
		while(j >= 0 && v[j].first == i) mx = max(mx, v[j--].second);
	}
	cout << ans << endl;
	
	return 0;
}


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

 vector<string> sortt(vector<string>A, int x) {
    if (A.size() == x+1)
    return A;
    
    for (int i = A.size() - 1; i > x; i--){
        if (A.at(i-1)>A.at(i)) {
            string B =A.at(i-1);
            A.at(i-1) = A.at(i);
            A.at(i) = B;
        }
    }
    return sortt(A, x+1);
}




int main () {
    int N, L;
    cin >> N >>L;
    vector<string> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    vector<string>B = sortt(A, 0);
    
    for (int i = 0; i<N-1; i++){
        cout << B.at(i);
    }
    cout << B.at(B.size()-1) << endl;
}

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

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

    int a, b, c, d;

    cin >> a >> b >> c >> d;
    if (a + b > c + d) {
      cout << "Left" << endl;
    } else if (a + b < c + d) {
      cout << "Right" << endl;
    } else {
      cout << "Balanced" << endl;
    }

    return 0;
}

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

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

  int N; cin >> N;
  vector<vector<int>> cs(2, vector<int>(N+1));
  for (int i = 0; i < 2; i++) {
    for (int j = 1; j <= N; j++) {
      int A; cin >> A;
      cs[i][j] = cs[i][j-1] + A;
    }
  }
  int ans = 0;
  for (int j = 1; j <= N; j++) {
    ans = max(ans, cs[0][j] + cs[1][N] - cs[1][j-1]);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.00000001
#define pi 3.141592653589793
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti multiset <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
bool comparion(pair <string,ll> a,pair <string,ll> b)
{
    if(a.ff==b.ff)
        return (a.ss>b.ss);
    return (a.ff<b.ff);
}
int main()
{  
    FAST
    ll a,p;
    cin>>a>>p;
    a*=3;
    a+=p;
    a/=2;
    cout<<a;
}

Measured memory_bytes: 256
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define NMAX 1000000

void solve()
{
	ll x;
	for (ll i = 1; i <= 5; i++)
	{
		cin >> x;
		if (x == 0)
		{
			cout << i << "\n";
			return;
		}
	}
}


int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	// ll t;
	// cin >> t;
	// while (t--)
	// {
	solve();
	// }

	return 0;
}

Measured memory_bytes: 3600