akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    int n;
    long x;
    long[] as;

    void run() {
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        x = sc.nextLong();
        as = new long[n];

        for (int i = 0; i < n; i++) {
            as[i] = sc.nextLong();
        }

        long[][] b = new long[2][n];
        Arrays.fill(b[0], 1L << 50);
        int idx = 1;
        long ans = 1L << 50;
        for (int k = 0; k < n; k++) {
            long sum = 0;
            for (int i = 0; i < n; i++) {
                b[idx][i] = Math.min(b[1 - idx][i], as[(i + n - k) % n]);
                sum += b[idx][i];
            }
            ans = Math.min(ans, k * x + sum);
            idx = 1 - idx;
        }

        System.out.println(ans);
    }

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


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

int calc(string str)
{
	char lst = 0;
	int cnt = 0;
	int ans = 0;
	for (auto x : str)
	{
		if (lst == x)
			cnt++;
		else {
			ans += cnt / 2;
			cnt = 1;
			lst = x;
		}
	}
	ans += cnt / 2;
	return ans;
}

int main()
{
	ios::sync_with_stdio(false);

	string s;
	cin >> s;
	int k;
	cin >> k;


	int r = s.size();
	while (r > 0 && s[r-1] == s[0])
		r--;
	if (r == 0)
	{
		cout << 1LL * k * s.size() / 2 << "\n";
		return 0;
	}
	ll ans = 0;
	ans += calc(s.substr(0, r));
	ans += calc(s.substr(r, s.size() - r));
	rotate(s.begin(), s.begin() + r, s.end());
	ans += 1LL * calc(s) * (k - 1);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
using namespace std;
int main() {
	string S;
	cin>>S;
	if(S=="SUN")
		cout<<7<<endl;
	if(S=="MON")
		cout<<6<<endl;
	if(S=="TUE")
		cout<<5<<endl;
	if(S=="WED")
		cout<<4<<endl;
	if(S=="THU")
		cout<<3<<endl;
	if(S=="FRI")
		cout<<2<<endl;
	if(S=="SAT")
		cout<<1<<endl;
	return 0;
}

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

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

  map<int, long long> ball;
  for (int i = 0; i < n; i++) {
    ball[a[i]]++;
  }

  map<int, long long> c;
  long long sum = 0;
  for (auto b: ball) {
    c[b.first] = b.second * (b.second - 1) / 2;
    sum += c[b.first];
  }

  for (int i = 0; i < n; i++) {
    cout << sum - c[a[i]] + (ball[a[i]] - 1) * (ball[a[i]] - 2) / 2 << endl;
  }
}

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



Measured memory_bytes: 18176
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll a, b;
int main() {
	cin >> a >> b;
	if (b - a > 2020) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = INF;
	FOR(i, a, b + 1) {
		FOR(j, i + 1, b + 1) {
			ans = min(ans, (i * j) % 2019);
		}
	}
	cout << ans << endl;
}
	

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    if(a>=k){
        ans = k;
    }else if(a+b>=k){
        ans = a;
    }else{
        ans = a - (k-a-b);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1000000007;
const int MAX = 5000;

long long mod(long long a) {
	a %= MOD;
	return a >= 0 ? a : a+MOD;
}

// i の逆元の MOD
long long inverse[MAX+1];
// i の階乗の MOD
long long factorial[MAX+1];
// i の階乗の逆元の MOD
long long factorial_inverse[MAX+1];

// 上の三つの配列を n まで埋める
// O( n )
void calc(int n) {
	inverse[1] = 1;
	factorial[0] = factorial[1] = 1;
	factorial_inverse[0] = factorial_inverse[1] = 1;
	for (int i = 2; i <= n; i++) {
		inverse[i] = MOD - inverse[MOD%i] * (MOD/i) % MOD;
		factorial[i] = i * factorial[i-1] % MOD;
		factorial_inverse[i] = inverse[i] * factorial_inverse[i-1] % MOD;
	}
}

long long comb(long long n, long long k) {
	if (k < 0 || k > n) return 0;
	return factorial[n] * (factorial_inverse[k] * factorial_inverse[n-k] % MOD) % MOD;
}

long long rep_comb(long long n, long long k) {
	return comb(n + k - 1, k);
}

int main() {
	calc(MAX);
	long long s;
	cin >> s;
	long long ans = 0;
	for (int i = 1; i < 1000; i++) {
		long long r = s - i * 3;
		if (r < 0) break;
		ans = mod(ans + rep_comb(i, r));
	}
	cout << ans << endl;
	return 0;
}

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

int n, ds[100100];
vector<pair<int, int>> a, b;

int get(int x)
{
  return x == ds[x] ? x : ds[x] = get(ds[x]);
}

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

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    int x;
    cin >> x;
    a.push_back({x, i});
    ds[i] = i;
  }
  for (int i = 0; i < n; i++)
  {
    int x;
    cin >> x;
    b.push_back({x, i});
  }

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  int swap = 0;
  for (int i = 0; i < n; i++)
  {
    if (a[i].first > b[i].first)
    {
      cout << "No" << endl;
      return 0;
    }

    int x = get(a[i].second), y = get(b[i].second);
    if (x != y)
    {
      swap++;
      ds[x] = y;
    }
  }

  if (swap <= n - 2)
  {
    cout << "Yes" << endl;
    return 0;
  }

  for (int i = 1; i < n; i++)
    if (a[i].first <= b[i - 1].first)
    {
      cout << "Yes" << endl;
      return 0;
    }

  cout << "No" << endl;
}


