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

using namespace std;

int N, K, mask[22][22], dp[22][(1 << 21) + 10], finalCount[(1 << 21) + 10], firstAppearance[2][(1 << 21) + 10], length[(1 << 21) + 10];
char sir[(1 << 21) + 2];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d\n", &N, &K);
for (int l=0; l<=N; l++)
{
    scanf ("%s", sir);
    for (int j=0; j<(1 << l); j++)
    {
        if (sir[j] == '1')
            dp[0][j | (1 << l)] ++;
        length[j | (1 << l)] = l;
    }
}
for (int i=0; i<(1 << (N + 1)); i++)
{
    firstAppearance[0][i] = firstAppearance[1][i] = -1;
    bool bit = i & 1;
    firstAppearance[bit][i] = i >> 1;
    if (firstAppearance[bit ^ 1][i >> 1] != -1)
        firstAppearance[bit ^ 1][i] = firstAppearance[bit ^ 1][i >> 1];
}
for (int i=0; i<=N + 1; i++)
    for (int j=i; j<=N + 1; j++)
        for (int k=i; k<=j; k++)
            mask[i][j] |= 1 << k;
for (int i=0; i<=N; i++)
    for (int j=1; j<(1 << (N + 1)); j++)
        if (dp[i][j] > 0)
        {
            int L = length[j], before = j & (i == 0 ? 0 : mask[0][i - 1]), after = (j & mask[i][L]) >> i;
            finalCount[before | (1 << i)] += dp[i][j];
            if (i < N)
            {
                for (int k=0; k<2; k++)
                    if (firstAppearance[k][after] > 0)
                    {
                        int newBefore = before, newAfter = firstAppearance[k][after];
                        if (k) newBefore |= 1 << i;
                        dp[i + 1][newBefore | (newAfter << (i + 1))] += dp[i][j];
                    }
            }
        }
int maxL = 0, how = 0;
for (int i=1; i<(1 << (N + 1)); i++)
    if (finalCount[i] >= K && length[i] > maxL)
        maxL = length[i], how = i;
    else
    if (finalCount[i] >= K && length[i] == maxL)
    {
        for (int k=maxL - 1; k>=0; k--)
            if (((i >> k) & 1) ^ ((how >> k) & 1))
            {
                if (how & (1 << k))
                    how = i;
                break;
            }
    }
for (int i=maxL - 1; i>=0; i--)
    if (how & (1 << i)) printf ("1");
    else printf ("0");
printf ("\n");
return 0;
}


Measured memory_bytes: 206208
///----> bismillahir rahmanir rahim <---- -- { ^ _ ^ }
///     { ^_^ }   { ^ _ ^ }
#include<bits/stdc++.h>
#include<bits/stdc++.h>
using namespace std;

//<--------------------------------------------typo section--------------------------------------------->
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;
typedef priority_queue<int>piwi;
typedef queue<int>kiwi;
typedef map<int,int>mi;
typedef map<string,int>mis;
typedef multimap<int,int>muli;
typedef multimap<string,int>muls;
typedef multiset<int>si;

//<----------------------------------------------------Narcos----------------------------------------------->
#define endl "\n"
#define Y cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define sp " "
#define PB push_back
#define F first
#define S second
#define as(a) (a).begin(),(a).end()
#define ras(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define ki 1LL
#define MOD 1000000007
#define over return 0;
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define test int t;cin>>t;while(t--)


//<-----------------------------------------------------Const--------------------------------------------------->
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;


//<--------------------------------------------------------------------------------------------------->
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

const long long MAX_SIZE = 1000001; vector<long long >isprime(MAX_SIZE , true); vector<long long >prime; vector<long long >SPF(MAX_SIZE); void manipulated_seive(int N) { isprime[0] = isprime[1] = false ; for (long long int i=2; i<N ; i++) { if (isprime[i]) { prime.push_back(i); SPF[i] = i; } for(int j=0;j < (int)prime.size() && i*prime[j] < N && prime[j] <= SPF[i]; j++) { isprime[i*prime[j]]=false; SPF[i*prime[j]] = prime[j] ; } } }
int man_seive(int n){ manipulated_seive(n); for(int i=0;i<prime.size() && prime[i]<=n;i++)
cout<<prime[i]<<endl;
}
ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }

//continue;

//-----------------------------> YOUR JOURNEY STARTS HERE ------------------------------------>>

int main(){
    optimize();
    int n;
    cin>>n;
    string h;cin>>h;
    string l;cin>>l;
    string ans;
    for(int i=0;i<n;i++){
        ans+=h[i];
        ans+=l[i];
    }
    cout<<ans<<endl;

over
}


Measured memory_bytes: 18624
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
#include <map>
#include <set>
using namespace std;
#define ForInt(i, n) for (int i = 0; i < (n); ++i)
#define ForIntInit(i, begin, n) for (int i = (begin); i < (n); ++i)
#define ForItr(it, begin, end) for (auto it = (begin); it != (end); ++it)
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;

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


