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

typedef string::iterator State;
typedef map<char, int> Env;

int formula(State& state, Env env) {
    if ('0' <= *state && *state <= '2') {
        return *state++ - '0';
    }

    if ('P' <= *state && *state <= 'R') {
        return env[*state++];
    }

    if (*state == '-') {
        ++state;
        return 2 - formula(state, env);
    }

    ++state; // '('
    int lhs = formula(state, env);
    char op = *state++;
    int rhs = formula(state, env);
    ++state; // ')'

    if (op == '+') {
        return max(lhs, rhs);
    } else if (op == '*') {
        return min(lhs, rhs);
    }

    assert(false);
}


int main() {
    string expr;
    Env env;
    while (true) {
        cin >> expr;

        if (expr == ".") {
            break;
        }

        int count = 0;

        for (int j = 0; j < 27; ++j) {
            env['P'] = j % 3;
            env['Q'] = (j / 3) % 3;
            env['R'] = j / 9;

            State state = expr.begin();
            if (formula(state, env) == 2) {
                ++count;
            }
        }
        
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 1188
'use strict'
var lines = require('fs').readFileSync(0, 'utf8').split('\n')
var str = lines[0]
var n = str.length - 1;
var dfs = (i, sum, order) => {
  if (i === n) return eval(order + str[n]) == 7 ? order + str[n] : '';
  var temp = dfs(i + 1, sum, order + str[i] + '+')
  return  temp ? temp : dfs(i + 1, sum, order + str[i] + '-');
}

var ans = dfs(0, 0, '');
console.log(ans ? ans + '=7' : '');

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) cout << "No";
    else if (a != b && a != c && b != c) cout << "No";
    else cout << "Yes";
    return 0;
}



Measured memory_bytes: 256
x = gets.to_i

h = {}
-1000.upto(100000) do |i|
  h[i ** 5] = i
end

-1000.upto(100000) do |a|
  b5 = a ** 5 - x;
  if h.key?(b5)
    puts "#{a} #{h[b5]}"
    break
  end
end


Measured memory_bytes: 22652
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int s, w;
  cin >> s >> w;
  if (w >= s)
    cout << "unsafe" << endl;
  else
    cout << "safe" << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <stdio.h>

using namespace std;

int A[51][51];
int B[51][51];
int N, M;