Measured memory_bytes: 3956
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int A,B;
int M;
int a[100000+20],b[100000+20];
bool cmp(mp A,mp B){
	return A>B; 
}
int main(){
	fastio;
	cin>>A>>B>>M;
	rb(i,1,A)
		cin>>a[i];
	rb(i,1,B)
		cin>>b[i];
	vector<mp> v[100000+20];
	multiset<int> s;
	rb(i,1,B)
		s.insert(b[i]);
	rb(i,1,M){ 
		int x,y,c;
		cin>>x>>y>>c;
		v[x].PB(II(y,c));
	}
	rb(i,1,A)
		sort(ALL(v[i]),cmp);
	int res=INF;
	rb(i,1,A){
		int las=-1;
		for(auto it:v[i]){
			if(it.FIR==las) continue;
			las=it.FIR;
			s.erase(s.find(b[it.FIR]));
			s.insert(b[it.FIR]-it.SEC);
		}
		res=min(res,a[i]+*s.begin());
		las=-1;
		for(auto it:v[i]){
			if(it.FIR==las) continue;
			las=it.FIR;
			s.erase(s.find(b[it.FIR]-it.SEC));
			s.insert(b[it.FIR]);
		}
	}
	cout<<res;
	return 0;
}


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

vector<int> vals;
int alphasize=0;
vector<string> strs;

int n;

void genall(int ind){
	if (ind==n){
		string s = "";
		for (int i = 0; i<n; i++){
			s.push_back(char('a'+vals[i]));
		}
		strs.push_back(s);
		return;
	}
	for (int i = 0; i<alphasize; i++){
		vals[ind]=i;
		genall(ind+1);
	}
	alphasize++;
	vals[ind]=alphasize-1;
	genall(ind+1);
	alphasize--;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	vals.resize(n);
	genall(0);
	sort(strs.begin(),strs.end());
	for (string s : strs){
		cout<<s<<'\n';
	}
	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	long long ujung = 1 + (N - 2)*1;
	long long sum = 0;
	sum = ((1 + (ujung-1)) * N) / 2;

	cout << sum << '\n';
}

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

int main() {
  int A, B;
  cin >> A >> B;
  for (int i = 0; i < 2000; i++) {
    if ((int)(i * 0.08) == A && (int)(i * 0.1) == B) return cout << i << "\n", 0;
  }
  cout << -1 << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <string>
#include <cstring>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <memory>

//#pragma comment(linker, "/STACK:16777216")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("unswitch-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
//#define double long double
//#define int ll
//#define int ull
//#define int short
//#define int unsigned short
//#define int unsigned int
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define hash hash228
const int SZ = 12 + 4;
const double EPS = 1e-7;
const int mod = 1e9 + 7;
const int hashpow = 2;
const int inf = 2e9;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int n, m, x;
int c[SZ];
int a[SZ][SZ];

inline void read() {
    cin >> n >> m >> x;
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        for (int j = 0; j < m; ++j) {
            cin >> a[i][j];
        }
    }
}

inline void solve() {
    int ans = inf;
    for (int i = 0; i < (1 << n); ++i) {
        int sum = 0;
        int b = i;
        int k = 0;
        vector<int> tmp(m, 0);
        while (b) {
            if (b & 1) {
                sum += c[k];
                for (int j = 0; j < m; ++j) {
                    tmp[j] += a[k][j];
                }
            }
            b >>= 1;
            ++k;
        }

        int mn = inf;
        for (int j = 0; j < m; ++j) {
            mn = min(mn, tmp[j]);
        }

        if (mn >= x) {
            ans = min(ans, sum);
        }
    }

    if (ans == inf) {
        cout << -1 << "\n";
    } else {
        cout << ans << "\n";
    }
}

signed main() {

#ifdef __LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
        read();
        solve();
//    }

    return 0;
}

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

#define scd second
#define fst first
#define pb push_back
#define mkp make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;
typedef list<int> lint;
typedef list<ll> llong;
typedef list<pii> lpii;
typedef list<pll> lpll;
typedef list<lint> llint;
typedef list<llong> lllong;