int main()
{
    int64 a, b;
    cin >> a >> b;
    if (a < b)
    {
        int64 tmp = a;
        a = b;
        b = tmp;
    }
    int64 g = gcd(a, b);

    int64 factMax = (int64)sqrt(g);
    set<int64> factors;
    ForIntInit(i, 2, factMax + 1)
    {
        bool divided = false;
        while (g % i == 0)
        {
            g /= i;
            divided = true;
        }
        if (divided)
        {
            factors.insert(i);
        }
    }
    factors.insert(g);
    factors.insert(1);

    cout << factors.size() << endl;

    return 0;
}


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

const int N = 505;
int n;
int a[N][N];
ll w[N][N], v[N][N], f[N][N];

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

inline ll calc(int a, int b, int c) { return w[b][c] - w[a - 1][c]; }

int main() {
	n = read();
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j)
			if(i ^ j)	a[i][j] = read();
	for(int i = 1; i <= n; ++i)
		for(int j = n; j >= i + 1; --j) {
			w[i][j] = w[i][j + 1];
			for(int k = 1; k <= i; ++k)	w[i][j] += a[j][k];
		}
	for(int i = 1; i <= n; ++i)
		for(int j = i + 1; j <= n + 1; ++j) {
			v[i][j] = v[i][j - 1];
			for(int k = i; k <= j - 1; ++k)	v[i][j] += a[k][j];
		}
	memset(f, 0x3f, sizeof(f));
	f[0][0] = 0;
	for(int i = 0; i <= n; ++i)
		for(int j = i; j <= n; ++j)
			if(f[i][j] < 1e18)
				for(int k = j + 1; k <= n + 1; ++k)
					f[j][k] = min(f[j][k], f[i][j] + v[j + 1][k] + calc(i + 1, j, k + 1));
	ll ans = 1e18;
	for(int i = 0; i <= n; ++i)	ans = min(ans, f[i][n + 1]);
	printf("%lld\n", ans);
	return 0;
}

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

int N;
vector<int> h;
vector<int> arr;

int dp(int i)
{
    if(arr[i] != -1)
        return arr[i];
    else if(i == N-1)
        return arr[i] = abs(h[i+1] - h[i]) + dp(i+1);
    else
        return arr[i] =  min(abs(h[i+1] - h[i]) + dp(i+1) , abs(h[i+2] - h[i]) + dp(i+2));
}

int main()
{
    cin>>N;
    h.resize(N+1);

    for(int i=1 ; i<=N ; i++)
        cin>>h[i];

    arr.resize(N+1,-1);

    arr[N] = 0;

    cout<<dp(1);
}


Measured memory_bytes: 4096
try:
    N_s,M_s=input().split(' ')
    N=int(N_s)
    M=int(M_s)
    
    if N>=1 and N<=100 and M>=1 and M<=100:
        votes=input().split(' ')
        counter=0
        vote = [int(i) for i in votes]
        summer=sum(vote)
        percent=summer/(4*M)
        for i in votes:
            if int(i)>=percent:
                counter+=1
        if counter>=M:
            print('Yes')
        else :
            print('No')
        
except Exception as e:
    print(e)

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

int main()
{
    vector <string> v;
    v.push_back("SUN");
    v.push_back("MON");
    v.push_back("TUE");
    v.push_back("WED");
    v.push_back("THU");
    v.push_back("FRI");
    v.push_back("SAT");
    string S;
    cin>>S;
    int counter;
    for(int i=0 ; i<v.size() ; i++)
    {
        if(S==v[i])
        {
            int j=i;
            counter = v.size()-j;
        }
    }
    cout<<counter<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int N;
    cin >> N;
    
    cout << 180*(N-2) << endl;
    return 0;
}


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

