akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
using ll = long long;

#define     _test int _TC; cin >> _TC; while(_TC--)
#define     CS(x) cout << "Case " << x << ": ";
#define     precision(n) cout << fixed << setprecision(n);
#define     Clear(a, b) memset(a, b, sizeof(a))
#define     sq(x) ((x) * 1LL * (x))
#define     eb emplace_back
#define     all(_n) _n.begin(), _n.end()
#define     rall(_n) _n.rbegin(), _n.rend()
#define     endl "\n"
#define     show(x) cout << x << endl
#define     nl cout << endl
#define     sz(x) int(x.size())
#define     gcd(a, b) __gcd(a, b)
#define     lcm(a, b) (abs((a) * (b)) / gcd(a, b))
#define     parity(a, b) ((a&1) ^ (b&1))
#define     make_unique(x) sort(all((x))); (x).erase(unique(all((x))), (x).end())
#define     IN(a) for(auto &it : a) cin >> it

template <typename T> void print (T t){ for(const auto &it : t) cout << it << ' '; nl; }
template <typename T> using OS = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // order_of_key find_by_order

const    double Pi = acos(-1.0);
const    int Mod = 1e9 + 7;
const    int Inf = 1 << 30; // INT_MAX = (1LL << 31) -1 // Inf -> 1e9
const    int Maxx = 1e6 + 10;

/************************************[Code Starts Here]************************************/


void _case()
{
    int n; cin >> n ;
    vector<int> v(n); IN(v);
    map<int, int> f;
    for (int it : v) f[it]++;
    ll ans = 0;
    for (auto it : f) {
        ans += (ll)it.second*(it.second-1)/2;
    } 
    for (int it : v) {
        show(ans + (1-f[it]));
    }
}

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    _case();
    return 0;
}




Measured memory_bytes: 8320
N = int(input())
A, B=map(int,input().split())
P = list(map(int,input().split()))
a = 0
b = 0
c = 0
for i in range(N):
    if P[i]<=A:
        a+=1
    elif P[i]<=B:
        b+=1
    else:
        c+=1
l = [a, b, c]
print(min(l))

Measured memory_bytes: 3064
#include<iostream>
#include<bitset>
using namespace std;typedef bitset<12> bit;const int N=107;
int n,i,j,m,mp[N][12],x,ans=-2e9,res;bit s[N],tmp;
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	for(cin>>n,i=1;i<=n;++i)for(j=0;j<10;++j)cin>>x,s[i][j]=x;
	for(i=1;i<=n;++i)for(j=0;j<=10;++j)cin>>mp[i][j];
	for(m=(1<<10)-1,i=1;i<=m;++i){
		tmp=bit(i);
		for(res=0,j=1;j<=n;++j)res+=mp[j][(tmp&s[j]).count()];
		ans=max(ans,res);
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  tmp = LINF;
  rep(i, n) {
    cin >> b;
    if (tmp > b) {
      tmp = b;
      ans = i;
    }
  }
  Cout(ans + 1);
  return 0;
}


