akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(){
  int a, b, dividing, divided, rest;
  cin >> a >> b;
  dividing = min(a, b);
  divided = max(a, b);
  rest = divided % dividing;
  while(rest != 0){
    divided = dividing;
    dividing = rest;
    rest = divided % dividing;
  }
  cout << dividing << endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
void dfs (int u, vector < vector < int > > &g, vector < bool > &used, vector < int > &comps, int comp) {
	used[u] = true;
	comps[u] = comp;
	for (int v: g[u]) {
		if (!used[v])
			dfs(v, g, used, comps, comp);
	}
}
 
signed main () {
	int n, m, k;
	cin >> n >> m >> k;
	vector < vector < int > > gf(n + 1), gb(n + 1);
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		gf[a].push_back(b);
		gf[b].push_back(a);
	}
	for (int i = 0; i < k; ++i) {
		int c, d;
		cin >> c >> d;
		gb[c].push_back(d);
		gb[d].push_back(c);
	}
	vector < int > comps(n + 1, 0);
	int comp = 0;
	vector < bool > used(n + 1, 0);
	for (int i = 1; i <= n; ++i) {
		if (!used[i])
			dfs(i, gf, used, comps, ++comp);
	}
	vector < int > cnt(comp + 1, 0);
	for (int i = 0; i <= n; ++i)
		++cnt[comps[i]];
	for (int i = 1; i <= n; ++i) {
		int banned = 0;
		for (int v: gb[i]) {
			if (comps[v] == comps[i])
				++banned;
		}
		cout << cnt[comps[i]] - gf[i].size() - banned - 1 << ' ';
	}
	cout << '\n';
}