int main(void) {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	int X = (A + D - 1) / D;
	int Y = (C + B - 1) / B;

	if (X >= Y) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <iomanip>
#include <set>
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define SORT(s) sort((s).begin(),(s).end())

// UnionFind
// coding: https://youtu.be/TdR816rqc3s?t=726
// comment: https://youtu.be/TdR816rqc3s?t=6822
struct UnionFind{
    //ノード情報のベクトル。
    //各ノードは親のノードを指す。
    //根なら木のサイズを負にして入れる。
    vector<int> d;
    //コンストラクタ dをn個の要素でそれぞれサイズ-1で初期化
    UnionFind(int n=0): d(n,-1){}
    //属する木のグループ番号を返す
    //実態は属する木の根のノード番号
    int find(int x){
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    //木の併合
    //木のサイズが小さい方を大きい方にくっつける
    //長いものにまかれにいく
    //木が深くならなくなる
    bool unite(int x, int y){
        //所属するグループの検索
        x = find(x); y = find(y); 
        //すでに所属グループが同じ
        if(x==y) return false;
        //xを大きいサイズのグループに設定する
        if(-d[x] < -d[y]) swap(x,y);
        //大きいグループxに小さいグループyをくっつける
        d[x] += d[y];
        //グループyの親をxにする
        d[y] = x;
        return true;
    }
    //ノードxとノードyが同じグループか判定する
    bool same(int x, int y) { return find(x) == find(y);}
    //所属するグループのサイズを返す
    int size(int x) { return -d[find(x)];}
};

int main(){
    ll N,M; cin >> N >> M;

    UnionFind tree(N);
    REP(i,M){
        int a,b;
        cin >> a >> b;
            tree.unite(a-1,b-1);
    }
    int ans = 0;
    REP(i,N){
        ans = max(ans,tree.size(i));
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4020
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.ArrayList;

public class Main {

  public static void main(String[] args) throws IOException {
	  Scanner in = new Scanner(System.in);
	  int n = in.nextInt();
	  long k = in.nextLong();
	  int[] visit = new int[n];
	  int[] node = new int[n];
	  for(int i=0; i<n; i++) {
		  node[i]=in.nextInt();
	  }
	  int count = 0;
	  int current = 1;
	  long loop = k-1;
	  while(loop>0) {
		  count++;
		  if(visit[current-1]==0) {
			  visit[current-1]=count;
			  current = node[current-1];
			  //System.out.println(current);
		  }else {
			  int cycle = count-visit[current-1];
			  //System.out.println("count: "+count);
			  //System.out.println("cycle: "+cycle);
			  int remain = visit[current-1]-1;
			  //System.out.println("remain: "+remain);
			  long target = ((k-remain) % cycle);
			  //System.out.println("target: "+target);
			  for(int i=0; i<n; i++) {
				  if(visit[i]==target+1+remain) {
					  System.out.print(i+1);
					  System.exit(0);
				  }
			  }
		  }
		  loop--;	  
	  }
	  System.out.print(node[current-1]);
      
  }
}

Measured memory_bytes: 61052
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
typedef long long ll;


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  vector<int> dishes(5);

  int mini_red = 10; int last = 0; int count = 1;
  rep(i, 5) {
      cin >> dishes[i];
      if (i != 0)
      {
          /* code */
          if (dishes[i-1] == dishes[i])
          {
              /* code */
              count++;
          }
      }
      
      if (dishes[i]%10 != 0 &&
          mini_red > dishes[i]%10)
      {
          /* code */
          mini_red = dishes[i]%10;
          last = dishes[i];
      }
  }

  int ans = 0;
  rep(i, 5) {
      if (dishes[i] != last)
      {
          /* code */
          ans += (dishes[i] + 10 - 1)/10 * 10;
      }
  }
  cout << ((count == 5) ? (dishes[0] + 10 - 1)/10 * 10 * 4 + last : ans + last) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int N,W;
    cin>>N>>W;
    vector<ll> v(N,0),w(N,0);
    rep(i,N) cin>>w[i]>>v[i];
    ll dp[110][100010];
    //dp[i][j]=i個目までの品物を用い、且つ重さj以下での価値の最大値
    rep(i,N){
        rep(j,W+1){
            if(j-w[i]<0){
                dp[i+1][j]=dp[i][j]; //追加できない
            }
            else{
                dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
            }
        }
    }
    cout<<dp[N][W]<<endl;
    return 0;
}

Measured memory_bytes: 80128
H, W, M = map(int, input().split())
hws = [list(map(lambda x :int(x)-1, input().split())) for _ in range(M)]

booms = [set() for _ in range(H)]

yoko = [0 for _ in range(W)]
tate = [0 for _ in range(H)]

for hw in hws:
    tate[hw[0]] += 1
    yoko[hw[1]] += 1
    booms[hw[0]].add(hw[1])
    
max_tate = max(tate)
max_yoko = max(yoko)


tate_candidates = []
yoko_candidates = []

for i in range(H):
    if tate[i] == max_tate:
        tate_candidates.append(i)
        
for i in range(W):
    if yoko[i] == max_yoko:
        yoko_candidates.append(i)

exist = 0
for tate_candidate in tate_candidates:
    for yoko_candidate in yoko_candidates:
        if yoko_candidate not in booms[tate_candidate]:
            exist = 1
            break
    else:
        continue
    break
print(max_tate + max_yoko + (exist-1))


Measured memory_bytes: 246884
use input::*;
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

mod input {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }
    pub fn str() -> String {
        read()
    }
    pub fn s() -> Vec<char> {
        str().chars().collect()
    }
    pub fn i() -> i64 {
        read()
    }
    pub fn u() -> usize {
        read()
    }
    pub fn f() -> f64 {
        read()
    }
    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }
    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }
    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }
    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}

