akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define REP(i,n) for(i=0;i<n;i++)

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);
int asc(const void *a, const void *b);
int desc(const void *a, const void *b);
double to_deg(double rad);
double distance(int xi, int yi, int xj, int yj);

//main function
int main() {
    int N = iin(), i, j;
    int x[N], y[N];
    double d, d_sum = 0;
    REP(i,N) {
        x[i] = iin();
        y[i] = iin();
    }
    REP(i,N) {
        REP(j,N) {
            if (i == j) {
                d = 0;
                d_sum += d;
                continue;
            }
            d = distance(x[i], y[i], x[j], y[j]);
            d_sum += d;
        }
    }
    dout(d_sum / N);
    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

/*
    int型の最大公約数
*/

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

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

    return b;
}

/*
    int型の最小公倍数
*/

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    long long型の最大公約数
*/

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

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

    return b;
}

/*
    long long型の最小公倍数
*/

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    int型の昇順用比較関数
*/

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

/*
    int型の降順用比較関数
*/

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

/*
    弧度法を度数法に
*/

double to_deg(double rad) {
    return rad * 180.0 / (atan(1.0) * 4.0);
}

double distance(int xi, int yi, int xj, int yj) {
    return hypot(xj - xi, yj - yi);
}


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

typedef long long ll;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(), a.end());
    vector<ll> sum(n);
    for(int i=0;i<n;i++) {
        if(i==0) sum[i] = a[i];
        else {
            sum[i] = sum[i-1] + a[i];
        }
    }
    int ans=n;
    for(int i = n-2;i>=0;i--) {
        if(sum[i] * 2 < a[i+1]) {
            ans -= (i + 1);
            break;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(auto & t : a) cin>>t;
    map<int,int> m;
    for(int i=0;i<n;++i){
        m[a[i]]++;
    }
    int count = 0;
    for(auto &mi : m){
        if(mi.second%2)count++;
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 5376
def selectionsort(a, n):
    count = 0
    for i in range(n):
        min = i
        for j in range(i, n):
            if a[min] > a[j]:
                min = j
        if i != min:
            count += 1
            a[i], a[min] = a[min], a[i]
    return count

N = int(input())
A = list(map(int, input().split()))

c = selectionsort(A, N)
print(*A)
print(c)


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

#define rep(i, u) for (int i = 0; i < u; i++)

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



Measured memory_bytes: 3228
K = int(input())

a = 0
ans = -1
S = set()
for i in range(1, K + 1):
    a = a * 10 + 7
    a %= K
    if a == 0:
        ans = i
        break
    elif a in S:
        break
    S.add(a)
print(ans)


Measured memory_bytes: 77844
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define vi vector<int>

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

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

const int MAX_N = 100005;

void Main() {
  int n, k;
  cin >> n >> k;
  vector<P> sushi;
  rep(i, n) {
    int t, d;
    cin >> t >> d;
    sushi.emplace_back(d, t);
  }
  sort(sushi.begin(), sushi.end());

  priority_queue<P, vector<P>, greater<P>> q;
  map<int, int> kinds;
  ll score = 0;
  rep(i, k) {
    P p = sushi.back(); sushi.pop_back();
    score += p.first;
    q.push(p);
    kinds[p.second]++;
  }
  ll kind = kinds.size();
  ll ans = score + kind * kind;

  queue<int> tuika;
  while(!sushi.empty()) {
    P p = sushi.back(); sushi.pop_back();
    if (kinds[p.second] != 0) continue;
    kinds[p.second] = 1;
    tuika.push(p.first);
  }

  while(!q.empty() && !tuika.empty() && kind != k) {
    P p = q.top(); q.pop();
    if (kinds[p.second] == 1) continue;
    kinds[p.second]--;
    kind++;
    score -= p.first;
    score += tuika.front(); tuika.pop();
    ans = max(ans, score+kind*kind);
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 6388
s=input()
t=input()

nmax=len(t)
nmin=len(t)

for i in range(len(s)-nmax+1):
  n=0
  for j in range(nmax):
    if s[i+j]!=t[j]:
      n=n+1
    if n==nmin:
      break
      
  nmin=n
  if nmin==0:
    break
print(nmin)

Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  int n, k;
  cin >> n >> k;
  vi v(n);
  rep(i, n) cin >> v[i];
  int ans = -INF;
  if (k >= n) {
    sort(ALL(v));
    int sum = 0;
    rep(i, v.size()) sum += v[i];
    int cnt = min(k - n, n);
    rep(i, cnt) if (v[i] < 0) sum -= v[i];
    cout << sum << endl;
    return 0;
  }
  rep(i, k+1) {
    int res = k - i;
    rep(l, i+1) {
      vi x;
      int r = i - l;
      if (r < 0) continue;
      rep(nl, l) {
        x.push_back(v[nl]);
      }
      int t = 0;
      while (r) {
        x.push_back(v[n - 1 - t]);
        ++t;
        --r;
      }
      sort(ALL(x));
      int sum = 0;
      rep(j, x.size()) sum += x[j];
      int cnt = min(res, (int)x.size());
      rep(j, cnt){
        if (x[j] < 0) sum -= x[j];
      }
      ans = max(ans, sum);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> p;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9

int n;
int a[100000];
p max_a;


void input() {
	cin >> n;
	max_a.first = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (max_a.first < a[i]) {
			max_a.first = a[i];
			max_a.second = i;
		}
	}
}

p dif[100000]; // first : 差の値
			   // second : 値の元々の添え字

void solve() {
	int half_num = max_a.first / 2;
	for (int i = 0; i < n; i++) {
		dif[i].first = abs(a[i] - half_num);
		dif[i].second = i;
	}

	sort(dif, dif + n);
	cout << a[max_a.second] << " ";
	
	if (dif[0].second != max_a.second) cout << a[dif[0].second] << endl;
	else cout << a[dif[1].second] << endl;
}

int main() {
	input();
	solve();

	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;
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 x = sc.nextInt();
        int cnt = 0;
        for(int i = 0;i <= a;i++){
            for(int j = 0;j <= b;j++){
                for(int k = 0;k <= c;k++){
                    if(500*i + 100*j + 50*k == x){
                        cnt++;
                    }
                }
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 23764
/****************************************************************************
Is this the real life? Is this just fantasy?
Caught in a landslide, no escape from reality
Open your eyes, look up to the skies and see
I'm just a poor boy, I need no sympathy
Because I'm easy come, easy go, little high, little low
Any way the wind blows doesn't really matter to me, to me!!!
--------------------------------------------------
CP is quite cool.It becomes cooler when you enjoy learning new things
******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(a) a.size()
#define ff first
#define ss second
#define debug(x) cout<<#x<<" = "<<x<<endl;
const int mod=1e9+7;

void solve()
{
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)
    cin>>a[i];

  ll ans=0;
  for(int i=1;i<n;i++)
  {
    if(a[i]<a[i-1])
    {
      ans+=a[i-1]-a[i];
      a[i]=a[i-1];
    }
  }



  cout<<ans<<endl;
} 

int main()
{

  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

  ios::sync_with_stdio(false);
  cin.tie(0);

  int t=1;
  // cin>>t;
  while(t--)
  {
    solve();
  }

  return 0;
}


Measured memory_bytes: 3920
#include<iostream>
#include<string>
//#include<vector>
//#include<math.h>
using namespace std;

bool isPalindrome(string s) {
  int N = s.size();
  int i;
  if (N % 2 == 0) i = N/2-1;
  else i = N/2;
  while (i >= 0) {
    if (s[i] != s[N-i-1]) return false;
    i--;
  }
  return true;
}

int main (void) {
  string S;
  cin >> S;
  int N = S.size();
  
  string former = S.substr(0,(N-1)/2);
  string latter = S.substr((N+3)/2-1, N-(N+3)/2+1);
  if (isPalindrome(S) && isPalindrome(former) && isPalindrome(latter)) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	
	public class Magic
	{
		public int Index {get;set;}
		public int Damage {get;set;}
		public int Cost {get;set;}
	}
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var h = p[0];
		var n = p[1];
		var magics = new Magic[n];
		for(int i = 0; i < n; i++)
		{
			p = Input().ToInt();
			magics[i] = new Magic(){Index = i, Damage = p[0], Cost = p[1]};
		}
		var dp = new long[h+1, n+1];	//相手のモンスターを体力hにするための最小コスト
		
		for(int i = 0; i < h+1; i++)
			for(int j = 0; j < n+1; j++)
				dp[i, j] = 99999999999;
		for(int i = 0; i < n+1; i++)
				dp[h, i] = 0;
		
		
		for(int i = h; i > 0; i--)
		{
			for(int j = 0; j < n; j++)
			{
				var m = magics[j];
				dp[Math.Max(0, i - m.Damage), j] = Math.Min(dp[Math.Max(0, i - m.Damage), j], dp[i, j] + m.Cost);
				dp[i, j + 1] = Math.Min(dp[i, j], dp[i, j + 1]);
			}
		}
		
		long min = 99999999999;
		for(int i = 0; i < n+1; i++)
		{
			min = Math.Min(min, dp[0, i]);
		}
		Console.WriteLine(min);
		
	}


	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


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

int main(){
    int n;
    cin >> n;
    vector<int> sub(n,0);
    for(int i = 1;i < n;i++){
        int a;
        cin >> a;
        a--;
        sub.at(a)++;
    }
    rep(i,n)cout << sub.at(i) << endl;
}

Measured memory_bytes: 3952
class MathUtil:
    # calculate {m+n}C{n}
    def egcd(self, a: int, b: int):
        if a == 0:
            return b, 0, 1
        else:
            g, y, x = self.egcd(b % a, a)
            return g, x - (b // a) * y, y

    def modinv(self, a: int, m: int):
        g, x, y = self.egcd(a, m)
        if g != 1:
            raise Exception('modular inverse does not exist')
        else:
            return x % m

    def combination(self, n: int, r: int, mod: int = 10**9+7) -> int:
        r = min(r, n-r)
        res = 1
        for i in range(r):
            res = res * (n-i) * self.modinv(i+1, mod) % mod
        return res

    def pow(self, x: int, n:int, mod: int = 10**9+7):
        if n == 0:
            return 1

        k = 1
        while n > 1:
            if n % 2 != 0:
                k *= x
            
            x *= x
            n //= 2

            if k >= mod:
                k %= mod
            if x >= mod:
                x %= mod

        return (k * x) % mod 

util = MathUtil()

n, a, b = map(int, input().split())

m = 10**9 + 7

if n >= a:
    ca = util.combination(n,a)
else:
    ca = 0

if n >= b :
    cb = util.combination(n,b)
else:
    cb = 0

print( (2 * m + util.pow(2, n) -1 - ca - cb) % m)

Measured memory_bytes: 93272
//第8回シンデレラガール総選挙は是非本田未央ちゃんに投票をお願いします！
//ファンのことも他のアイドルの子たちのことも本当に大事にしてて、今まで周りに色んなものを与えてくれました。
//今度は私たちが未央ちゃんにお返しをする番です。みんなでガラスの靴を履かせてあげましょう！
// #本田未央を一番星に #本田未央を令和のシンデレラガールに #第8回シンデレラガール総選挙
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<lint,lint> pl;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
ostream &operator<<(ostream &os, const vector<int> &a) {
	os<<"[";
	rep(i,a.size()){
		os<<a[i];
		if(i<a.size()-1) os<<",";
	}
	os<<"]";
	return os; 
}
vector<int> gr[200100],g2[200100];
vector<int> ro;//Vが1である頂点たち
lint num[200100];
int V[200100];
set<int> s;
//void dfs(int v);
int dfs2(int r,int v){
	//cout<<r<<v<<endl;
	int ret=0;
	if(V[v]>0){
		g2[r].pb(v);
		return ret;
	}
	ret++;
	rep(i,gr[v].size()) ret+=dfs2(r,gr[v][i]);
	return ret;
}
void dfs(int v){
	if(V[v]<1 && v>0){
		rep(i,gr[v].size()) dfs(gr[v][i]);
		return;
	}
	num[v]=0;
	rep(i,gr[v].size()) num[v]+=dfs2(v,gr[v][i]);
	rep(i,g2[v].size()) dfs(g2[v][i]);
}

pl dp[200100];
lint d2[200100];
void add(int a,int b){
	d2[a]+=dp[b].fi*dp[a].se;
	d2[a]+=d2[b];
	dp[a].fi+=dp[b].fi;dp[a].se+=dp[b].se;
}
bool comp(int a,int b){
	return dp[a].fi*dp[b].se<dp[a].se*dp[b].fi;
}
struct Compare : public binary_function<int,int,bool> {
  bool operator()(const int &a, const int &b) {
    return dp[a].fi*dp[b].se<dp[a].se*dp[b].fi;
  }
};
priority_queue<int,vector<int>,Compare> q[252521];
void dfs3(int v){
	rep(i,g2[v].size()){
		dfs3(g2[v][i]);q[v].push(g2[v][i]);
	}
	//cout<<v<<'a'<<endl;
	dp[v]=mp(num[v],V[v]);d2[v]=num[v]*V[v];
	//if(!q[v].empty()) cout<<q[v].top()<<endl;
	while(!q[v].empty() && comp(v,q[v].top())){
		int w=q[v].top();
		//cout<<w<<'a'<<endl;
		q[v].pop();
		add(v,w);
		while(!q[w].empty()){
			q[v].push(q[w].top());q[w].pop();
		}
	}
}
int main()
{
	int n,a;
	cin>>n;
	rep(i,n-1){
		cin>>a;a--;
		gr[a].pb(i+1);
	}
	rep(i,n) cin>>V[i];
	dfs(0);
	dfs3(0);
	while(!q[0].empty()){
		int w=q[0].top();
		q[0].pop();
		//cout<<w<<endl;
		add(0,w);
		//cout<<dp[0].fi<<' '<<dp[0].se<<' '<<d2[0]<<endl;
		while(!q[w].empty()){
			//cout<<q[w].top()<<endl;
			q[0].push(q[w].top());q[w].pop();
		}
	}
	cout<<d2[0]<<endl;
}


Measured memory_bytes: 62592
from itertools import product

H, W = [int(i) for i in input().split()]
grid = [list(input()) for _ in range(H)]

ans = "Yes"
for y, x in product(range(H), range(W)):
    if grid[y][x] != "#":
        continue
    for dy, dx in ((0, -1), (0, 1), (-1, 0), (1, 0)):
        ny, nx = y + dy, x + dx
        if not (0 <= ny < H and 0 <= nx < W):
            continue
        if grid[ny][nx] == "#":
            break
    else:
        ans = "No"
print(ans)


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

typedef struct date{
  long long min;
  long long max;
}date;

int cmp( const void *p, const void *q ) {
    return  ((date*)q)->min - ((date*)p)->min ;
}

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


Measured memory_bytes: 256
n,w = map(int, input().split())
item = [list(map(int,input().split())) for i in range(n)]
dp = [0 for i in range(w+2)]
for v in item:
    for i in range(1,w+2):
        if w+1-i+v[1] <= w:
            dp[w+1-i+v[1]] = max(dp[w+1-i+v[1]],dp[w+1-i]+v[0])
print(dp[w])


Measured memory_bytes: 5928
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let a: usize = sc.read();
    let b: usize = sc.read();
    let mut s = String::new();
    for _ in 0..b {
        s.push((a as u8 + '0' as u8) as char);
    }

    let mut t = String::new();
    for _ in 0..a {
        t.push((b as u8 + '0' as u8) as char);
    }

    if s > t {
        println!("{}", t);
    } else {
        println!("{}", s);
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
$arr=Array.new
root=0
class Tree
  attr_accessor :id,:children,:parent
  def initialize(id,children)
    @id=id
    @parent=-1
    @children=children
  end

  def preParse
    print " #{id}"
    $arr[children[0]].preParse unless children[0]==-1
    $arr[children[1]].preParse unless children[1]==-1
  end
  def inParse
    $arr[children[0]].inParse unless children[0]==-1
    print " #{id}"
    $arr[children[1]].inParse unless children[1]==-1
  end
  def postParse
    $arr[children[0]].postParse unless children[0]==-1
    $arr[children[1]].postParse unless children[1]==-1
    print " #{id}"
  end
end
n=gets.to_i
n.times do
  num,*children=gets.split.map(&:to_i)
  $arr << Tree.new(num,children)
end
$arr.sort_by! do |e|
  e.id
end
$arr.each do |ele|
  ele.children.each do |e|
    $arr[e].parent=ele.id unless e==-1
  end
end
$arr.each do |e|
  if e.parent==-1
    root=e.id
  end
end
puts "Preorder"
$arr[root].preParse
print "\n"
puts "Inorder"
$arr[root].inParse
print "\n"
puts "Postorder"
$arr[root].postParse
print "\n"

Measured memory_bytes: 8720
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  
  if(e-a <= k){
    cout << "Yay!" << endl;
  }
  
  else {
    cout << ":(" << endl;
  }
  
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int ans = a + b + c;
    if (ans <= 21) { cout << "win" << endl; }
    else if (ans > 21) { cout << "bust" << endl; }
}

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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 200005;

int N;
int longest[MX];

void solve() {
    cin >> N;
    vector<int> a(N);
    for (auto& i : a) cin >> i;
    set<int> seen;
    int cm = 0;
    for (int i = 0; i < N; i++) {
		if (seen.find(a[i] - 1) != seen.end()) {
			longest[a[i]] = longest[a[i] - 1] + 1;
			// cout << "Hei";
		} else longest[a[i]] = 1;
		chmax(cm, longest[a[i]]);
		seen.insert(a[i]);
	}
	cout << N - cm;
    // Trying to find the number of numbers out of order
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n;
string s;
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> s;
	int cnt = 0;
	for(int i=0; i<n-2; i++){
		if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') cnt++;
	}
	cout << cnt << endl;
	
	return 0;
}


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

using namespace std;
typedef long long ll;

#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 FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    ll n;
    cin >> n;

    vector<ll> a,a_;
    REP(i,n){
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
        a_.push_back(tmp);
    }
    
    sort(ALL(a));

    REP(i,n){
        if(a_[i]==a[n-1]){
            cout << a[n-2] << endl;
        }
        else{
            cout << a[n-1] << endl;
        }
    }
    
    return 0;
}

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

int n, A, B, C, l[10];
constexpr long long inf = 1000000000;
long long dfs(int now, long long a, long long b, long long c) {
	if (now == n)
		if (std::min({ a, b, c }) > 0)
			return std::abs(a - A) + std::abs(b - B) + std::abs(c - C) - 30;
		else
			return inf;

	auto ret0 = dfs(now + 1, a, b, c);
	auto ret1 = dfs(now + 1, a + l[now], b, c) + 10;
	auto ret2 = dfs(now + 1, a, b + l[now], c) + 10;
	auto ret3 = dfs(now + 1, a, b, c + l[now]) + 10;
	return std::min({ ret0,ret1,ret2,ret3 });
}

int main()
{
	std::cin >> n >> A >> B >> C;
	for (int i = 0; i < n; ++i)
		std::cin >> l[i];

	std::cout << dfs(0, 0, 0, 0) << std::endl;
	return 0;
}


Measured memory_bytes: 256
<?php
  
fscanf(STDIN,"%s",$s);$flg =false;
if(strpos($s, "A") === false){
}else{
  	if(strpos($s,"B") === false){
    }else{
      $flg = true;
    }
}
       
if($flg){
	echo "Yes";
}else{
	echo "No";
}

Measured memory_bytes: 3700
#include <cstdio>
    #include <cstdlib>
    #include <string>
    #include <iostream>
    #include <fstream>
    #include <vector>
    using namespace std;
     
    int main() {
    #ifdef LOCAL
        ifstream in("input.txt");
        cin.rdbuf(in.rdbuf());
    #endif
        long long A, B, K;
        cin >> A >> B >> K;
        if (A == 0 && B == 0) {
            cout << 0 << ' ' << 0 << endl;
        } else if (K < A) {
            cout << A - K << ' ' << B << endl;
        } else if (K <= A + B){
            cout << 0 << ' ' << B - (K - A) << endl;
        } else {
        	cout << 0 << ' ' << 0 << endl; 
        }
        return 0;
    }

Measured memory_bytes: 256
import math as mt
import sys
import bisect
input=sys.stdin.readline
#t=int(input())
t=1

# Python 3 program to answer queries 
# of nCr in O(1) time. 
N = 1000001
  
# array to store inverse of 1 to N 
factorialNumInverse = [None] * (N + 1) 
  
# array to precompute inverse of 1! to N! 
naturalNumInverse = [None] * (N + 1) 
  
# array to store factorial of  
# first N numbers 
fact = [None] * (N + 1) 
  
# Function to precompute inverse of numbers 
def InverseofNumber(p): 
    naturalNumInverse[0] = naturalNumInverse[1] = 1
    for i in range(2, N + 1, 1): 
        naturalNumInverse[i] = (naturalNumInverse[p % i] * 
                                   (p - int(p / i)) % p) 
  
# Function to precompute inverse  
# of factorials 
def InverseofFactorial(p): 
    factorialNumInverse[0] = factorialNumInverse[1] = 1
  
    # precompute inverse of natural numbers 
    for i in range(2, N + 1, 1): 
        factorialNumInverse[i] = (naturalNumInverse[i] * 
                                  factorialNumInverse[i - 1]) % p 
  
# Function to calculate factorial of 1 to N 
def factorial(p): 
    fact[0] = 1
  
    # precompute factorials 
    for i in range(1, N + 1): 
        fact[i] = (fact[i - 1] * i) % p 
  
# Function to return nCr % p in O(1) time 
def Binomial(N, R, p): 
      
    # n C r = n!*inverse(r!)*inverse((n-r)!) 
    ans = ((fact[N] * factorialNumInverse[R])% p * 
                      factorialNumInverse[N - R])% p 
    return ans 
p = 1000000007
InverseofNumber(p) 
InverseofFactorial(p) 
factorial(p)
x1=10**6+1


mod=10**9+7
for _ in range(t):
    
    n=int(input())
    #a,b,c,d=map(int,input().split())
    #u1,d1=map(int,input().split())
    #u2,d2=map(int,input().split())
    #l=list(map(int,input().split()))
    ans=0
    i=1
    while n-i*3>=0:
        ans=(ans%mod+Binomial(n-3*i+i-1, i-1, p))%mod
        i+=1
    print(ans%mod)    

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

using namespace std;

int n, m;
int wa[105000];
bool ac[105000];

int main() {
	cin >> n >> m;
	int wac = 0;
	int acc = 0;
	for (int i = 0; i < n; i++) {
		wa[i] = ac[i] = 0;
	}
	while (m--) {
		int p;
		string s;
		cin >> p >> s;
		if (ac[p]) continue;
		if (s == "AC") {
			ac[p] = 1;
			acc++;
			wac += wa[p];
		}
		else {
			wa[p]++;
		}
	}

	cout << acc << " " << wac << endl;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  cout << n - k + 1 << endl;
  return 0;
}

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

out = n - 1
q, mod = divmod(n, 2)
if mod == 0 and q < out:
    out = q  # (q - 1) + 2 -  1
if n > 2:
    for m in range(3, int(n ** 0.5) + 1):
        q, mod = divmod(n, m)
        if mod == 0 and (q - 1) + (m - 1) < out:
            out = q - 1 + m - 1

print(out)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s=to_string(n);
    int l=s.size();
    if(l==1){
        cout<< n <<endl;
    }
    else if(l==2){
        cout<< 9 <<endl;
    }
    else if(l==3){
        cout<< n-99+9 <<endl;
    }
    else if(l==4){
        cout<< 999-99+9 <<endl;
    }
    else if(l==5){
        cout<< n-9999+999-99+9 <<endl;
    }
    else if(l==6){
        cout<< 99999-9999+999-99+9 <<endl;
    }
}

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

bool a[1001] = {};

int main()
{

  for (int i = 0; i < 1001; ++i)
  {
    //a[i] = true;
  }
  a[1] = true;
  int x;
  cin >> x;
  for (int i = 2; i * i <= x; ++i)
  {
    if (!a[i])
    {
      for (int j = i * i; j <= x; j *= i)
      {
        a[j] = true;
      }
    }
  }

  for (int i = x; i >= 0; --i)
  {
    if (a[i])
    {
      cout << i << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 256
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
mc = 0

for i, j in D:
    if i == j:
        cnt += 1

    else:
        if cnt > mc:
            mc = cnt
        cnt = 0

if cnt > mc:
    mc = cnt

print("Yes" if mc >= 3 else "No")


Measured memory_bytes: 9172
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

public class Main {

    public static int vacation(int[][] arr) {
        if(arr == null || arr.length == 0) {
            return 0;
        }

        int n = arr.length;
        int m = arr[0].length;
        int[][] dp = new int[n][m];

        for(int j = 0; j < m; j++) {
            dp[0][j] = arr[0][j];
        }

        for(int i = 1; i < n; i++) {
            for(int j = 0; j < m; j++) {
                int max = 0;
                for(int k = 0; k < m; k++) {
                    if(k != j) {
                        max = Math.max(max, dp[i - 1][k]);
                    }
                }
                dp[i][j] = max + arr[i][j];
            }
        }
        
        int result = 0;
        for(int j = 0; j < m; j++) {
            result = Math.max(result, dp[n - 1][j]);
        }
        return result;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int[][] arr = new int[n][3];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < 3; j++) {
                arr[i][j] = sc.nextInt();
            }
        }
        
        System.out.println(vacation(arr));
  }
}


Measured memory_bytes: 103476
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long ;
const long long INF = 1e18 ;
int main(){
	ll n , m , q ;
	cin >> n >> m >> q ;
	vector<ll> s(n+2) , t(m+2);
	for(ll i=1;i<=n;i++){
		cin >> s[i] ;
	}
	for(ll i=1;i<=m;i++){
		cin >> t[i] ;
	}
	s[0] = t[0] = -INF ;
	s[n+1] = t[m+1] = INF ;
	while(q--){
		ll x ;
		cin >> x ;
		ll a = lower_bound(s.begin(),s.end(),x) - s.begin() ;
		ll b = lower_bound(t.begin(),t.end(),x) - t.begin() ;
		ll ans = 1e18 ;
		for(ll i=a-1;i<=a;i++){
			for(ll j=b-1;j<=b;j++){
				ans = min({ans,abs(s[i]-x)+abs(s[i]-t[j]),abs(t[j]-x)+abs(t[j]-s[i])});
			}
		}
		cout << ans << endl;
	}

	return 0 ;
}




Measured memory_bytes: 2944
package main

import (
	"bufio"
	"fmt"
	"os"
	"regexp"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		r := regexp.MustCompile(`AtCoder (?P<CName>[A-Z])[a-z]{0,99} Contest`)
		ss := r.FindStringSubmatch(scanner.Text())
		fmt.Printf("A%sC\n", ss[1])
	}
}


Measured memory_bytes: 1024
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  ll a, b, x;
  cin >> a >> b >> x;
  ll ans;
  if (a % x == 0) ans = 1 + b / x - a / x;
  else ans = b / x - a / x;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define testcase() int t; cin>>t; while(t--)
#define fo(n) for (int i = 0; i < n; i++)
#define deb(x) cout << #x << " = " << x << endl;
#define ll long long

using namespace std;

void solve()
{
    int n;
    cin >> n;
    int x;
    ll sum = 0;
    ll arr[100005];
    fo(100005)
        arr[i] = 0;
    fo (n)
    {
        ll x;
        cin >> x;
        arr[x]++;
        sum += x;
    }
    int q;
    cin >> q;
    while (q--)
    {
        int b, c;
        cin >> b >> c;
        ll temp = b * arr[b];
        sum -= temp;
        arr[c] += arr[b];
        sum += arr[b] * c;
        arr[b] = 0;
        cout << sum << endl;
    }
}

int main()
{
    //testcase()
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4340
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val RGB = Array.fill(3)(sc.next).mkString("").toInt

    if (RGB % 4 == 0) "YES" else "NO"
  }
}



Measured memory_bytes: 25784
import copy

n = int(input())
t_li = list(map(int, input().split()))
m = int(input())
px_li = []
result = []

for i in range(m):
  p, x = map(int, input().split())
  px_li.append([p, x])

for j in range(m):
  c_li = copy.copy(t_li)
  c_li[px_li[j][0] - 1] = px_li[j][1]
  result.append(str(sum(c_li)))

string = "\n".join(result)
print(string)

Measured memory_bytes: 3444
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdint.h>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <tuple>
#include <unordered_set>
#include <assert.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))

using namespace std;

#define PB push_back
#define MP make_pair

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;
typedef unsigned long long ULL;

const int MOD = 1000000007;

LL powMod(LL x, int y) {
    LL z = 1;
    for (; y; y >>= 1) {
        if (y & 1) z = z * x % MOD;
        x = x * x % MOD;
    }
    return z;
}

const int N = 200007;

LL frac[N], dfrac[N];

LL choose(int n, int k) {
    return frac[n] * dfrac[k] % MOD * dfrac[n - k] % MOD;
}

int main() {
    frac[0] = dfrac[0] = 1;
    for (int i = 1; i < N; ++i) {
        frac[i] = frac[i - 1] * i % MOD;
        dfrac[i] = powMod(frac[i], MOD - 2);
    }
    int n;
    cin >> n;

    MII times;
    VI a(n + 1);

    int which = -1;
    REP(i, n + 1) {
        scanf("%d", &a[i]);
        if (++times[a[i]] == 2) {
            which = a[i];
        }
    }
    assert(which != -1);

    int first = -1, last = -1;
    REP(i, n + 1) {
        if (a[i] == which) {
            if (first == -1) {
                first = i;
            } else {
                last = i;
            }
        }
    }

    int rest = first + n - last;
    // cout << "rest is " + rest << endl;
    for (int len = 1; len <= n + 1; ++len) {
        LL ans = choose(n + 1, len);
        if (len - 1 <= rest) {
            ans -= choose(rest, len - 1);
        }
        ans = (ans % MOD + MOD) % MOD;
        printf("%d\n", (int) ans);
    }
    return 0;
}

Measured memory_bytes: 9344
#include<iostream>
#include<algorithm>
#include<iterator>
#include<vector>
#include<string>
#include<map>

using namespace std;


#define mod(cans) cans%10**9+7
#define cin_pl(x,y) for(int i=0;i<x;i++){cin>>y[i];}
#define pl_twin(x,y,z) for(int i=0;i<x;i++){cin>>y[i]>>z[i];}
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
//#define st(s) size_t size = s.length()
#define prians(Answer) cout<<Answer<<"\n"
#define make_pair mp;
#define com_div(x,Co) for(int i=1;i<x+1;i++){if(x%i==0){Co++;}}
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int,int> pr;
typedef greater<int> gi;

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


Measured memory_bytes: 256
import itertools

n,m,x = map(int, input().split())

c = [0] * n
a = [[]] * n
for i in range(n):
  c[i], *a[i] = map(int, input().split())

min = float('inf')
for i in range(n + 1):
  for com in list(itertools.combinations(a, i)):
    cost = 0
    skill = [0] * m
    for l in com:
      cost += c[a.index(l)]
      for mi in range(m):
        skill[mi] += l[mi]

    ans = True
    for sm in skill:
      ans = sm >= x and ans

    if ans and min > cost:
      min = cost

if min == float('inf'):
  print(-1)
else:
  print(min)


Measured memory_bytes: 9228
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using llGraph = vector<vl>;
using vb = vector<bool>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

template<typename T>
struct is_vector : false_type{};

template<typename T>
struct is_vector<vector<T>> : true_type{};

template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

template<typename T>
bool CompareBySecond(pair<T, T> a, pair<T, T> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

template<typename T>
bool CompareBySlope(pair<T, T> a, pair<T, T> b) {
// counterclockwise from 12 o'clock direction
  if (a.first * b.first < 0) {
    return a.first < b.first;
  }
  if (a.first == 0) {
    if (a.second >= 0) {
      return true;
    }
    return a.first < b.first;
  }
  if (b.first == 0) {
    if (b.second >= 0) {
      return false;
    }
    return a.first < b.first;
  }
  return a.second * b.first < a.first * b.second;
}

template<typename T>
T GCD(T a, T b) {
  T c = a % b;
  while (c != 0) { a = b; b = c; c = a % b; }
  return b;
}


/* -------- <templates end> -------- */


void solve() {
  double a, b, x; cin >> a >> b >> x;
  double na, nb;
  if (x < a*a*b/2) {
    na = x*2 / (a*b);
    nb = b;
  } else {
    na = a;
    nb = (a*a*b - x)*2 / (a*a);
  }
  double radian = atan2(nb, na);
  cout << radian * (180/M_PI) << endl;
}


/* -------- <programs end> -------- */


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long H;
  cin >> H;

  for (int i = 0; i < H; i++) {
  	if (pow(2.0, double(i+1)) > H) {
      cout << fixed << setprecision(0) << pow(2.0, double(i+1)) - 1 << endl;
      return 0;
    }
  }
}

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

int main(){
  int a, b; cin >> a >> b;
  int plus = a+b;
  int minus = a-b;
  int multiply = a*b;
  int better;
  if(plus >= minus){
    better = plus;
  }else{
    better = minus;
  }
  if(better>=multiply){
    cout << better << endl;
  }else{
    cout << multiply << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    char pre = '@';
    int ans = 0;
    for(char c: s) {
        if (c == pre) {
            ans += 1;
        }
        pre = c;
    }
    cout << min(ans+k*2, n-1) << endl;
    return 0;
}



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

int main(){
  int N;
  cin >> N;
  int A[N+2];
  int diff[N+1];
  int sum = 0;
  int result = 0;
  A[0] = 0;
  A[N+1] = 0;
  for(int i=1;i<=N;i++) cin >> A[i];
  for(int i=1;i<=N+1;i++){
  	diff[i-1] = abs(A[i]-A[i-1]);
    //cout << diff[i-1] << " ";
	sum += diff[i-1];
  }
  for(int i=1;i<=N;i++){
    result = sum - diff[i-1] - diff[i] + abs(A[i+1] - A[i-1]);
	cout << result << endl;
  }
  /*
  for(int i=0;i<N;i++){
  	sum = 0;
	before = 0;
	for(int j=0;j<N;j++){
	  if(i!=j){
	    sum += abs(A[j] - before);
		before = A[j];
	  }
	}
	sum += abs(before);
	cout << sum << endl;
  }
  */
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N ;
    cin >> N ;
    vector<ll> a;
    ll o = 0 ;
    ll e = 0;
    rep(i,N){
        ll inp;
        cin >> inp;
        if(inp %2 == 0) e ++;
        else o ++;
        a.pb(inp);
    }
    
    if(o != 0) cout << "first" << endl;
    else cout << "second" << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int x, a, b;
	cin >> x >> a >> b;
	
	if( abs(x - a) > abs(x - b) ) {
		cout << "B" << endl;
	} else {
		cout << "A" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3648