Measured memory_bytes: 13568
/**
 * @Author:      G_bg
 * @DateTime:    2019-04-27 21:00:44
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn=1e5+10;
int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(0);cin.tie(0);
    int a,b,t;cin >> a >> b >> t;
    cout << t/a*b << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
ll n;
    cin >> n;
    vector<ll> a(n);
    vector<vector<ll>> dp(n, vector<ll>(n));
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        dp[i][i] = a[i];
    }
    // dp[i+1][j], dp[i][j-1]
    for (int i = n-2; i >= 0; --i) {
        for (int j = i+1; j < n; ++j) {
            dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1]);
        }
    }
    cout << dp[0][n-1];
  return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, K;
  cin >> N >> K;
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }
  sort(ALLOF(v));

  int ret = 0;
  rep(i,K){
    ret += v[i];
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 3600
// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll MOD=1000000007;

#define fast_cin() ios_base::sync_with_stdio(false)
#define pb push_back
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug1(x) cerr << x << endl;
#define debug2(x,y) cerr << x << " " << y << endl;
#define debug3(x,y,z) cerr << x << " " << y << " " << z << endl;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define FORR(i, a, b) for (int i=a; i>=(b); i--)
ll INF = 2000000000000000001;
double EPS = 1e-9;
ll nextInt(){ll inp; cin>>inp; return inp;}
string nextStr(){string inp; cin>>inp; return inp;}
double nextDouble(){double inp; cin>>inp; return inp;}
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{int res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(int* a, int* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	string s;
	int skip;
	cin>>s>>skip;
	int i=0;
	while(i<s.size()){
		cout<<s[i];
		i+=skip;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
#ifndef ONLINE_JUDGE
    scanf("%lld", &a);
#else
    scanf("%I64d", &a);
#endif
    return a;
}

int main() {
    int a = gi();
    int b = gi();
    if (a+b == 15)
        printf("+\n");
    else if (a*b == 15)
        printf("*\n");
    else
        printf("x\n");

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void swap(int *xp, int *yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}

void bubbleSort(int arr[], int n)
{
    int i, j;
    for (i = 0;i < n - 1; i++)
        for (j = 0; j < n - i - 1; j++)
            if (arr[j] > arr[j + 1])
                swap(&arr[j], &arr[j + 1]);
}

int main(void)
{
    int n;
    scanf("%d", &n);

    int s[n];
    int i, j;
    for (i = 0; i < n; i++)
        scanf("%d", &s[i]);
    
    bubbleSort(s, n);

    int sum = 0;
    for (i = 0; i < n; i++)
        sum += s[i];
    
    if (sum % 10) {
        printf("%d\n", sum);
        return 0;
    }
    else {
        for (i = 0; i < n; i++)
            if (s[i] % 10) {
                j = s[i];
                printf("%d\n", sum - j);
                return 0;
            }
    }
    printf("0\n");
    return 0;
}

Measured memory_bytes: 128
import sys

l = [True] * 1000000
for i in range(2, 1000000):
    if (l[i - 1]):
        for j in range(i ** 2 - 1, 1000000, i):
            l[j] = False

for s in sys.stdin:
    print(l[1:int(s)].count(True))

Measured memory_bytes: 24188
from fractions import gcd


n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
x = a[0]
for i in range(1, len(a)):
    x = (x * a[i]) // gcd(x, a[i])
gcd=x
res = 0
for i in a:
    res += gcd//i
    #res%=mod
print(res%mod)



Measured memory_bytes: 6072
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int[][] A = new int[3][3];
            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                    A[i][j] = sc.nextInt();
                }
            }
            int N = sc.nextInt();
            int[] B = new int[N];
            for (int i = 0; i < N; i++) {
                B[i] = sc.nextInt();
            }

            boolean[][] C = new boolean[3][3];

            for (int i = 0; i < N; i++) {
                for (int j = 0; j < 3; j++) {
                    for (int k = 0; k < 3; k++) {
                        if (A[j][k] == B[i]) {
                            C[j][k] = true;
                        }
                    }
                }
            }

            for (int i = 0; i < 3; i++) {
                if (C[i][0] && C[i][1] && C[i][2]) {
                    System.out.println("Yes");
                    return;
                }
            }

            for (int i = 0; i < 3; i++) {
                if (C[0][i] && C[1][i] && C[2][i]) {
                    System.out.println("Yes");
                    return;
                }
            }

            if (C[0][0] && C[1][1] && C[2][2]) {
                System.out.println("Yes");
                return;
            }

            if (C[0][2] && C[1][1] && C[2][0]) {
                System.out.println("Yes");
                return;
            }

            System.out.println("No");
        }
    }

}


Measured memory_bytes: 23120
using System;
using System.Linq;

namespace A___Curtain
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim().Split(' ').Select(s => int.Parse(s)).ToArray();
            int a = line[0];
            int b = line[1];
            int ans = a - (b * 2);
            if (ans < 0)
            {
                ans = 0;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long k,a,b;
	cin>>k>>a>>b;
	if(a>=b-1)
	{
		cout<<k+1<<endl;
		return 0;
	}
	k-=a-1;
	long long tot=a;
	tot+=(k/2)*(b-a);
	if(k&1)
		tot++;
	cout<<tot<<endl;
	return 0;
}


Measured memory_bytes: 256
s = input().split()
h = int(s[0])
w = int(s[1])

ain = ["" for i in range(h)]

for i in range(h):
    ain[i] = input()

aout = ["" for j in range(h+2)]

aout[0] = "#" * (w+2)

for i in range(h):
    aout[i+1] = "#" + ain[i] + "#"

aout[h+1] ="#" * (w+2)

for i in range(h+2):
    print(aout[i])


Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	
    public static void main(String[] args) {
    	FastScanner sc = new FastScanner();
    	
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	int k = sc.nextInt();
    	
    	int f = gcd(a,b);
    	
    	int st = 1;
    	int kazu = 0;
    	
    	for(int i=1;st<=k;i++){
    		if(f%i==0){
    			if(st==k){
    				kazu = i;
    			}
    			st+=1;
    		}
    	}
    	
    	System.out.println(f/kazu);
    	
    }
    
  //最大公約数を求める
    public static int gcd(int a, int b){
        if(b == 0){
       	 return a;
        }
        return gcd(b, a%b);
    }
}


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

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> h(n);
  rep_i(i, n){
    cin >> h[i];
  }
  vector<int> dp(n);
  dp[0] = 0;
  for (int i = 1; i < n; i++){
    if(i == 1){
      dp[i] = abs(h[i] - h[0]);
    }else{
      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] << endl;
}

Measured memory_bytes: 1024
# coding: utf-8
# ABC146B

alpha = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
n = int(input())
s = list(input())

res = []
for i in s[:]:
    idx = (alpha.index(i) + n) % len(alpha)
    res.append(alpha[idx])

print(''.join(res))

Measured memory_bytes: 3188
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.Deque;


public class Main {
    static int count = 0;
    static boolean[] visited;
    static boolean[][] connected;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        while (true) {
            int cost = Integer.parseInt(br.readLine());
            if (cost == 0) break;
            calculator(cost);
        }
        
        
    }
    
    static int[] coins = {500, 100, 50, 10, 5, 1};
    static void calculator(int cost) {
        int index = 0;
        int count = 0;
        int change = 1000 - cost;
        while (change != 0) {
            if (change - coins[index] >= 0) {
                change -= coins[index];
                count++;
            }
            else {
                index++;
            }
        }
        
        System.out.println(count);
    }
}



Measured memory_bytes: 24056
N = int(input())
p = [0]
p += list(map(float, input().split(' ')))
dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
dp[1][0], dp[1][1] = 1- p[1], p[1]
for i in range(2, N + 1):
  for j in range(i + 1):
      dp[i][j] = dp[i-1][j-1]  * p[i]
      dp[i][j] += dp[i-1][j] * (1 - p[i])
res = 0
for i in range(N // 2 + 1, N + 1):
  res += dp[N][i]
print(res)

Measured memory_bytes: 258440
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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; }
const int INF = 1<<30;
const double P = 3.1415926535;

vector<int> G[100010];
int indeg[100010];
int dp[100010];

int main(){
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
		indeg[y]++;
	}
	queue<int> que;
	rep(i,n) if(indeg[i] == 0) que.push(i);
	while(!que.empty()){
		int node = que.front(); que.pop();
		rep(i,G[node].size()){
			int to = G[node][i];
			indeg[to]--;
			if(indeg[to] == 0){
				que.push(to);
				chmax(dp[to], dp[node] + 1);
			}
		}
	}

	int ans = 0;
	rep(i,n) chmax(ans, dp[i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6528
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

satisfiction = 0

for i in range(len(a)):
    tmpb = b[a[i] - 1]
    satisfiction += b[a[i] - 1]
    if i <= len(a) - 2 and (a[i + 1] - a[i] == 1):
        satisfiction += c[a[i]-1]
        # c.remove(c[0])
print(satisfiction)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int head=s.size();
  int back=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='A'){head=min(head,i);}
    else if(s.at(i)=='Z'){back=max(back,i);}
  }
  cout<<back-head+1;
}

Measured memory_bytes: 640
#include <stdio.h>
int main()
{
int N;
scanf("%d",&N);
if((N%10==2)||(N%10==4)||(N%10==5)||(N%10==7)||(N%10==9))
    printf("hon");
else if((N%10==0)||(N%10==1)||(N%10==6)||(N%10==8))
    printf("pon");
else if(N%10==3)
    printf("bon");
  return 0;
} 

Measured memory_bytes: 1728
#include <iostream>
using namespace std;
int summ(int x, int d[], int n)
{
	int sum = 0;
	for(int i = (x+1); i<n ; i++)
	{
		sum = sum + d[i];
	}
	sum = (sum*d[x]);
	return sum;
}

int main(){
	int N, i, res;
	res = 0;
	cin>>N;
	int d[N];
	for(i=0; i<N; i++)
	{
		cin>>d[i];
	}
	for(i = 0; i<N; i++)
	{	
		res = res + summ(i, d, N);
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 3604
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans += b_list[a_list[i]-1]
    if i > 0 and (a_list[i-1] == a_list[i] - 1):
        ans += c_list[a_list[i-1]-1]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end() 

int const N = 200001;
int n, an[N];
pair<int,int> v[N];

int main(){
    scanf("%d", &n);
    for(int i = 0; i<n; ++i){
        scanf("%d", &v[i].first);
        v[i].second = i;
    }
    sort(v, v+n);
    int f = v[n/2].first, s = v[n/2-1].first;
    for(int i = 0; i<n; ++i){
        if(i < n/2)an[v[i].second] = f;
        else an[v[i].second] = s;
    }
    for(int i = 0; i<n; ++i)printf("%d\n", an[i]);
}

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

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int i;
    for(i=1; i<=n; i++){
      if(i % 3 == 0){
        out.printf(" "+i);
        continue;
      }

      int x = i;
      do{
        if(x % 10 == 3){
          out.printf(" "+i);
          break;
        }
        x /= 10;
      }while(x != 0);
    }
    out.println();
  }
}


Measured memory_bytes: 31352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <functional>
#define ll long long int
using namespace std;
int h[6], w[6];

int main() {
	ll len, ans = 0;
	string S, T;

	cin >> S >> T;

	len = (ll)(S.length());

	for (int i = 0; i < len; i++){
		if (S[i] == T[i])
			continue;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(int i = (int)k; i < (int)n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(int i = (int)n-1; i > (int)k-1; i--)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl;

typedef long long ll;

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const int dx8[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy8[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

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

    deque<ll> deq;
    int n;
    cin >> n;
    ll a[200000 +1];
    REP(i,1,n+1) cin >> a[i];

    int p = n%2;
    REP(i,1,n+1) {
        if(i%2 == p) deq.push_front(a[i]);
        else deq.push_back(a[i]);
    }

    cout << deq[0];
    REP(i,1,deq.size()) cout << " " << deq[i];
    cout << endl;
    return 0;
}

//
// int main(){
//     cin.tie(0);
//     ios::sync_with_stdio(false);
//
//     int n;
//     cin >> n;
//     ll a[100000 +1];
//     REP(i,1,n+1) cin >> a[i];
//
//
//
//     cout << a[n];
//     int i=n-2;
//     while(true) {
//         if (i==2) i--;
//         if (i<=1) break;
//         cout << " " << a[i];
//         i -= 2;
//     }
//     while(true) {
//         cout << " " << a[i];
//         if (i>=n-1) break;
//         i += 2;
//     }
//
//     cout << endl;
//     return 0;
// }


Measured memory_bytes: 5376
N, X = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
for i in range(1, N):
    if A[i - 1] > X:
        ans += A[i - 1] - X
        A[i - 1] = X
    if A[i - 1] + A[i] > X:
        ans += A[i] - (X - A[i - 1])
        A[i] = X - A[i - 1]

print(ans)

Measured memory_bytes: 14592
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
L=[1,-1]
L2=[]
for i in L:
  for j in L:
    for k in L:
      L2.append([i,j,k])

ansL=[]
for i in range(8):
  L3=[]
  for j in range(n):
    L3.append(l[j][0]*L2[i][0]+l[j][1]*L2[i][1]+l[j][2]*L2[i][2])
  L3.sort()
  L3.reverse()
  ansL.append(sum(L3[0:m]))

print(max(ansL))

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

int main(){
  int n; cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2!=0)continue;
    if(a[i]%3!=0 && a[i]%5!=0){
      cout<<"DENIED"<<endl;
      return 0;
    }
  }
  cout<<"APPROVED"<<endl;
  return 0;
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

  int n, x;
  cin >> n >> x;
  vi l(n);
  REP(i, 0, n) cin >> l[i];
  int d = 0;
  int ans = 1;

  REP(i, 0, n){
    d = d + l[i];
    if(d <= x)
      ans++;
  }

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


Measured memory_bytes: 256
N,M,X = map(int, input().split())
A = list(map(int, input().split()))

cost1 = 0
cost2 = 0
for i in range(N):
   if (i<X)and(i in A):
      cost1 += 1
   elif (i>X)and(i in A):
      cost2 += 1

print(min([cost1,cost2]))

   


Measured memory_bytes: 3060
line_count,limit_time=gets.split.map(&:to_i)
array=[]
line_count.times do |i|
  name,time=gets.split
  array.push [name,time.to_i]
end
total=0
while array.size != 0
  process,time=array.shift
  if time<=limit_time
    total+=time
    puts "#{process} #{total}"
  else
    time-=limit_time
    total+=limit_time
    array.push [process,time]
  end
end

Measured memory_bytes: 13272
package main

import (
	"fmt"
	//"math"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	var s string
	fmt.Scanf("%s", &s)
	if n < 3200 {
		fmt.Print("red")
	} else {
		fmt.Print(s)
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



int main() {
	int n, r;
	cin >> n >> r;
	if (n < 10) {
		cout << r + 100 * (10 - n) << endl;
	}
	else {
		cout << r << endl;
	}

}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)

ll sq(ll x){
	return x*x;
}

int main(void){
	int n,i;
	ll a[123],tmp,ans=INFLL,mx=-INFLL,mn=INFLL,j;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
		mn = min(mn,a[i]);
		mx = max(mx,a[i]);
	}
	for(j=mn; j<=mx; ++j){
		tmp = 0ll;
		for(i=0; i<n; ++i){
			tmp += sq(a[i]-j);
		}
		ans = min(tmp,ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; i<n; ++i)
#define rep1(i, n) for(int i = 1; i<n; ++i)
#define rev_rep(i, n) for(int i = n - 1; i >= 0; --i)
#define range(a, i, b) for(int i = a; i <b; ++i)
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readl(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}
#define greater_than [](ll l, ll r){return l > r;}
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  readl(N);
  readl(W);
  vector<vector<ll>> a, dp;
  a.resize(N);
  rep(i, N){
    a[i].resize(2);
    cin >> a[i][0] >> a[i][1];
  }
  dp.resize(N + 1);
  rep(i, N + 1){
    dp[i].resize(W + 1);
  }
  rep(w, W + 1){
    rep(i, N){
      if(w >= a[i][0]){
        chmax(dp[i + 1][w], dp[i][w - a[i][0]] + a[i][1]);
      }
      chmax(dp[i + 1][w], dp[i][w]);
    }
  }
  // dump(a);
  // dump(dp);
  cout << dp[N][W];
  
}
#endif


Measured memory_bytes: 79488
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

bool check[20000];

int main(){
	
	int N;
	
	cin >> N;
	
	for(int i = 0; i < 20000; i++){
		check[i] = false;
	}
	
	check[0] = true;
	
	for(int i = 0; i < N; i++){
		int num;
		cin >> num;
		for(int j = 15000; j - num >= 0; j--){
			check[j] = check[j] || check[j - num];
		}
	}
	/*
	for(int i = 0; i < 20000; i++){
		if(check[i]){
			cout << i << " ";
		}
	}
	*/
	int ans = 0;
	
	for(int i = 15000; i >= 0; i--){
		if(i % 10 != 0 && check[i]){
			ans = i;
			break;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n-i+1):
        k = n - i - j
        #print("check:",i, j, k)
        s = 10000 * i + 5000 * j + 1000 * k
        if s == y:
            print(i,j,k)
            exit()
print(-1,-1,-1)

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

int main(){
    int N;
    cin >>N;
    vector<int> ans(N);
    for(int i=0;i<N-1;i++){
        int a;
        cin >> a;
        ans.at(a-1) ++;
    }
    for(int i=0;i<N;i++){
        if(i==N-1) cout<<0<<endl;
        else cout << ans[i] << endl;
    }
}

Measured memory_bytes: 4048
fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 1000000007L

fun modpow(n:Long,p:Long = mod-2L):Long = when {
	p==0L->1L
	p%2==1L->n*modpow(n,p-1)%mod
	else-> {
		val d = modpow(n,p/2)
		d*d%mod
	}
}

fun main() {
	abc000X()
}

fun abc000X() {
	var (a,b,c)=list()
	var r=0
	val k=int()
	while(a>=b){
		++r
		b*=2
	}
	while(b>=c){
		++r
		c*=2
	}
	System.err.println(r)
	println(if(k>=r)"Yes" else "No")
}


Measured memory_bytes: 36356
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define len(x)           x.length()
#define pb                push_back
#define mp                make_pair
#define all(x)            (x).begin(),(x).end()
#define M                 1000000007
#define MM                998244353
#define ff                first
#define ss                second
#define pii               pair<int,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define GCD(x,y)          (__gcd((x), (y)))
#define LCM(x,y)          (((x)/__gcd((x), (y)))*(y))
#define mem0(x)           memset(x, 0, sizeof (x))
#define mem1(x)           memset(x, -1, sizeof (x))
#define IOS ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);

//coded by Avijit Mandal 

int main(){
   IOS;
   ll i,j,k,t1,t2,n,m,sum=0,mx;
   cin>>k>>n;
   ll a[n];
   for(i=0;i<n;i++)cin>>a[i];
   mx=k-a[n-1]+a[0];
   sum+=mx;
   for(i=1;i<n;i++){
         sum+=a[i]-a[i-1];
         mx=max(mx,a[i]-a[i-1]);
   }

   cout<<sum-mx<<endl;
   



}


Measured memory_bytes: 1920
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

class Combination {
    private:
    vector<int> x, y;
    int mod = (int)1e9 + 7;
    
    void make(int n) {
        x.resize(n+1);
        y.resize(n+1);        
        x[0] = y[0] = 1;
        for (int i = 1; i <= n; i++) {
            x[i] = (x[i-1]*i) % mod;
            y[i] = modpow(x[i],mod-2);
        }
    }
    
    int modpow(int x, int n) {
        int ret = 1;
        while (n > 0) {
            if ((n & 1)) {
                ret = ret * x % mod;
            }
            x = x * x % mod;
            n >>= 1;
        }
        return ret;
    }
    
    public:
    Combination(int n) {
        make(n);
    }
    
    Combination(int n, int mod) {
        this->mod = mod;
        make(n);
    }
    
    int get(int n, int r) {
        if (n < r) return 0;
        return x[n] * y[n - r] % mod * y[r] % mod;
    }
    
};

void run(){
    int n,k;
    cin>>n>>k;
    vi a(n);
    rep(i,n)cin>>a[i];
    SORT(a);
    Combination c(n);
    int ans=0;
    rep(i,n){
        ans+=a[i]*c.get(i,k-1);
        ans%=mod;
    }
    rep(i,n){
        ans-=a[i]*c.get(n-i-1,k-1);
        ans%=mod;
    }
    cout<<(ans+mod)%mod<<endl;
}

Measured memory_bytes: 5512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int N,Q;
vector<ll> S,T;

int main(){
  cin>>N;
  for (int i=0;i<N;i++){
    ll temp;
    cin>>temp;
    S.push_back(temp);
  }
  cin>>Q;
  for (int i=0;i<Q;i++) {
    ll temp;
    cin>>temp;
    T.push_back(temp);
  }

  int ans=0;
  for (int i=0;i<Q;i++){
    if (binary_search(S.begin(),S.end(),T[i])) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000 //2e9
#define LLINF 3000000000000000000ll // 1e18
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define dmp(x) cerr << #x << ": " << x << endl;

template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}

template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T,vector<T>,greater<T>>;
template<class T> vector<T> vect(int len,T elem){ return vector<T>(len,elem); }

template<class T,class U>
ostream& operator << (ostream& os,const pair<T,U>& p){
  os << p.fi << ',' << p.sec; return os;
}
template<class T,class U>
istream& operator >> (istream& is,pair<T,U>& p){
  is >> p.fi >> p.sec; return is;
}
template<class T>
ostream& operator << (ostream &os,const vector<T> &vec){
  for(int i=0;i<vec.size();i++){
    os << vec[i];
    if(i+1<vec.size())os << ' ';
  }
  return os;
}
template<class T>
istream& operator >> (istream &is,vector<T>& vec){
  for(int i=0;i<vec.size();i++)is >> vec[i];
  return is;
}
void fastio(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(20);
}
void solve(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  cin >> a;
  sort(all(a));
  vector<int> b;
  int ans = a.back()-a.front();
  for(int i=1;i<a.size();i++){
    b.push_back(a[i]-a[i-1]);
  }
  sort(all(b));
  reverse(all(b));
  for(int i=0;i<min(n-1,m-1);i++){
    ans -= b[i];
  }
  cout << ans << endl;
}
signed main(){
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


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

int mins(char *, char *);

int main(void){

    char a[1000], s[1000];
    int la;
    int ls;
    int i;
    int max = 0;

    scanf("%s%s",a,s);

    la = strlen(a);
    ls = strlen(s);

    for(i=0;i<=la-ls;i++){
        if(max < mins(a+i,s)){
            max = mins(a+i,s);
        }
    }

    printf("%d",ls-max);

    return 0;
}

int mins(char *a, char *s){
    int i = 0;
    while(*s != '\0'){
        if(*a == *s){
            i++;
        }
        a++;
        s++;
    }
    return i;
}

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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int a, b, c, d, e, f;
int xx, yy;

bool check(int x, int y)
{
	bool flag = false;
	for (int i = 0; i * 100 * a <= x; i ++ )
		for (int j = 0; j * 100 * b <= x - i * 100; j ++ )
			if (!flag && i * a * 100 + j * b * 100 == x)
			{
				flag = true;
				break;
			}
	if (!flag) return false;
	
	flag = false;
	for (int i = 0; i * c <= y; i ++ )
		for (int j = 0; j * d <= y - i; j ++ )
			if (!flag && i * c + j * d == y)
			{
				flag = true;
				break;
			}
	return flag;
}

int main()
{
	cin >> a >> b >> c >> d >> e >> f;
	
	double res = -1;
	for (int x = 0; x <= f / 100; x ++ )
		for (int y = 0; y <= x * e; y ++ )
			if (100 * x + y <= f && check(100 * x, y))
				if (res < (double)y / (100 * x + y))
				{
					res = (double)y / (100 * x + y);
					xx = x, yy = y;
				}
	
	cout << xx * 100 + yy << ' ' << yy << endl;
    return 0;
}

Measured memory_bytes: 3640
MOD = 1000000007

N = int(input())
S1 = list(input())
S2 = list(input())

if S1[0] == S2[0]:
    ans = 3
else:
    ans = 6

for i in range(0,N-1):
    if S1[i] == S2[i]:
        ans *= 2
    elif S1[i] != S2[i] and S1[i+1] != S2[i+1] and S1[i] != S1[i+1]:
        ans *= 3
    ans %= MOD

print(ans)

Measured memory_bytes: 3064
s = input()
n = len(s)
ac = ["A","C","G","T"]
acgt = []
for i in range(n+1):
    for j in range(i+1,n+1):
        #print(s[i:j])

        a = list(set(list(s[i:j])))
        for k in range(len(a)):
            if a[k] not in ac:
                break
        else:
            #acgt += [s[i:j]]
            #print(f"○{s[i:j]}")
            acgt += [len(s[i:j])]    

if acgt == []:
    acgt += [0]

print(max(acgt))

Measured memory_bytes: 9048
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define ar array
#define pb push_back

int n,m;
const int mxn=2e5+2;
vector<vector<int>> adj;
const int INF=0x3f;
int d[mxn];
bool vis[mxn];

void dfs(int node)
{
	vis[node]=true;
	if(node==0)
	{
		d[0]=1;
	}
	else
	{
		d[node]=0;
	}
	for(auto i:adj[node])
	{
		if(!vis[i])
		{
			dfs(i);
		}
		d[node]=max(d[node],d[i]+1);
		//cout<<node<<' '<<d[node]<<'\n';
	}
}

int main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("outputc.txt","w",stdout);
	// #endif
	
	//int t;
	//cin>>t;
	//while(t--)
	{
		cin>>n>>m;
		adj=vector<vector<int>> (n);
		for(int i=0;i<m;i++)
		{
			int x,y;
			cin>>x>>y;
			--x,--y;
			adj[x].pb(y);
		}
		memset(d,-INF,sizeof(d));
		d[0]=0;
		for(int i=0;i<n;i++)
		{
			if(!vis[i])
			{
				dfs(i);
			}
		}
		int ans=0;
		for(int i=0;i<n;i++)
		{
			ans=max(ans,d[i]);
		}
		cout<<ans<<'\n';
		
	}
		
}


Measured memory_bytes: 12224
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Map<Integer, Integer>> scoreMap = new TreeMap<String, Map<Integer, Integer>>();
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            int p = sc.nextInt();
            if (scoreMap.containsKey(s)) {
                scoreMap.get(s).put(p, i + 1);
            } else {
                // scoreの降順に格納するmap
                Map<Integer, Integer> shopMap = new TreeMap<Integer, Integer>(new Comparator<Integer>() {
                    public int compare(Integer k1, Integer k2) {
                        return k2.compareTo(k1);
                    }
                });
                shopMap.put(p, i + 1);
                scoreMap.put(s, shopMap);
            }
        }
        sc.close();

        for (String key : scoreMap.keySet()) {
            Map<Integer, Integer> map = scoreMap.get(key);
            for (Integer score : map.keySet()) {
                System.out.println(map.get(score));
            }
        }
    }
}