fn main() {
    let (n, m, v, p) = (u(), u(), u(), u());
    let a = uv(n);

    let mut b = a.clone();
    b.sort();
    b.reverse();
    let border = b[p - 1];
    let mut sum = 0;
    let mut count = 0;

    let mut ans = 0;
    for i in 0..n {
        let k = b[i];
        if k > border {
            ans += 1;
            continue;
        }
        if k + m >= border {
            if p >= v && k >= border {
                ans += 1;
                continue;
            }
            let rest = n - i - 1;
            let t = m * v;
            let cap = p * m + rest * m + count * (k + m) - sum;
            //dbg!(&t, &cap, &count, &(p * v), &(k + m), &sum);
            // println!("");
            if t <= cap {
                ans += 1;
            }

            if border <= k + m {
                sum += k;
                count += 1;
            }
        } else {
            break;
        }
    }
    println!("{}", ans);
    //dbg!(border, b, ans);
}


Measured memory_bytes: 6396
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N,K = map(int,input().split())
A = list(map(int,input().split()))
if N == 1:
    print(1)
else:
    
    old = A
    for _ in range(K):
        li = [0]*N
        for i in range(N):
            MIN = max(0,i-old[i])
            MAX = min(N-1,i+old[i])
            li[MIN] += 1
            if MAX != N-1:
                li[MAX+1] -= 1
        s = 0
        for i in range(N):
            s += li[i]
            old[i] = s
        if min(old) == N:
            break
    print(*old)


Measured memory_bytes: 151468
#include <iostream>

int main(){
   std::string s;
   std::cin >> s;
   int ABCD[4];
   for(int i=0; i<4; ++i){
      ABCD[i] = s[i] - '0';
   }

   std::string ans = s;
   for(int i=0; i<2; ++i){
      for(int j=0; j<2; ++j){
	 for(int k=0; k<2; ++k){
	    int n = ABCD[0];
	    if(i==0) n += ABCD[1];
	    else n -= ABCD[1];
	    if(j==0) n += ABCD[2];
	    else n -= ABCD[2];
	    if(k==0) n += ABCD[3];
	    else n -= ABCD[3];
	    if(n==7){
	       ans.insert(ans.begin()+1, i==0 ? '+' : '-'); 
	       ans.insert(ans.begin()+3, j==0 ? '+' : '-'); 
	       ans.insert(ans.begin()+5, k==0 ? '+' : '-'); 
	       ans += "=7";
	       std::cout << ans << std::endl;
	       return 0;
	    }
	 }
      }
   }
   return -1;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
map<int, int> factor(int m) {
	map<int, int>res;
	for (int i = 2; i*i <= m; i++) {
		while (m%i == 0) {
			res[i]++;
			m /= i;
		}
	}
	if (m != 1)res[m]++;
	return res;
}

/*--------Library Zone!--------*/


signed main() {
	int n, ans = 0;
	cin >> n;
	string s, t, u;
	cin >> s >> t >> u;
	rep(i, n) {
		if (s[i] == t[i] && t[i] == u[i])continue;
		if (s[i] != t[i] && t[i] != u[i] && s[i] != u[i]) {
			ans += 2;
		}
		else if (s[i] == t[i] || t[i] == u[i] || s[i] == u[i])ans++;
	}
	cout << ans << endl;
	endre;
}

Measured memory_bytes: 256
#include <cmath>
#include <stack>
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[100009], b[100009], p[200009];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	for (int i = 0; i < 2 * n; i++) p[i] = i;
	sort(p, p + 2 * n, [](int v1, int v2) { return (v1 < n ? a[v1] : b[v1 - n]) < (v2 < n ? a[v2] : b[v2 - n]); });
	int d = 0, ret = 1;
	for (int i = 0; i < 2 * n; i++) {
		int nd = d + (p[i] < n ? 1 : -1);
		if (abs(d) > abs(nd)) ret = 1LL * ret * abs(d) % 1000000007;
		d = nd;
	}
	cout << ret << endl;
	return 0;
}

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

