akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <string.h>
#include <map>
#include <iomanip>
#include <time.h>
using namespace std;
typedef long long ll;

void twin(bool b) {
    cout << (b ? "Yay!" : ":(" ) << endl;
}

int main() {
    int n;
    char s[30030];
    cin >> n;
    cin >> s;

    int ans = 0;
    for (int i = 0; i < 1000; i++) {
        int ic = i;
        char v[3];
        for (int j = 0; j < 3; j++) {
            v[2 - j] = ic % 10 + '0';
            ic /= 10;
        }
        int tmp = 0;
        for (int j = 0; j < n; j++) {
            if (s[j] == v[tmp]) tmp++;
            if (tmp == 3) break;
        }
        ans += (tmp == 3);
    }

    cout << ans << endl;
    

}

Measured memory_bytes: 256
a = list(map(int, input().split()))
k = int(input())
count = 0
while a[0] >= a[1]:
    count += 1
    a[1] *= 2
while a[1] >= a[2]:
    count += 1
    a[2] *= 2
if count > k:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 61884
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
using namespace std;
const int inf=1e9+10;
const int mod=1e9+7;
const int maxn=2e5+10;
int n,k,a[maxn];
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n>>k;
	for (int i = 1; i <= n; ++i)
	{
		cin>>a[i];
	}
	double ans=0,ret=0;
	for(int i=1;i<=n;i++){
		ret+=(1+a[i])/2.0;
		if(i>k) ret-=(1+a[i-k])/2.0;
		ans=max(ans,ret);
	}
	printf("%.7f\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

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

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int main() {
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    rep(i, s.size()) if (s[i] != t[i]) cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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; }

int main() {
  ll k;
  cin>>k;
  ll ans = 0;
  ll now = 0;
  REP(i, 1000005) {
    now *= 10;
    now += 7;
    now %= k;
    if(now == 0) {
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
ll n;
int ans = 0;
vector<int> vec={3, 5, 7};

void dfs(ll c, int b) {
  if (c > n) {
    return;
  }
  if (0b111 == b) {
    ans++;
  }
  dfs(c*10 + 7, b | 0b100);
  dfs(c*10 + 5, b | 0b010);
  dfs(c*10 + 3, b | 0b001);
}


int main()
{

  cin >> n;
  
  dfs(0, 0);
  
  cout << ans << endl;
  
  
  return 0;
}

Measured memory_bytes: 3524
s = int(input())

mod = 10 ** 9 + 7
N = 10000

#逆元テーブル
inv_t = [0]+[1]
for i in range(2, N):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]

#階乗計算
kai = [1, 1]
rev_kai = [1, inv_t[1]]
for i in range(2, N):
	kai.append(kai[-1] * i % mod)
	rev_kai.append(rev_kai[-1] * inv_t[i] % mod)

# コンビネーション計算
def cmb(n, r):
	return kai[n] * rev_kai[r] * rev_kai[n-r] % mod

ans = 0
for i in range(1, s // 3 + 1):
    ans += cmb(s-2*i-1, i-1)
    ans %= mod

print(ans)

Measured memory_bytes: 68396
use std::io;
use std::cmp::*;

fn main() {
    let mut string = String::new();
    io::stdin().read_line(&mut string).expect("read error");
    let int_vec: Vec<u32> = string.trim().split(" ")
        .map(|x| {
            x.parse::<u32>()
                .expect("Not an integer!")
        })
        .collect();
    
    let m = min(int_vec[0], int_vec[1]);
    let n = max(int_vec[0], int_vec[1]);
    let k = int_vec[2];

    for i in 0..(m + 1) {
        for j in 0..(n + 1) {
            if m * n - (m - i) * (n - j) - i * j == k {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
N = int(input())
digits_sum_min = 1e9
for A in range(1, N):
    B = N - A
    digits_sum = 0
    for a in str(A):
        digits_sum+=int(a)
    for b in str(B):
        digits_sum+=int(b)      
    if digits_sum < digits_sum_min:
        digits_sum_min = digits_sum
print(digits_sum_min)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,m;
    cin>>n>>m;
    int arr[50]= {0};
   for(int i=0;i<n;i++)
    {
        int k;
        cin>>k;
        while(k--)
        {
            int a;
            cin>>a;
            arr[a]++;
        }
    }
    int cnt=0;
    for(int i=1; i<=m; i++)
    {

        if(arr[i]==n)
            cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


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

using namespace std;

#define long long long
#define INF (long) 1e18
#define MOD 1'000'000'007
#define mll map<long, long>
#define pll pair<long, long>
#define umap unordered_map
#define umll umap<long, long>
#define uset unordered_set
#define pb push_back
#define FOR(i, a, b) \
  for (long i = (a); i < (long) (b); i++)

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

  long n;
  cin >> n;

  long resp = n / 3;
  printf("%lld\n", resp);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
/*
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
*/

int main() {
	int N; cin >> N;
	int M; cin >> M;
	string S; cin >> S;
	bool f = true;
	string ans = "";
	int x = N;
	while (x > 0) {
		// db(x);
		bool g = false; // 進めるマスがあるか
		rep3(i, min(M, x), 0) {
			// db(i);
			if (S.at(x - i) == '0') {
				g = true;
				x -= i;
				ans = to_string(i) + " " + ans;
				break;
			}
		}
		if (!g) {
			f = false;
			break;
		}		
	}
	if (f) {
		cout << ans << endl;
	} else {
		cout << -1 << endl;
	}
}

Measured memory_bytes: 1056
import sys
input = sys.stdin.readline
INF = 9223372036854775808


def calc_score(D, C, S, T):
    """
    開催日程Tを受け取ってそこまでのスコアを返す
    コンテストi 0-indexed
    d 0-indexed
    """
    score = 0
    last = [0]*26  # コンテストiを前回開催した日
    for d, t in enumerate(T):
        last[t] = d + 1
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
        score += S[d][t]
    return score


def evaluate(D, C, S, T, k):
    """
    d日目終了時点での満足度を計算し，
    d + k日目終了時点での満足度の減少も考慮する
    """
    score = 0
    last = [0]*26
    for d, t in enumerate(T):
        last[t] = d + 1
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
        score += S[d][t]

    for d in range(len(T), min(len(T) + k, D)):
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
    return score


def update_score(D, C, S, T, score, ct, ci):
    """
    ct日目のコンテストをコンテストciに変更する
    スコアを差分更新する

    ct: change t 変更日 0-indexed
    ci: change i 変更コンテスト 0-indexed
    """
    last = [0]*26  # コンテストiを前回開催した日
    for d in range(ct):
        last[T[d]] = d + 1
    prei = T[ct]  # 変更前に開催する予定だったコンテストi
    score -= S[ct][prei]
    score += S[ct][ci]
    for d in range(ct, D):
        if d != ct and T[d] == prei:
            break
        score += C[prei]*(d + 1 - ct - 1)
        score -= C[prei]*(d + 1 - last[prei])
    for d in range(ct, D):
        if d != ct and T[d] == ci:
            break
        score += C[ci]*(d + 1 - last[ci])
        score -= C[ci]*(d + 1 - ct - 1)
    T[ct] = ci
    return score, T


def greedy(D, C, S):
    Ts = []
    for k in range(8, 14):
        T = []  # 0-indexed
        max_score = -INF
        for d in range(D):
            # d+k日目終了時点で満足度が一番高くなるようなコンテストiを開催する
            best_i = 0
            for i in range(26):
                T.append(i)
                score = evaluate(D, C, S, T, k)
                if max_score < score:
                    max_score = score
                    best_i = i
                T.pop()
            T.append(best_i)
        Ts.append((max_score, T))
    res = max(Ts, key=lambda pair: pair[0])
    return res


def local_search():
    
    res = -1
    return res


if __name__ == '__main__':
    D = int(input())
    C = [int(i) for i in input().split()]
    S = [[int(i) for i in input().split()] for j in range(D)]
    init_score, T = greedy(D, C, S)
    for t in T:
        print(t+1)


Measured memory_bytes: 74496
#include<iostream>
using namespace std;
int dp[105][105][2][2], H, W;
int main() {
	while (true) {
		for (int i = 0; i < 11025; i++) { for (int j = 0; j < 4; j++) { dp[i / 105][i % 105][j / 2][j % 2] = 0; } }
		cin >> H >> W; dp[0][0][0][0] = 1; dp[0][0][1][0] = 1; if (H + W == 0)break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				dp[i + 1][j][0][0] += dp[i][j][1][1]; dp[i + 1][j][0][0] %= 100000;
				dp[i + 1][j][0][1] += dp[i][j][0][0] + dp[i][j][0][1]; dp[i + 1][j][0][1] %= 100000;
				dp[i][j + 1][1][0] += dp[i][j][0][1]; dp[i][j + 1][1][0] %= 100000;
				dp[i][j + 1][1][1] += dp[i][j][1][0] + dp[i][j][1][1]; dp[i][j + 1][1][1] %= 100000;
			}
		}
		cout << (dp[H - 1][W - 1][0][0] + dp[H - 1][W - 1][0][1] + dp[H - 1][W - 1][1][0] + dp[H - 1][W - 1][1][1]) % 100000 << endl;
	}
	return 0;
}

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
		cin.tie(0);							     \
		cout.tie(0);
#define sz(arr) int(arr.size())

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
ll div_floor(ll a, ll b) { return a / b - (((a ^ b) < 0) and a % b); }
ll div_ceil(ll a, ll b) { return a / b + (((a ^ b) >= 0) and a % b); }

//ll f[200005];
//ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }

ll pre[200001];
ll f[200001];

int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	fastio;
	
	f[0] = 1;
	for (int i = 1; i <= 200001; ++i)
		f[i] = (f[i - 1] * 10) % 2019;

	string s;
	cin >> s;
	int n = sz(s);
	map<ll, ll> mp;
	ll ans = 0;
	mp[0] = 1;
	for (int i = 0; i < n; ++i) {
		pre[i + 1] = pre[i] + (s[i] - '0') * f[n - 1 - i];
		pre[i + 1] %= 2019;
		if (mp.find(pre[i + 1]) != mp.end())
			ans += mp[pre[i + 1]];
		mp[pre[i + 1]]++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 6876
import sys
input = sys.stdin.readline
N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N)]

A = []
B = []
for x,y in XY:
    A.append(x+y)
    B.append(x-y)

a = max(A) - min(A)
b = max(B) - min(B)
print(max(a,b))

Measured memory_bytes: 51848
S = gets.chomp
if S.size < 26
  puts S+("a".."z").to_a.find{ |a| !S.include?(a) }; exit
end

x = S[-1]
y = x
(0...S.size-1).reverse_each{ |i|
  if S[i] > y
    y = S[i]
    next
  end
  puts S[0...i]+S[i..-1].split("").select{ |c| S[i] < c }.sort[0]; exit
}
p -1


Measured memory_bytes: 1788
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        
        if (k >= n || n == 1) {
            System.out.println(0);
            return;
        }
        
        int[] x = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }
        Arrays.sort(x);
        
        int[] d = new int[n - 1];
        int sum = 0;
        for (int i = 0; i < n - 1; i++) {
            d[i] = x[i + 1] - x[i];
            sum += d[i];
        }
        Arrays.sort(d);
        
        int answer = sum;
        for (int i = n - 2; i > n - 1 - k; i--) {
            answer -= d[i];
        }
        
        System.out.println(answer);
    }
}

Measured memory_bytes: 50784
#include<bits/stdc++.h>
#define int long long
#define p pair<int,int>//cost to
#define P pair<int,p>//cost to high
using namespace std;

int d[100000];
vector<p>rinsetu[100000];
int mincost[100000];
signed main() {
	int a, b, c; cin >> a >> b >> c;
	for (int e = 0; e < a; e++)scanf("%lld", &d[e]);
	for (int f = 0; f < b; f++) {
		int g, h, i; scanf("%lld%lld%lld", &g, &h, &i);
		g--; h--;
		if (i <= d[g])rinsetu[g].push_back(p(i, h));
		if (i <= d[h])rinsetu[h].push_back(p(i, g));
	}
	fill(mincost, mincost + a, LLONG_MAX/3);
	priority_queue<P, vector<P>, greater<P>>Q;
	mincost[0] = 0; Q.push(P(0,p(0,c)));
	while (Q.size()) {
		P t = Q.top(); Q.pop();
		if (mincost[t.second.first] < t.first)continue;
		if (t.second.first == a - 1) { cout << t.first + abs(t.second.second - d[t.second.first])<<endl; return 0; }
		for (p q : rinsetu[t.second.first]) {
			if (t.second.second - q.first < 0) {
				if (mincost[q.second] > t.first + q.first + (0 - (t.second.second - q.first))) {
					mincost[q.second] = t.first + q.first + (0 - (t.second.second - q.first));
					Q.push(P(mincost[q.second], p(q.second, 0)));
				}
			}
			else if (t.second.second - q.first > d[q.second]) {
				if (mincost[q.second] > t.first + q.first + (t.second.second-q.first-d[q.second])) {
					mincost[q.second] = t.first + q.first + (t.second.second - q.first - d[q.second]);
					Q.push(P(mincost[q.second], p(q.second, d[q.second])));
				}
			}
			else {
				if (mincost[q.second] > t.first + q.first) {
					mincost[q.second] = t.first + q.first;
					Q.push(P(mincost[q.second],p(q.second,t.second.second-q.first)));
				}
			}
		}
	}
	puts("-1");
}

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

int main(){
    string T;
    cin >> T;

    string S = "";

    rep(i,T.size()) {
      if (T[i] == 'P') S += 'P';
      if (T[i] == 'D') S += 'D';
      if (T[i] == '?') S += 'D';
    }

    cout << S << endl;
}

Measured memory_bytes: 3920
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int half = s.length()/2;
        int cnt=0;

        if(s.length()==1){
            cnt++;
        }
        if(s.length()%2==1){
            cnt++;
        }

        for(int i =0; i<half;i++){
            if(s.charAt(i)!=s.charAt(i+half)){
                cnt++;
            }
        }

        if(cnt==0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

     
    }
}


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

int dp[22][11][156];

int main ()
{
    int n, m, p;

    for (int i = 0; i <= 20; i++) {
        dp[i][1][i] = 1;
    }

    for (int i = 1; i <= 20; i++) {
        for (int k = 1; k <= 155; k++) {
            for (int j = 1; j <= 10; j++) {
                if (dp[i][j][k]) {
                    dp[i + 1][j][k] += dp[i][j][k];
                    if (j < 10 && k + i + 1 <= 155)
                        dp[i + 1][j + 1][k + i + 1] += dp[i][j][k];
                }
            }
        }
    }

    while (cin >> n >> m >> p, (n || m || p)) {
        cout << dp[n][m][p] << endl;
    }

    return 0;
}

Measured memory_bytes: 1300
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 配列数 - 取得
	int liACnt;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &liACnt);

	// 奇数の数 - 取得
	int liOCnt = 0;
	for (i = 0; i < liACnt; i++) {
		int liVal;
		fscanf(szpFpI, "%d", &liVal);
		liOCnt += liVal % 2;
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	return liOCnt % 2;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// １行出力
	if (liRet == 0) {
		sprintf(lc1Buf, "YES\n");
	}
	else {
		sprintf(lc1Buf, "NO\n");
	}
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

class Proc{
public:
  string nam;
  int tim;
  Proc(){ nam=""; tim=0;}
};

Proc Q[1000001];

class Queue{
private:
  int fp;
  int rp;
public:
  Queue(){ fp=0; rp=0;}
  int next(int p) { return (p+1)%100001;}
  bool isFull() { return (next(rp)==fp);}
  bool isEmpty() { return (rp==fp);}
  void push(Proc d);
  Proc front();
  void pop();
};

void Queue::push(Proc d){
  if(isFull())
    return;

  Q[rp]=d;
  rp=next(rp);
}

Proc Queue::front(){
  if(isEmpty()){
    Proc er;
    er.tim=-1;
    return er;
  }
  return Q[fp];
}

void Queue::pop(){
  if(isEmpty())
  return;
  fp=next(fp);
}

int main(){
  Queue que;
  int n,q;
  cin>>n>>q;
  for(int i=0;i<n;i++){
    Proc p;
    cin>>p.nam>>p.tim;
    que.push(p);
  }
  int total_tim=0;

  while(!que.isEmpty()){
    Proc p=que.front();
    que.pop();
    if(p.tim<=q){
      total_tim += p.tim;
      cout<<p.nam<<' '<<total_tim<<endl;
    }else{
      total_tim += q;
      p.tim -= q;
      que.push(p);
    }
  }
  return 0;
}



Measured memory_bytes: 21040
#include <bits/stdc++.h>
 
#define ff first
#define ss second
#define mp make_pair
 
using namespace std;

typedef long long ll;

int v[200005];
bool mark[200005][5][2];
ll dp[200005][5][2];
int n,T;

ll f(int i, int j, bool has) {
	if(i == n) return j > 1 ? - 1e18 : 0;
	if(mark[i][j][has]) return dp[i][j][has];
	mark[i][j][has] = true;

	ll ret = - 1e18;

	if(has) {
		ret = max(ret, f(i+1, j, false) + v[i]);
		if(j) ret = max(ret, f(i+1, j-1, true));
	}
	else ret = max(ret, f(i+1, j, true));

	return dp[i][j][has] = ret;
}

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

	ll ans = 0;
	for(int i = 0; i < n; i++)
		scanf("%d", &v[i]);

	int space = (n%2 == 0) ? 1 : 2;
	printf("%lld\n", f(0, space, true));

	return 0;
}


Measured memory_bytes: 34556
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod = 1'000'000'007;
const int INF = 1e9;

vvi dp(100010, vi(3, -1));
vvi a(100010, vi(3));

int rec(int n, int k){
    if (dp[n][k] != -1) return dp[n][k];
    if (n == 0) return dp[0][k] = 0;
    int res = 0;
    rep(i,3){
        if (k == i) continue;
        res = max(res, rec(n-1, i) + a[n][i]);
    }
    return dp[n][k] = res;
}

int main(){
    int n;
    cin >> n;
    REP(i,1,n+1)rep(j,3) cin >> a[i][j];
    int ans = 0;
    rep(i,3){
        ans = max(ans,rec(n, i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 20424
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main(){
  ll a,b,c,d;
  cin >>a>>b>>c>>d;
  ll ans=-pow(10,18)-1;
  vector<ll> vec={a,b};
  vector<ll> vec2={c,d};
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      ans=max(ans,vec[i]*vec2[j]);
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 
ll findgcd(ll,ll);
 
int main(){
  int i,j;
  int count=0,acou=0,bcou=0,xcou=0;
  int N;
  cin >> N;
  vector<string> s(N);
  for(i=0;i<N;i++){
    cin >> s[i];
    for(j=0;j<s[i].size()-1;j++){
      if(s[i][j]=='A' && s[i][j+1]=='B') count++;
    }
    if(s[i][0]=='B') bcou++;
    if(s[i][s[i].size()-1]=='A') acou++;
    if(s[i][0]=='B' && s[i][s[i].size()-1]=='A') xcou++;
  }
  if(acou==xcou && bcou==xcou && xcou!=0) count += xcou-1;
  else count += min(acou,bcou);
  cout << count << endl;
  return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
	int A, B, C, X;
	cin >> A >> B >> C >> X;

	int target_sum = X;
	int sum = 0;
	int answer = 0;
	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				sum = (500 * i) + (100 * j) + (50 * k);
				if (sum == target_sum) {
					answer++;
				}
			}
		}
	}

	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map> 
using namespace std;
typedef long long ll;
const double pi=acos(-1.0);


int main()
{
	int a,b,c,d;
	scanf("%d%d",&a,&b);
	while(b--)
	{
		scanf("%d",&c);
		a-=c;
	}
	if(a<0)printf("-1\n");
	else printf("%d\n",a);
	
}



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

int main(){
  long long n, x;
  cin >> n >> x;

  long long a[100010] = {};

  long long ans = 0;
  for(int i = 0;i < n;i++){
    cin >> a[i];
    if(a[i] > x){
      long long tmp = a[i]-x;
      ans += tmp;
      a[i] -= tmp;
    }
  }

  for(int i = 0;i < n-1;i++){
    if(a[i] + a[i+1] > x){
      long long tmp = a[i+1] + a[i] - x;

      ans += tmp;
      a[i+1] -= tmp;
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 1024
import sys

a,b=map(int,input().split())
c,d=map(int,input().split())
t=int(input())
if(d>b):
	print("NO")
else:

    p1=0
    p2=0
    if(a<=c):
        p1=a+t*b
        p2=c+t*d
        if(p1>=p2):
            print("YES")
        else:
            print("NO")
    else:
        p1=a-t*b
        p2=c-t*d
        if(p1<=p2):
            print("YES")
        else:
            print("NO")


	

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

int main(){
	string input;
  	string ans = "";
  	
  	cin >> input;
	for(int i = 0 ; i < input.length() ; ++i){
    	switch(input[i]){
          case '0':
          	ans += "0";
            break;
          case '1':
          	ans += "1";
            break;
          case 'B':
          	ans = ans.substr(0,ans.length()-1);
            break;
        }
    }
  	cout << ans;
}

Measured memory_bytes: 256
//Author : Ayush Jain

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

#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define PI acos(-1.0)
const int N=1e5 + 5;
const int M=1e5 + 5;


int main()
{
	ios_base::sync_with_stdio(false);
	ll n;
	cin>>n;
	if(n<10){
		cout<<n<<endl;
		return 0;
	}
	int a=0,b=0,c=0,ls;
	ll foo=n;
	while(foo>0){
		a+=foo%10;
		c++;
		ls=foo%10;
		foo/=10;
	}
	b=(c-1)*9 + (ls-1);
	cout<<max(a,b)<<endl;

		
	
		
	return 0;
}

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

using namespace std;

int main()
{
    int N;
    cin>>N;
    vector< vector<int> > v(3, vector<int>(N));
    for (int i=0;i<3;i++) {
        for (int j=0;j<N;j++) {
            cin>>v[i][j];
        }
    }
    sort(v[0].begin(), v[0].end());
    sort(v[1].begin(), v[1].end());
    sort(v[2].begin(), v[2].end());
    long sum=0;
    for (int i=0;i<N;i++) {
        auto it0=lower_bound(v[0].begin(), v[0].end(), v[1][i]);
        //中央に対してそれ以下の上段の個数
        long kosu0=it0-v[0].begin();
        auto it2=upper_bound(v[2].begin(), v[2].end(), v[1][i]);
        //中央に対してそれ以上の下段の個数
        long kosu2=v[2].end()-it2;
        sum+=kosu0*kosu2;
    }
    cout<<sum<<endl;

    
    return 0;
}


Measured memory_bytes: 1792
//-----------------------
// author : xyqkoala
// time : 2020-07-06
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


void solve(){
	int n;
	cin>>n;
	int res = 1000-(n%1000);
	if(res==1000) res = 0;
	cout<<res<<endl;
}


Measured memory_bytes: 3660
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int main() {
    // Convert decimal to base 26
    // Base 26 uses a -> z
    // Method
        // Base | N         remainder1
        // Base | Quotient  remainder2
        // Base | Quotient  remainder3
        // :
        // Base | Quotient  remaindern
    // N in base 26 = remaindern, (n-1), (n-2), ..., remainder1

    // get input
    ll n;
    cin >> n;

    // base 26
    int base{26};

    ll quotient {n};
    vector<int> remainders;

    while (quotient > 0) {
        --quotient;
        remainders.push_back(quotient % base); // remainder
        quotient /= base; // get next quotient
    }

    string d_to_alpha[27] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", 
                            "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
    
    for (int i=remainders.size()-1; i>=0; --i) {
        cout << d_to_alpha[remainders[i]];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3632
#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() {
  ll n, a, cnt = 0;
  cin >> n;

  map<ll, ll> mp;
  rep(i, n) {
    cin >> a;
    if ((a / 400) >= 8) {
      cnt++;
    } else {
      mp[a / 400]++;
    }
  }

  // for (auto x : mp) cerr << x.first << ' ' << x.second << endl;

  cout << max(int(mp.size()), 1) << ' ' << mp.size() + cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <array>
#include <climits>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1000000000 + 7;
const ll INF = 99999999;
const ll MAX_V = 105;
const double EPS = 10e-8;
const double PI = 3.14159265359;

ll dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
    int a[3], k, t = 1;
    for(int i=0;i<3;i++)cin >> a[i];
    cin >> k;
    for(int i=0;i<k;i++)t*=2;
    sort(a,a+3);
    cout << a[0] + a[1] + a[2]*t << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int r, g, b;

	scanf("%d %d %d", &r, &g, &b);
	
	if((100 * r + 10 * g + b) % 4 == 0){
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;

}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        List<Pair> l = new ArrayList<>();
        Map<Pair, String> map1 = new HashMap<>();
        Map<Integer, List<Integer>> map2 = new HashMap<>();
        for (int i = 0; i < m; i++) {
            Pair p = new Pair(Integer.parseInt(sc.next()), Integer.parseInt(sc.next()));
            List<Integer> list = map2.getOrDefault(p.p, new ArrayList<>());
            list.add(p.y);
            map2.put(p.p, list);
            l.add(p);
        }

        for (Map.Entry<Integer, List<Integer>> entry : map2.entrySet()) {
            int p = entry.getKey();
            List<Integer> list = entry.getValue();
            list.sort(Comparator.comparingInt(value -> value));
            for (int i = 0; i < list.size(); i++) {
                int y = list.get(i);
                Pair pair = new Pair(p, y);
                String id = id(p, i + 1);
                map1.put(pair, id);
            }
        }

        for (Pair pair : l) {
            System.out.println(map1.get(pair));
        }


    }

    private static String id(int p, int y) {
        StringBuilder sb = new StringBuilder();
        if (p < 10) {
            sb.append("00000");
        } else if (p < 100) {
            sb.append("0000");
        } else if (p < 1000) {
            sb.append("000");
        } else if (p < 10000) {
            sb.append("00");
        } else if (p < 100000) {
            sb.append("0");
        }
        sb.append(p);
        if (y < 10) {
            sb.append("00000");
        } else if (y < 100) {
            sb.append("0000");
        } else if (y < 1000) {
            sb.append("000");
        } else if (y < 10000) {
            sb.append("00");
        } else if (y < 100000) {
            sb.append("0");
        }
        sb.append(y);

        return sb.toString();
    }

    public static class Pair {
        int p;
        int y;

        public Pair(int p, int y) {
            this.p = p;
            this.y = y;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Pair pair = (Pair) o;
            return p == pair.p &&
                    y == pair.y;
        }

        @Override
        public int hashCode() {
            return Objects.hash(p, y);
        }
    }
}


Measured memory_bytes: 91764
nt = input().split()
ct = [0]
for i in range(int(nt[0])):
    inp = input().split()
    if int(inp[1]) <= int(nt[1]):
        ct.append(int(inp[0]))
ct.sort()
if len(ct) == 1:
    print("TLE")
else:
    print(ct[1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
string s;
int a[3];
int zero,maxx,minn;
int main()
{
    cin>>s;
    int siz=s.size();
    for(int i=0;i<siz;i++)
    {
        if(s[i]=='a')
            a[0]++;
        if(s[i]=='b')
            a[1]++;
        if(s[i]=='c')
            a[2]++;
    }
    maxx=-1;
    minn=10000000;
    for(int i=0;i<3;i++)
        {
            if(a[i]==0)
        zero++;
        if(a[i]>maxx)
            maxx=a[i];
        if(a[i]<minn)
            minn=a[i];
        }
    if(zero==2)
    {
        if(siz==1)
            cout<<"YES\n";
        else
            cout<<"NO\n";
    }
    else if(zero==1)
    {
        if(siz==2)
            cout<<"YES\n";
        else
            cout<<"NO\n";
    }
    else
    {
        if(maxx-minn>=2)
            cout<<"NO\n";
        else
            cout<<"YES\n";
    }
}


Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String args[]) {
		ArrayList<String> list = new ArrayList<>();
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		String T = sc.nextLine();
		String tmp;
		int L = S.length();
		boolean check = true;
		for (int i = 0; i < L; i++) {
			list.add(String.valueOf(S.charAt(i)));
		}
		for (int i = 0; i < L; i++) {
			tmp = list.get(L - 1);
			list.add(0, tmp);
			list.remove(list.size() - 1);
			int cnt = 0;
			for (int j = 0; j < L; j++) {
				if(list.get(j).equals(String.valueOf(T.charAt(j)))) {
					cnt++;
				}
			}
			if (cnt == L) {
				System.out.println("Yes");
				check = false;
				break;
			}
		}
		if (check) {
			System.out.println("No");
		}
		
	}
}


Measured memory_bytes: 22612
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e4+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    ll x;
    cin>>x;
    loop(200,i,-200){
        loop(200,j,-200)
            if(pow(i,5)-pow(j,5)==x){
                cout<<i<<' '<<j<<endl;
                return;
            }
    }
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}

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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(a) a.begin(), a.end()
#define ll long long
#define mod 1e9+7

using namespace std;

int main()
{
  set<int> s;
  rep (i, 3) {
    int a;
    cin >> a;
    s.insert(a);
  }
  cout << s.size() << endl;
}


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

using namespace std;

#define rep(x, y) for (int x=0; x<y; x++) 

void print(vector<vector<int> > board)
{
#if 0
	cerr << "------" << endl;
	rep(y, board.size()) {
		rep(x, board[y].size()) {
			if (board[y][x] != -1) 
				cerr << board[y][x] << " ";
			else cerr << "  ";
		}
		cerr << endl;
	}
	cerr << "------" << endl;
#endif
}

int main()
{
	int H;
	while (cin>>H, H) {
		vector<vector<int> > board(H, vector<int>(6));
		rep(i, H) rep(j, 5) cin >> board[i][j];
		rep(i, H) board[i][5] = -1;
		
		print(board);
		
		int ans=0;
		
		while (true) {
			// erase
			bool update = false;
			print(board);
			//cerr << "A" << endl;
			
			rep(y, H) {
				int cnt=1;
				for (int x=1; x<6; x++) {
					if (board[y][x] == board[y][x-1] && board[y][x] != -1) {
						cnt++;
					} else {
						if (cnt>=3) {
							for (int i=x-1; i>=x-cnt; i--) {
								ans += board[y][i];
								board[y][i] = -1;
							}
							update = true;
							cnt = 0;
						} else {
							cnt = 1;
						}
					}
				}
			}	
			
			//cerr << "B" << endl;
			
			// drop
			for (int y=H-2; y>=0; y--) {
				for (int x=0; x<5; x++) {
					int yy=y;
					while (yy<H-1 && board[yy+1][x] == -1) {
						swap(board[yy+1][x], board[yy][x]);
						yy++;
					}
				}
			}
			
			//cerr << "C" << endl;
		
			if (!update) break;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1216
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

int main(){
    int n, k;
    std::cin >> n >> k;

    std::vector<char> d(k);
    for(int i = 0; i < k; i++) std::cin >> d[i];

    for(int i = n; i <= 10 * n; i++){
        bool flag = true;
        std::string s = std::to_string(i);

        for(int j = 0; j < k; j++){
            if(std::count(s.begin(),s.end(),d[j])){
                flag = false;
                break;
            }
        }

        if(flag) {
            std::cout << i << std::endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll maxi = a + b * (n - 1);
  ll mini = b + a * (n - 1);
  ll ans = maxi - mini+1;
  if(ans<0){
    print(0);
    return 0;
  }
  print(ans);
}


Measured memory_bytes: 3596
package main

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

func main() {
	// var input = StrStdin(1)

	// N, _ := strconv.Atoi(input[0][0])

	var N int
	fmt.Scanf("%d", &N)

	var fizz int = N / 3
	var bazz int = N / 5
	var fizzbazz int = N / 15

	var sum int = (1 + N) * N / 2
	var sumF int = 3 * (1 + fizz) * fizz / 2
	var sumB int = 5 * (1 + bazz) * bazz / 2
	var sumFB int = 15 * (1 + fizzbazz) * fizzbazz / 2

	// fmt.Printf("fizz:%d bazz:%d fizzbuzz:%d\n", fizz, bazz, fizzbazz)
	// fmt.Printf("sum:%d sumF:%d sumB:%d sumFB:%d\n", sum, sumF, sumB, sumFB)

	fmt.Println(sum - sumF - sumB + sumFB)
}

func StrStdin(num int) [][]string {
	var stringInput [][]string
	scanner := bufio.NewScanner(os.Stdin)

	for i := 0; i < num; i++ {
		scanner.Scan()
		if s := scanner.Text(); s != "" {
			stringInput = append(stringInput, strings.Split(strings.TrimSpace((scanner.Text())), " "))
		} else {
			break
		}
	}

	return stringInput
}


Measured memory_bytes: 1824
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <queue>
using namespace std;

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

long long int dp[100005];
int main(){
    int n, we; cin >> n >> we;
    vector<long long int> w(n),v(n); rep(i,n) cin >> w[i] >> v[i];
    rep(i,100005) dp[i] = 2000000000000;
    dp[0] = 0;

    for(int i=0;i<n;i++){
        for(int j=100005;j>=v[i];j--){
            dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
        }
    }
    long long  ans = 0;
    rep(i, 100005) if(dp[i] <= we) ans = max((long long int)i, ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64_t INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int n, d; cin >> n >> d;
  d = d * 2 + 1;
  cout << (n + d - 1) / d << '\n'; 

  return 0;
}

Measured memory_bytes: 256
class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def nhr(self, n, r):  # 重複組合せ
        return self.ncr(n + r - 1, n - 1)

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]

H, W, A, B = map(int, input().split())
comb = Combination(H + W + 100)
MOD = 10**9 + 7

ans = 0
for w in range(B + 1, W + 1):
    ans += comb.ncr(H - A + w - 2, w - 1) * comb.ncr(A + W - w - 1, A - 1)
print(ans % MOD)


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

using namespace std;

int main() {
  
  int N, K, ans = 1;
  cin >> N >> K;
  
  for (int i = 0 ; i < N ; i++){
    if (ans > K)
      ans += K;
    else
      ans *= 2;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] sum;
	static int n;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	
	static boolean read(){
		n = sc.nextInt();
		if(n == 0)return false;
		
		sum = new int[n];
		int score = 0;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < 5; j++){
				score += sc.nextInt();
			}
			sum[i] = score;
			score = 0;
		}
		
		return true;
	}
	
	static void solve(){
		Arrays.sort(sum);
		System.out.println(sum[sum.length-1] + " " + sum[0]);
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
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() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    int n; cin >> n;
    ll now = 1LL;
    rep(i, 0, n) {
        ll t; cin >> t;
        now = lcm(t, now);
    }
    printf("%lld\n", now);
    return 0;
}


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

using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll n;
    cin >> n;
    //--n;

    string s = "";
    //ll z = 26;
    if (n == 0) {
        s = "a" + s;
    }
    while(n > 0) {
        ll m = n-1;

        int i = m % 26;
        char c = 'a'+i;
        s = string(1,c) + s;
        --n;
        n/=26;
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3648