akhauriyash/Code-Regression huggingface dataset:
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num){
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; 
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2){
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n-1) + f(n-2);
}

int main() {
	ll a, b; cin >> a >> b;
	if (a > 0) {
		cout << "Positive" << endl;
		return 0;
	}
	else if(a <= 0 && b >= 0) {
		cout << "Zero" << endl;
		return 0;
	}
	else {
		if ((b - a) % 2 == 0) {
			cout << "Negative" << endl;
			return 0;
		}
		else {
			cout << "Positive" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 8064
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int INF = 0x3f3f3f3f;
const int N = 5e5 + 5;
int seg[N << 2];

#define mid (l + r >> 1)
#define lc (rt << 1)
#define rc (rt << 1 | 1)

void modify(int rt, int l, int r, int p, int v)
{
	seg[rt] = min(seg[rt], v);
	if (l == r) return;
	
	if (p <= mid) modify(lc, l, mid, p, v);
	if (p > mid) modify(rc, mid + 1, r, p, v);
}

int query(int rt, int l, int r, int L, int R)
{
	if (L > R) return INF;
	if (L <= l && R >= r) return seg[rt];
	
	int ret = INF;
	if (L <= mid) ret = min(ret, query(lc, l, mid, L, R));
	if (R > mid) ret = min(ret, query(rc, mid + 1, r, L, R));
	return ret;
}

#undef mid
#undef lc
#undef rc

vector<int> G[N];
int deg[N], ans[N], p[N], n, k, tot;

void addedge(int u, int v)
{
	G[u].push_back(v);
	++deg[v];
}

void Toposort()
{
	priority_queue<int, vector<int>, greater<int> > Q;
	for (int i = 1; i <= n; ++i) 
		if (!deg[i]) Q.push(i);
	
	while (!Q.empty())
	{
		int u = Q.top();
		Q.pop();
		
		ans[u] = ++tot;
		
		for (int v : G[u])
			if (!(--deg[v])) Q.push(v);
	}
}

int main()
{
	n = read();
	k = read();
	memset(seg, 0x3f, sizeof(seg));
	
	for (int i = 1; i <= n; ++i) p[read()] = i;
	for (int i = n, cur; i >= 1; --i)
	{
		cur = query(1, 1, n, p[i] + 1, min(n, p[i] + k - 1));
		if (cur != INF) addedge(p[i], p[cur]);
		cur = query(1, 1, n, max(1, p[i] - k + 1), p[i] - 1);
		if (cur != INF) addedge(p[i], p[cur]);
		
		modify(1, 1, n, p[i], i);
	}
	
	Toposort(); 
	for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]);
	
	return 0;
}


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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int n;  cin >> n;
  vector<int> l(n); cin >> l;
  ll ans = 0;
  for (int i = 0; i < n; ++i){
    for (int j = i+1; j < n; ++j){
      for (int k = j+1; k < n; ++k){
        if(l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i] and max({l[i], l[j], l[k]})<l[i]+l[j]+l[k]-max({l[i], l[j], l[k]}))
          ans++;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}

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

using namespace std;

const int MOD = 998244353;

int main(){
    int N, S;
    while(cin >> N >> S){
        vector<int> A(N);
        for(auto& t : A) cin >> t;
        vector<long long> dp(S, 0);
        long long res = 0;
        // dp[i] = 部分列の和がiとなるL=1~Nの時の場合の数
        for(int i=0;i<N;i++){
            for(int j=S-1;j>0;j--){
                if(j+A[i] == S){
                    res += dp[j] * (N-i); // Rはi以降
                    res %= MOD;
                } else if(j+A[i] < S){
                    dp[j+A[i]] += dp[j]; // j+A[i]はjにA[i]を足しただけだからjの場合の数を含む
                    dp[j+A[i]] %= MOD;
                }
            }
            if(A[i] == S){
                res += (i+1) * (N-i); // L=1~i+1 R=i+1~N
                res %= MOD;
            } else if(A[i] < S){
                dp[A[i]] += (i+1); // L=1~iまでの分
                dp[A[i]] %= MOD;
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 256
import           Data.Char

main :: IO ()
main = do
    s <- getLine :: IO String
    putStrLn $ if judge s then "AC" else "WA"

judge :: String -> Bool
judge s =
    let t = drop 2 (take (length s - 1) s)
    in  head s == 'A' && 'C' `elem` t && length (filter isUpper s) == 2


Measured memory_bytes: 380
#include <stdio.h>

int main(void) {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  while(a > 0 && c > 0) {
    if(a > 0) {
      c -= b;
    }
    if(c > 0) {
      a -= d;
    }
  }
  if(a > 0) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 1700
# https://tenka1-2018-beginner.contest.atcoder.jp/tasks/tenka1_2018_b

import itertools
from collections import Counter
import bisect

def main():
    A, B, K = map(int, input().split())
    for i in range(1, K+1):
        if i % 2 == 1:
            A -= A % 2
            A, B = A // 2, B + A // 2
        else:
            B -= B % 2
            B, A = B // 2, A + B // 2
    print("{} {}".format(A, B))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int N, M;
  cin >> N >> M;
  vll x(N);
  vll y(N);
  vll z(N);
  rep(i, N) {
    cin >> x[i] >> y[i] >> z[i];
  }
  
  //0 ... 負に寄せる，1 ... 正に寄せる
  ll maxv = 0;
  rep(sx, 2) {
    rep(sy, 2) {
      rep(sz, 2) {
        vll ad(N, 0);
        rep(i, N) {
          ad[i] = 
            (sx == 0 ? -x[i] : x[i]) +
            (sy == 0 ? -y[i] : y[i]) +
            (sz == 0 ? -z[i] : z[i]);
        }
        
        sort(all(ad));
        reverse(all(ad));
        
        ll sum = 0;
        rep(i, M) {
          sum += ad[i];
        }
        chmax(maxv, sum);
      }
    }
  }
  
  fin(maxv);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin>>n;
  vl a(n);
  ll dp[n];
  rep(i,n){
      cin>>a[i];
      if(i==0){
          dp[0]=a[0];
      }
      dp[i]=dp[i-1]+a[i];
  }
  ll ans=0;
  rep(i,n){
      ll tmp=dp[n-1]-dp[i];
      tmp%=MOD;
      ans+=a[i]*tmp;
      ans%=MOD;
  }
  print(ans);
}


Measured memory_bytes: 6348
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x = c - a;
	int y = d - b;
	printf("%d %d %d %d\n", c-y, d+x, a-y, b+x);
	return 0;
}


Measured memory_bytes: 3740
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
	int H,W;
	while(1){
		cin>>H>>W;
		if(H==0&&W==0)
			break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cout<<"#";
			}
			cout<<endl;
		}
		cout<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<stdlib.h>

int main(){
	int n,a[1000],i,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	int closer[2]={0,-1};
	for(i=0;i<n;i++){
		if(abs(a[i]*n-sum)<abs(closer[0]*n-sum)){
			closer[0]=a[i];
			closer[1]=i;
		}
	}
	printf("%d\n",closer[1]);
	return 0;
}


Measured memory_bytes: 128
S = input().rstrip()
s = list(S)
N = len(S)
c = 0
v = [None] * N
v[0] = s[0]
if N == 1:
  print(c)
else:
  for i in range(1,N):
    
    if s[i]=='0' and v[i-1] =='0':
      v[i] = '1'
      c +=1
    elif s[i] =='1' and v[i-1] == '1':
      v[i] = '0'
      c +=1
    elif s[i] =='1' and v[i-1] == '0':
      v[i] = '1'
    elif s[i] =='0' and v[i-1] == '1':
      v[i] = '0'
    

  print(c)

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

const int maxn = 100005;
long long low, high;
int a[maxn], n;

int main() {
	scanf("%d", &n);
	for (int i=1; i<=n; i++) scanf("%d", &a[i]);
	if (a[n] != 2) { puts("-1"); return 0; }
	low = 2; high = 3;
	for (int i=n-1; i>=1; i--) {
		low = (low + a[i] - 1) / a[i] * a[i];
		high = (high / a[i] + 1) * a[i] - 1;
		if (high < low) {
			puts("-1"); return 0;
		}
	}
	printf("%lld %lld\n", low, high);
	return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 998244353
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li v[55];

map<li, li> cnt;

li a, b;

li dp[111][55];

int main() {
    dp[0][0] = 1;
    repp(i, 1, 51) {
        dp[i][0] = 1;
        repp(j, 1, i + 1) {
            dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1];
        }
    }
    li n;
    cin >> n >> a >> b;
    rin{
        cin >> v[i];
        cnt[v[i]]++;
    }
    sort(v, v + n);
    li res = 0;
    rep(i, a) {
        res += v[n - 1 - i];
    }
    printf("%.12f\n", res * 1.0 / a);
    if (v[n - 1] == v[n - a]) {
        li num = 0;
        repp(i, a, min(b + 1, cnt[v[n - 1]] + 1)) {
            num += dp[cnt[v[n - 1]]][i];
        }
        cout << num << endl;
    } else {
        li border_cnt = 0;
        li tmp = n - a;
        while (v[tmp] == v[n - a]) {
            border_cnt++;
            tmp++;
        }
        cout << dp[cnt[v[n - a]]][border_cnt] << endl;
    }


    return 0;
}

Measured memory_bytes: 256
//From Naruto to Hokage
//#include <RJ>
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n;
    cin>>n;
    vi v(n+1);
    rep(i,1,n) cin>>v[i];
    ll dp[n+1];
    memset(dp,0,sizeof(dp));
    dp[1]=0;
    rep(i,2,n){
        dp[i]=(abs(v[i]-v[i-1])+dp[i-1]);
        if(i-2>=1)dp[i]=min(dp[i],abs(v[i]-v[i-2])+dp[i-2]);
    }
    // rep(i,1,n) cout<<dp[i]<<" ";
    cout<<dp[n];
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#define MN 110000
using namespace std;

const int MOD=1e9+7;
int n,f[MN],I[MN],t[MN],a,b,m,mmh;
inline int mi(int x,int y){
	int mmh=1;
	while(y){
		if (y&1) mmh=1LL*mmh*x%MOD;
		y>>=1;x=1LL*x*x%MOD;
	}
	return mmh;
}
inline void M(int &x){while(x>=MOD)x-=MOD;while(x<0)x+=MOD;}
inline int C(int n,int r){
	if (n<r) return 0;
	return 1LL*f[n]*I[r]%MOD*I[n-r]%MOD;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n+1;i++){
		scanf("%d",&m);
		if (t[m]) a=t[m],b=i;else t[m]=i;
	}
	I[0]=f[0]=1;
	for (int i=1;i<=n+1;i++) f[i]=1LL*f[i-1]*i%MOD,I[i]=mi(f[i],MOD-2);
	for (int i=1;i<=n+1;i++){
		mmh=0;
		if (i<n) M(mmh+=C(n-1,i));
		if (i>1) M(mmh+=C(n-1,i-2));
		M(mmh+=C(n-1,i-1)*2%MOD);
		M(mmh-=C(n+1-b+a-1,i-1));
		//printf("%d %d\n",a,b,C(a-1,i-1),mmh);
		printf("%d\n",mmh);
	}
}

Measured memory_bytes: 2304
#include <iostream>
using namespace std;
int main(){
    int n; cin >> n;
    int nnum = n+1;
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        int a; cin >> a;
        if(a <= nnum){
            nnum = min(nnum,a);
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3628
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
tLst = [[] for _ in range(N)]
vLst = [0] * N

for i in range(M):
    a, b = map(int, input().split())
    tLst[a - 1].append(b - 1)
    tLst[b - 1].append(a - 1)

def dfs(n, index, v, ans):
    vLst[index] = 1
    if n == N - 1:
        ans += 1
        return ans
    for i in tLst[index]:
        if v == i:
            continue
        elif vLst[i] == 1:
            continue
        ans = dfs(n + 1, i, index, ans)
        vLst[i] = 0
    return ans
print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#include <stdio.h>

typedef struct Card{
	char suit,value;
}Card;

void selectionSort(Card *,int);
void bubbleSort(Card *,int);
int isStable(Card *,Card *,int);
void printData(Card *,int);

int main(void){
	int i,n;
	Card c1[36],c2[36];
	char S[3];
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",S);
		c1[i].suit=S[0];
		c1[i].value=S[1];
	}
	for(i=0;i<n;i++){
		c2[i]=c1[i];
	}
	
	bubbleSort(c1,n);
	printData(c1,n);
	printf("Stable\n");
	selectionSort(c2,n);
	printData(c2,n);
	if(isStable(c1,c2,n)){
		printf("Stable\n");
	}
	else{
		printf("Not stable\n");
	}
	
	return 0;
}

void selectionSort(Card *c,int n){
	int i,j;
	int minj;
	
	for(i=0;i<n;i++){
		minj=i;
		for(j=i;j<n;j++){
			if(c[j].value<c[minj].value)
				minj=j;
		}
		if(c[i].value!=c[minj].value){
			Card t=c[i];
			c[i]=c[minj];
			c[minj]=t;
		}
	}
}

void bubbleSort(Card *c,int n){
	int i;
	int flag=1;
	while(flag){
		flag=0;
		for(i=n-1;i>0;i--){
			if(c[i].value<c[i-1].value){
				Card t=c[i];
				c[i]=c[i-1];
				c[i-1]=t;
				flag=1;
			}
		}
	}
}

int isStable(Card *c1,Card *c2,int n){
	int i;
	
	for(i=0;i<n;i++){
		if(c1[i].suit!=c2[i].suit){
			return 0;
		}
	}
	
	return 1;
}

void printData(Card *c,int n){
	int i;
	for(i=0;i<n;i++){
		printf("%c%c",c[i].suit,c[i].value);
		if(i<n-1)
			printf(" ");
	}
	printf("\n");
}

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

int main(){
    ll n,m,k;
    cin >> n >> m >> k;
    ll a[n];
    rep(i,n){
        cin >> a[i];
    }
    ll b[m];
    rep(i,m){
        cin >> b[i];
    }
    ll ans = 0;
    ll tot = 0;
    rep(i,m) tot += b[i];
    ll j = m;
    for(int i=0; i<=n; i++){
        while(j>0 && tot > k){
            j--;
            tot -= b[j];
        }
        if(tot>k) break;
        ans = max(ans, i+j);
        if(i==n) break;
        tot += a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 6716
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
using namespace std;
const int inf=1e9+10;
const int maxn=1e5+10;
const int maxm=20;
const int mod=1e9+7;
const double pi=acos(-1.0);
int n;
struct node
{
    int x,y;
    int id;
}town[maxn];
struct edge
{
    int st,ed;
    int cost;
}e[maxn*4];
int fa[maxn];
bool cmp1(const node &a,const node &b)
{
    return a.x<b.x;
}
bool cmp2(const node &a,const node &b)
{
    return a.y<b.y;
}
bool cmp3(const edge &a,const edge &b)
{
    return a.cost<b.cost;
}
int Find(int x)
{
    if(fa[x]!=x)
        fa[x]=Find(fa[x]);
    return fa[x];
}
int main()
{
    //freopen("in.txt","r",stdin);
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=n;i++)
        {
            scanf("%d %d",&town[i].x,&town[i].y);
            town[i].id=i;
        }
        int k=0;
        sort(town+1,town+1+n,cmp1);
        for(int i=1;i<=n-1;i++)
        {
            e[k].st=town[i].id;
            e[k].ed=town[i+1].id;
            e[k++].cost=abs(town[i].x-town[i+1].x);
        }
        sort(town+1,town+1+n,cmp2);
        for(int i=1;i<=n-1;i++)
        {
            e[k].st=town[i].id;
            e[k].ed=town[i+1].id;
            e[k++].cost=abs(town[i].y-town[i+1].y);
        }
        sort(e,e+k,cmp3);
        for(int i=1;i<=n;i++)
            fa[i]=i;
        int ans=0;
        for(int i=0;i<k;i++)
        {
            int a=Find(e[i].st),b=Find(e[i].ed);
            if(a!=b)
            {
                ans+=e[i].cost;
                fa[b]=a;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 6528
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const N = nextInt()
    let dict = {}
    let max = 0
    while(hasNext()){
        let str = next()
        if(!dict[str]) dict[str] = 1
        else dict[str]++
        max = Math.max(max, dict[str])
    }
    let ans = []
    for(let key of Object.keys(dict)){
        if(dict[key] === max){
            ans.push(key)
        }
    }
    ans.sort()
    for(let el of ans){
        myout(el)
    }
}
Main()


Measured memory_bytes: 111864
s=input()
a=[0]
for i,j,k in zip(s[:-1],s[1:],range(1,len(s))):
  if i=="R" and j=="L":
    a.append(k)
  else:
    a.append(a[-1])

b=[len(s)-1]*len(s)
for i,j,k in zip(s[-2::-1],s[:0:-1],range(len(s)-2,-1,-1)):
  if i=="R" and j=="L":
    b[k]=k
  else:
    b[k]=b[k+1]
c=[0]*len(s)
for i,j in enumerate(s):
  if j=="R":
    c[(b[i]-i)%2+b[i]]+=1
  else:
    c[a[i]-(i-a[i])%2]+=1
print(" ".join([str(i) for i in c]))

Measured memory_bytes: 55052
#include <iostream>
#include <cstdio>
#include <string>
#include <set>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int nb;
	cin >> nb;
	char a;
	set<char> s;
	for (int i=0; i<nb; ++i){
		cin >> a;
		s.emplace(a);
	}
	if (s.size() == 3){
		cout << "Three";
	}
	else{
		cout << "Four";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
  
int main() 
{   int n;
    int a;
    cin>>n;
    int count=0;
    map<int, int, less <int> > mymap;
    for(int i=0;i<n;i++){
        cin>>a;
        count++;
        mymap.insert(make_pair(a, count));  }
    map<int,int> :: iterator it; 
    for (it=mymap.begin() ; it!=mymap.end() ; it++) 
        cout << (*it).second <<" "; 
    return 0; } 

Measured memory_bytes: 5504
mass = [0] * 2000
num = [0] * 1000
while True:
  N, M = map(int, raw_input().split())
  if N == 0 and M == 0:
    break
  p = 0
  for i in range(N):
    mass[i] = input()
  for i in range(M):
    num[i] = input()

  for i in range(M):
    p += num[i];
    p += mass[p]
    if p >= N - 1:
      print i + 1
      break

Measured memory_bytes: 4296
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountll((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzll(x))
#define rep(i, n) for(int i = 0; i < n; i++)
const int inf9 = 1e9; const lint inf18 = 1e18;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ double y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); } double euclidean(double first, double second){ return sqrt(first * first + second * second); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint P(int n, int r){ if(r < 0 || n < r) return 0; return (fact[n] * inv[n - r] % mod); } lint C(int p, int q){ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }
inline int at(lint i, int j){ return (i >> j) & 1; }

int main(){
    set<int> x;
    for(int i = 0; i < 3; i++){
        int a;
        cin >> a;
        x.insert(a);
    }
    Yes(x.size() == 2);
}


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

int main() {
  int N;
  cin >> N;
  int min=40;
  for (int i=0; i<N; i++) {
    int A;
    cin >> A;
    int c=0;
    while ((A%2) == 0) {
      A /= 2;
      c++;
    }
    if (min > c) {
      min = c;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  int n; cin >> n;
  vi a(n),b(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];

  ll sum = 0;
  vi diff;
  rep(i,n){
    sum += a[i]-b[i];
    if(0 <= a[i]-b[i]) diff.push_back(a[i]-b[i]);
  }
  if(sum < 0){
    cout << -1;
    return 0;
  }
  sort(all(diff));
  int ans = n;
  rep(i,n){
    if(sum < 0 || sum < diff[i]) break;
    ans--;
    sum -= diff[i];
  }
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 4664
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
using ll = long long;



int main() {
	int a, b, x;
	cin >> a >> b >> x;
	if (x >= a && a+b >= x) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i;
  char a[2];
  for(i=0;i<3;i++){
    scanf("%c",&a[i]);
    if(a[i]=='1'){
      a[i]='9';
    }else{
      a[i]='1';
    }
  }
  printf("%s",a);
  return 0;
}
  


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

using namespace std;

using Point = complex<double>;

int main() {
    int N;
    cin >> N;
    vector<Point> points;
    points.reserve(N);
    for (int i = 0; i < N; ++i) {
        int x, y;
        cin >> x >> y;
        points.emplace_back(x, y);
    }
    const double mxX = 1000;
    const double mxY = 1000;
    const double mxR = sqrt((mxX * mxX) + (mxY * mxY)) / 2;
    const double err = 1e-7;

    auto intersection = [](Point a, Point b, double r) -> vector<Point> {
        Point mid = (a + b) / 2.0;
        double half_a_b_distance = abs(a - b) / 2.0;
        double h = sqrt(r * r - half_a_b_distance * half_a_b_distance);
        Point normal = (a - b) * polar(1.0, M_PI / 2.0);
        normal = 1.0 / abs(normal) * normal;
        return {mid + h * normal, mid - h * normal};
    };
    auto determine = [&](const double r) -> bool {
        for (int i = 0; i < N; ++i) {
            for (int j = i + 1; j < N; ++j) {
                const auto &a = points[i];
                const auto &b = points[j];
                if (abs(a - b) <= r * 2.0 + err) {
                    auto intersectionPoints = intersection(a, b, r);
                    for (Point p : intersectionPoints) {
                        if (all_of(points.begin(), points.end(),
                                   [&](const auto &x) -> bool {
                                       return abs(p - x) <= r + err;
                                   })) {
                            return true;
                        }
                    }
                }
            }
        }
        return false;
    };
    double lo = err;
    double hi = mxR + err;
    while (lo + err < hi) {
        double mid = (hi + lo) / 2.0;
        if (determine(mid)) {
            hi = mid;
        } else {
            lo = mid;
        }
    }
    cout << setiosflags(ios::fixed); //保证setprecision()是设置小数点后的位数。
    cout << setprecision(7) << lo << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = 5e15;
int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    set<ll> se;
    for(ll keta = 0; keta < 10; keta++){
        ll m = pow(3, keta + 1);
        for(ll i = 0; i < m; i++){
            ll tmp = 0;
            ll j = i;
            bool a = 0, b = 0, c = 0;
            for(ll cnt = 0; cnt < keta; cnt++){
                ll po = j % 3;
                j /= 3;
                tmp *= 10;
                (po == 0 ? a : (po == 1 ? b : c)) = 1;
                if(po == 0) tmp += 3;
                else if(po == 1) tmp += 5;
                else if(po == 2) tmp += 7;
            }
            if(se.find(tmp) == se.end() && tmp <= N && a && b && c){
                ans++;
                se.insert(tmp);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;

int n,m,k;
int main()
{
    cin>>n>>m>>k;
    int temp=m/n;
    if(k<=temp)  cout<<k<<endl;
    else         cout<<temp<<endl;
}


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

int main(){
	map<int,int> mp;
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i,n){
		int input;
		cin >> input;
		mp[input]++;
	}
	vector<pair<int,int>> pr;
	for(auto a:mp){
		pr.push_back(make_pair(a.second,a.first));
	}
	sort(pr.begin(),pr.end());
	int ans =0;
	int i=0;
	while(k<pr.size()){
		ans+=pr[i].first;
		k++;
		i++;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12536
package main

import (
	"fmt"
	"math"
)

func main() {
	var a string
	fmt.Scan(&a)
	if a[2] == a[3] && a[4] == a[5] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

//-------------------------------------------
// util tools

// abs 絶対値を返す
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// sliceInt []intをスライスする
func sliceInt(k int) []int {
	s := make([]int, getDigit(k))
	count := 0
	for k > 0 {
		i := k % 10
		s[len(s)-1-count] = i
		count++
		k = k / 10
	}
	return s
}

// sliceIntSum []intの合計を出す
func sliceIntSum(v []int) int {
	sum := 0
	for _, x := range v {
		sum += x
	}
	return sum
}

// reverse []intを反転
func reverse(s []int) []int {
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
	return s
}

// getDigit intの桁数を取得
func getDigit(num int) int {
	digit := 0
	for num != 0 {
		num /= 10
		digit++
	}
	return digit
}

// getSumDigit intの各位の和を返す
func getSumDigit(num int) int {
	sum := 0
	for num != 0 {
		t := num % 10
		num /= 10
		sum += t
	}
	return sum
}

// lastPrime 素数 エラトステネスの篩
func lastPrime(max int64) int64 {
	if max <= 1 {
		return 2
	}
	primes := make([]int64, 1, max)
	primesF := make([]float64, 1, max)
	primes[0] = 2
	primesF[0] = 2.0

	count := int64(1)
	for n := int64(3); ; n += 2 {
		flag := true
		f := float64(n)
		rf := math.Sqrt(f)
		for i := 1; i < len(primes); i++ {
			if primesF[i] > rf {
				break
			} else if (n % primes[i]) == 0 {
				flag = false
				break
			}
		}
		if flag {
			count++
			if count >= max {
				return n
			}
			primes = append(primes, n)
			primesF = append(primesF, f)
		}
	}
}


Measured memory_bytes: 512
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}
 int arr[30];
int main()
{
    fast
  //  FI(); /// skip this line for compile
    string s;

    cin >> s;
    for(int i=0;i<s.size();i++){
        arr[s[i]-'a'+1]++;
    }

    for(int i=1;i<=26;i++){
        if(arr[i]%2){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll int
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

bool cmp(pair<string,pair<ll,ll>> a,pair<string,pair<ll,ll>> b){
    if(a.first == b.first) return a.second.first > b.second.first;
    return a.first<b.first;
}
void solve(){
    ll n; cin>>n;

    pair<string,pair<ll,ll>> x[n+1];

    FOR(i,1,n) x[i].second.second = i,cin>>x[i].first>>x[i].second.first;

    sort(x+1,x+n+1,cmp);

    FOR(i,1,n) cout<<x[i].second.second<<endl;
}   

signed main(){

   FastRead;    


    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}




Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);


    string s;
    cin >> s;

    for (auto& c : s) {
        if (c == '1') {
            c = '9';
        } else if (c == '9') {
            c = '1';
        }
    }

    cout << stoi(s) << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;

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

	public static void main(String[] args) {
		new A1135().ans(sc);

	}

}

class A1500 {
	int count1500 = 0;

	public void ans(Scanner sc) {
		int len = sc.nextInt();
		sc.nextLine();
		String id = sc.nextLine();
		int x = sc.nextInt();
		ArrayList<Integer> pa = new ArrayList<Integer>();
		ArrayList<Integer> po = new ArrayList<Integer>();
		for (int i = 0; i < x; i++) {
			pa.add(sc.nextInt());
			if (pa.get(i) % 2 == 0) {

			} else {
				po.add(pa.get(i));
			}
		}

		int sum = 0;
		int even = 0;
		int odd = 0;

		for (int i = 0; i < id.length(); i++) {
			int t = id.length() - i - 1;

			char c = id.charAt(t);
			if (c == '*') {
				if (t % 2 == 0) {
					even++;
				} else {
					odd++;
				}
			} else {
				int d = Integer.parseInt(String.valueOf(c));
				if (t % 2 == 0) {
					sum += (d / 10) + (d % 10);
				} else {
					sum += d;
				}
			}
		}

		System.out.println(sum);
		System.out.println(even);
		System.out.println(odd);

		System.out.println(id);
	}

	void re1500(int sum, int even, int odd, ArrayList<Integer> pa,
			ArrayList<Integer> po) {
		if (even == 0 && odd == 0) {

		} else {
			if (sum % 2 == 0) {

			} else {
				if (odd > 0) {
					for (Iterator iterator = po.iterator(); iterator.hasNext();) {
						Integer integer = (Integer) iterator.next();
						re1500(sum + integer, even, odd - 1, pa, po);
					}
				}
			}
		}
	}

}

class A1129 {

	public void ans(Scanner sc) {

		while (true) {
			int n = sc.nextInt();
			int r = sc.nextInt();

			if (n == 0) {
				break;
			}
			LinkedList<Integer> yama = new LinkedList<Integer>();
			for (int i = 0; i < n; i++) {
				yama.addFirst(i + 1);
			}
			for (int i = 0; i < r; i++) {
				int p = sc.nextInt();
				int c = sc.nextInt();

				for (int j = 0; j < c; j++) {
					yama.add(j, yama.remove(p + j - 1));
				}
			}
			System.out.println(yama.getFirst());
		}

	}

}

class A1135 {

	public void ans(Scanner sc) {
		int M = sc.nextInt();

		for (int m = 0; m < M; m++) {
			int money = sc.nextInt();
			int year = sc.nextInt();

			int n = sc.nextInt();
			int max = 0;
			for (int i = 0; i < n; i++) {
				int me = sc.nextInt();
				double ri = sc.nextDouble();
				int te = sc.nextInt();

				int A = money;
				if (me == 1) {
					for (int y = 0; y < year; y++) {
						A = A + (int) (A * ri) - te;
					}
				} else {
					int Risi = 0;
					for (int y = 0; y < year; y++) {
						Risi += (int) (A * ri);
						A = A - te;
					}
					A += Risi;
				}
				max = Math.max(max, A);
			}

			System.out.println(max);
		}

	}

}

Measured memory_bytes: 42836
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll INF = 1LL << 50;

int main() {
  ll n;
  cin >> n;

  vvll dist(n, vll(n, 0));

  vector<tuple<ll, ll, ll>> sv;

  rep(i, n) rep(j, n) cin >> dist[i][j];

  rep(k, n) rep(i, n) rep(j, n) {
    if(dist[i][j] > dist[i][k] + dist[k][j]){
      puts("-1");
      return 0;
    }
  };

  rep(k, n) rep(i, n) rep(j, n) {
    if (k == i || k == j) continue;
    if (dist[i][j] == dist[i][k] + dist[k][j]) {
      dist[i][j] = INF;
      dist[j][i] = INF;
    }
  };

  ll ans = 0;
  rep(i, n) rep(j, n) {
    if(dist[i][j] != INF){
      ans += dist[i][j];
    }
  };  

  cout << ans/2 << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
    string s;   cin>>s;
    if(s[0]==s[1]&&s[1]==s[2])
            cout<<"Yes"<<endl;
    else if(s[1]==s[2]&&s[2]==s[3])
            cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
}

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

int main() {
	int N;
	cin >> N;
	int a=0, b=0, c=0, x, y, z;
	rep(i, N) {
		cin >> x >> y;
		if (x == y) a++;
		else a = 0;
		if (a == 3) {
			std::cout << "Yes" << '\n';
			return 0;
		}
	}
	std::cout << "No" << '\n';
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define P pair<int, int>

using namespace std;
const int INF=1e5;

int main(){
  long long n, a, b;
  cin >> n >> a >> b;
  if(a>b){
    cout << 0 << endl;
    return 0;
  }
  if(n==1){
    if(a==b)cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
  }
  if(n==2){
    cout << 1 << endl;
  }
  cout << (n-2)*(b-a)+1 << endl;
}


Measured memory_bytes: 256
ALPHABETS = ('a'..'z').to_a

N = gets.to_i

def naming(num)
  results = []
  while num > 0 do
    num, mod = num.divmod(ALPHABETS.size)
    num -= 1 if mod == 0
    results << ALPHABETS[mod - 1]
    # p results
  end
  ans = results.reverse.join
end

ans = naming(N)

puts ans

Measured memory_bytes: 14416
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back 
#define mp make_pair
typedef long long ll;



int main(){
	int h,n; cin>>h>>n;
	ll temp;
	ll sum=0;
	for(int i=0;i<n;i++){
		cin>>temp;
		sum+=temp;
	}
	if(sum>=h) cout<<"Yes";
	else cout<<"No";	
	
	return 0;
}	


Measured memory_bytes: 256
a,b,x = map(int, input().split())
point = 0
if x < b:
    print(int(a*x/b)-(a*int(x/b)))
else:
    for i in range(b-100, b+100):
        point = max(int(a*i/b)-(a*int(i/b)), point)
    print(point)
# for i in range(1,x+1):
#     print(int(a*i/b),a*int(i/b),int(a*i/b)-(a*int(i/b)))

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(System.Console.ReadLine());

            string[] strList = Console.ReadLine().Split(' ');

            int[] intList = strList.Select(int.Parse).ToArray();
            int answer = 0;

            for(int i=0; i<num; i++)
            {
                for(int j=1; j<num-i; j++)
                {
                    answer = answer + intList[i] * intList[i + j];
                }
            }

            
            Console.Write(answer);
            

            

        }
    
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
long long int gcd(long long int m, long long int n)
{
	if(n == 0){
      return m;
    }
  return gcd(n,m%n);
}
long long int lcm(long long int m, long long int n)
{
	long long int a = gcd(m,n);
  return m/a*n;
}
int main() {
	int n;
	long long int t[101] = {};
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	long long int m = 1;
  	for(int i = 0;i<n;i++){
      m = lcm(m,t[i]);
    }
  cout<<m<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
#define MOD (ll)(1e9 +7)
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	ll t,n,i,j,k,l,c,f;
	cin>>n;
	cout<<(n+n*n+n*n*n);
	return 0;
}


Measured memory_bytes: 3644
n = int(input())

x = [int(i) for i in range(n)]
y = [int(i) for i in range(n)]
h = [int(i) for i in range(n)]
for i in range(n):
  x[i], y[i], h[i] = [int(i) for i in input().split()]
for i in range(101):
  for j in range(101):
    for k in range(n):
      if h[k] != 0:
        H = abs(i - x[k]) + abs(j - y[k]) + h[k] 
    for k in range(n):
      if H - abs(i - x[k]) - abs(j - y[k]) <=0:
        if h[k] != 0:
          break
      elif  H != abs(i - x[k]) + abs(j - y[k]) + h[k]:
        break
    else:
      ansx = i
      ansy = j
      ansH = H
      
print(ansx, ansy, ansH)
      

Measured memory_bytes: 3064