int main() {
    int N, M, T;
    cin >> N >> M >> T;
    vector<int> v(N);
    for (auto& i : v) cin >> i;

    int sum = 0;
    for (int i = 0; i < N-1; i++) {
        if (v[i+1]-v[i] > M*2) {
            sum += v[i+1]-v[i]-2*M;
        }
    }

    sum += (v[0] - M) + max(0, T - v[N-1] - M);
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3100
import itertools
import numpy as np

N = int(input())
lst = np.array(list(map(int,input().split())))
lst2 = np.array(list(itertools.combinations(lst,2)))
lst3 =[]

for i in range(len(lst2)):
               dot = np.dot(lst2[i][0],lst2[i][1])
               lst3.append(dot)

print(sum(lst3))

Measured memory_bytes: 12424
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

vector<pii> v[25];
int n,a[25];

int main()
{ios_base::sync_with_stdio(false);
cin>>n;
rep(i,0,n-1)
{
	cin>>a[i];
	rep(j,0,a[i]-1)
	{
		int x,y;
		cin>>x>>y;
		x--;
		v[i].pb(mp(x,y));
	}
}
int ans=0;
rep(msk,0,(1<<n)-1)
{
	int foo=1;
	rep(i,0,n-1)
	{
		if((msk&(1<<i))==0)continue;
		tr(v[i],it)
		{
			int id=it->ff,c=it->ss;
			if(c==0&&(msk&(1<<id))>0)foo=0;
			if(c==1&&(msk&(1<<id))==0)foo=0;
		}
	}
	if(foo)ans=max(ans,__builtin_popcount(msk));
}
ol(ans);
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>A>>B;
    ll w = 626, b = 625;
    w -= A; b -= B;
    S = "";
    rep(i,100) S.push_back('.');
    vector<string> ans(100,S);
    rep(i,25){
        rep(j,25){
            ll l = i*4, u = j*4;
            rep(p,3) {
                ans[u+p][l] = ans[u+p][l+2] = '#';
                ans[u][l+p] = ans[u+2][l+p] = '#';
            }
            if(w > 0){
                --w;
                ans[u+2][l+1] = '.';
            }
            if(b > 0){
                if((j != 0) || (i != 24)) --b;
                if(j == 0){
                    ans[u][l+3] = '#';
                }else{
                    ans[u-1][l] = '#';
                }
            }
        }
    }
    cout<<"100 100"<<endl;
    rep(i,100){
        rep(j,100) cout<<ans[i][j];
        cout<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    long long int a[n];
    for(int i=0; i<n; i++) {
        cin>>a[i];
    }
    
    long long int ans = 0;
    for(int i=0; i<n-1; i++) {
        if(a[i]>a[i+1]) {
            ans += a[i] - a[i+1];
            a[i+1]=a[i];
        }
    }
    
    cout<<ans;
    
}


Measured memory_bytes: 5136
import sys
input = sys.stdin.readline
N = int(input())
S = input().rstrip()
Q = int(input())
qs = [input().split() for i in range(Q)]

def ctoi(c):
    return ord(c) - ord('a')

bit = [[0]*(N+2) for _ in range(26)]
def bit_add(x,w,ci):
    while x <= N+1:
        bit[ci][x] += w
        x += (x & -x)
def bit_sum(x,ci):
    ret = 0
    while x > 0:
        ret += bit[ci][x]
        x -= (x & -x)
    return ret

for i,c in enumerate(S):
    bit_add(i+1,1,ctoi(c))

s = list(S)
ans = []
for a,b,c in qs:
    if a=='1':
        x = int(b)
        bit_add(x,1,ctoi(c))
        bit_add(x,-1, ctoi(s[x-1]))
        s[x-1] = c
    else:
        tmp = 0
        for i in range(26):
            if bit_sum(int(c),i) - bit_sum(int(b)-1,i) > 0:
                tmp += 1
        ans.append(tmp)
print(*ans, sep='\n')

Measured memory_bytes: 172148
import collections

n = int(input())
s = list(input() for i in range(n))


c = collections.Counter(s)

cm = c.most_common()

ans = []


max_num = cm[0][1]
for string, num in cm:
    if max_num == num:
        ans.append(string)

ans.sort()

print(*ans,sep='\n')


Measured memory_bytes: 126544
#include<stdio.h>
#include<memory.h>
#include<queue>
int Last[1000002],Next[10000002],End[10000002],Len[10000002],tot=1,cur[1000002];
int a[100002],b[100002],n,dep[1000002],f[100002],g[100002],tp1=0,tp2=0,u[100002],v[100002],tp;
int gf(int p){return f[p]==p?p:(f[p]=gf(f[p]));}
int gg(int p){return g[p]==p?p:(g[p]=gg(g[p]));}
inline int Min(int a,int b){return a<b?a:b;}
void add(int p,int q,int v1,int v2){
	End[++tot]=q;Next[tot]=Last[p];Last[p]=tot;Len[tot]=v1;
	End[++tot]=p;Next[tot]=Last[q];Last[q]=tot;Len[tot]=v2;
}
bool init(){
	std::queue<int>Q;
	Q.push(1);memset(dep,0,sizeof(int)*(tp+10));
	while(!Q.empty()){
		int p=Q.front();Q.pop();
		for(int i=Last[p];i;i=Next[i])if(!dep[End[i]]&&End[i]!=1&&Len[i]>0)dep[End[i]]=dep[p]+1,Q.push(End[i]);
	}return dep[tp]!=0;
}
int dfs(int p,int res){
	if(p==tp)return res;int tot=0;
	for(int i=cur[p];i;i=Next[i]){cur[p]=i;
		if(dep[End[i]]==dep[p]+1&&Len[i]){
			int val=dfs(End[i],Min(res-tot,Len[i]));
			tot+=val;Len[i]-=val;Len[i^1]+=val;
			if(tot==res)return tot;
		}
	}return tot;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),f[i]=i,a[i]++;
	for(int i=1;i<=n;i++)scanf("%d",&b[i]),g[i]=i,b[i]++;
	for(int i=1;i<=n;i++)if(gf(i)!=gf(a[i]))f[f[i]]=f[a[i]];
	for(int i=1;i<=n;i++)if(gg(i)!=gg(b[i]))g[g[i]]=g[b[i]];
	for(int i=1;i<=n;i++)gf(i),gg(i);
	for(int i=1;i<=n;i++)if(!u[f[i]])u[f[i]]=++tp1;
	for(int i=1;i<=n;i++)if(!v[g[i]])v[g[i]]=++tp2;
	tp=tp1+tp2+2;int ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]==i){
			if(b[i]==i)ans++;
			else add(v[g[i]]+tp1+1,tp,1,0);
		}else if(b[i]==i)add(1,u[f[i]]+1,1,0);
		else if(b[i]==a[i])add(v[g[i]]+tp1+1,u[f[i]]+1,1,1);
		else add(v[g[i]]+tp1+1,u[f[i]]+1,1,0);
	}while(init())memcpy(cur,Last,sizeof(int)*(tp+10)),ans+=dfs(1,1e9);
	printf("%d",n-ans);
}