ll const LINF=numeric_limits<long long int>::max();
int const INF=numeric_limits<int>::max();

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

ll pow_mod(ll a, ll e, ll m){
	ll res=1;
	while(e){
		if(e&1) res=res*a%m;
		a=a*a%m;
		e>>=1;
	}
	return res;
}

ll inv_mod(ll b, ll m){
	b%=m;
	ll x=0, y=1, r, q, a=m;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=m;
	return x%m;
}

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

	int x, y, n;
	cin>>x>>y;
	ll ans=0, mod=1e9+7;
	n=(x+y);
	if(n%3==0){
		n/=3;
		int sx=n*2;
		int dx=sx-x;
		if(dx>=0){
			int sy=n+dx;
			// cout<<n<<" "<<sx<<" "<<dx<<" "<<sy<<endl;
			if(sy==y){
				int d=(2*y-x)/3;
				if(d>=0){
					ll f1=1, f2=1;
					for(int i=1; i<=d; i++){
						f1=f1*(n-i+1)%mod;
						f2=f2*i%mod;
					}
					ans=f1*inv_mod(f2,mod)%mod;
				}
			}
		}
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
    long long a,b,c,d,p,q,r,s,t;
    cin>>a>>b>>c>>d;
    p=b*d;
    q=a*c;
    r=a*d;
    s=b*c;
    cout<<max(max(p,q),max(r,s))<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
	int N;
	cin >> N;
	char* s = new char[10];
	int iA, iW, iT, iR;
	iA = 0;
	iT = 0;
	iW = 0;
	iR = 0;
	for (int i = 0; i < N; i++) {
		cin >> s;
		if (*s == 'A') {
			iA++;
		}
		else if(*s == 'W') {
			iW++;
		}
		else if (*s == 'T') {
			iT++;
		}
		else if (*s == 'R') {
			iR++;
		}
	}
	cout << "AC x " << iA << endl;
	cout << "WA x " << iW << endl;
	cout << "TLE x " << iT << endl;
	cout << "RE x " << iR << endl;
	return(0);
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
    char b;
    cin >> b;
    if(b == 'A') cout << 'T' << endl;
    if(b == 'T') cout << 'A' << endl;
    if(b == 'G') cout << 'C' << endl;
    if(b == 'C') cout << 'G' << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N ; cin >> N;
  vector<int> x(N);
  for(int i = 0;i<N;i++){
  	cin >> x[i];
  }
  long min_cost = 100100100;
  for(int i = 1;i<101;i++){
	long c_cost = 0;
   	for(int j = 0;j<N;j++){
    	c_cost=c_cost + long((x[j] - i)*(x[j] - i));
    }
    if(c_cost < min_cost){
    	min_cost = c_cost;
    }
  }
  cout << min_cost<<endl;
}

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