Measured memory_bytes: 3232
#include<cstdio>
#include<algorithm>
using namespace std;
long long a[4];
int main(){
	scanf("%lld%lld%lld",&a[1],&a[2],&a[3]);
	sort(a+1,a+3+1);
	long long ans=a[1]+a[2];
	int k;
	scanf("%d",&k);
	while (k--) a[3]*=2;
	ans+=a[3];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;

main(){
    int n,k;
    cin>>n>>k;
    if(n+1<2*k){
        cout<<-1;
    }
    else{
        int c=k+2*n;
        int a=k,b=c-(n+1)/2;
        rep(i,(n+1)/2){
            cout<<a<<" "<<b<<" "<<c<<endl;
            c+=2;
            a++;b++;
        }
        b=k+n;c=k+2*n+1;
        rep(i,n/2){
            cout<<a<<" "<<b<<" "<<c<<endl;
            c+=2;
            a++;
            b++;
        }
    }
}


Measured memory_bytes: 2304
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  string s;cin>>s;
  ll ans=0;
  rep(i,s.size()-1){
    if(s[i+1]!=s[i])ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
typedef pair<ll,ll> ipair;
#define F first
#define S second
 
/*
//functions from gfg
 
long long int power(long long int x,long long int y,long long  int p)
{
    long long int res = 1;     // Initialize result
 
    x = x % p;  // Update x if it is more than or 
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            {//d=(long double)x/p;
            res = (res*x) % p;
            }
 
        // y must be even now
        y = y>>1; // y = y/2
        x=(x*x)%p;
        
    }
    return res%p;
}
 
long long int gcd(long long int a,long long int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
 
long long int binomialCoeff(long long int n, ll k) 
{ 
    ll res = 1; 
  
    // Since C(n, k) = C(n, n-k) 
    if (k > n - k) 
        k = n - k; 
  
    // Calculate value of [n*(n-1)*---*(n-k+1)] / [k*(k-1)*---*1] 
    for (ll i = 0; i < k; ++i) 
    { 
        res *= (n - i); 
        res /= (i + 1); 
    } 
  
    return res; 
} 
 

void sieve(int n, vector<ll> &primes) 
{ 
    vector<int> prime(n,1);
    ll p;
    for ( p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == 1) 
        { 
            
            for (int i=p*p; i<=n; i += p) 
                prime[i] = 0; 
        } 
    } 
  
    for(p=2;p<=n;p++)
    {
        if(prime[p])
        primes.pb(p);
    }
   
} 


void dfs(vector<ll> adj[] ,ll src,vector<ll> &vis)
{
    vis[src]=1;
    for(ll i=0;i<adj[src].size();i++)
    {
        if(vis[adj[src][i]]==0)
        dfs(adj,adj[src][i],vis)
    }
}
 
*/
ll calc (string a)
{
    ll n=a.length(),i;
    ll ans=0;
    for(i=1;i<n;i++)
    {
        if(a[i]==a[i-1])
        {
            ans++;
            a[i] = 0;
        }
    }
    return ans;
}

int main() {
	ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);
    
    
	ll n,i,j,p,k,m,ans=0;
    // cin>>n;
    string a,two,three;
    cin>>a;
    cin>>n;
    ans=0;
    for(i=1;i<a.length();i++)
    {
        if(a[i]!=a[i-1])
        {ans=1;break;}
    }
    if(ans==0)
    {
        m = a.length()*n;
        cout<<m/2<<endl;
    }
    else
    {
    two = a+a;
    three = two+a;
    
    if(n==1)
    {
        cout<<calc(a)<<endl;
    }
    else if(n==2)
    {
        cout<<calc(two)<<endl;
    }
    else if(n==2)
    {
        cout<<calc(three)<<endl;
    }
    else
    {
        cout<<calc(two) + (n-2)*(calc(three) - calc(two));
    }
    }
    
    
    // for(i=0;i<n;i++)
    // {
    //     cout<<a[i]<<" ";
    // }
    // cout<<endl;
    
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

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

int N, M;
int V;
vector<vector<int> > E;
vector<vector<int> > rE;
vector<vector<int> > undE;

int tag[310];
int even[310];
bool same[310][310];
int adj[310][310];

void init() {
	E.clear(); rE.clear(); undE.clear();
	rep(i,310) {
		tag[i] = -1;
		even[i] = -1;
		rep(j,310) {
			same[i][j] = false;
			adj[i][j] = 0;
		}
	}
};

bool dfs(int n, int tg, int d) {
	if(tag[n]+1)
		return false;
	tag[n] = tg;
	even[n] = d % 2;
	for(int i = 0; i < undE[n].size(); i++) {
		dfs(undE[n][i], tg, d+1);
	}
	return true;
}

bool used[310];
bool solve(int n, int gl) {
	if(n == gl) return true;
	if(used[n]) return false;
	used[n] = true;

	bool res = false;
	rep(i,rE[n].size()) {
		if(solve(rE[n][i], gl))
			res = true;
	}
	rep(i,V) {
		if(same[n][i]) {
			if(solve(i,gl)) res = true;
		}
	}
	/*
	rep(i,E[n].size()) {
		rep(j,rE[E[n][i]].size()) {
			if(solve(rE[E[n][i]][j], gl))
				res = true;
		}
	}
	rep(i,rE[n].size()) {
		rep(j,E[rE[n][i]].size()) {
			if(solve(E[rE[n][i]][j], gl))
				res = true;
		}
	}
	// */
	return res;
}

int main() {
	while(cin >> N, N) {
		init();
		map<string, int> mp;
		for(int i = 0; i < N; i++) {
			string s, s0, s1;
			cin >> s;
			s0 = string(s.begin(), s.begin()+s.find('-'));
			s1 = string(s.begin()+s0.size()+1, s.end());
			vector<string> vs;
			vs.pb(s0); vs.pb(s1);
			for(int j = 0; j < vs.size(); j++) {
				if(mp.find(vs[j]) == mp.end()) {
					int id = mp.size();
					mp[vs[j]] = id;
					E.pb(vector<int>());
					rE.pb(vector<int>());
					undE.pb(vector<int>());
				}
			}
			int a, b;
			a = mp[s0];
			b = mp[s1];
			E[b].pb(a);
			rE[a].pb(b);
			undE[b].pb(a);
			undE[a].pb(b);
			adj[b][a] = true;
		}
		V = mp.size();
		cout << V << endl;
		//for(auto it = mp.begin(); it != mp.end(); it++) cout << it->second << ":" << it->first << endl;
		int tg = 0;
		for(int i = 0; i < V; i++) {
			tg += dfs(i, tg, 0);
		}
		/*
		for(int i = 0; i < 10; i++)
			cout << even[i] << " " ;
		cout << endl;
		// */

		rep(i, V) {
			rep(j, V) {
				rep(k, V) {
					if((adj[i][k] && adj[j][k]) || (adj[k][i] && adj[k][j])) {
						same[i][j] = true;
					}
				}
				rep(k, V) {
					if((adj[i][k] && adj[k][j]) || (adj[j][k] && adj[k][i])) {
						same[i][j] = false;
					}
				}
			}
		}

		cin >> M;
		for(int i = 0; i < M; i++) {
			rep(j,310) used[j] = false;
			string s, ss[2];
			cin >> s;
			ss[0] = string(s.begin(), s.begin()+s.find('-'));
			ss[1] = string(s.begin()+s.find('-')+1, s.end());
			bool res = true;
			if(mp.find(ss[0]) == mp.end() || mp.find(ss[1]) == mp.end()
					|| ss[0] == ss[1] || even[mp[ss[0]]] == even[mp[ss[1]]])
				res = false;
			if(res)
				res = solve(mp[ss[0]], mp[ss[1]]);
			
			cout << (res ? "YES" : "NO") << endl;
		}
	}
}

Measured memory_bytes: 1808
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;

const int N=200005;
const int M=2000005;
const int inf=2000000000;
const int mod=1000000007;

struct E{
	int to,next;
}mem[M<<1];
struct node{
	int c,w;
}a[N];
int n,x,y,num,s,t,w1,w2,tot,ans;
int head[N],cnt[N],fac[N],inv[N];
bool vis[N];

bool cmp(node a,node b){
	return a.c<b.c||(a.c==b.c&&a.w<b.w);
}

void add(int x,int y){
	num++;
	mem[num].to=y; mem[num].next=head[x];
	head[x]=num;
}

void dfs(int k){
	int j,u;
	vis[k]=1;
	for (j=head[k];j;j=mem[j].next){
		u=mem[j].to;
		if (!vis[u]) dfs(u);
	}
}

int quickpow(int x,int y){
	int s=1;
	for (;y;y>>=1,x=1ll*x*x%mod)
		if (y&1) s=1ll*s*x%mod;
	return s; 
}

void init(int n){
	int i;
	fac[0]=inv[0]=1;
	for (i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=quickpow(fac[n],mod-2);
	for (i=n-1;i;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}

int main(){
	int i,j,k;
	scanf("%d%d%d",&n,&x,&y);
	for (i=1;i<=n;i++) scanf("%d%d",&a[i].c,&a[i].w);
	sort(a+1,a+1+n,cmp);
	w1=w2=inf;
	for (i=1;i<=n;i=j+1){
		j=i;
		for (;j<n&&a[j+1].c==a[i].c;j++);
		if (a[i].w<w2) w2=a[i].w,t=i;
		if (w1>w2) swap(w1,w2),swap(s,t);
		for (k=i+1;k<=j;k++)
			if (a[k].w+a[i].w<=x){
				add(i,k);
				add(k,i);
			}
	}
	for (i=1;i<=n;i++){
		if (a[i].c!=a[s].c&&a[i].w+a[s].w<=y){
			add(i,s);
			add(s,i);
		}
		if (a[i].c!=a[t].c&&a[i].w+a[t].w<=y){
			add(i,t);
			add(t,i);
		}
	}
	dfs(s);
	init(n);
	for (i=1;i<=n;i++)
		if (vis[i]){
			tot++; cnt[a[i].c]++;
		}
	ans=fac[tot];
	for (i=1;i<=n;i++) ans=1ll*ans*inv[cnt[i]]%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 12544
s = input().split()

w = int(s[0])
a = int(s[1])
b = int(s[2])

answer = 0

if a + w < b:
    answer = b - (a + w)
else:
    answer = a - (b + w)

if (a <= b and b <= a + w) or (a <= b + w and b + w <= a + w):
    answer = 0
    
print(answer)


Measured memory_bytes: 9188
#include<stdio.h>
#include<string.h>

int main() {
    int i, a, m, ans1, ans;
	while(scanf("%d",&a)!=EOF) {
		ans = ans1 = 1;
		if(a==1) {
			scanf("%d",&m);
			printf("1\n");
			continue;
		}
        for(i=1;i<=a;i++) {
        	ans*=3;
        	scanf("%d",&m);
        	if(m%2==0) ans1 *= 2;
		}
		ans -= ans1;
		printf("%d\n",ans);
	}
}

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

using namespace std;

#define sp << " " <<
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define int long long
#define double long double
#define INF 1e18
#define PI 3.14159265359

int power(int p,int y)
{
    int res=1;
    p=p%mod;
    while(y>0)
    {
        if(y&1)
            res=(res*p)%mod;
        y=y>>1;
        p=(p*p)%mod;
    }
    return res;
}

/*
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int dice()
{
    uniform_int_distribution<int> uid(0,1);//specify l and r.
    return uid(rng) ;
}

int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int dp = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          dp = dp * 10 + cc - '0';
          cc = getc(stdin);
       }
      return dp;
}

inline void print(int n)
{
  if (n == 0)
  {
    putchar('0');
    putchar('\n');
  }
  else if (n == -1)
  {
    putchar('-');
    putchar('1');
    putchar('\n');
  }
  else
  {
    char buf[20];
    buf[19] = '\n';
    int i = 18;
    while (n)
    {
      buf[i--] = n % 10 + '0';
      n /= 10;
    }
    while (buf[i] != '\n')
      putchar(buf[++i]);
  }
}

int n;

vector<vector<int>> mat_mul(vector<vector<int>> a,vector<vector<int>> b)
{
    int n=5;
	vector<vector<int>> t(n,vector<int>(n,0));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				t[i][j]+=((a[i][k]*b[k][j])%mod);
				t[i][j]%=mod;
			}
		}
	}
	return t;
}

vector<vector<int>> pow_mat(vector<vector<int>> mat_a,int p)
{
	if(p==1)
        return mat_a;
	vector<vector<int>> temp=pow_mat(mat_a,p/2);
	vector<vector<int>> res=mat_mul(temp,temp);
	if(p&1)
        res=mat_mul(res,mat_a);
	return res;
}
*/

vector<int> g[100013];

int v[100013];

map<pair<int,int>,int> k;

int dp;

void dfs(int n,int c)
{
    v[n]=1;
    int j=0;
    for(int i=0;i<g[n].size();i++)
    {
        if(v[g[n][i]]==0)
        {
            int x=min(n,g[n][i]),y=max(n,g[n][i]);
            pair<int,int> z=mp(x,y);
            k[z]=((c+j)%dp+1);
            dfs(g[n][i],(c+j)%dp+1);
            j++;
        }
    }
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    pair<int,int> a[n-1];
    for(int i=0;i<n-1;i++)
    {
        int d,p;
        cin >> d >> p;
        g[d].pb(p);
        g[p].pb(d);
        a[i].first=min(d,p);
        a[i].second=max(d,p);
    }
    dp=0;
    for(int i=1;i<=n;i++)
    {
        dp=max(dp,(int)g[i].size());
        sort(g[i].begin(),g[i].end());
    }
    cout << dp << endl;
    dfs(1,0);
    for(int i=0;i<n-1;i++)
        cout << k[a[i]] << endl;
    return 0;
}


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

using namespace std;
string lcs(string s,string t,int m,int n,vector<vector<int>> dp){
	
	for (int i = 0; i <= m; ++i)
	{
		for (int j = 0; j <= n; ++j)
		{
			if(i==0 || j==0)
				dp[i][j] = 0;
			else if(s[i-1] == t[j-1])
				dp[i][j] = 1 + dp[i-1][j-1];
			else
				dp[i][j] = max(dp[i][j-1] , dp[i-1][j]);
		}
	}
	int commonstrlen = dp[m][n];
	//3
	char ans[commonstrlen+1];

	ans[commonstrlen] = '\0';
	int i=m,j=n;
	while(i>0 && j>0){
		if(s[i-1] == t[j-1]){
			ans[commonstrlen - 1] = s[i-1];
			i--;	
			j--;
			commonstrlen--;
		}
		else if(dp[i-1][j] > dp[i][j-1]){
			i--;
		}
		else{
			j--;
		}
	}
	return ans;
}
int main(int argc, char const *argv[])
{
	string s;
	string t;
	cin>>s>>t;
	int slen = s.size(),tlen = t.size();
	vector< vector<int> > dp (slen+1,vector<int> (tlen+1, -1));
	string ans = lcs(s,t,slen,tlen,dp);
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 70784
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF 1000000001
#define endl "\n"
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
typedef long long int lli;
using namespace std;

int main()
{
  string st;

  cin >> st;

  REP( i , 3 )
    {
      if( st[i] == '1' )
	{
	  cout << '9';
	  
	}
      else
	{

	  cout << '1';
	  
	
	}

      
    }

  cout << endl;
  
  

}

/*

  　　　　　　　　　　　　　　,.. -- ､,.. --　､
  　 　 　 　 　 　 　　　,　'´:::.: .::.:::...::.:::::..: ::ヽ
  　　　　　　　　　　 , ' . ..::::::::. :: .::::::::::::::::.. :.. ﾞ､
  　 　 　 　 　 　 　/.::　.::::..:..::::::::.:::::..:..:. ..:::::::::. ',
  　　　　　　　　　/.:: .:.::::::::::::::.:. :::::::::.. :::::::.. ::...:: !
  　　　　　　　　 ,' .: :/:. .:::.:..:l:::::.:::::l.:::::::.i:::::: .::::.　!
  　 　 　 　　 　 ! !:.:.: .:. :/:: :l!::::l::::::l:::::|!::i::::::::.::.::. !
  　　　　　　　　l l .::.::.i:::i:.:|!::|:.:li:|::l.:|i:|::l:::i::l::|::i:| ! |
  　　　　　　　　| :::::!:.:|:l|:l!|:iﾞlトl i l! |!l:|キl|::i|:::l:|i. l
  　　　　　　　　| ::|:i::::', 〈.{::::::}` 　 　'{::::::}.〉!:::::::l: |　
  　　　　　　　　!. :l.:::::ﾊ. `ｰ‐'′　 　ー‐' /:i:::::::i; l
  　　　　　　　 ,':.l::|::::i::::ヽ、　　 _,_ 　 　／::.|::l::::::i ',
  　 　 　 　 　 i:::|::|::.:l.: ::::::`:,､.　ﾞ"　 .ィ:: |::::l::..::l!::i il
  　　　　　　　 l:::､|::.:i :::l::レ'l､.`'一'" ﾉヾl:.::l:::.ﾉ:|.:l.ﾉ
  　　　　　　　　`''`"＞'";;;;;;;;:ヽ 　／;;;;;;;;:ヾ`｀''"''′
  　　　　　　　　,. ‐'";;;;;;;;;;;;;;;;;;;;;;`´;;;;;;;;;;;;;;;;;;｀ヽ、
  　　　　 　 ,　'′;;;;;;:;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;｀ヽ、
  　　　　　/;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ヽ

*/


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
MOD = 10 ** 9 + 7

def main():
    string = input().strip()
    n = len(string)
    dp = [[0, 0, 0, 0] for _ in range(n + 1)]
    dp[0][0] = 1
    for i, s in enumerate(string):
        if s == "A":
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1] + dp[i][0]
            dp[i + 1][2] = dp[i][2]
            dp[i + 1][3] = dp[i][3]
        elif s == "B":
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1]
            dp[i + 1][2] = dp[i][2] + dp[i][1]
            dp[i + 1][3] = dp[i][3]
        elif s == "C":
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1]
            dp[i + 1][2] = dp[i][2]
            dp[i + 1][3] = dp[i][3] + dp[i][2]
        else:
            dp[i + 1][0] = 3 * dp[i][0]
            dp[i + 1][1] = 3 * dp[i][1] + dp[i][0]
            dp[i + 1][2] = 3 * dp[i][2] + dp[i][1]
            dp[i + 1][3] = 3 * dp[i][3] + dp[i][2]
        for j in range(4):
            dp[i + 1][j] %= MOD
    print(dp[-1][-1] % MOD)
    
main()

Measured memory_bytes: 32040
Scanf.scanf "%d %d" (fun n k ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let allsum = Array.make n 0 in
    let possum = Array.make n 0 in
    allsum.(0) <- a.(0);
    possum.(0) <- max a.(0) 0;
    for i = 1 to n - 1 do
        allsum.(i) <- allsum.(i - 1) + a.(i);
        possum.(i) <- possum.(i - 1) + max a.(i) 0
    done;
    let rec loop i acc =
        if i + k > n then acc else
            let score = possum.(i - 1) + max 0 (allsum.(i + k - 1) - allsum.(i - 1)) + possum.(n - 1) - possum.(i + k - 1)
            in
            loop (i + 1) (max acc score)
    in
    Printf.printf "%d\n" @@ loop 1 (max 0 allsum.(k - 1) + possum.(n - 1) - possum.(k - 1))
)

Measured memory_bytes: 6400
n, q = gets.chomp.split.map(&:to_i)
s = gets.chomp
l = []
r = []
q.times do |i|
  l[i], r[i] = gets.chomp.split.map(&:to_i)
end

memo = []
(n-1).times do |i|
  if s[i..i+1] == 'AC'
    memo.push(i)
  end
end

q.times do |i|
  le = l[i] - 1
  ri = r[i] - 2
  le_ind = memo.bsearch_index { |x| x >= le } || memo.size
  ri_ind = memo.bsearch_index { |x| x > ri } || memo.size
  p ri_ind - le_ind
end


Measured memory_bytes: 4856
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
 
using namespace std;
 
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);++(i))
#define REP(i,n)   FOR((i),0,(n))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long

const int MOD = 1e9 + 7;

int main() {
    vector<vector<int>> map;
    vector<int> a, b,c,d;
    int H, W;
    cin >> H >>W;
    map.resize(H,vector<int>(W));
    REP(y, H) REP(x, W) {
        cin >> map[y][x];
    }
    
    int dx = 1, x = 0, y = 0, x2, y2;
    int cnt = 0;
    while(1) {
        if(x + dx == W || x + dx == -1) {
            dx *= -1;
            x2 = x;
            y2 = y + 1;
        } else {
            x2 = x + dx;
            y2 = y;
        }

        if(y2 >= H) {
            break;
        }

        if(map[y][x] % 2 == 1) {
            a.push_back(y+1);
            b.push_back(x+1);
            c.push_back(y2+1);
            d.push_back(x2+1);
            map[y][x]--;
            map[y2][x2]++;
            cnt++;
        }

        x = x2;
        y = y2;
    }
cout<<cnt <<endl;
    REP(i, cnt) {
cout << a[i]<<" "<<b[i]<<" "<<c[i]<<" "<<d[i]<<endl;
    }
}



Measured memory_bytes: 5224
n = gets.to_i

if n < 2
  puts 0
else
  all = 10 ** n
  include_0 = all - (9 ** n)
  include_9 = all - (9 ** n)
  include_0_or_9 = all - (8 ** n)
  puts (include_0 + include_9 - include_0_or_9) % (10 ** 9 + 7)
end


Measured memory_bytes: 24316
#include<stdio.h>

#define N 20
#define Q 200

void solve(int,int);

int n,q,ar1[N],ar2[Q];
int i,j;
int sugi;
int main()
{
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&ar1[i]);
    }
  scanf("%d",&q);
 for(i=0;i<q;i++)
    {
      scanf("%d",&ar2[i]);
    }

 for(i=0;i<q;i++)
   {
     sugi = 0;
     solve(0,ar2[i]);
     if(sugi==1)
       {
	 printf("yes\n");
       }
     else
       {
	 printf("no\n");
       }
   }
 return 0;
}