Measured memory_bytes: 19456
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define all(v) (v).begin(), (v).end()
const char newl = '\n';

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

  ll n, a, minute=0;
  cin >> n;
  pl Trans;
  vpl Portations;
  rep(i, 5) {
    cin >> a;
    Trans.first = a;
    Trans.second = i;
    Portations.push_back(Trans);
  }
  sort(all(Portations));
  
  cout << (ll)(n+Portations[0].first-1)/Portations[0].first+4 << newl;
}

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

using namespace std;
using ll = long long;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> scores(n + 1, k);
    vector<int> freq(n + 1);
    for (int i = 0; i < q; i++) {
        int p;
        cin >> p;
        freq[p]++;
    }
    for (int i = 1; i <= n; i++) {
        scores[i] -= (q - freq[i]);
        if (scores[i] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


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

int n;
std::vector<int>a;
bool solve(int i, int j){
    if(j == 0){
        return true;
    }
    if(i >= n){
        return false;
    }
    bool res = solve(i+1, j) || solve(i+1, j-a[i]);;
    return res;
}

int main(void){
    int q;
    scanf("%d", &n);
    a.resize(n);
    //selv.resize(n);

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

    scanf("%d", &q);
    std::vector<int> m(q);

    for(int i = 0; i < q; i++){
        //std::cin >> m[i];
        scanf("%d", &m[i]);
    }
    
    for(int i = 0; i < q; i++){
        if(solve(0, m[i])){
            std::cout << "yes" << std::endl;
        }else{
            std::cout << "no" << std::endl;
        }
    }
    
   
    return 0;
}
/*
int n = 3;
std::vector<int> S(n);

int rec(int i){
    if(i == n){
        for(auto j : S){
            std::cout << j << " ";
        }
        std::cout << std::endl;
        return 0;
    }
    
    rec(i+1);
    S[i] = 1;
    rec(i+1);
    S[i] = 2;
    rec(i+1);
    S[i] = 0;

}

int main(void){
    for(int i = 0; i < n-1; i++){
        S[i] = 0;
    }
    rec(0); 

    return 0;
}
*/




Measured memory_bytes: 3164
#include <cstdio>
#include <cmath>
#define EPS 1e-6

using namespace std;

double cross(double a, double b, double c, double d)
{
  return a * d - b * c;
}

int main()
{
  double a[3], b[3];
  while (scanf(" %lf %lf %lf %lf %lf %lf ", &a[0],&a[1],&a[2],&b[0],&b[1],&b[2]) == 6) {
    double x = cross(a[2], a[1], b[2], b[1]) / cross(a[0], a[1], b[0], b[1]),
      y = cross(a[0], a[2], b[0], b[2]) / cross(a[0], a[1], b[0], b[1]);
    if (fabs(x) < EPS) {x = fabs(x);}
    if (fabs(y) < EPS) {y = fabs(y);}
    printf("%.3lf %.3lf\n", x, y);
  }
  return 0;
}

Measured memory_bytes: 0
fn main() {
    proconio::input! {
        n: usize,
        ds: [usize; n],
    }
    const M: usize = 998244353;
    if ds[0] != 0 || ds.iter().skip(1).any(|d| *d == 0) {
        println!("0");
        return;
    }
    let mut count = 1usize;
    let mut m = std::collections::BTreeMap::new();
    for d in ds.into_iter().skip(1) {
        *m.entry(d).or_default() += 1;
    }
    let mut distance = 0;
    let mut prev = 1usize;
    for (d, num) in m.iter() {
        if distance + 1 != *d {
            println!("0");
            return;
        }
        for _ in 0..*num {
            count *= prev;
            count %= M;
        }
        distance = *d;
        prev = *num;
    }
    println!("{}", count);
}


Measured memory_bytes: 6144
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >> K >> X;
  rep_s(i, X-K+1, X+K){
    cout << i << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const int MAX = 205;
/* global variables */
/* function */
/* main */
int main(){
    ll N, M, R, a, b, c;
    cin >> N >> M >> R;
    vector<ll> r(R);
    sort(r.begin(), r.end());
    for (int i = 0; i < R; i++) {cin >> r[i]; r[i]--;}
    vector<vector<ll> > d(MAX, vector<ll>(MAX, INF));
    for (int i = 0; i < M; i++) {
        cin >> a >> b >> c;
        a--, b--;
        d[a][b] = c; d[b][a] = c;
    }

    for (int i = 0; i < MAX; i++) d[i][i] = 0;
    for (int k = 0; k < MAX; k++) {
        for (int i = 0; i < MAX; i++) {
            if (d[i][k] == INF) continue;
            for (int j = 0; j < MAX; j++) {
                if (d[k][j] == INF) continue;
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    sort(r.begin(), r.end());
    ll ans = INF;
    do {
        ll tmp = 0;
        for (int i = 0; i < R - 1; i++) { tmp += d[r[i]][r[i+1]]; }
        ans = min(ans, tmp);
    } while(next_permutation(r.begin(), r.end()));

    cout << ans << '\n';
}

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

int main(){
  int N;cin>>N;
  std::vector<int> t(N+1),x(N+1),y(N+1);
  for(int i=1;i<=N;i++)cin>>t[i]>>x[i]>>y[i];
  t[0]=x[0]=y[0]=0;
  bool OK=true;
  for(int i=1;i<=N;i++){
    int T=t[i]-t[i-1];
    int D=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
    if(T<D)OK=false;
    if((T+D)%2==1)OK=false;
  }
  if(OK)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int n, a, b;
int ans;

int main()
{
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++){
		scanf ("%d %d", &a, &b);
		ans += (b - a + 1);
	}
	printf ("%d\n", ans);
}


Measured memory_bytes: 128
import re
S=input()
good = True

if S[0] != 'A':
    print('WA')
    exit()
n = 0
iC = -1
for i in range(2,len(S)-1):
    if S[i] == 'C':
        n += 1
        iC = i
if n != 1:
    print('WA')
    exit()
for i in range(1,len(S)):
    if i == iC:
        continue
    if not re.match(r'[a-z]', S[i]):
        print('WA')
        exit()

print('AC')


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

int main(void){
    int w,h,n,l,r,u,d;
    cin>>w>>h>>n;
    l=0,r=w,u=h,d=0;
    for(int i=0;i<n;i++){
        int x,y,a;
        cin>>x>>y>>a;
        if(a==1) l=max(l,x);
        if(a==2) r=min(r,x);
        if(a==3) d=max(d,y);
        if(a==4) u=min(u,y);
    }
    cout<<(max(r-l,0)*max(u-d,0))<<endl;
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

ll x, y, a, b, c;
ll p[100001], q[100001], r[100001];

int main() {
    cin >> x >> y >> a >> b >> c;
    for (int i = 0; i < a; ++i)
        cin >> p[i];
    for (int i = 0; i < b; ++i)
        cin >> q[i];
    for (int i = 0; i < c; ++i)
        cin >> r[i];
    p[a] = 0;
    q[b] = 0;
    r[c] = 0;
    sort(p, p + a + 1);
    sort(q, q + b + 1);
    sort(r, r + c + 1);
    ll ans = 0, xy = 0, xx = 0, yy = 0;
    while (xy < x + y) {
        if (p[a] >= q[b] && p[a] >= r[c]) {
            if (xx < x) {
                ans += p[a];
                xy++;
                xx++;
            }
            a--;
        }
        else if (q[b] >= p[a] && q[b] >= r[c]) {
            if (yy < y) {
                ans += q[b];
                xy++;
                yy++;
            }
            b--;
        }
        else if (r[c] >= p[a] && r[c] >= q[b]) {
            ans += r[c];
            c--;
            xy++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
s="".join(sorted(list(input())))
t="".join(sorted(list(input()),reverse=True))


if len(s)<len(t) and s==t[:len(s)]:
    print("Yes")
else:
    for i in range(min([len(s),len(t)])):
        if s[i]!=t[i]:
            if s[i]<t[i]:
                print("Yes")
            else:
                print("No")
            break
        if i==min([len(s),len(t)])-1:
            print("No")



Measured memory_bytes: 3064
import java.util.Scanner;

//Factorial II
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int c = 0;
			while(n>=5){
				c += n/5;
				n/=5;
			}
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 11000
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
   string n;
   cin >> n;
   for(int i=0; i < (int)n.size(); i++){
      if(n[i] == '1'){n[i] = '9';}
      else if(n[i] == '9'){n[i] = '1';}
   }
   cout << n << endl;

   return 0;
}

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

int n, m;
pair<long long int, long long int> z[200000];

int main() {
    cin >> n >> m;
    for(int i = 0; i < n; ++i)
        cin >> z[i].second, z[i].first = 1;
    for(int i = n; i < m + n; ++i)
        cin >> z[i].first >> z[i].second;
    sort(z, z + m + n, [](const pair<long long int, long long int> a, const pair<long long int, long long int> b){ return a.second < b.second;});
    long long int pr = n, sum = 0, i = m + n - 1;
    //cout << endl;
    //for(int i = 0; i < n + m; ++i)
    //    cout << z[i].first << " " << z[i].second << endl;
    while(pr != 0) {
        sum += min(z[i].first, pr) * z[i].second;
        pr -= min(z[i].first, pr);
        --i;
    }
    cout << sum << endl;
    return 0;
}


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

int main() {
	int x[10] = {0,0,0,0,0,0,0,0,0,0};
	int a, b, c;
	cin >> a >> b >> c;
	x[a-1]++;
	x[b-1]++;
	x[c-1]++;
	if(x[4] == 2 && x[6] == 1) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n=0;
  int x[100001]={};
  int done[100001]={};
  scanf("%d",&n);
  for(int i=0;i<n;i++){
      scanf("%d",&x[i]);
      x[i]--;
  }
  int pos=0;
  int count=0;
  int imp=0;
  done[0]++;
  
  while(pos!=1){
      pos=x[pos];
      if(done[pos]==0){
          done[pos]++;
          count++;
      }else{
          imp++;
          break;
      }
  }
  
  if(imp==0){
      printf("%d\n",count);
  }else{
      printf("-1\n");
  }
 
  return 0;
}

Measured memory_bytes: 2476
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int W,H;

void solve(){
    vector<string> s(H);
    rep(i,H) cin>>s[i];

    map<string,int> mp;


    rep(i,H) rep(j,W){
        //cout << i << " " << j << endl;
        for(int dx=-1;dx<=1;dx++) for(int dy=-1;dy<=1;dy++) if(!(dx==0 and dy==0)){
            vector<vector<bool>> visited(H,vector<bool>(W,false));
            int x=i,y=j;
            string t = "";
            //cout << i << " " << j << " "  << dx << " " << dy << endl;
            while(!visited[x][y]){
                //cout << "ok" << endl;
                visited[x][y] = true;
                t.pb(s[x][y]);
                x+=dx;
                y+=dy;
                x += H;
                y += W;
                x%=H;
                y%=W;
                if(t.size()>1) mp[t]++;
            }
        }
    }


    string ans;
    for(auto p : mp){
        if(p.se >= 2){
            if(ans=="" or p.fi.size() > ans.size()){
                ans = p.fi;
            }
        }
    }
    if(ans == ""){
        cout << 0 << endl;
        return;
    }
    cout << ans << endl;
    return;
}

int main(){
    while(1){
        cin >> H >> W;
        if(H==0 and W==0) break;
        solve();
    }
}

Measured memory_bytes: 37928
//This disgusting code is wriiten by Juruo D0zingbear
//Please don't hack me! 0v0 <3
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#define LL long long
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 19260817
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}

// cf IO: I64d
// atcoder IO: £ì£ì£ä
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int main(){
	string s;
	cin>>s;
	bool flag=false;
	for (int i=0;i<s.size()-1;i++){
		if (s[i]=='A' && s[i+1]=='C') flag=true;
	}
	if (flag){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
#include <numeric>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int a, b; cin >> a >> b;

    int ans = max(a - 2 * b, (int)0);

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
li = input().split()
t = 0
li2 = []
for i in li:
    t  = 0
    while True:
        if int(i) % 2 == 0:
            i = int(i) / 2
            t += 1
        else:
            li2.append(t)
            break

li2.sort()
ans = li2[0]
print(ans)

Measured memory_bytes: 3064
'''input
3
4
1 2 3 6
1
8
2
1 1
'''
# A coding delight
from sys import stdin
from collections import defaultdict


# main starts
a = int(stdin.readline().strip())
b = int(stdin.readline().strip())
arr = [1, 2, 3]
for i in arr:
	if i != a and i != b:
		print(i)
		exit()

Measured memory_bytes: 3316
from sys import stdin
input = stdin.readline
while True:
    n, x = map(int, input().split())
    
    if n == 0 and x == 0:
        break
    
    ans = 0
    for a in range(1, n-1):
        for b in range(a+1, n):
            c = x - a - b
            if c > b and c <= n:
                ans += 1
    
    print(ans)


Measured memory_bytes: 5596