int main() {

	int x; cin >> x;
	int p = 200;
	int ans;
	if (x < 400) {
		ans = 8;
		return 0;
	}
	for (int i = 2; i <= 9; i++) {
		if (p * i <= x && x < p * (i + 1)) {
			ans = 10 - i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a+b>=c) cout << "Yes"<< endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int linearsearch(int key,int S[],int n){
  int i;
  for(i=0;i<n;i++){
    if(key == S[i]) return 1;
  }
  return 0;
}

int main(){
  int i,n,S[10000],q,T[500],ans=0;

  scanf("%d",&n);

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

  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  
  for(i=0;i<q;i++){
    if(linearsearch(T[i],S,n) == 1)
      ans++;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 2108
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 20:56:46 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

K = int(input())
A, B = map(int,input().split())
#A = list(map(int,input().split()))
#graph = [[] for _ in range(N+1)]
#for _ in range(N-1):
#    a, b = map(lambda x : int(x)-1, input().split())
#    graph[a].append(b)
#    graph[b].append(a)


ans = 'NG'
if A % K == 0 or B % K == 0:
    ans ='OK'
for i in range(A,B+1):
    if i % K == 0:
        ans = 'OK'
print(ans)


Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	vector<string> strings(n);
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		sort(s.begin(), s.end());
		strings[i] = s;
	}
	sort(strings.begin(), strings.end());
	long long ans = 0;
	long long curr = 0;
	for (int i = 1; i < n; i++) {
		if (strings[i] == strings[i - 1]) {
			curr++;
		} else {

			long long dict = (curr * (curr + 1)) / 2;
			ans += dict;
			curr = 0;

		}
	}
	long long dic = (curr * (curr + 1)) / 2;
	if (dic >= 0) ans += dic;

	cout << ans << "\n";
}

Measured memory_bytes: 6304
#define _CRT_SECURE_NO_WARNIGNS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
using namespace std;
#define sci(n) scanf(“%lld”, &(n))
#define scd(n) scanf(“%Ld”, &(n))
typedef long long LL;

int main(void)
{
	LL x, y;
	cin >> x >> y;
	cout << x + (y / 2);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	string s;
	cin >> s;
	int r(0), l(0);
	int k = 1;
	int p;
	vector<int>ans(s.size());

	rep(i, s.size()) {
		if (k == 1) {
			if (s[i] == 'R') {
				++r;
			}
			else {
				k = k * (-1);
				r = r - 1;
				p = i;
				ans[p - 1] += r / 2;
				ans[p] += r - (r / 2);
				ans[p - 1] += 1;
				ans[p] += 1;
				r = 0;
				continue;
			}
		}
		if (k == -1) {
			if (s[i] == 'L') {
				++l;
				if (i == s.size() - 1) {
					ans[p] += (l / 2);
					ans[p - 1] += (l - (l / 2));
				}
			}
			else {
				k = k * (-1);
				ans[p] += (l / 2);
				ans[p - 1] += (l - (l / 2));
				l = 0;
				++r;
			}
		}
	}
	rep(i, ans.size()) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
A, B, C = map(int, input().split())

for i in range(10 ** 5):
    if A % 2 or B % 2 or C % 2:
        print(i)
        break
    A, B, C = B // 2 + C // 2, C // 2 + A // 2, A // 2 + B // 2
else:
    print(-1)


Measured memory_bytes: 3316
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int N = Integer.parseInt(scanner.nextLine());
		int K = Integer.parseInt(scanner.nextLine());
		
		int num = 1;
		for (int i=0; i<N; i++) {
			
			if (mul(num) < add(num, K)) {
				num = mul(num);
			} else {
				num = add(num, K);
			}
		}
		
		System.out.println(num);
	}
	
	static int mul(int n) {
		return 2*n;
	}
	
	static int add(int n, int k) {
		return n + k;
	}
}


Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {
	
	static int N,M;
	static int[][] cityArr;

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
//		long startTime = new Date().getTime();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		N = Integer.valueOf(st.nextToken());
		M = Integer.valueOf(st.nextToken());
		
		cityArr = new int[M][4];
		
		for(int i=0;i<M;i++) {
			st = new StringTokenizer(br.readLine());
			int xq =  Integer.valueOf(st.nextToken());
			int year =  Integer.valueOf(st.nextToken());
			cityArr[i][0] = xq;//区域
			cityArr[i][1] = year;//年
			cityArr[i][2] = i;//序号
			if(i>0 && (xq < cityArr[i-1][0] || (xq==cityArr[i-1][0] && year < cityArr[i-1][1]))) {
				//change
				cityArr[i][0] = cityArr[i-1][0];//区域
				cityArr[i][1] = cityArr[i-1][1];//年
				cityArr[i][2] = cityArr[i-1][2];//序号
				
				cityArr[i-1][0] = xq;
				cityArr[i-1][1] = year;
				cityArr[i-1][2] = i;
			}
		}
		//sort
		Arrays.sort(cityArr, new Comparator<int []>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				// TODO Auto-generated method stub
				if(o1[0]>o2[0]) {
					return 1;
				}else if(o1[0] == o2[0]){
					if(o1[1]>o2[1]) {
						return 1;
					}else{
						return -1;
					}
				}else {
					return -1;
				}
			}
		});
		int startt = 1;
		for(int i=0;i<M;i++) {
			if(i>0 && cityArr[i][0] != cityArr[i-1][0]) {
				startt = 1;
			}
			cityArr[i][3]=startt++;
		}
		
		//sort
		Arrays.sort(cityArr, new Comparator<int []>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				// TODO Auto-generated method stub
				if(o1[2]>o2[2]) {
					return 1;
				}else{
					return -1;
				}
			}
		});

//		for(int i=0;i<M;i++) {
//			System.out.println(cityArr[i][0]+" - "+cityArr[i][1]+" - "+cityArr[i][2]+" - "+cityArr[i][3]);
//		}
		
		for(int i=0;i<M;i++) {
			System.out.format("%06d%06d\n", cityArr[i][0],cityArr[i][3]);
		}
		
		
//		long endTime = new Date().getTime();
//		System.out.println(endTime-startTime);
		
	}
	
}


Measured memory_bytes: 115152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int r = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();

		for (int i = 0; i < 10; i++) {
			x = r * x - d;
			System.out.println(x);
		}

		sc.close();
	}
}

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

cnt_1 = 0 # 4の倍数の個数
cnt_2 = 0 # 奇数の個数

for i in range(N):
    if A[i] % 4 == 0:
        cnt_1 += 1
    elif A[i] % 2 != 0:
        cnt_2 += 1

if (N % 2 == 0 and cnt_1 >= cnt_2) or (N % 2 != 0 and cnt_1 >= cnt_2 - 1):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 15020
from collections import deque

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

sl = []
flag = False
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            sl.append([i, j])