void solve(int a, int b)
{
  if(a==n)
    {
      if(b==0)
	{
	  sugi=1;
	}
    }

  else
    {
      solve(a+1,b-ar1[a]);
      solve(a+1,b);
    }
}

Measured memory_bytes: 580
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main()
{
	vector<string>vs;
	long long n;
	string s;
	cin >> n;
	cin.ignore();
	for(long long i=0;i<n;i++){
		cin >> s;
		sort(s.begin(),s.end());
		vs.push_back(s);
	}
	sort(vs.begin(),vs.end());
	long long sz = vs.size();
	long long i,j,sum = 0;
	for(i=0;i<sz;){
		long long temp = 0;
		for(j=i;j<sz&&vs[j]==vs[i];j++);
		temp = (j-i)*(j-i-1)/2;
		i=j;
		//~ temp = (j-i)*(j-i-1)/2;
		sum += temp;
	}
	cout << sum << endl;
}


Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountll
#define m_p make_pair
#define infi 1e18+1
#define eps 0.000000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
//////////////
auto clk=clock();
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define sz(x) ((long long)x.size())
#define int long long  
#define f80 __float128
#define pii pair<int,int>
/////////////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n,k,c;
	cin>>n>>k>>c;
	string s;
	cin>>s;
	s=" "+s;
	int ans1[n+2]={};
	for(int i=n;i>=1;--i)
	{
		if(s[i]=='x')
			ans1[i]=ans1[i+1];
		else
		{
			ans1[i]=max(ans1[i+1],ans1[min(i+c+1,n+1)]+1);
		}
	}
	int ans2[n+2]={};
	for(int i=1;i<=n;++i)
	{
		if(s[i]=='x')
			ans2[i]=ans2[i-1];
		else
			ans2[i]=max(ans2[i-1],1+ans2[max(0ll,i-1-c)]);
	}
	if(c==0)
	{
		vector<int> v;
		for(int i=1;i<=n;++i)
		{
			if(s[i]=='x')
				continue;
			if(ans2[i-1]+ans1[i+1]<k)
			{
				v.push_back(i);
			}
		}
		for(auto r:v)
			cout<<r<<" ";
		return 0;
	}
	multiset<int> ss;
	for(int i=1;i<=c;++i)
	{
		ss.insert(ans2[0]+ans1[i]);
	}
	vector<int> v;
	for(int i=1;i<=n;++i)
	{
		ss.erase(ss.find(ans1[i]+ans2[max(0ll,i-1-c)]));
		ss.insert(ans2[i-1]+ans1[min(i+c,n+1)]);
		// cout<<i<<endl;
		if(s[i]=='x')
			continue;
		if(*(--ss.end())<k)
			v.push_back(i);
	}
	for(auto r:v)
		cout<<r<<"\n";
	#ifdef ANIKET_GOYAL
		cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	string s;
	map<char,ll> m;
	cin >> s;
	rep(i,SIZE(s)) m[s[i]]++;
	YES(abs(m['a']-m['b'])<2 && abs(m['a']-m['c'])<2 && abs(m['c']-m['b'])<2);
	return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main{
	String name = "CYRMGB";
	
	//サイコロ	//dice is, 2 = south, 3 = east, 1 = top, 6 = bottom, 4 = west, 5 = north;
	class Dice{
		int [] dice;
		public Dice(int[] dice) {
			this.dice = dice;
		}
		private void slide() {
			swap(2,4,5,3);
		}
		private void turn(char c) {
			switch(c){
			case 'n': swap(1,5,6,2); break;
			case 's': swap(1,2,6,5); break;
			case 'w': swap(1,4,6,3); break;
			case 'e': swap(1,3,6,4); break;
			}
		}
		private void swap(int i, int j, int k, int l) {
			int temp = dice[l];
			dice[l] = dice[k];
			dice[k] = dice[j];
			dice[j] = dice[i];
			dice[i] = temp;
		}
		@Override
		public String toString() {
			return "Dice [dice=" + Arrays.toString(dice) + "]";
		}
		
	}
	
	//サイコロが同じかどうか判定する
	private boolean isSame(Dice aa, Dice bb) {
		String [] order = {"", "n", "s", "w", "e", "nn"};
		String [] revorder = {"", "s", "n", "e", "w", "nn"};
		Dice a = new Dice(aa.dice);
		Dice b = new Dice(bb.dice);
		for(int i = 0; i < order.length ; i++){
			for(int j = 0; j < order[i].length(); j++){
				char c = order[i].charAt(j);
				b.turn(c);
			}
			for(int j = 0; j < 4; j++){
				b.slide();
				if(a.toString().equals(b.toString())){
					return true;
				}
			}
			for(int j = 0; j < revorder[i].length(); j++){
				char c = revorder[i].charAt(j);
				b.turn(c);
			}
		}
		return false;
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			Dice [] d = new Dice[n];
			for(int i = 0; i < n; i++){
				int [] tempdice = new int[7];
				for(int j = 1; j <= 6; j++){
					String s = sc.next().charAt(0) + "";
					tempdice[j] = name.indexOf(s);
				}
				d[i] = new Dice(tempdice);
			}
			
			int count = 0;
			for(int i = 0; i < n; i++){
				for(int j = i + 1; j < n; j++){
					if(isSame(d[i], d[j])){
						count++;
						break;
					}
				}
			}
			System.out.println(count);
		}
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

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

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

#define int long long

constexpr long long MOD = 1000000007;
constexpr long long INF = (long long)1e18;

signed main(){
  int H, W, h, w;
  int sum = 0;

  vector<vector<int>> ans;

  cin>>H>>W>>h>>w;

  ans.resize(H, vector<int>(W, 4000));

  for(int i = h-1; i < H; i += h){
    for(int j = w-1; j < W; j += w){
      ans[i][j] = - (h * w - 1)* 4000 - 1;
    }
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      sum += ans[i][j];
    }
  }

  // sum = 1;
  if(sum > 0) {
    cout<<"Yes"<<endl;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if(j) cout<<" ";
        cout<<ans[i][j];
      }
      cout<<endl;
    }
  } else {
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3584
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    S = input()

    ans = 0

    if S[0] == S[1] == S[2] == "R":
        print(3)
        return

    if S[0] == S[1] == S[2] == "S":
        print(0)
        return

    for i in range(1, 3):
        if S[i-1] == S[i] == 'R':
            ans += 1

    print(ans + 1)


main()


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

int main() {
	// your code goes here
	string s,t;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(u==s)
	a-=1;
	if(u==t)
	b-=1;
	cout<<a<<" "<<b;
	return 0;
}


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

int a, b, k;

int main(){
  cin >> a >> b >> k;
  for(int i = a; i <= b; i++){
    if(i < a + k){
      cout << i << endl;
    }else if(i > b - k){
      cout << i << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 384
fn main() {
    let n = read();
    let ans = solve(n);
    write(ans);
}

fn read() -> i32 {
    let mut l1 = String::new();
    std::io::stdin().read_line(&mut l1).ok();
    let n: i32 = l1.trim().parse().unwrap();

    n
}

fn write(a: bool) {
    println!("{}", if a {"Yes"} else {"No"});
}

fn solve(n: i32) -> bool {
    for c in n.to_string().as_str().chars() {
        if c == '7' {
            return true;
        }
    }

    return false;
}

Measured memory_bytes: 2092
//Abhinav ---IIIT_A
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
#define my vector<pii>
ld pie=3.141592653589;
int mod=1e9+7;


bool Compare(pii a, pii b)
{
	return a.ff > b.ff;
}
priority_queue<pii, vector<pii>, function<bool(pii, pii)>> pq(Compare);

vi adj[200005];
bool vis[200005];
int n,m;

int dfs(int s){
	vis[s]=1;
	int ret=0;
	for(auto it : adj[s]){
		if(!vis[it]){
			ret+=dfs(it);
		}
	}
	return ret+1;
}

void solve(){
	cin>>n>>m;
	f(i,0,m){
		int u,v; cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	int mx=LLONG_MIN;
	f(i,1,n+1){
		if(!vis[i]){
			int xp=dfs(i);
			mx=max(mx,xp);	
		}
	}
	cout<<mx;
}

int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int t=1; //cin>>t;
  while(t--) solve();
  return 0;
}
// check for overflows dummy !!!

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

string order(const string &s, int c) {
    int n = s.size();
    string ret;
    for (int i = 0; i < n; i++) {
        if (((c >> i) & 1) == 1) {
            ret.push_back(s[i]);
        }
    }
    for (int i = n-1; i >= 0; i--) {
        if (((c >> i) & 1) == 0) {
            ret.push_back(s[i]);
        }
    }
    return ret;
}
    
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    vector<unordered_map<string, int>> m(n+1);
    
    string fh = s.substr(0, n);
    for (int i = 0; i < (1 << n); i++) {
        int c = __builtin_popcount(i);
        m[c][order(fh, i)]++;
    }
    ll ans = 0;
    string sh = s.substr(n, 2*n);
    reverse(sh.begin(), sh.end());
    for (int i = 0; i < (1 << n); i++) {
        int c = __builtin_popcount(i);
        ans += m[c][order(sh, i)];
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 72372
k, x = list(map(int, input().split()))

m, M = x-k, x+k
if m < -100000:
    m = -100000
if M > 100000:
    M = 100000

for i in range(m+1, M-1):
    print(str(i) + ' ', end="")
print(M-1)


Measured memory_bytes: 3060
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    T1, T2 = in_nn()
    A1, A2 = in_nn()
    B1, B2 = in_nn()

    if A1 > B1:
        A1, B1 = B1, A1
        A2, B2 = B2, A2

    da1 = T1 * A1
    da2 = T2 * A2
    db1 = T1 * B1
    db2 = T2 * B2

    if da1 == db1:
        if db1 == db2:
            ans = "infinity"
        else:
            ans = 1
    else:
        if da1 + da2 == db1 + db2:
            ans = "infinity"
        elif da1 + da2 < db1 + db2:
            ans = 0
        else:
            d1 = db1 - da1
            d2 = (da1 + da2) - (db1 + db2)
            ans = 1 + (d1 // d2) * 2
            if d1 % d2 == 0:
                ans -= 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <functional>
#include <set>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	int x[5], ans;

	rep(i,5) cin >> x[i];

	rep(i, 5){
		ans = i+1;
		if (x[i] == 0)break;
	}

	cout << ans << endl;

	return 0;
}

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

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

queue<int> count ;
queue<int> x ;
queue<int> y ;

int main(){
	
	int w , h ;
	int nx , ny , nc ;
	
	while(1){
		cin >> w >> h ;
		if( w==0 && h==0 ) break ;
		
		for( int i=0 ; i<=(h-1)*2 ; i++ ){
			for( int j=(i+1)%2 ; j<=(w-1)*2 ; j += 2  ){
				cin >> map[i][j] ;
			}
		}
		
		count.push(1) ;
		x.push(0) ;
		y.push(0) ;
		
		while(1){
			if( count.empty() ){
				cout << 0 << endl ;
				break ;
			}
			else if( x.front() == (w-1)*2 && y.front() == (h-1)*2 ){
				cout << count.front() << endl ;
				break ;
			}
			
			nc = count.front() ;
			nx = x.front() ;
			ny = y.front() ;
			count.pop() ;
			x.pop() ;
			y.pop() ;
			
			for( int i=0 ; i<4 ; i++ ){
				if( nx+dx[i]*2 >= 0 && nx+dx[i]*2 <= (w-1)*2 &&
					ny+dy[i]*2 >= 0 && ny+dy[i]*2 <= (h-1)*2 &&
					map[ ny+dy[i]*2 ][ nx+dx[i]*2 ] == 0 &&
					map[ ny+dy[i] ][ nx+dx[i] ] == 0 ){
					map[ ny+dy[i]*2 ][ nx+dx[i]*2 ] = nc+1 ;
						x.push( nx+dx[i]*2 ) ;
						y.push( ny+dy[i]*2 ) ;
						count.push( nc+1 ) ;
				}
			}
		}
		
		while(1){
			if( count.empty() ) break ;
			else{
				count.pop() ;
				x.pop() ;
				y.pop() ;
			}
		}
		
		for( int i=0 ; i<=(h-1)*2 ; i++ ){
			for( int j=0 ; j<=(w-1)*2 ; j++ ){
				map[i][j] = 0 ;
			}
		}
	}
	
return 0 ;
}

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

int main(){
int N, x, saidai;
  x = 0;
  saidai = 0;
  cin >> N;
  string S;
  cin >> S;

    
  for(int i = 0;i < S.size();i++){
  if(S.at(i) == 'I'){
  x++;
  saidai = max(saidai, x);
  }
    else{
    x--;
    }
  }
  cout << saidai << endl;
}

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

using namespace std;

int main() {
    int n, c;
    int v[51];
    cin >> n;
    int answer = 0;
    for (int i = 0; i < n; ++i) cin >> v[i];
    for (int i = 0; i < n; ++i) {
        cin >> c;
        answer += max(0, v[i] - c);
    }
    cout << answer << endl;
}


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

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

	const long long MOD = 1000000000 + 7;
	vector<long long> v( 26 );
	for( int i = 0; i < N; i++ ) {
		int n = S[i] - 'a';
		v[n]++;
	}
	long long ans = 1;
	for( int i = 0; i < 26; i++ ) {
		if( v[i] == 0 ) continue;
		ans *= v[i] + 1;
		ans %= MOD;
	}
	ans = (ans - 1 + MOD) % MOD;

	cout << ans << endl;
}


Measured memory_bytes: 3768
#include <iostream>
#include <map>
#include <algorithm>    
#include <vector>       
#include <set>
#include <utility>  
#include <cstring>
#include <stdio.h>
#include <limits.h>
#include <queue>
#include <algorithm> 
#define MAX_DOUBLE  40000000000.0 
#include <math.h> 
#include <unistd.h>

using namespace std;


int min(int a, int b){
	if( a > b ) return b;
	return a; 
}

int max(int a, int b){
	if( a < b ) return b;
	return a; 
}

int days[100010][3];


int main(){
	int n;
	cin>>n;
	
	for(int i = 0; i < n; i++){
		cin>>days[i][0]>>days[i][1]>>days[i][2];	
	}
	
	int maxA = days[0][0];
	int maxB = days[0][1];
	int maxC = days[0][2];
	
	for(int i = 1; i < n; i++){
		int tmpA = max(maxB, maxC) + days[i][0];
		int tmpB = max(maxA, maxC) + days[i][1];
		int tmpC = max(maxB, maxA) + days[i][2];
		
		maxA = tmpA;
		maxB = tmpB;
		maxC = tmpC;			
	}
	
	
	cout<<max(max(maxA, maxB), maxC);
	
}


Measured memory_bytes: 1408
# AOJ 1516: Nasty Boys
# Python3 2018.7.13 bal4u

rr = [0,0,0,1,1,1,2,2,2]
cc = [0,1,2,0,1,2,0,1,2]
A = ord('A')

for i in range(1000):
	buf = list(input())
	j = 0
	r, c = rr[ord(buf[j])-A], cc[ord(buf[j])-A]
	j, f = j+1, True
	while j < len(buf) and f:
		f = False
		r2, c2 = rr[ord(buf[j])-A], cc[ord(buf[j])-A]
		j += 1
		if r2 == r:
			if c2 == c+1 or c2 == c-1: f = True
		elif c2 == c:
			if r2 == r+1 or r2 == r-1: f = True
		r, c = r2, c2
	if f: print(*buf, sep='')


Measured memory_bytes: 5580
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

/*
 貪欲
 ①決定問題 必ず解に含まれる(含むように変換できる)ものから決めていく みんプロ本選B
 ②最適化問題 任意の解から評価を落とさず解に含められるようなものから決めていく 区間スケジューリングとか
 ③
 */

/*
 DP
 ①DPはある程度決め打ちをするべき(解を帰納的に構成できないか？)
 */

vector<vector<ll>> c;
vector<ll> d;
vector<ll> pa;
ll dfs(ll pos,ll par) {
	pa[pos]=par;
	ll ret=1;
	REP(i,c[pos].size()) {
		if(c[pos][i]==par) continue;
		ret+=dfs(c[pos][i],pos);
	}
	return d[pos]=ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	c.resize(n);
	d.resize(n);
	pa.resize(n);
	REP(i,n-1) {
		ll a,b;
		cin>>a>>b;
		--a;
		--b;
		c[a].pb(b);
		c[b].pb(a);
	}
	dfs(0,-1);
	ll c=0;
	ll pos=n-1;
	while(pos!=0) {
		pos=pa[pos];
		c++;
	}
	c--;
	ll hoge=c/2;
	pos=n-1;
	REP(i,hoge) pos=pa[pos];
	if(n<=2*d[pos]) {
		cout<<"Snuke"<<endl;
	} else cout<<"Fennec"<<endl;
}


Measured memory_bytes: 12032
# = int(input())
N, K = map(int, input().split())
A = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]
next = 1
List = [-1]*N

for i in range(K):
    if List[next-1] == -1:
        List[next-1] = i
        next = A[next-1]

    else:
        loop = i - List[next-1]
        afterloop = (K-(i-loop))%loop
        print(List.index((i-loop) + afterloop)+1)
        exit()

print(next)


Measured memory_bytes: 32300
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
typedef long long int ll;

void input(){
   int n; cin >>n;
   vector<double>a(n);
   f(i, n)cin >> a[i];
   double ans = 0;
   f(i,n)ans += 1.0 / a[i];
   double x = 1.0 / ans;
   cout <<fixed << showpoint<< setprecision(6) << x << endl;
}
int main()
{
 input();
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const int64_t mod = 1e9 + 7;

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

    int64_t ans = 1;
    for(int i = 2; i <= N; ++i){
        bool check = true;
        for(int j = 2; j * j <= i; ++j){
            if(i % j == 0){
                check = false;
                break;
            }
        }
        if(check){
            int k = i;
            int64_t n = 0;
            while(k <= N){
                n += N / k;
                k *= i;
            }
            ans *= (n + 1);
            ans %= mod;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
int main(void){
    int n,i,j,k,l,c;
    char s[1000][2000];
    while(1){
        n=in();
        if(!n)break;
        MEMSET(s);
        rep(i,n)chin(s[i]);
        rep(i,n){
            if(!i)continue;
            for(k=0;s[i][k+1]=='.';k++);
            s[i][k]='+';
        }
        rep(i,n){
            for(k=0;s[i][k]!='+';k++);
            for(l=i+1;l<n;l++){
                if(s[l][k]=='+')break;
                if(isalpha(s[l][k])){
                    l=n;
                    break;
                }
            }
            if(l!=n){
                for(j=i+1;j<l;j++)s[j][k]='|';
            }
            for(j=0;!isalpha(s[i][j]);j++){
                if(s[i][j]=='.')s[i][j]=' ';
            }
        }
        rep(i,n)puts(s[i]);
    }
    return 0;
}



Measured memory_bytes: 3668