int solve(){
  for(int i = 0; i + M <= N; i++){
    for(int j = 0; j + M <= N; j++){
      int result = 1;
      for(int k = 1; k <= M; k++){
        for(int l = 1; l <= M; l++){
          //cout << k << " " << l << " " <<
          if(A[i+k][j+l] != B[k][l]){
            result = 0;
            l = M+1;
            k = M+1;
          }
        }
      }
      if(result == 1){
        cout << "Yes" << endl;
        i = N+1;
        j = N+1;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

int main(){
  char c;
  cin >> N >> M;

  for(int i = 1; i <= N; i++){
    for(int j = 1; j <= N; j++){
      cin >> c;
      if(c == '#')  A[i][j] = 1;
      else A[i][j] = 0;
      //cout << A[i][j] << endl;
    }
  }
  for(int i = 1; i <= M; i++){
    for(int j = 1; j <= M; j++){
      cin >> c;
      if(c == '#') B[i][j] = 1;
      else B[i][j] = 0;
      //cout << B[1][1] << endl;
    }
  }
  int p = solve();

  return 0;

}


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

ll gcd(ll a, ll b){
  if (b==0) return a;
  return gcd(b,a%b);
}

// a以上b以下の整数のうち、xで割り切れるものの個数を求める
ll divs(ll a, ll b, ll x){
  return b/x-(a-1)/x;
}

int main() {
  ll a,b,c,d; cin >>a >>b >>c >>d;
  ll g = gcd(c,d);
  ll lcm = c * (d / g);
  ll ans = (b-a+1)-divs(a,b,c)-divs(a,b,d)+divs(a,b,lcm);
  cout <<ans <<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

int main() {
  int N;
  while (cin >> N) {
    vector<char> prime(1200, true);
    int ret = 1;
    for (int i = 2; i <= N; ++i) {
      if (!prime[i]) continue;
      for (int j = 2 * i; j <= N; j += i) prime[j] = false;
      int cnt = 0;
      for (int j = i; j <= N; j += i) {
        int x = j;
        while (x % i == 0) {
          x /= i;
          cnt++;
        }
      }
      // if (N<=10) cout<<"#"<<i<<" "<<cnt<<endl;
      ret = ((ll)ret * (cnt + 1)) % 1000000007;
    }
    cout << ret << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define MAX_N 1000000

bool f[MAX_N + 1];

void
preparation()
{
	for (int i = 0; i <= MAX_N; ++i)
		f[i] = false;

	for (int i = 1; i <= MAX_N; ++i)
	{
		int j = i;
		while (j % 2 == 0)
			j /= 2;

		while (j % 3 == 0)
			j /= 3;

		while (j % 5 == 0)
			j /= 5;

		if (j == 1)
			f[i] = true;
	}
}

int
main(int argc, char **argv)
{
	preparation();

	while (true)
	{
		int m, n;
		scanf("%d", &m);
		if (m == 0)
			break;

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

		printf("%d\n", count);
	}

	return 0;
}


Measured memory_bytes: 2824
def main():
    import sys
    from operator import itemgetter
    buf = sys.stdin.buffer

    class UnionFind:
        def __init__(self, size):
            self.parent = [-1] * size
            self.rank = [1] * size

        def get_root(self, node):
            parent = self.parent[node]
            if parent == -1:
                root = node
            else:
                root = self.get_root(parent)
                self.parent[node] = root  # 同じnodeへの2回目以降のget_rootを高速にするために、直接rootに繋いでおく
            return root

        def in_same_group(self, node1, node2):
            root1 = self.get_root(node1)
            root2 = self.get_root(node2)
            return root1 == root2

        def unite(self, node1, node2):
            if self.in_same_group(node1, node2):
                return
            main_root = self.get_root(node1)
            sub_root = self.get_root(node2)
            if self.rank[main_root] < self.rank[sub_root]:  # rankの大きい方をmain_rootにする
                main_root, sub_root = sub_root, main_root

            self.parent[sub_root] = main_root
            self.rank[main_root] += self.rank[sub_root]

    n, m, k = map(int, buf.readline().split())
    uf = UnionFind(n)
    minus_count = [1] * n

    query = map(int, buf.read().split())

    def gen():
        for num in query:
            yield num

    generator = gen()
    for _ in range(m):
        a, b = generator.__next__(), generator.__next__()
        uf.unite(a-1, b-1)
        minus_count[a-1] += 1
        minus_count[b-1] += 1

    for i in range(k):
        a, b = generator.__next__(), generator.__next__()
        if uf.in_same_group(a-1, b-1):
            minus_count[a-1] += 1
            minus_count[b-1] += 1

    result = []
    for i in range(n):
        parent = uf.get_root(i)
        count = uf.rank[parent]
        ans = count - minus_count[i]
        result.append(ans)

    print(*result)

if __name__ == '__main__':
    main()

Measured memory_bytes: 34152
n,m=map(int,input().split())
e=[list(map(int,input().split())) for _ in range(m)]

cnt=0
for x in e:
  l=list(range(n))
  for y in e:
    if y!=x:l=[l[y[0]-1] if l[i]==l[y[1]-1] else l[i] for i in range(n)]
  if len(set(l))!=1:cnt+=1
print(cnt)

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

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;

    double mx = 1.0 * w / 2, my = 1.0 * h / 2;
    double ans = w * h / 2.0;
    int flg = (mx == x && my == y) ? 1 : 0;
    cout << fixed << setprecision(10) << ans << " " << flg << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
long long n,a[200100];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int k=0;	
	for(int i=1;i<=n;i++)
		if(a[i]==k+1)
			k++;
	if(k==0)		
		cout<<-1<<endl;
	else
		cout<<n-k<<endl;	
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
ll inf = 1e9+7;

ll gcd(ll a, ll b){
  return (b != 0) ? gcd(b, a%b) : a;
}

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n; ll k;
  cin >> n >> k;
  vpii ab(n);
  rep(i, n) cin >> ab[i].first >> ab[i].second;
  sort(ab.begin(), ab.end());
  ll cnt = 0;
  rep(i, n){
    cnt += ab[i].second;
    if(cnt >= k){cout << ab[i].first << "\n"; return 0;}
  }
  return 0;
}   

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std; 
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)

int main()  
{ 
    FAST_INP;
    int n;
    cin >> n;
    vector<int> h(n), dp(n);
    for(int i=0;i<n;i++) cin >> h[i];
  	dp[0]=0;
  	dp[1]=abs(h[1]-h[0]);
  	for(int i=2;i<n;i++) {
    	dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
  	cout << dp[n-1] << "\n";
    return 0;
} 

Measured memory_bytes: 3972
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int euler(int num){

	 int ret = num;

	 for(int i = 2; i*i <= num;  i++){
			if(num%i == 0) {
				  ret  = ret/i*(i-1);
				  while(num%i == 0)num /= i;
			}
	  }
	  if(num != 1) ret = ret/num*(num-1);
	  return ret;
}

int main(){

	ll* table = new ll[1000001];

	table[1] = 2;

	for(int i = 2; i <= 1000000; i++){
		table[i] = table[i-1] + euler(i);
	}

	int Q;
	scanf("%d",&Q);

	int tmp;

	for(int loop = 0; loop < Q; loop++){
		scanf("%d",&tmp);
		printf("%lld\n",table[tmp]);
	}

	return 0;
}

Measured memory_bytes: 10884
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

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

    vl v(100010);
    vl ans(100010);
    rep(i, n) {
        ll a;
        cin >> a;
        v[a]++;
        ans[0] += a;
    }

    ll q;
    cin >> q;
    exrep(i, 1, q) {
        ll b, c;
        cin >> b >> c;
        ans[i] = ans[i-1];
        ans[i] += (c - b)*v[b];
        v[c] += v[b];
        v[b] = 0;
    }

    exrep(i, 1, q) {
        out(ans[i]);
    }

    re0;
}

Measured memory_bytes: 4828
N, Y = map(int, input().split())

q = Y//1000 - N

x = [0, 4, 8, 3, 7, 2, 6, 1, 5]

B = x.index(q%9)
b = B
while 4*b <= q:
    c = (q - 4*b) // 9
    a = N-c-b
    if a<0:
        b += 9
        continue
    else:
        print(c, b, a)
        break
else:
    print(-1, -1, -1)


Measured memory_bytes: 61964
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD = 1000000007;
//
int fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
        signed main() {
            COMinit();
            int n;
            cin>>n;
            int x[n];
            for(int i=0;i<n;i++)cin>>x[i];
         int ans=0,k=0;
         for(int i=0;i<n-1;i++){
             k=(k+inv[i+1])%MOD;
             ans=(ans+k*(x[i+1]-x[i])%MOD)%MOD;
         }
         cout<<fac[n-1]*ans%MOD;
         return 0;

        }


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

const int N = 1e3 + 10;
const int M = 1e5 + 10; 

int n, w;
//ll dp[N][M];
ll dp[2][M];
ll weight[N], value[N];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	cin >> n >> w;
	for (int i = 1; i <= n; ++i) cin >> weight[i] >> value[i];
	
	/*
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= w; ++j) {
			if (weight[i] <= j)
				dp[i][j] = max(value[i] + dp[i-1][j-weight[i]], 
								          dp[i-1][j]);
			else
				dp[i][j] = dp[i-1][j];
		}
	}

	cout << dp[n][w] << "\n";*/

	int m = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= w; ++j) {
			if (weight[i] <= j)
				dp[m][j] = max(value[i] + dp[m^1][j-weight[i]],
										  dp[m^1][j]);
			else
				dp[m][j] = dp[m^1][j];
		}
		m^=1;
	}

	cout << dp[m^1][w] << "\n";

	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int minimum(int min, int x) {
    if (x <= min) {
        return x;
    } else {
        return min;
    }
}

int maximum(int max, int x) {
    if (x >= max) {
        return x;
    } else {
        return max;
    }
}

void process() {
    int n;
    int i;
    int x, min=1000000, max=-1000000;
    long sum=0;
        
    scanf("%d\n", &n);
    for (i=0; i<n; i++) {
        scanf("%d", &x);
	sum += x;
	min = minimum(min, x);
	max = maximum(max, x);
    }
    printf("%d %d %ld\n", min, max, sum);
}

int main(void) {
    process();
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

int main(){
  long long H, W; cin >> H >> W;

  long long ans = H * W;
  if (H % 3 == 0 || W % 3 == 0){
    ans = 0;
  }else{
    for (int i = 1; i < H - 1; i++){
      long long A = i * W;
      long long B = (H - i) * (W / 2);
      long long C = (H - i) * (W - W / 2);

      long long M = max(A, max(B, C));
      long long m = min(A, min(B, C));

      if (ans > M - m) ans = M - m;
    }

    for (int i = 1; i < W - 1; i++){
      long long A = i * H;
      long long B = (W - i) * (H / 2);
      long long C = (W - i) * (H - H / 2);

      long long M = max(A, max(B, C));
      long long m = min(A, min(B, C));

      if (ans > M - m) ans = M - m;
    }

    if (ans > min(H, W)) ans = min(H, W);
  }
  if (H == 2 && W == 2){
    ans = 1;
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b;
	char op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		if(op=='?'){
			break;
		}
		if(op=='+'){
			printf("%d\n",a+b);
		}else if(op=='-'){
			printf("%d\n",a-b);
		}else if(op=='*'){
			printf("%d\n",a*b);
		}else if(op=='/'){
			printf("%d\n",a/b);
		}
	}
}


Measured memory_bytes: 2140
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		int a, b, c, d, e, f;
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		d = sc.nextInt();
		e = sc.nextInt();
		f = sc.nextInt();
		
		float max;
		int maxw, maxs;
		max = -10.0f;
		maxw = 0;
		maxs = 0;
		
		for(int i=0; i*a*100<=f; i++){
			for(int j=0; i*a*100 + j*b*100<=f; j++){
				for(int k=0; i*a*100 + j*b*100 + k*c<=f; k++){
					for(int l=0; i*a*100 + j*b*100 + k*c + l*d<=f; l++){
						if((i*a+j*b)*e >= k*c+l*d){
							if(i+j == 0){
								break;
							}
							if((float)(100*(k*c+l*d)) / (float)(100*i*a+100*j*b+k*c+l*d) > max){
								max = (float)(100*(k*c+l*d)) / (float)(100*i*a+100*j*b+k*c+l*d);
								maxw = 100*i*a + 100*j*b;
								maxs = k*c + l*d;
							}
						}
					}
				}
			}
		}
		
		System.out.println((maxw+maxs) + " " + maxs);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

signed main(){
  static int N,X,m[1000],sum=0,min=1000;
  cin>>N>>X;
  for(int t=0;t<N;t++){
    cin>>m[t];
    sum+=m[t];
    if(min>m[t])min=m[t];
  }
  X-=sum;
  int ans=N+X/min;
  cout<<ans<<"\n";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (signed)(a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define MOD 1000000007
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
#define tp(a, b, c) make_tuple(a, b, c)
using namespace std;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
//------------------変数-----------------------//
//-------------------関数----------------------//

//-------------------??¢??°----------------------//

int main() {
  ll n;
  cin >> n;
  if (n >= 24) {
    cout << 0 << endl;
    return 0;
  }
  vector<ll> s;
  REP(i, n) {
    ll h;
    cin >> h;
    if (h == 0) {
      cout << 0 << endl;
      return 0;
    }
    s.pb(h);
  }
  sort(s.begin(), s.end());
  bool flag[1010] = {};
  REP(i, (signed)s.size() - 1) {
    if (s[i] == s[i + 1]) {
      if (flag[s[i]] == true || s[i] == 12) {
        cout << 0 << endl;
        return 0;
      }
      flag[s[i]] = true;
    }
  }
  s.erase(std::unique(s.begin(), s.end()), s.end());
  ll maxe = 0;
  REP(i, (1 << s.size())) {
    vector<ll> se;
    ll maxa = INF;
    se.pb(0);
    REP(j, s.size()) {
      if (flag[s[j]]) {
        se.pb(s[j]);
        se.pb(24 - s[j]);
      } else if ((i >> j) & 1) {
        se.pb(24 - s[j]);

      } else {
        se.pb(s[j]);
      }
    }
    sort(se.begin(), se.end());
    REP(i, se.size()) {
      REP(j, se.size()) {
        if (i == j) {
          continue;
        }
        maxa = min({maxa, abs(se[i] - se[j]), 24 - abs(se[i] - se[j])});
      }
    }
    if (maxa == INF || maxa == 24) {
      maxa = 0;
    }
    maxe = max(maxa, maxe);
  }

  cout << maxe << endl;
  return 0;
}


Measured memory_bytes: 256
// @author PraveenKumarRana

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define int long long int
#define vi vector<int>
#define pi pair<int, int>
#define IOS std::ios_base::sync_with_stdio(false);
#define all(x) x.begin(), x.end()
#define f(i, a, n) for (int i = a; i < n; i++)
#define fr(i, n, a) for (int i = n - 1; i >= a; --i)

const int mod = 1e9 + 7;
const int inf = 1e16 + 7;

void SOLVE() {
    // Write your code here ?
    int n, k;
    cin >> n >> k;
    map<int, int> mp;
    f(i, 0, k) {
        int x;
        cin >> x;
        mp[x] = 1;
    }

    while (true) {
        bool ok = true;
        int N = n;
        while (N > 9) {
            if (!mp[N % 10]) {
                N /= 10;
            } else {
                ok = false;
                break;
            }
        }

        if (N > 0 && !mp[N]) {
            N /= 10;
        } else {
            ok = false;
        }

        if (!ok) {
            N = n + 1;
            n++;
        } else {
            break;
        }
    }

    cout << n << endl;
}

int32_t main() {
    IOS;
    SOLVE();
    return 0;
}


Measured memory_bytes: 8580
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

  int n;
  cin >> n;
  int s[n], l[n], p[n];
  rep(i, 0, n) {
    cin >> s[i] >> l[i] >> p[i];
  }

  ll dp[400];
  memset(dp, 0, sizeof(dp));
  rep(i, 0, n) {
    rep(j, 0, 400) {
      rep(k, s[i], l[i] + 1) {
        if(j - k >= 0) {
          chmax(dp[j], dp[j - k] + p[i]);
        }
      }
    }
  }

  int m;
  cin >> m;
  vector<int> rsl;
  rep(i, 0, m) {
    int w;
    cin >> w;
    if(dp[w] == 0) {
      cout << -1 << endl;
      return 0;
    }
    rsl.push_back(dp[w]);
  }

  rep(i, 0, rsl.size()) {
    cout << rsl[i] << endl;
  }
}



Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl

/*--------------------template--------------------*/

ll f(ll a,ll b){
    ll ret = 0;
    string c = to_string(a);
    string d = to_string(b);
    REP(i,c.size()) {
        ret += c[i] - '0';
    }
    REP(i,d.size()) {
        ret += d[i] - '0';
    }
    return ret;
}

int main() {
    cin >> n;
    m = n / 2;
    k = n - m;
    n = m;
    ans = f(m,k);
    REP(i,n-1) {
        m--;
        k++;
        chmin(ans, f(m, k));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int knapsack(long long int wt[], long long int val[], long long int w, long long int n)
{
	long long int knap[n+1][w+1];
	for(int i = 0; i < n+1; i++ ){
		for(int j = 0; j < w+1; j++ ){
			if(i == 0 || j == 0)
				knap[i][j] = 0;
			else if( wt[i-1] <= j)
				knap[i][j] = max(val[i-1] + knap[i-1][j-wt[i-1]], knap[i-1][j]);
			else
				knap[i][j] = knap[i-1][j];
		}
	}
	return knap[n][w];
}
int main()
{
  long long int n,w;
  cin>>n>>w;
  long long int wt[n],val[n];
  for(int i = 0; i < n; i++){
  	cin>>wt[i]>>val[i];
  }
  cout<<knapsack(wt,val,w,n);
}

Measured memory_bytes: 82316
#include<bits/stdc++.h>
#define re    return
#define pii   pair<int,int>
#define hell  1000000007
#define rep(i,a,b)  for (__typeof(b) i=(a)-((a)>(b));i!=(b)-((a)>(b));i+=1-2*((a)>(b)))
#define boost ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define pb  push_back
#define ff          first
#define ss          second
#define sz(x)       (int)x.size()
#define all(a)      (a).begin(),(a).end()

//v.resize(distance(v.begin(),unique(v.begin(),v.end())));

typedef long long  ll;
using namespace std;

const ll INF=(1LL<<60)-1;
const int nax=1e5+20;

const int Maxn = 505;

int n, m, q;
int dp[Maxn][Maxn];

int main()
{
	boost;
	
	scanf("%d %d %d", &n, &m, &q);
	while (m--) {
		int l, r; scanf("%d %d", &l, &r);
		dp[l][r]++;
	}
	for (int l = 1; l <= n; l++)
		for (int i = 1,j = i+l; j <= n; i++,j++) {
			dp[i][j] += dp[i + 1][j] + dp[i][j - 1] - dp[i + 1][j - 1];
		}
	while (q--) {
		int l, r; scanf("%d %d", &l, &r);
		printf("%d\n", dp[l][r]);
	}
	return 0;
}


Measured memory_bytes: 1920
fun main(args: Array<String>) {
    val s = readLine()!!
    print(if (req1(s)&&req2(s)&&req3(s)) "AC" else "WA")
}

fun req1(s: String): Boolean {
    return s[0] == 'A'
}

fun req2(s: String): Boolean {
    return s.substring(2 until s.length-1).filter{it == 'C'}.length == 1
}

fun req3(s: String): Boolean {
    return s.filter{(it != 'A' && it != 'C')}.all{it.isLowerCase()}
}


Measured memory_bytes: 33908
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int n;cin >> n;
  int ans=0;
  orep(i,n) {
    int a;cin >> a;
    if(i%2==0) continue;
    if(a%2==1) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3596
// Problem : B - Colorful Creatures
// Contest : AtCoder - AtCoder Grand Contest 011
// URL : https://atcoder.jp/contests/agc011/tasks/agc011_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;
 
//krishrawat 
 
 
//----------------------------MACROS-------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 1e6 + 1;//                                                             |
//----------------------------------------------------------------------------------
 
 
void solve(){
    ll n;cin>>n;
    vp v;
    for(int i=0;i<n;i++){
    	ll k;cin>>k;
    	v.eb(k,i);
    }
    sort(all(v));
    vl vis(n,0);
    ll sums=0;
    vis[n-1]=1;
    for(int i=0;i<n-1;i++){
    	sums+=v[i].ff;
    	if(v[i+1].ff<=2*sums){
    		vis[i]=1;
    	}
    }
    
    ll ans=0;
    for(int i=n-1;i>=0;i--){
    	if(vis[i]){
    		ans++;
    	}
    	else break;
    }
    cout<<ans<<"\n";
}
 
int main()
{	
	/*#ifndef ONLINE_JUDGE 
   		freopen("input.txt", "r", stdin);  
   		freopen("output.txt", "w", stdout); 
   	#endif*/
 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
     
 
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    
	return 0;
}

Measured memory_bytes: 5552
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,f,g,h,i,j,x;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if(a<0){
			f=a*-1;
			g=f*c;
			h=g+d;
			i=b*e;
			j=h+i;
	}
	else if(a>0){
			x=b-a;
			j=x*e;
	}
	printf("%d\n",j);
	return 0;
}


Measured memory_bytes: 2708
#include<stdio.h>
#include<math.h>

typedef struct{
  double x;
  double y;
} point;

void koch(int d, point p1, point p2){
  if(d == 0)
    return;
  point s, t, u;
  s.x = (p1.x * 2 + p2.x)/3;
  s.y = (p1.y * 2 + p2.y)/3;
  t.x = (p1.x + p2.x * 2)/3;
  t.y = (p1.y + p2.y * 2)/3;
  u.x = (p1.x + p2.x)/2 + (p1.y - p2.y)/(2 * sqrt(3));
  u.y = (-p1.x + p2.x)/(2 * sqrt(3)) + (p1.y + p2.y)/2;
  koch(d-1, p1, s);
  printf("%f %f\n", s.x, s.y);
  koch(d-1, s, u);
  printf("%f %f\n", u.x, u.y);
  koch(d-1, u, t);
  printf("%f %f\n", t.x, t.y);
  koch(d-1, t, p2);
}

int main(void){
  int n;
  scanf("%d", &n);
  point p1, p2;
  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;
  printf("%f %f\n", p1.x, p1.y);
  koch(n, p1, p2);
  printf("%f %f\n", p2.x, p2.y);
  return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;


signed main(){
	//cout << fixed << setprecision(10);
	ll n; cin >> n;
	ll sum_gcd;
	ll m = 0;
	map<ll,ll> mp;
	bool ans = 1;
	vector<bool> vec(1001000,false);
	rep(i,0,n){
		ll a; cin >> a;
		if(mp[a] > 0 && a != 1){
			ans = 0;
		}
		mp[a]++;
		vec[a] = 1;
		if(i == 0)sum_gcd = a;
		else sum_gcd = __gcd(a,sum_gcd);
		chmax(m,a);
	}
	vector<bool> not_prime(m + 1);
	for(ll i = 2;i <= m;i++){
		if(not_prime[i])continue;
		ll cnt = 0;
		ll j = i;
		bool ok = true;
		while(j <= m){
			not_prime[j] = 1;
			if(vec[j])cnt++;
			if(cnt > 1){
				ok = 0;
				break;
			}
			j += i;
		}
		if(!ok){
			ans = 0;
			break;
		}
	}
//	cout << sum_gcd << endl;
	if(ans)cout << "pairwise coprime" << endl;
	else if(sum_gcd == 1)cout << "setwise coprime" << endl;
	else cout << "not coprime" <<endl;


	return 0;
}


Measured memory_bytes: 66380
/*
    アリナ・グレイはかわいい
*/

#include<bits/stdc++.h>
using namespace std;
#define itn int
#define ll long long

int main(void){
    int k,n;
    cin >> k >> n;
    int a[n];
    for(int i = 0;i < n;i++)cin >> a[i];
    sort(a,a+n);
    ll sum = a[n-1]-a[0];
    for(int i = 1;i < n;i++){
        ll sum2 = (k-a[i])+a[i-1];
        sum = min(sum,sum2);
    }
    cout << sum << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

string K[3] = { "Sunny", "Cloudy", "Rainy"};
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    rep(i, 3) if(S == K[i]) cout << K[(i + 1) % 3] << endl;


    return 0;
}


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

#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>=(ll)(b);i--)
typedef long long ll;
using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C){
    if(A == B && B != C && C != A){ cout << YES << endl; return ;}
    if(A != B && B != C && C == A){ cout << YES << endl; return ;}
    if(A != B && B == C && C != A){ cout << YES << endl; return ;}

    cout << NO << endl;
    return;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;


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

	void run(){
		Scanner sc = new Scanner(System.in);
		String a;
		while(true){
			if(!sc.hasNext()){
				break;
			}
			a = sc.next();
			BigInteger bi1 = new BigInteger(a);
			BigInteger bi12 = bi1;
			a = sc.next();
			BigInteger bi2 = new BigInteger(a);
			BigInteger bi22 = bi2;
			switch(bi1.compareTo(bi2)){
			case 1:
				//テ・ツシツ陛ヲツ閉ーテ」ツつ暗」ツつ甘・ツ、ツァテ」ツ?催」ツ??
				bi1 = solve(bi1,bi2);
				break;
			case 0:
				//テ・ツシツ陛ヲツ閉ーテ」ツ?ィテ・ツ青古」ツ??
				break;
			case -1:
				bi1 = solve(bi2,bi1);
				break;
			}
			System.out.println(bi1+" "+bi12.multiply(bi22).divide(bi1));
		}
	}

	BigInteger solve(BigInteger bi1, BigInteger bi2){
		if(!bi1.remainder(bi2).equals(new BigInteger("0"))){
			bi1 = bi1.remainder(bi2);
			return solve(bi2,bi1);
		}
		return bi2;
	}
}

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

int n; string s;
vector<int> v[3];

ll cal(int a, int b, int c) {
	ll ret = 0;
	for (int i = 0; i < v[a].size(); i++) {
		for (int j = upper_bound(v[b].begin(), v[b].end(), v[a][i]) - v[b].begin(); j < v[b].size(); j++) {
			for (int k = upper_bound(v[c].begin(), v[c].end(), v[b][j]) - v[c].begin(); k < v[c].size(); k++) {
				if (v[b][j] - v[a][i] != v[c][k] - v[b][j]) {
					++ret;
				}
			}
		}
	}
	return ret;
}

int main() {
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') v[0].push_back(i);
		else if (s[i] == 'G') v[1].push_back(i);
		else v[2].push_back(i);
	}
	ll ans = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (i != j && i !=k && j != k) {
					ans += cal(i, j, k);
				}
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int a, b, c;
int main() {
	for(int i = 0; i < 3; i++) {
		int t1, t2;
		cin >> a >> b >> c; t1 = a * 3600 + b * 60 + c;
		cin >> a >> b >> c; t2 = a * 3600 + b * 60 + c;
		int t3 = t2 - t1;
		cout << t3 / 3600 << ' ' << t3 / 60 % 60 << ' ' << t3 % 60 << endl;
	}
	return 0;
}

Measured memory_bytes: 3044
n = int(input())
h = list(map(int, input().split()))

max_move = 0
current_move = 0
for h1, h2 in zip(h[:-1], h[1:]):
    if h2 <= h1:
        current_move += 1
    else:
        if max_move < current_move:
            max_move = current_move
        current_move = 0
if max_move < current_move:
    max_move = current_move

print(max_move)

Measured memory_bytes: 14224
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var S = Console.ReadLine();
            var T = Console.ReadLine();
            var answer = "";
            for (var i = 0; i < S.Length; i++)
            {
                answer += S[i];
                if (i < T.Length) answer += T[i];
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 25812
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>


#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int N, A, B, C;

int rec(int a, int b, int c, int i, vector<int>& l){
  if(i == N){
    return (a && b && c ? abs(A - a) + abs(B - b) + abs(C- c) - 30: INT_MAX - 1000);
  }
  return min({rec(a + l[i], b, c, i + 1, l) + 10,
	      rec(a, b + l[i], c, i + 1, l) + 10,
	      rec(a, b, c + l[i], i + 1, l) + 10,
	      rec(a, b, c, i + 1, l)
            });
}

int main(){  
  cin >> N >> A >> B >> C;
  vector<int> l(N);
  for(int i = 0; i < N; i++) cin >> l[i];
  cout << rec(0, 0, 0, 0, l) << endl;
  return 0;
}

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

int main() {
    string s;
    bool tag = false;
    cin >> s;
    if (s.at(2)==s.at(3)) {
        if (s.at(4)==s.at(5)) {
            tag = true;
        }
    }
    if (tag==true) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0; i<n; i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    cout << vec.at(n-1) - vec.at(0) << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n string
	fmt.Scan(&n)

	n = strings.Replace(n, "1", "2", -1)
	n = strings.Replace(n, "9", "1", -1)
	n = strings.Replace(n, "2", "9", -1)

	fmt.Println(n)
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		System.out.println(Math.min(b/a,c));
		sc = null;
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#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>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    cout << min(A*N, B) << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> ii;
int main(){
  int n;
  cin >> n;
  vector<ll>a(n), b(n);
  for(int i = 0; i < n; i++)
    cin >> a[i] >> b[i];
  ll cnt = 0;
  ll ans = 0;
  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());
  for(int i = 0; i < n; i++){
    a[i]+=cnt;
    ll tmp = (b[i] - (a[i]%b[i]))%b[i];
    cnt+=tmp;
    ans+=tmp;
  }
  cout << ans << '\n';




return 0;}


Measured memory_bytes: 1920
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int H,W,h,w;
	cin>>H>>W>>h>>w;
	cout<<H*W-H*w-W*h+h*w<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void solve(int A,int B,int C,int K){
     while(B<=A){
          B*=2;
          K--;
          if(K==-1){
               cout << "No";
               // cout << A << " " << B << " " << C << endl;
     
	          return;
          }
     }
	while(C<=B){
	     
	    // if(C<=B){
     	     C*=2;
     	     K--;
	    // }
	     if(K==-1){
	          cout << "No";
	         // cout << A << " " << B << " " << C << endl;
     
	          return;
	     }
	}
	cout << "Yes" << endl;;
     
}
int main() {
	int A,B,C;
	cin >> A >> B >> C;
	int K;
	cin >> K;
	
	solve(A,B,C,K);
	
	
	return 0;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans=0;
    bool x = true;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n;i++){
        cin >> a.at(i);
    }
    while(x){
        for (int i = 0; i < n; i++){
            if(a.at(i)%2==1){
                x = false;
                 break;
            }
            a.at(i) /= 2;
        }
        if(!x) break;
        ans++;
    }

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


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

using namespace std;

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

    vector<int> L_i;

    for (int i { 0 }; i < N; ++i) {
        int tmp;
        cin >> tmp;
        L_i.push_back(tmp);
    }

    int count { 1 };
    int d { 0 };
    for (int i { 0 }; i < N; ++i) {
        d = d + L_i[i];

        if (d > X) break;

        count++;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	H, W, N := nextInt(), nextInt(), nextInt()
	// an := make([]int, N)
	a := make([]int, 0)

	for i := 0; i < N; i++ {
		num := nextInt()
		for j := num; j > 0; j-- {
			a = append(a, i+1)
		}
	}
	Chw := make([][]int, H)
	for i := range Chw {
		Chw[i] = make([]int, W)
	}
	// for i := range an {
	// 	an[i] = nextInt()
	// }
	var ai int
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			var index int
			if i%2 == 0 {
				index = j
			} else {
				index = W - 1 - j
			}
			Chw[i][index] = a[ai]
			ai++
			// fmt.Println(index)
		}
	}
	// fmt.Println(a, Chw)
	for i := 0; i < H; i++ {
		fmt.Println(strings.Trim(fmt.Sprint(Chw[i]), "[]"))
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}

// ここから拝借
// https://shoman.hatenablog.com/entry/2020/02/25/185456
// Stackは[]intのエイリアス
type Stack []int

// Push adds an element
func (s *Stack) Push(v int) {
	*s = append(*s, v)
}

// Pop removes the top element and return it
func (s *Stack) Pop() (int, error) {
	if s.Empty() {
		return 0, fmt.Errorf("stack is empty")
	}

	v := (*s)[len(*s)-1]
	*s = (*s)[:len(*s)-1]
	return v, nil
}

// Peek returns the top value
func (s *Stack) Peek() (int, error) {
	if s.Empty() {
		return 0, fmt.Errorf("stack is empty")
	}

	return (*s)[len(*s)-1], nil
}

// Size returns the length of stack
func (s *Stack) Size() int {
	return len(*s)
}

// Empty returns true when stack is empty
func (s *Stack) Empty() bool {
	return s.Size() == 0
}

// NewStack generates stack
func NewStack() *Stack {
	s := new(Stack)
	return s
}


Measured memory_bytes: 2488
N,K = gets.chomp.split.map(&:to_i)
H = gets.chomp.split.map(&:to_i)

h_size = H.size
if h_size <= K
  puts 0
else
  h_sorted = H.sort
  kill_size = h_size - K - 1
  result = 0
  for i in 0..kill_size
    result += h_sorted[i]
  end
  puts result
end

Measured memory_bytes: 21360
fun main(args: Array<String>) {
    val sa = readLine()!!.toCharArray().map { ij -> ij.toString() }
    val sb = readLine()!!.toCharArray().map { ij -> ij.toString() }
    val sc = readLine()!!.toCharArray().map { ij -> ij.toString() }
    
    println(game("a", sa, sb, sc).toUpperCase())
}

fun game(now: String, sa: List<String>, sb: List<String>, sc: List<String>): String {
    when (now) {
        "a" -> {
            return if (sa.isEmpty()) {
                "a"
            } else {
                game(sa[0], sa.drop(1), sb, sc)
            }
        }
        "b" -> {
            return if (sb.isEmpty()) {
                "b"
            } else {
                game(sb[0], sa, sb.drop(1), sc)
            }
        }
        "c" -> {
            return if (sc.isEmpty()) {
                "c"
            } else {
                game(sc[0], sa, sb, sc.drop(1))
            }
        }
        else -> {
            return "error"
        }
    }
}

Measured memory_bytes: 33780