q = deque()
dire = [(0, 1), (0, -1), (1, 0), (-1, 0)]
ans = 0
for sh, sw in sl:
    c = [[0]*w for _ in range(h)]
    q.append((sh, sw, 0))
    while q:
        ph, pw, k = q.pop()
        if c[ph][pw] == 0:
            ans = max(ans, k)
            c[ph][pw] = 1
            for dh, dw in dire:
                hdh, wdw = ph+dh, pw+dw
                if 0 <= hdh < h and 0 <= wdw < w and c[hdh][wdw] == 0:
                    if s[hdh][wdw] == '.':
                        q.appendleft((hdh, wdw, k+1))

print(ans)

Measured memory_bytes: 9424
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#define MAX_NUM 10000000000
int ketasuu(long long N) {
	long long i = 1;
	while (N >= 10) {
		N = N / 10;
		i++;
	}
	return i;
}

int main()
{
	long long N;
	long long i;
	long long minnum;
	long long warunum;
	long long wararetanum;
	long long num;
	scanf("%lld", &N);

	minnum = MAX_NUM;
	for (i = 1; (i * i) <= N; i++) {
		if (N % i == 0) {
			warunum = ketasuu(i);
			wararetanum = ketasuu(N / i);
			if (warunum > wararetanum) {
				num = warunum;
			}
			else {
				num = wararetanum;
			}

			if (minnum > num) {
				minnum = num;
			}
		}
	}

	printf("%lld", minnum);

    return 0;
}

Measured memory_bytes: 128
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())

    tree = [[] for _ in range(n)]
    for _ in range(m):
        x, y, _ = map(int, input().split())
        tree[x - 1].append(y - 1)
        tree[y - 1].append(x - 1)

    def dfs(v):
        for u in tree[v]:
            if visited[u]:
                continue
            else:
                visited[u] = True
                dfs(u)

    visited = [False for _ in range(n)]
    res = 0
    for i in range(n):
        if not visited[i]:
            res += 1
            visited[i] = True
            dfs(i)

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 129112
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define ll long long 

int main () {
	int i,j,k,n,m;
	double l;
	cin>>l;
	printf("%.7lf",(l*l*l)/27);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

ll d[13][100001]={};

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(b+c-a>0)cout<<b+c-a<<endl;
	if(b+c-a<=0)cout<<"0"<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
       Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
       long a,b,c,d,e;
       a=2;
       b = sc.nextLong();
       c = b;
       d = b;
       e = b;
       while(a<=n){
    	   b = sc.nextLong();
    	   c = c + b;
    	   if (b > d){
    		   d = b;
    	   }else if (b < e){e = b;}
    	   a = a+1;
       }
       System.out.println(e + " " + d + " " + c);
	}

}

Measured memory_bytes: 42220
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
ll N;
ll dfs(ll n) {
    if (n > N) return 0;
    string s = to_string(n), t = "753";
    ll ret = 1;
    for (char c : t)
        if (s.find(c) == string::npos) ret = 0;
    for (char c : t)
        ret += dfs(10 * n + (c - '0'));
    return ret;
}
int main() {
    cin >> N;
    cout << dfs(0) << endl;
}


Measured memory_bytes: 256
// Contest: AtCoder Beginner Contest 155 (https://atcoder.jp/contests/abc155)
// Problem: C: Poll (https://atcoder.jp/contests/abc155/tasks/abc155_c)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    int n; cin >> n;
    map<string, int> m;
    int mx = 0;
    rep(i, n) {
        string s; cin >> s;
        mx = max(mx, ++m[s]);
    }
    vector<string> v;
    for (auto& p : m)
        if (p.second == mx)
            v.push_back(p.first);
    sort(all(v));
    trav(s, v)
        cout << s << '\n';

    return 0;
}

Measured memory_bytes: 25584
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
 
int n;
int x[10], y[10];

double dist(int i, int j)
{
    double a = x[i] - x[j];
    double b = y[i] - y[j];

    return pow(a*a + b*b, 0.5);
}



int main(){

    cin >> n;
    

    for (int i = 1; i <= n; i++)
    {
        cin >> x[i] >> y[i];
    }

    double ans = 0.0;

    for (int i = 1; i <= n; i++)
    {
        for (int j = i+1; j <= n; j++)
        {
            ans += dist(i, j)*2/n;
        }
    }
    cout << fixed << setprecision(10) << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int day,j,m,jp,mp;
  cin>>day>>j>>m>>jp>>mp;
  int jans,mans;
  jans=j/jp;
  if(j%jp!=0)jans++;
  mans=m/mp;
  if(m%mp!=0)mans++;
  cout<<day-max(jans,mans)<<endl;
}

