akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
 
 
void merge(int * ,int , int ,int);
void mergeSort(int*,int,int);
 
#define N 500000
 
int count=0;
 
int main(){
 
  int S[N],n,i;
 
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&S[i]);
 
   mergeSort(S,0,n);
 
 for(i=0;i<n-1;i++)printf("%d ",S[i]);
 
  printf("%d\n",S[i]);
  printf("%d\n",count);
 
  return 0;
}
 
void merge(int *A , int left, int mid, int right){
 
  int L[N],R[N],n1,n2,i,j,k;
 
  n1=mid-left;
  n2=right-mid;
 
  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];
 
  L[n1]=1000000001;
  R[n2]=1000000001;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }
    else{
      A[k]=R[j];
      j++;
    }
    count++;
  }
 
  
}
 
void mergeSort(int *A,int left, int right){
 
  int mid;
 
  if(left+1<right) {
    mid=(left+right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }  
   
   
}

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

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

int main()
{
	int X, Y;
	scanf("%d %d", &X, &Y);
	
	if ((X + Y) % 3 != 0 || X * 2 < Y || Y * 2 < X) {
		printf("0\n");
		fflush(stdout);
		return 0;
	}
	
	long long i, total = (X + Y) / 3, left = (X * 2 - Y) / 3, right = total - left, min = (left < right)? left: right, ans = 1;
	for (i = 0; i < min; i++) ans = ans * (total - i) % 1000000007;
	for (i = 2; i <= min; i++) ans = div_mod(ans, i, 1000000007);
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  ll x,y; cin >>x >>y;
  ll res = INT_MAX;
  if (x <= y){
    res = y-x;
    if (x*y < 0) res = 1 + abs(y+x);
  }else if (x > y){
    if (x*y == 0) res = 1 + x-y;
    else if (x*y > 0) res = 2 + x-y;
    else res = 1 + abs( abs(x) - abs(y) );
  }
  cout <<res <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n;
	cin >> n;
	vector<int> a(n+1);
	rep(i, 1, n+1)cin >> a[i];
	int cnt = 1;
	int tmp = a[1];
	rep(i, 0, 100003) {
		if (tmp == 2) {
			cout << cnt << endl;
			return 0;
		}
		tmp = a[tmp];
		cnt++;
	}
	cout << "-1" << endl;
	return 0;
}


Measured memory_bytes: 640
N = int(input())
A = sorted([int(input()) for _ in range(N)])
if N%2==0:
    B = A[:N//2]
    C = A[N//2:]
    C = C[::-1]
    D1 = []
    D2 = []
    for i in range(N//2-1):
        D1.append(B[i])
        D1.append(C[i])
        D2.append(C[i])
        D2.append(B[i])
    D1.append(B[-1])
    D1.insert(0,C[-1])
    D2.append(C[-1])
    D2.insert(0,B[-1])
    cnt1 = 0
    cnt2 = 0
    for i in range(1,N):
        cnt1 += abs(D1[i]-D1[i-1])
        cnt2 += abs(D2[i]-D2[i-1])
    print(max(cnt1,cnt2))
else:
    B = A[:N//2]
    C = A[N//2+1:]
    C = C[::-1]
    D1 = []
    D2 = []
    for i in range(N//2):
        D1.append(B[i])
        D1.append(C[i])
        D2.append(C[i])
        D2.append(B[i])
    cnt1 = 0
    cnt2 = 0
    for i in range(1,N-1):
        cnt1 += abs(D1[i]-D1[i-1])
        cnt2 += abs(D2[i]-D2[i-1])
    cnt1 += max(A[N//2]-D1[0],D1[-1]-A[N//2])
    cnt2 += max(D2[0]-A[N//2],A[N//2]-D2[-1])
    print(max(cnt1,cnt2))

Measured memory_bytes: 95044
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  int a, b,c;
  cin >> a >> b >> c;
  if(a < b && b < c) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3076
import sys
N,Q = map(int,sys.stdin.readline().rstrip().split())
S = sys.stdin.readline().rstrip()
D = [0]
DD = 0
for i in range(1,len(S)):
  if S[i-1] + S[i] == "AC":
    DD += 1
  D.append(DD)
for _ in range(Q):
  l,r  = map(int,sys.stdin.readline().rstrip().split())
  print(D[r-1]- D[l-1])
  del l
  del r

Measured memory_bytes: 6284
#include <iostream>

using namespace std;

typedef long long ll;

int construction[16][16];

ll solve(int a, int b) {
    int n,x,y;
    cin >> n;
    for(int i=0;i<n;i++) {
        cin >> x >> y;
        construction[y-1][x-1] = 1;
    }

    ll dp[b][a];
    fill(dp[0], dp[b-1]+a, 0LL);
    dp[0][0] = 1;
    for(int i=0;i<b;i++) {
        for(int j=0;j<a;j++) {
            if(!dp[i][j]) continue;
            if(construction[i][j]) continue;
            if(i < b-1) dp[i+1][j] += dp[i][j];
            if(j < a-1) dp[i][j+1] += dp[i][j];
        }
    }

    return dp[b-1][a-1];
}

int main() {
    int a,b;
    while(cin >> a >> b, a) {
        cout << solve(a, b) << endl;
        fill(construction[0], construction[15]+16, 0);
    }

}


Measured memory_bytes: 3064
import Control.Applicative
import Control.Monad
import Data.List.Split

myRead :: String -> (Int, Int)
myRead s = (l, r)
    where
        [a, b] = splitOn " " s
        l = read a
        r = read b

solve :: [(Int, Int)] -> Int
solve = sum . ( map (\(l, r) -> r-l+1) )

main :: IO ()
main = do
    n <- read <$> getLine
    contents <- map myRead <$> replicateM n getLine
    print $ solve contents


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B,c=0;
  cin >> A >> B;
  for(int i=A;i<=B;i++){
    if(i/10000==i%10&&(i/1000)%10==(i%100)/10){
      c++;
    }
  }
  cout<<c<<endl;
}
 

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

ll pow(ll a, ll b) {
  if (b == 0) {
    return 1;
  } else if (b % 2 == 0) {
    ll d = pow(a, b / 2);
    return (d * d) % MOD;
  } else {
    ll d = pow(a, b - 1);
    return (a * d) % MOD;
  }
}

vector<ll> a(100001);

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

    if(a[0] == 1){
        if(n == 0){
            cout << 1 << endl;
        } else {
            cout << -1 << endl;
        }
        return 0;
    }

    ll ans = 0;
    vector<ll> pos(n+1,0);
    ll calc = 1;
    for(int i = 0; i <= n; i++){
        if(a[i] > calc || (i!=0 && (pos[i-1]*2 < a[i] || pos[i-1] == 0))){
            cout << -1 << endl;
            return 0;
        } else {
            if(i!=0){
                if(pos[i-1]-a[i] < INF/2){
                    pos[i] = pos[i-1]*2-a[i];
                } else {
                    pos[i] = pos[i-1]-a[i];
                }
                ans += a[i];
            } else {
                pos[i] = 1;
            }
        }
        if(calc < INF/2){
            calc *= 2;
        }
    }

    pos[n] = a[n];
    for(int i = n-1; i >= 0; i--){
        pos[i] = min(pos[i+1],pos[i]);
        ans += pos[i];
        pos[i] += a[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4816
s = input()
t = input()
y = []
for i in range(len(s)-len(t)+1):
    si = s
    for j in range(len(t)):
        if si[i+j] == '?':
            si = si[:i+j] + t[j] + si[i+j+1:]
        elif s[i+j] != t[j]: 
            break
    else: 
        for j in range(len(si)):
            if si[j] == '?':
                si =si[:j] + 'a' + si[j+1:]
        y.append(si)
y.sort()
if y == []:
    print('UNRESTORABLE')
else: print(y[0])
    

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#define C_NUM 37

int inputnumber(int *n){
	cin >> *n;
	return 0;
}

int inputcards(int n, char (*c)[3]){
	for(int i=0;i<n;i++)
		cin >> *(c+i);
	return 0;
}


int printcards(int n, char (*c)[3]){
	for(int i=0;i<n-1;i++)
		cout << *(c+i) << ' ';
	cout << *(c+n-1) << endl;
	return 0;
}

int printcards0(int n, char (*c)[3]){
	for(int i=0;i<n-1;i++)
		cout << *(c+i)[0] << ' ';
	cout << *(c+n-1)[0] << endl;
	return 0;
}

int printcards1(int n, char (*c)[3]){
	for(int i=0;i<n-1;i++)
		cout << c[i][1] << ' ';
	cout << c[n-1][1] << endl;
	return 0;
}



void strcopy(int n,char *b, char *a){
	for(int i=0;i<n;i++){
		b[i]=a[i];
	}
}

void swap(int n,int m, char (*c)[3]){
	char val[3];

	strcopy(3,val,c[n]);
	strcopy(3,c[n],c[m]);
	strcopy(3,c[m],val);
}

int bubblesort(int n,char (*a)[3]){
	int i,j;
	for(i=0;i<n;i++){
		for(j=n-1;j>=i+1;j--){
			if(a[j-1][1]>a[j][1]){
				swap(j-1,j,a);
			}
		}
	}
	return 0;
}

int selectionsort(int n,char (*a)[3]){
	int i,j,mini;
	for(i=0;i<n;i++){
		mini=i;
		for(j=i+1;j<n;j++){
			if(a[mini][1]>a[j][1]){
				mini=j;
			}
		}
		swap(i,mini,a);
	}

	return 0;
}

void cardcopy(int n,char (*b)[3],char (*a)[3]){
	for(int i=0;i<n;i++){
		strcopy(3,b[i],a[i]);
	}
}

int comparecards(int n,int i,int k,char c,char (*org)[3],char (*sorted)[3]){
	int j,m=0,check;
	char cd[4],d[4];

	for(j=0;j<=k;j++){
		cd[j]=sorted[i+j][0];
	}

	for(j=0;j<n && m<=4;j++){
		if(org[j][1]==c){
			d[m]=org[j][0];
			m++;
		}
	}

	check=0;
	for(j=0;j<m && check==0;j++){
		if(cd[j] != d[j])
			check=-1;
	}

	return check;
}



int checkstable(int n,char (*org)[3],char (*sorted)[3]){
	int i,k,check=0;
	char c;
	for(i=0;i<n && check==0;i++){
		c=sorted[i][1];
		k=0;
		if(c==sorted[i+1][1]){
			k++;
			while(c==sorted[i+1+k][1] && i+1+k<n)
				k++;
			check = comparecards(n,i,k,c,org,sorted);

		}
		i+=k;
	}
	return check;
}

void printstable(int n){
	if(n==0)
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;
}

int main() {
	int n,check;
	char card[C_NUM][3];
	char card1[C_NUM][3];
	char card2[C_NUM][3];

	inputnumber(&n);
	inputcards(n,card);
	cardcopy(n,card2,card);
	cardcopy(n,card1,card);
	//printcards(n,card);
	//printcards(n,card2);

	bubblesort(n,card1);
	check=checkstable(n,card,card1);
	printcards(n,card1);
	printstable(check);

	selectionsort(n,card2);
	check=checkstable(n,card,card2);
	printcards(n,card2);
	printstable(check);

	//cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
	return 0;
}



Measured memory_bytes: 3088
import java.util.*;

public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = sc.nextInt();
	int t,s,y;


	if(a>b){
	  t = a;
	  a = b;
	  b = t;

	   if(b>c){
	      s = b;
	      b = c;
	      c = s;

	       if(a>b){
         	 y = b;
	 	 b = a;
	 	 a = y;
	       }
           }
        }

	if(a==c){
	  t = b;
	  b = c;
	  c = t;
	 } 

	System.out.println(a+" "+b+" "+c);

  }
}

Measured memory_bytes: 26280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
const string yes = "Yes";
const string no = "No";

bool f(string s) {
  int len = s.length();
  if (len==1) return true;
  for (int i=0; i<len/2; i++) {
    if (s[i]!=s[len-i-1]) {
      return false;
    }
  }
  return true;
}

int main()
{
  string s;
  cin >> s;
  int n = s.length();
  if (!f(s)) {
    cout << no << endl;
    return 0;
  }
  if (!f(s.substr(0, n/2))) {
    cout << no << endl;
    return 0;
  }
  if (!f(s.substr(n/2+1, n/2))) {
    cout << no << endl;
    return 0;
  }
  cout << yes << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL << 60;    // 1.15x10^18
using edge = pair<int, long long>;
using Graph = vector<vector<edge>>;
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; }

Graph g;
vector<long long> a, b;
vector<bool> seen;
void dfs(int u) {
    seen[u] = true;
    for (auto &p: g[u]) {
        int v = p.first; long long s = p.second;
        if (seen[v]) continue;
        a[v] = -a[u];
        b[v] = s - b[u];
        dfs(v);
    }
}

int main() {
    int n, m; cin >> n >> m;
    g.resize(n);
    while (m--) {
        int u, v, s; cin >> u >> v >> s; u--, v--;
        g[u].emplace_back(v, s);
        g[v].emplace_back(u, s);
    }
    a.resize(n);
    b.resize(n);
    seen.resize(n);
    a[0] = 1, b[0] = 0;
    dfs(0);
    long long l = 1LL, r = INF, x = -1;
    for (int u = 0; u < n; u++) {
        if (a[u] == 1) chmax(l, 1 - b[u]);
        else chmin(r, b[u] - 1);
        for (auto &p: g[u]) {
            int v = p.first; long long s = p.second;
            long long num = a[u] + a[v];
            long long den = b[u] + b[v];
            if (num == 0) {
                if (den != s) return !(cout << 0 << endl);
            } else {
                if ((s - den) % 2) return !(cout << 0 << endl);
                long long x0 = (s - den) / num;
                if (x0 <= 0) return !(cout << 0 << endl);
                if (x == -1) x = x0;
                if (x != x0) return !(cout << 0 << endl);
            }
        }
    }
    if (x == -1) cout << max(0LL, r - l + 1) << endl;
    else {
        if (l <= x && x <= r) cout << 1 << endl;
        else cout << 0 << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;


typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

template <typename ... Args>
std::string format(const std::string& fmt, Args ... args )
{
    size_t len = std::snprintf( nullptr, 0, fmt.c_str(), args ... );
    std::vector<char> buf(len + 1);
    std::snprintf(&buf[0], len + 1, fmt.c_str(), args ... );
    return std::string(&buf[0], &buf[0] + len);
}

typedef pair<int,pair<ll,ll>> P;
bool cmp(const P& i, const P& j) {
     if(i.second.first == j.second.first)
        return i.second.second < j.second.second;
     return i.second.first < j.second.first;
}
int main() {
    ll n,m;

    vector<P> py;

    cin>>n>>m;
    REP(i,m){
        ll p,y;
        cin>>p>>y;
        py.emplace_back(P(i, pair<ll,ll>(p,y)));
    }

    sort(ALL(py), cmp);
    // REP(i,m){
    //     DEBUG(py[i].second.first);
    //     DEBUG(py[i].second.second);
    // }

    vector<string> ans(m);
    int pp = -1;
    int cnt = 0;
    REP(i,m){
        if(pp == py[i].second.first)
            cnt += 1;
        else
            cnt = 1;
        
        ans[py[i].first] = format("%06d%06d", py[i].second.first, cnt);
        pp = py[i].second.first;
    }

    REP(i,m){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 9712
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;




ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}



void oneCase () {
    int a, b;
    cin >> a >> b;
    for (int i = 0; i < max(a, b); ++i) {
        cout << min(a, b);
    }
    cout << "\n";

}




int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//
//using namespace std;
//
//int a[510][510],dp[510][510];
//int main()
//{
//    int n,m,q;
//    while(scanf("%d%d%d",&n,&m,&q)==3){
//        memset(a,0,sizeof(a));
//        memset(dp,0,sizeof(dp));
//        int l,r;
//        for(int i=0;i<m;i++){
//            scanf("%d%d",&l,&r);
//            a[l][r]++;
//        }
//        for(int i=n;i>0;i--){
//            for(int j=1;j<=n;j++){
//                dp[i][j]=a[i][j]+dp[i+1][j]+dp[i][j-1]-dp[i+1][j-1];
//            }
//        }
//        while(q--){
//            scanf("%d%d",&l,&r);
//            printf("%d\n",dp[l][r]);
//        }
//    }
//    return 0;

#include <bits/stdc++.h>

using namespace std;


int main()
{
    int n,m,q;
    while(scanf("%d%d%d",&n,&m,&q)==3){
        int sum[510][510];
        int l,r;
        while(m--){
            scanf("%d%d",&l,&r);
            for(int i=r;i<=n;i++){
                sum[l][i]++;
            }
        }
        while(q--){
            scanf("%d%d",&l,&r);
            int ans=0;
            for(int i=l;i<=r;i++){
                ans+=sum[i][r];
            }
            printf("%d\n",ans);
        }
    }
    return 0;
}


Measured memory_bytes: 1920
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
llint LBI(vector<llint>&ar,llint in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint UBI(vector<llint>&ar,llint in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int i,j,n,da,db;cin>>n>>da>>db;
	int sa=1,sb=1;
	while(da%4==0){da/=4;sa*=2;}
	while(db%4==0){db/=4;sb*=2;}
	int deta=0;
	for(i=0;i<n+n;i++){
		for(j=0;j<n+n;j++){
			if(deta>=n*n){return 0;}
			int ia=i/sa,ja=j/sa,ib=i/sb,jb=j/sb;
			if(da%2){ia+=ja;}
			if(db%2){ib+=jb;}
			if(ia%2==0&&ib%2==0){cout<<i<<" "<<j<<endl;deta++;}
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=1;i<=n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
using namespace std;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef pair<ll,ll> P;
int main(){
    int a,b; cin >> a >> b;
    int c = b-a;
    int aa = c*(c-1)/2;
    int ans = aa-a;
    cout << ans;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string n;
    cin >> n;
    if (n.size() == 1) {
        cout << n << "\n";
        return 0;
    }
    bool nine = true, n0 = n[0] == '9';
    for (int i = 1; i < (int)n.size(); ++i) {
        if (n[i] != '9') {
            nine = false;
        }
    }
    if (nine && n0)
        cout << 9 * n.size() << "\n";
    else if (nine && !n0)
        cout << n[0] - '0' + 9 * (n.size() - 1) << "\n";
    else
        cout << n[0] - '0' - 1 + 9 * (n.size() - 1) << "\n";
    return 0;
}

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

#define INF 1e9
#define PI 3.141592653589793238
typedef long long ll;

int main() {
    ll n;cin>>n;
    ll a[n];
    int flag=0;
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a, a+n);
    for(int i=0; i<n-1; i++){
        if(a[i]==a[i+1]) flag=1;
    }
    if(flag==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}

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


#define MAX 1000


int main()
{
	int  buf_len,i, j,cnt = 0, len_max = 0,cnt_max=0;
	char str[MAX][32];
	char buf[32] = { 0 }, word_count_max[32] = { 0 }, word_length_max[32] = {0};
	char ch;

	while (1)
	{
		j = 1;
		scanf("%s", buf);
		strcpy(str[cnt], buf);                
		buf_len=strlen(buf);
		if (buf_len > len_max)
		{
			len_max = buf_len;
			strcpy(word_length_max, buf);       //word_length_max = buf;
		}

		for (i = 0; i < cnt; i++)
		{
			if (strcmp(str[i], buf)==0)
			{
				++j;
			}
		}
		if (j> cnt_max)
		{
			cnt_max = j;
			strcpy(word_count_max, buf);       //word_length_max = buf;
		}
		++cnt;
		if ((ch = getchar()) == '\n')
		{
			break;
		}
	}

	printf("%s %s\n",word_count_max,word_length_max);
	
	return 0;
}


Measured memory_bytes: 572
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

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

    ll ans = 1LL << 60LL;
    int cnt = 0;
    ll mod1 = 1;
    ll mod2 = 0;
    while (cnt < 2)
    {
        ll acc = 0;
        ll res = 0;

        for (int i = 0; i < n; i++)
        {
            acc += a[i];
            if (i % 2 == mod2 & acc >= 0)
            {
                res += abs(acc) + 1;
                acc = -1;
            }
            if (i % 2 == mod1 & acc <= 0)
            {
                res += abs(acc) + 1;
                acc = 1;
            }
        }
        ans = min(ans, res);
        swap(mod1, mod2);
        cnt++;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,t;
    cin >> n >> t;
    vector<P> a(n);
    for (int i = 0;i < n;++i) cin >> a[i].first >> a[i].second;
    vector<vector<int>> dp(n+1,vector<int>(t+1,0));
    sort(a.begin(),a.end());
    for (int i = 0;i < n;++i) {
        dp[i+1] = dp[i];
        for (int j = 0;j < t;++j) dp[i+1][min(t,j+a[i].first)] = max(dp[i+1][min(t,j+a[i].first)],dp[i][j]+a[i].second);
    }
    cout << *max_element(dp[n].begin(),dp[n].end()) << endl;
    // for (int i = 0;i < n+1;++i) p_ary(dp[i],0,t+1);
}

Measured memory_bytes: 35584
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#include <bitset>
#include <cmath>
#include <utility>
#define Maxn 100005
#define Maxm 1000005
#define lowbit(x) x&(-x)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define PI acos(-1.0)
#define LL long long 
#define Inf (1LL<<62)
#define inf 0x3f3f3f3f
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
using namespace std;
int main()
{
	int n,x,cnt,color[10];
	//input;output;
	while(cin>>n)
	{
		cnt=0;
		memset(color,0,sizeof(color));
		for(int i=0;i<n;i++)
		{
			cin>>x;
			if(x<400)
				color[0]++;
			else if (x<800)
				color[1]++;
			else if(x<1200)
				color[2]++;
			else if(x<1600)
				color[3]++;
			else if(x<2000)
				color[4]++;
			else if(x<2400)
				color[5]++;
			else if(x<2800)
				color[6]++;
			else if(x<3200)
				color[7]++;
			else
				color[8]++;
		}
		for(int i=0;i<8;i++)
			if(color[i]==0)
				cnt++;
		if(color[8]==0)
			cout<<8-cnt<<" "<<8-cnt<<endl;
		else if(cnt!=8)
			cout<<8-cnt<<" "<<8-cnt+color[8]<<endl;
		else 
			cout<<1<<" "<<n<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
c_list = []
if N % 2 ==0:
    for i in range(1, int((N+2)/2)):
        A = i
        a1 = A//10**5
        a2 = (A - 10**5*a1)//10**4
        a3 = (A-10**5*a1-10**4*a2)//10**3
        a4 = (A-10**5*a1-10**4*a2-10**3*a3)//10**2
        a5 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4)//10
        a6 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4-10*a5)
        B = N - i
        b1 = B//10**5
        b2 = (B - 10**5*b1)//10**4
        b3 = (B-10**5*b1-10**4*b2)//10**3
        b4 = (B-10**5*b1-10**4*b2-10**3*b3)//10**2
        b5 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4)//10
        b6 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4-10*b5)
        C = a1+a2+a3+a4+a5+a6+b1+b2+b3+b4+b5+b6
        c_list.append(C)
else:
    for i in range(1, int((N+1)/2)):
        A = i
        a1 = A//10**5
        a2 = (A - 10**5*a1)//10**4
        a3 = (A-10**5*a1-10**4*a2)//10**3
        a4 = (A-10**5*a1-10**4*a2-10**3*a3)//10**2
        a5 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4)//10
        a6 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4-10*a5)
        B = N - i
        b1 = B//10**5
        b2 = (B - 10**5*b1)//10**4
        b3 = (B-10**5*b1-10**4*b2)//10**3
        b4 = (B-10**5*b1-10**4*b2-10**3*b3)//10**2
        b5 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4)//10
        b6 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4-10*b5)
        C = a1+a2+a3+a4+a5+a6+b1+b2+b3+b4+b5+b6
        c_list.append(C)
print(min(c_list))

Measured memory_bytes: 3672
import java.util.*;
import java.io.*;
import static java.lang.System.*;

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int sum[] = new int[100010];
    for(int i=3; i<100000; i+=2){
      sum[i] = sum[i-2];
      if(prime(i) && prime((i+1) / 2) ) sum[i]++;
    }
    int Q = sc.nextInt();
    for(int i=0; i<Q; i++){
      int l = sc.nextInt();
      int r = sc.nextInt();
      if(l == 1) out.println(sum[r]);
      else out.println(sum[r] - sum[l-2]);
    }
  }
    
  public static boolean prime(int n){
    for(int i=2; i*i<=n; i++){
      if(n % i == 0) return false;
    }
    return true;
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

Measured memory_bytes: 41516
#include <iostream>

using namespace std;

int main() {

    for (int i = 0; i < 9; ++i) {
        for (int j = 0; j < 9; ++j) {
            int n1 = i + 1;
            int n2 = j + 1;
            cout << to_string(n1) + "x" + to_string(n2) + "=" + to_string(n1 * n2) << endl;

        }
    }

    return 0;
}

Measured memory_bytes: 3228
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, l int
	fmt.Scanf("%d %d", &n, &l)

	var apl = make([]int, n)

	for i := range apl {
		apl[i] = l + i
	}

	absMin := int(math.Abs(float64(apl[0])))
	minOrg := apl[0]

	for i := 0; i < n; i++ {
		if int(math.Abs(float64(apl[i]))) < absMin {
			minOrg = apl[i]
			absMin = int(math.Abs(float64(apl[i])))
		}
	}

	sum := 0

	for i := 0; i < n; i++ {
		sum += apl[i]
	}

	fmt.Println(sum - minOrg)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch DDCCFinals | diff DDCCFinals.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address DDCCFinals.cpp && ./a.out

/*
 
 11/23/2019
 
 4:00-
 
 */

int X,Y;

VI A={0,300000,200000,100000};
void solve() {
  int res=0;
  if(X<SZ(A)) res=A[X];
  if(Y<SZ(A))res+=A[Y];
  if(X==1&&Y==1) {
    res+=400000;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>X>>Y;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const ll inf = 1e16 + 7;
const int N = 1e3 + 5;
const double eps = 1e-9;
vii adj[N];
ll dp[N], dp2[N];

int main() {
  int n, m; scanf("%d %d", &n, &m);
  for (int i =1; i <= m; i++) {
    int u, v, w; scanf("%d %d %d", &u, &v, &w);
    adj[u].pb({v, -w});
  }
  for (int i = 1; i <= n; i++)
    dp[i] = inf;
  dp[1] = 0;
  vector<ll> arr;
  for (int i = 1; i <= 2*m; i++) {
    int fl = 0;
    for (int j = 1; j <= n; j++)
      dp2[j] = dp[j];
    for (int j = 1; j <= n; j++)
      trav(v, adj[j])
        if (dp2[v.st] > dp[j] + (ll)v.nd)
          dp2[v.st] = dp[j] + (ll)v.nd, fl = 1;
    swap(dp2, dp);
    arr.pb(dp[n]);
    if (!fl) break;
    if (i == 2*m) {
      if (dp[n] == arr[m-1])
        break;
      printf("inf\n");
      return 0;
    }
  }
  printf("%lld\n", -dp[n]);
  return 0;
}


Measured memory_bytes: 384
import sys


def _i(): return int(sys.stdin.readline().strip())


class Bigint:
    def __init__(self, n, mod=10**9+7):
        self.n = n % mod
        self.mod = mod
        return

    def __str__(self):
        return str(self.n)

    def __add__(self, other):
        ot = type(other)
        if ot == Bigint:
            return Bigint(self.n+other.n, self.mod)
        elif ot == int:
            return Bigint(self.n+other, self.mod)
        else:
            raise ValueError("Invalid type")

    def __iadd__(self, other):
        return self.__add__(other)

    def __sub__(self, other):
        ot = type(other)
        if ot == Bigint:
            o = other.n
        elif ot == int:
            o = other
        else:
            raise ValueError("Invalid type")
        #
        return Bigint(self.n - o, self.mod)

    def __isub__(self, other):
        return self.__sub__(other)

    def __mul__(self, other):
        ot = type(other)
        if ot == Bigint:
            return Bigint(self.n*other.n, self.mod)
        elif ot == int:
            return Bigint(self.n*other, self.mod)
        else:
            raise ValueError("Invalid type")

    def __imul__(self, other):
        return self.__mul__(other)

    def __pow__(self, other):
        assert type(other) == int, "power should be integer"
        #
        if other < 0:
            return self ** (other % (self.mod-1))
        ret = Bigint(1, self.mod)
        now = Bigint(self.n, self.mod)
        while other > 0:
            if other % 2 == 0:
                pass
            else:
                ret *= now
            other //= 2
            now *= now
        return ret

    def __truediv__(self, other):
        ot = type(other)
        if ot == Bigint:
            o = other
        elif ot == int:
            o = Bigint(other)
        else:
            raise ValueError("Invalid type")

        self *= (o ** (o.mod-2))
        return self

    def __itruediv__(self, other):
        return self.__truediv__(other)


def factorial(n):
    fact = [Bigint(1)]
    for i in range(n):
        fact.append(fact[i]*(i+1))
    return fact


def i_factorial(n, nf):
    ifact = [None] * (n+1)
    ifact[n] = nf
    for i in range(n-1, -1, -1):
        ifact[i] = ifact[i+1] * (i+1)
    return ifact


def main():
    n = _i()
    fact = factorial(n)
    ifact = i_factorial(n, fact[-1]**-1)

    cnt = Bigint(0)
    for bou in range(n//3):
        maru = n - 3 * (bou+1)
        tot = maru + bou
        cnt += (fact[tot] * ifact[maru] * ifact[bou])
    return cnt


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 67868
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int a,b; cin>>a>>b; 
    int s=0,r;
    while (a%4) s = s^a, a++;
    r = (b+1)%4;
    for (int i=r;i>0;i--) s = s^(b--);
    cout << s << endl;

}
// 1 2 0 4 7 8 0

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3596
//
// Created by Myabu on 2020/01/17.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>

using namespace std;


int main(void){
    int N;
    int A[110];
    cin>>N;
    for (int i = 0; i < N; ++i) {
        cin>>A[i];
    }

    sort(A, A+N);

    cout<<abs(A[0]-A[N-1])<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


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


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

int main() {
  string S;
  cin >> S;
  if (S.at(0) == S.at(1) && S.at(1) == S.at(2) ) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


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

using namespace std;

const int N = 305, mod = 1e9 + 7;

int n, m, l[N], r[N], col[N], q[N], ans, dp[N][N][N];

bool cmp(int x, int y) {
    if (r[x] != r[y]) return r[x] < r[y];
    return l[x] < l[y];
}

int main() {
    cin >> n >> m;
    for (int i = 1; i <= m; i++)  {
        cin >> l[i] >> r[i] >> col[i];
        q[i] = i;
    }
    sort (q + 1, q + m + 1, cmp);
    dp[1][0][0] = 3;
    int now = 1;
    for (int i = 1; i <= n; i++) {
        int pos1 = 0, pos2 = 0, pos3 = 0, st1 = n + 1, st2 = n + 1, st3 = n + 1;
        while (now <= m && r[q[now]] < i) now++;
        while (now <= m && r[q[now]] == i) {
            if (col[q[now]] == 1) pos1 = l[q[now]];
            if (col[q[now]] == 2) pos2 = l[q[now]];
            if (col[q[now]] == 3) pos3 = l[q[now]];
            if (col[q[now]] == 1 && st1 > n) st1 = l[q[now]];
            if (col[q[now]] == 2 && st2 > n) st2 = l[q[now]];
            if (col[q[now]] == 3 && st3 > n) st3 = l[q[now]];
            now++;
        }
        for (int j = 0; j <= i; j++) {
            for (int k = 0; k <= j; k++) {
                if (j >= st1 || j < pos2 || k >= st2 || k < pos3) dp[i][j][k] = 0;
                dp[i + 1][j][k] = (dp[i + 1][j][k] + dp[i][j][k]) % mod;
                if (j == 0) {
                    dp[i + 1][i][k] = (dp[i + 1][i][k] + dp[i][j][k] * 2) % mod;
                }
                else {
                    dp[i + 1][i][k] = (dp[i + 1][i][k] + dp[i][j][k]) % mod;
                    dp[i + 1][i][j] = (dp[i + 1][i][j] + dp[i][j][k]) % mod;
                }
                if (i == n) ans = (ans + dp[i][j][k]) % mod;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 59128
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

x,y,a,b,c=mii()

p=deque(list(reversed(sorted(limii(),reverse=True)[:x])))
q=deque(list(reversed(sorted(limii(),reverse=True)[:y])))
r=deque(sorted(limii(),reverse=True))
pp=p.popleft()
qq=q.popleft()
rr=r.popleft()
for i in range(c):
    if pp>qq:
        if qq<rr:
            q.append(rr)
            if i!=c-1:
                rr=r.popleft()
            qq=q.popleft()
    else:
        if pp<rr:
            p.append(rr)
            if i!=c-1:
                rr=r.popleft()
            pp=p.popleft()
p.append(pp)
q.append(qq)
print(sum(list(p))+sum(list(q)))
        
        


Measured memory_bytes: 119708
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();

		int l = N.length();
		int[] H = new int[l];
		int sum = 0;

		for(int i=0; i<l; i++) {
			H[i] = Character.getNumericValue(N.charAt(i));
			sum += H[i];
		}

		if(Integer.parseInt(N)%sum == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	char c;
	map<char, int> cnt;
	rep(i,h)rep(j,w){
		cin >> c;
		cnt[c]++;
	}
	int two = 0, four = 0;
	for(auto p : cnt){
		four += p.second / 4;
		p.second %= 4;
		two += p.second / 2;
		p.second %= 2;
	}
	bool yes = true;
	if(four < (h/2)*(w/2)) yes = false;
	else four -= (h/2)*(w/2);
	two += four*2;
	if(two < ((h*w) - (h/2)*(w/2)*4)/2) yes = false;
	cout << (yes ? "Yes" : "No") << endl;
	return 0;
}


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

int  main()
{
	long a,b; cin >> a >> b;
	long g = max(a,b);
	long ans = -1;
	for (int i = 0; i <= g; i++)
	{
		if (labs(a-i) == labs(b-i))
		{
			ans = i;
			break;
		}
	}
	if (ans == -1)
		cout << "IMPOSSIBLE\n";
	else
		cout << ans << endl;
	return (0);
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;

// https://atcoder.jp/contests/abc174/submissions/15644479 のテスト
public class Main {
	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] first = br.readLine().split(" ", 2);
 		int n = Integer.parseInt(first[0]);
		int q = Integer.parseInt(first[1]);
		String[] nums = br.readLine().split(" ", n);
		Query[] queries = new Query[q];
		for (int i = 0; i < q; i++) {
		    String[] line = br.readLine().split(" ", 2);
		    queries[i] = new Query(i, Integer.parseInt(line[0]), Integer.parseInt(line[1]));
		}
		Arrays.sort(queries);
		int[] idxes = new int[n + 1];
		BinaryIndexedTree bit = new BinaryIndexedTree(n + 1);
		int[] ans = new int[q];
		int idx = 0;
		for (int i = 0; i < n; i++) {
		    int y = Integer.parseInt(nums[i]);
		    if (idxes[y] > 0) {
		        bit.add(idxes[y], - 1);
		    }
		    bit.add(i + 1, 1);
		    idxes[y] = i + 1;
		    while (idx < q && queries[idx].right == i + 1) {
		        ans[queries[idx].idx] = bit.getSum(queries[idx].left, queries[idx].right);
		        idx++;
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int x : ans) {
		    sb.append(x).append("\n");
		}
		System.out.print(sb);
	}
	
	static class Query implements Comparable<Query> {
	    int idx;
	    int left;
	    int right;
	    
	    public Query(int idx, int left, int right) {
	        this.idx = idx;
	        this.left = left;
	        this.right = right;
	    }
	    
	    public int compareTo(Query another) {
	        return right - another.right;
	    }
	}
}
 
class BinaryIndexedTree {
    int size;
    int[] tree;
    
    public BinaryIndexedTree(int size) {
        this.size = size;
        tree = new int[size];
    }
    
    public void add(int idx, int value) {
        int mask = 1;
        while (idx < size) {
            if ((idx & mask) != 0) {
                tree[idx] += value;
                idx += mask;
            }
            mask <<= 1;
        }
    }
    
    public int getSum(int from, int to) {
        return getSum(to) - getSum(from - 1);
    }
    
    public int getSum(int x) {
        int mask = 1;
        int ans = 0;
        while (x > 0) {
            if ((x & mask) != 0) {
                ans += tree[x];
                x -= mask;
            }
            mask <<= 1;
        }
        return ans;
    }
}

Measured memory_bytes: 107400
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int a, b; cin >> a >> b;
    cout << (a + b) % 24 << "\n";
    return 0;
}

Measured memory_bytes: 256