Measured memory_bytes: 21844
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String input;
		for(int i = 0; i < h; i++) {
			input = sc.next();
			System.out.println(input + "\n" + input);
		}
	}
}

Measured memory_bytes: 10952
///-----Bismillahir Rahmanir Rahim-----///

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

///---FAST I/O---///
#define Boost() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

///---DATA TYPE---///
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

///---LOOP---///
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)

///---I/O---///
#define sf scanf
#define pf printf

///---OTHERS---///
#define pb push_back
#define all(c)		c.begin(),c.end()
#define MK make_pair
#define F first
#define S second
#define endl '\n'


///---INITIALIZATION---//
#define mem(a,b) memset(a, b, sizeof(a) )

///---CALCULATE---///
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

///---BIT OPERATION---///
inline bool checkBit(ll n, int i)
{
    return n&(1LL<<i);
}
inline ll setBit(ll n, int i)
{
    return n|(1LL<<i);;
}
inline ll resetBit(ll n, int i)
{
    return n&(~(1LL<<i));
}

///------String/Char Related Functions-----///
string makeintString(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
string makellString(ll x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
char cpp(char c)
{
    return static_cast<char>(c + 1);
}

///------------Sorting STL----------///
struct func
{
    //this is a sample overloading function for sorting stl
    bool operator()(pii const &a, pii const &b)
    {
        if(a.F==b.F)
            return (a.S<b.S);
        return (a.F<b.F);
    }
};

///---CONSTANT---///
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

int dis[10];
int main()
{
    Boost();

    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        int n,k,x,ans;
        cin>>n>>k;
        for(int i=0; i<k; i++)
        {
            cin>>x;
            dis[x]=1;
        }
        for(int i=n; i<=100000; i++)
        {
            int tmp=i,flag=0;
            while(tmp>0)
            {
                int d=tmp%10;
                if(dis[d]==1)
                {
                    flag=1;
                    break;
                }
                tmp/=10;
            }
            //cout<<flag<<" "<<i<<endl;
            if(flag==0)
            {
                ans=i;
                break;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define vc vector<int>
#define um unordered_map<int,int>
#define ll long long 
#define rep(i,a,b) for(__typeof(a) i=a; i<b; i++)
#define si(a) a.size()
#define all(a) a.begin(),a.end()
#define ss(a) a.second
#define ff(a) a.first
#define M 1000000
#define pb push_back
#define repit(i,a) for(auto i=a.begin(); i!=a.end(); i++)
#define take(arr,n) for(int i=0;i<n;i++)cin>>arr[i]
#define out(arr,n) for(int i=0;i<n;i++)cout<<arr[i]<<' '
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define reprev(i,b,a) for(__typeof(b) i=b; i>=a; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define doublearray vector<vector<int>>
#define mod 998244353 
using namespace std;
ll max(ll a, ll b){ return a>b?a:b; }
ll min(ll a, ll b){ return a<b?a:b; }
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
int binaryS(int x, int sb[], int m){
    int l = 0, r=m;
    int mid = (l+r)/2;
    while(l<r){
        mid = (l+r)/2;
        if(sb[mid]<x) l= mid+1;
        else if(sb[mid]>x) r = mid-1;
        else return mid;
    }
    return l;
}
int main(){
    fastio;
    // int t; cin>>t;
    // while(t--){
      string s, t; cin>>s>>t;
      int mini = INT_MAX;
      rep(i,0,si(s)-si(t)+1){
          int j = i;
          int c =0 ;
          rep(k,0,si(t)){
              if(s[j]!=t[k]){
                  c++;
              }
              j++;
          }
          mini = min(mini,c);
      }
    //}c
    cout<<mini<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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


int main(){
    ll m, k;   cin >> m >> k;
    if(m == 1){
        if(k == 0){
            cout << "0 0 1 1" << endl;
        }
        else{
            cout << -1 << endl;
        }
        return 0;
    }

    int ma = (1 << m) - 1;
    if(k > ma){
        cout << -1 << endl;
        return 0;
    }
    vector<P> res;
    for(int i = 0; i <= ma; i++){
        int x = k ^ i;
        if(i <= x){
            res.emplace_back(P(i, x));
        }
    }

    for(auto p: res){
        cout << p.fs << " " << p.sc << " ";
    }
    if(k > 0) {
        for (auto p: res) {
            cout << p.sc << " " << p.fs << " ";
        }
    }
    cout << endl;



    return 0;
}


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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 505;

int n, health[maxr][maxr];
bool done[maxr][maxr];
vector<int> dx = {0, 0, -1, 1};
vector<int> dy = {1, -1, 0, 0};

void update(int x, int y) {

	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (0 > nx || nx >= n || 0 > ny || ny >= n)
			continue;
		int co = !done[x][y];
		if (health[nx][ny] > health[x][y] + co) {
			health[nx][ny] = health[x][y] + co;
			update(nx, ny);
		}
	}
}

int32_t main()
{
	GO;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			health[i][j] = min(min(i, n - i - 1), min(j, n - j - 1));
			done[i][j] = false;
		}
	}
	int ans = 0;
	for (int i = 0; i < n * n; i++) {
		int p;
		cin >> p;
		int x = (p - 1) / n;
		int y = (p - 1) % n;
		ans += health[x][y];
		done[x][y] = true;
		update(x, y);
	}

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

//!

Measured memory_bytes: 17308
#!/usr/bin/env python3
# coding: utf-8
# import pprint
# import numpy as np
# import code
import functools

if __debug__:
    def debug(arg):
        pass
else:
    import sys
    def debug(arg):
        debug = lambda *x: None
        print(arg, file=sys.stderr)

ｘ, y, z = (int(x) for x in input().split())
debug([x, y, z])

a = z
b = x
c = y

print(' '.join(map(str, [a, b, c])))


Measured memory_bytes: 3700
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
const int INF = 1e9;
const double PI = acos(-1.0);

int main() {
	
	string str;
	cin >> str;
	int k, n;
	cin >> k;
	n = str.size();

	vector<int> toa(n);
	rep(i, n) toa[i] = 26 - (int)(str[i] - 'a');

	rep(i, n) {
		if (i == n - 1) str[n - 1] = ((str[n - 1] - 'a' + k) % 26) + 'a';
		else if (str[i] == 'a')continue;
		else if (toa[i] <= k) {
			k -= toa[i];
			str[i] = 'a';
		}
	}

	cout << str << endl;

	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;
public class Main {
   public static void main(String[] args) {
       Scanner input = new Scanner(System.in);
       int a = input.nextInt();
       int b = input.nextInt();
       int c = input.nextInt();
       if(a == b+c || a+b == c || a+c == b){
             System.out.println("Yes");
          }
       else{
             System.out.println("No");

          }
     }
}

Measured memory_bytes: 27024
#include <iostream>

using namespace std;

int main()
{
    int a,b,c[10]={0};
    cin>>a>>b;
    c[a]=1;c[b]=1;
    for(int i=1;i<=3;i++)
    {
        if(c[i]==0)
        {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256