Measured memory_bytes: 3088
#include <iostream>
#include<math.h>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {

    string S, T;
    cin >> S >> T;

    long length = S.size();
    for (int i = 0; i < length; ++i) {

        // 一個ずらす
        string first = S.substr(0, 1);
        string last = S.substr(length - 1, 1);
        S = S.substr(1, length - 1) + first;

        if (S == T) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

int customers1[1001];
int customers2[1001];

int main() {
    int n;
    string s;
    stringstream ss;
    while(getline(cin,s)) {
        if (s =="") break;
        ss.str("");
        ss << s;
        ss >> n;
        customers1[n]++;
    }
    while(getline(cin,s)) {
        ss.str("");
        ss << s;
        ss >> n;
        customers2[n]++;
    }
    REP(i,1001) {
        if (customers1[i] && customers2[i]) {
            cout << i << " " << customers1[i]+customers2[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1244
def input_int():
    hoge = input().split()
    A = int(hoge[0])
    B = int(hoge[1])
    return A, B

if __name__ == "__main__":
    A, B = input_int()
    if A <=9 and B <= 9:
        ret = A * B
    else:
        ret = -1
    print(ret)



Measured memory_bytes: 2940
#include <stdio.h>
int main(void){
    // Your code here!
    int H,W;
    
    while(1){
    
        scanf("%d %d",&H,&W);
        if(H==0&&W==0){
            break;
        }
        
        for(int i=0;i<H;i++){
            
            for(int j=0;j<W;j++){
                if(i%2==0){
                    if(j%2==0){
                        printf("#");
                    }else{
                        printf(".");
                    }
                }else{
                    if(j%2==0){
                        printf(".");
                    }else{
                        printf("#");
                }
                    
                }
            }
            printf("\n");
        }
        
        putchar('\n');
        
    }
}



Measured memory_bytes: 2140
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
    ini(A, B);
    if (A == 1) A = 14;
    if (B == 1) B = 14;

    if (A == B)
        out("Draw");
    else if (A > B)
        out("Alice");
    else
        out("Bob");
}


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

int main(){

	// #ifndef ONLINE_JUDGE
 //    	freopen("input", "r", stdin);
 //    	freopen("output", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);

   	int r;
   	cin>>r;
   	cout<<3*r*r<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    string s;
    cin >> s;
    int a[s.size() + 1] = {};
    for(int i = 0;i < s.size();i++)
    {
        if(s[i] == '<')
        {
            a[i + 1] = max(a[i + 1],a[i] + 1);
        }
    }
    for(int i = s.size() - 1;i >= 0;i--)
    {
        if(s[i] == '>')
        {
            a[i] = max(a[i],a[i + 1] + 1);
        }
    }
    long long int ans = 0;
    for(int i = 0;i < s.size() + 1;i++)
    {
        ans += a[i];
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 2820
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  vector<char> S(101);
  for(int i=0;i<101;i++){
    cin >> S.at(i);
  }
  int ans=0;
  for(int i=0;i<101;i++){
    if(i%2==0&S.at(i)=='L'){
        ans=1;
        break;
    }
    else if(i%2==1&S.at(i)=='R'){
        ans=1;
        break;
    }
  }
  if(ans==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI=2147483647;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


struct UnionFind{
  vector<int> par;  // 親ノードを格納
  vector<int> rank; // 木の深さを格納

  UnionFind(int N) : par(N), rank(N, 0) { // N要素で初期化する
    rep(i, N) par[i] = i;
  }

  int root(int x){ // 木の根を求める。自分じゃなかったら親の根を調べていき調べたノードの親はすべて根に
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  void unite(int x, int y){ // xとyの木を併合
    x = root(x), y = root(y);
    if (x==y) return; // 元々同じならそのまま
    if (rank[x] < rank[y]){
      par[x] = y;
    }else{
      par[y] = x;
      if (rank[x]==rank[y]) rank[x]++; // 元のrankが同じなら親になる方のrankは1増える
    } 
  }

  bool same(int x, int y){ // x,yの木が同じかどうか
    return root(x) == root(y);
  }
};

int main() {
  int n,k,l; cin >>n >>k >>l;
  UnionFind uf1(n);
  rep(qqqqqqqqqqq, k){
    int p,q; cin >>p >>q;
    p--; q--;
    uf1.unite(p, q);
  }
  UnionFind uf2(n);
  rep(qqqqqqqqqqq, l){
    int r,s; cin >>r >>s;
    r--; s--;
    uf2.unite(r, s);
  }
  map<pair<int, int>, int> res;
  rep(i, n){
    res[{uf1.root(i), uf2.root(i)}]++;
  }
  rep(i, n){
    cout <<res.at({uf1.root(i), uf2.root(i)}) <<endl;
  }
}


Measured memory_bytes: 15104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main()
        {
            var read = Console.ReadLine();
            string[] split = read.Split(' ');
            int N = Int32.Parse(split[0]);
            int T = Int32.Parse(split[1]);
            read = Console.ReadLine();
            split = read.Split(' ');
            int[] t = new int[N];
            for (int c = 0; c < N; ++c)
            {
                t[c] = Int32.Parse(split[c]);
            }
            Console.WriteLine(calculator(N, T, t));
            ;
        }
        static int calculator(int N, int T, int[] t)
        {
            int output = 0;
            int temp = 0;
            for (int c = 0; c < N-1; c++)
            {
                if (t[c + 1] - t[c] < T) output += t[c + 1] - t[c];
                else output += T;
                temp = c;
            }
            return output+T;
        }
    }
}


Measured memory_bytes: 28256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int a[5]={0};
bool fun(){
	for(int i=0;i<4;i++){
		if(a[i]==0){
			return false;
		}
	}
	return true;
}
int main(){
	int temp;
	for(int i=0;i<4;i++){
		scanf("%d",&temp);
		if(temp==1){
			a[0]=1;
		}else if(temp==9){
			a[1]=1;
		}else if(temp==7){
			a[2]=1;
		}else if(temp==4){
			a[3]=1;
		}
	}
	if(fun()){
		printf("YES");
	}else {
		printf("NO");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    int x, y;
    cin >> x >> y;
    for (int c=0; c<=x; c++) {
        int t = x-c;
        int asi = c*2+t*4;
        if (asi == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    string S1;
    cin >> S1;
    string S2;
    cin >> S2;
    ll ans = 1;
    ll prev = 0;
    ll now = 0;
    if (S1[0] == S2[0]){
        prev = 1;
        now++;
        ans = 3;
    }
    else{
        prev = 2;
        now += 2;
        ans = 6;
    }
    while(now < N){
        if (S1[now] == S2[now]){
            now++;
            if (prev == 1){
                ans = (ans * 2) % 1000000007;
                prev = 1;
            }
            else{
                prev = 1;
            }
        }
        else{
            now += 2;
            if (prev == 1){
                ans = (ans * 2) % 1000000007;
                prev = 2;
            }
            else{
                ans = (ans * 3) % 1000000007;
                prev = 2;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N)]

import itertools
from math import hypot
l = k = 0
for ptn in itertools.permutations(XY):
    k += 1
    for (x1,y1),(x2,y2) in zip(ptn,ptn[1:]):
        d = hypot(x1-x2, y1-y2)
        l += d
print(l/k)

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

void run() {
  int n, k;
  std::cin >> n >> k;
  std::vector<bool> dislike(10, 0);
  for (int i = 0; i < k; ++i) {
    int d;
    std::cin >> d;
    dislike[d] = 1;
  }
  for (; ; ++n) {
    bool flag = true;
    for (int m = n; m; m /= 10) {
      if (dislike[m % 10]) flag = false;
    }
    if (flag) break;
  }
  printf("%d\n", n);
}

int main() {
  run();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll>PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e4+7;
int main() {
    string s, t;
    cin >> s >> t;
    vector<string> a;
    rep(i, s.size()-t.size()+1) {
        int j = 0;
        bool ok = true;
        while(1) {
            if ( j == t.size() ) break;
            if ( s[i+j] != '?' && s[i+j] != t[j] ) {
                ok = false;
                break;
            }
            ++j;
        }
        if ( ok ) {
            string tmp_s = s;
            rep(j, s.size()) {
                if ( j >= i && j <= i + t.size() - 1 ) {
                    tmp_s[j] = t[j-i];
                }
                else if ( s[j] == '?' ) tmp_s[j] = 'a';
            }
            a.push_back(tmp_s);
        }
    }
    sort(a.begin(), a.end());
    if ( a.empty() ) cout << "UNRESTORABLE" << endl;
    else             cout << a[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    char S[3];
    
    scanf("%s",&S);
    
    if('S' == S[0] && 'U' == S[1]){
        printf("7");
        return 0;
    }
    else if('M' == S[0]){
        printf("6");
        return 0;
    }
    else if('T' == S[0] && 'U' == S[1]){
        printf("5");
        return 0;
    }
    else if('W' == S[0]){
        printf("4");
        return 0;
    }
    else if('T' == S[0] && 'H' == S[1]){
        printf("3");
        return 0;
    }
    else if('F' == S[0]){
        printf("2");
        return 0;
    }
    else if('S' == S[0] && 'A' == S[1]){
        printf("1");
        return 0;
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <list>
#include <math.h>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int A, B;
  cin >> A >> B;
  cout << max(0, A - 2 * B);
  return 0;
}


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

#define endl '\n'
#define rep(i,s,n)      for (int i = s ; i < n ; i++)
#define repp(i,s,n)    for (int i = s ; i <= n ;i++)
#define all(a)      a.begin(),a.end()
#define sz(v)    (int)v.size()
#define NumofDigits(n)    ((long long)log10(n)+1)
#define Unique(n)         (n).erase(unique(all(n)), (n).end())
#define test    int s ; cin >> s; while (s--)
#define readArr    int n ; cin >> n ; int arr[n]; rep(i,0,n)cin>>arr[i]
#define isvowel(a)   (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fast     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll ;

void readFromText ()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
#endif // ONLINE_JUDGE
}

const double Pi = acos(-1.0);

bool countIF (int a){
    return a%4==0;
}

bool myFun (int i , int j ) {

}

const int MAX = 1e6 ;
int sum [MAX+9];
int freq [MAX+9];

int main()
{
//    fast;
//    readFromText();
    int n ; cin >> n ;
    int m = 0 ;
    int arr[n];
    rep(i,0,n)cin>>arr[i],m^=arr[i];
    rep(i,0,n){int mm = m^arr[i];cout << mm << " ";}
    return 0;
}



Measured memory_bytes: 4212
x, y = map(int, (input().split()))
ans = 0

ans = 300000 if x == 1 else (200000 if x == 2 else (100000 if x == 3 else 0))
ans += 300000 if y == 1 else (200000 if y == 2 else (100000 if y == 3 else 0))
ans += 400000 if x == 1 and y == 1 else 0


print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
      int64_t a;
      cin >> a;
      vector<int64_t> z(a+1);
      vector<int64_t> b(a);
      for (int i = 0;i < a;i++){
      cin >> b.at(i);
      z.at(b.at(i))++;}
      int64_t x = 0;
      for (int i = 0;i < a+1;i++){
        int64_t v = z.at(i)*(z.at(i)-1) / 2;
          x += v;}
      for (int i = 0;i < a;i++){        
       cout <<  x-z.at(b.at(i)) + 1 << endl;}
      
    }

Measured memory_bytes: 5760
import java.io.*;

public class Main {
    public static void main(String[] a) throws NumberFormatException, IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line;
        // データ読み込み
        while ((line = in.readLine()) != null) {
            String res = String.valueOf(Integer.parseInt(line.split(" ")[0]) + Integer.parseInt(line.split(" ")[1]));
            System.out.println(res.length());
        }
    }
}

Measured memory_bytes: 17100
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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 dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll a,b;
vector<ll> pn;
int main(){
	cin>>a>>b;
	ll g=gcd(a,b);
	for(int i=2;i<=1000000;i++){
		int flag=1;
		for(int j=0;j<pn.size();j++){
			if(pn[j]*pn[j]>i)break;
			if(i%pn[j]==0){
				flag=0;
				break;
			}
		}
		if(flag)pn.push_back(i);
		//cout<<i<<endl;
	}
	int ans=0;
	for(int i=0;i<pn.size();i++){
		int flag=0;
		while(g%pn[i]==0){
			g=g/pn[i];
			if(flag==0)ans++;
			flag=1;
		}
	}
	if(g!=1)ans++;
	cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int INF = 1000000000;

int main() {

  int N, M, a, b, c;
  cin>>N>>M;
  int v[105][105];
  for(int i=0; i<N; i++){
      for(int j=0; j<N; j++){
        v[i][j] = INF;
      }
  }
  for(int i=0; i<M; i++){
    cin>>a>>b>>c;
    v[a-1][b-1] = c;
    v[b-1][a-1] = c;
  }

  set< pair<int, int> > s;

  for(int i=0; i<N; i++){
    int dist[105];
    bool visit[105];
    fill(dist, dist+N, INF);
    fill(visit, visit+N, false);
    dist[i] = 0;
    while(1){
      int u = -1, d = INF;
      for(int k=0; k<N; k++){
        if(!visit[k] && dist[k] < d){
          u = k;
          d = dist[k];
        }
      }
      if(u == -1) break;
      visit[u] = true;
      for(int j=0; j<N; j++){
        if(v[u][j] != 0){
          dist[j] = min(dist[j], dist[u]+v[u][j]);
        }
      }
    }

    //cout<<"i:"<<i<<endl;
    for(int l=0; l<N; l++){
      for(int r=0; r<N; r++){
        if(dist[l] - v[l][r] == dist[r] || dist[r] - v[l][r] == dist[l]){
          int a = l, b = r;
          if(a > b){
            swap(a, b);
          }
          //cout<<"a:"<<a<<" b:"<<b<<endl;
          s.insert(make_pair(a,b));
        }
      }
    }

  }

  cout<<M - (int)s.size()<<endl;

  //cout<<"s.size(): "<<s.size()<<endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pt;

#define fi first
#define se second
#define lson (p<<1)+1
#define rson (p<<1)+2
#define dump(x) cout << #x << " = " << x << endl
#define comb(x) ((x * (x + 1)) >> 1)
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll n, a[107], sum;

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

    for(li i = 0; i < n; i ++) {
        for(li j = i + 1; j < n; j ++) {
            sum += a[i] * a[j];
        }
    }
    cout << sum;

}


Measured memory_bytes: 256