akhauriyash/Code-Regression huggingface dataset:
#define LOCAL

#undef _GLIBCXX_DEBUG

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

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define LLINF 1e18
#define INF (int)1e9+1

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

const llong MOD = 998244353;
const double PI = acos(-1);

vector<int> dis(10);
bool can(int n) {
	while (n > 0) {
		if (dis[n % 10]) return false;
		n /= 10;
	}
	return true;
}

int main() {
	IOS;
	int n, k; cin >> n >> k;
		for (int i = 0; i < k; i++) {
		int a; cin >> a;
		dis[a] = 1;
	}
	for (int i = n; ; i++) {
		if (can(i)) {
			cout << i << "\n";
			return 0;
		}
	}
}

Measured memory_bytes: 3656
///
// File:  b.cpp
// Author: ymiyamoto
//
// Created on Sun Dec  3 21:03:20 2017
//

#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

int32_t main()
{
  string str;
  cin >> str;

  int64_t n = stoll(str);

  int64_t sum = 0;
  for (uint32_t i = 0; i < str.size(); i++) {
    sum += str[i] - '0';
  }

  if (n % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

const int maxn = 1e5 + 10;
int n, a[maxn], _count[maxn];

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        _count[a[i]]++;
    }
    int res = 0;
    for (int x = -1; x <= 1e5; x++) {
        res = max(res, _count[x + 2] + _count[x + 1] + _count[x]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int,int> pii;
typedef priority_queue<int,vector<int>,greater<int> > small_heap;
typedef priority_queue<int> big_heap;
int n,m;
vector<int>v[60];
ll path[60];
void dfs(int x,int fa,ll num){
    path[x]=num;
    for(auto vv:v[x]){
        if(vv==fa)continue;
        dfs(vv,x,num|(1ll<<vv));
    }
}
ll info[60];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n-1;i++){
        int x,y;scanf("%d%d",&x,&y);
        v[x].push_back(y);v[y].push_back(x);
    }
    dfs(1,0,0ll);
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        int x,y;scanf("%d%d",&x,&y);
        info[i]=(path[x]^path[y]);
    }
    ll maxstate=(1ll<<m)-1;
    ll ans=0ll;
    for(int i=0;i<=maxstate;i++)
    {
        ll num=0ll;
        int cnt=0;
        for(int j=0;j<=m-1;j++)
        {
            if(i&(1<<j))
            {
                cnt++;
                num|=info[j];
            }
        }
        int free=n-1-__builtin_popcountll(num);
        ans+=(1ll<<free) * (cnt & 1 ? -1ll : 1ll);//这边奇为减，是因为直接计算合法的总数，2^ n-1  - 其他
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int**dp;

void func(int N,int C){
	int beat[N][16],push[C][16];

	int maximum = 0;

	for(int i = 0; i < N; i++){
		for(int k = 0; k < 16; k++)scanf("%d",&beat[i][k]);
	}

	for(int i = 0; i < C; i++){
		for(int k = 0; k < 16; k++)scanf("%d",&push[i][k]);
	}

	int tmp,S,code;

	int work[C][16];

	S = 1;
	code = 0;
	for(int i = 0; i < 16; i++){
		code += S*beat[0][i];
		S *= 2;
	}
	dp[1][code] = 0;


	for(int k = 0; k < C; k++){
		tmp = 0;
		for(int p = 0; p < 16; p++){
			work[k][p] = beat[0][p];
			if(work[k][p] == 1){
				if(push[k][p] == 1){
					work[k][p] = 0;
					tmp++;
				}
			}
		}

		S = 1;
		code = 0;
		for(int i = 0; i < 16; i++){
			code += S*work[k][i];
			S *= 2;
		}
		dp[1][code] = max(dp[1][code],tmp);
		maximum = max(maximum,dp[1][code]);
	}

	for(int i = 1; i < N; i++){
		for(int state = 0; state < 65536; state++){
			if(dp[i][state] != -1){

				S = 1;
				code = 0;
				for(int loop = 0; loop < 16; loop++){
					if(state & (1 << loop)){
						code += S;
					}else{
						code += S*beat[i][loop];
					}
					S *= 2;
				}
				dp[i+1][code] = dp[i][state];

				for(int k = 0; k < C; k++){
					tmp = 0;
					for(int p = 0; p < 16; p++){
						if(state & (1 << p)){
							if(push[k][p] == 1){
								work[k][p] = 0;
								tmp++;
							}else{
								work[k][p] = 1;
							}

						}else{
							work[k][p] = beat[i][p];
							if(work[k][p] == 1){
								if(push[k][p] == 1){
									work[k][p] = 0;
									tmp++;
								}
							}
						}
					}

					S = 1;
					code = 0;
					for(int a = 0; a < 16; a++){
						code += S*work[k][a];
						S *= 2;
					}
					dp[i+1][code] = max(dp[i+1][code],tmp+dp[i][state]);
					maximum = max(dp[i+1][code],maximum);
				}
			}
		}
	}

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

int main(){

	int N,C;
	dp = new int*[31];
	for(int i = 0; i < 31; i++){
		dp[i] = new int[65536];
	}

	while(true){
		scanf("%d %d",&N,&C);
		if(N == 0 && C == 0)break;

		for(int i = 0; i <= N; i++){
			for(int k = 0; k < 65536; k++)dp[i][k] = -1;
		}

		func(N,C);
	}

    return 0;
}

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

A_bit = [0] * 40
B_bit = [0] * 40

A -= 1
i = 0
while True:
  a_shou, a_amari = divmod(A, 2**i)
  if 2**i > A+1 :
    break
  if a_shou % 2 == 0:
    A_bit[i] = (a_shou//2) * (2**i)
  else:
    A_bit[i] = (a_shou//2) * (2**i) + a_amari + 1
  i += 1

j = 0
while True:
  b_shou, b_amari = divmod(B, 2**j)
  if 2**j > B+1 :
    break
  if b_shou % 2 == 0:
    B_bit[j] = (b_shou//2) * (2**j)
  else:
    B_bit[j] = (b_shou//2) * (2**j) + b_amari + 1
  j += 1
ans = 0
for i in range(40):
  if (B_bit[i] - A_bit[i]) % 2 == 0:
    continue
  else:
    ans += 2**i
    
print(ans)
    

Measured memory_bytes: 3188
from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

iter = list(permutations(range(1, N+1), N))

for i in range(len(iter)):
    if iter[i] == P:
        p = i + 1
    if iter[i] == Q:
        q = i + 1
print(abs(p - q))


Measured memory_bytes: 79688
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdio>
#include<utility>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;

int N,M;
int X[100],Y[100],h[100];

void gcl(int& x,int& y){
    if(x<y) swap(x,y);
    while(y>0){
        int t=x%y;
        x=y;
        y=t;
    }
    return;
}


int main(){
    int N;cin>>N;
    int ans=1000000000;
    rep(i,0,N+1){
        int j=N-i;
        int count=0;
      int t;
      t=i;
        while(t>0){
            count+=t%6;
            t/=6;
        }
      t=j;
        while(t>0){
            count+=t%9;
            t/=9;
        }
        ans=min(ans,count);
    }
    cout<<ans<<endl;
}

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

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

    vvl dist(MAX_V, vl(MAX_V));  // dist[u][v] : 頂点uと頂点vの最短距離
    rep(i, n) {
        rep(j, n) {
            if(i != j) {
                dist[i][j] = INF;
            }
        }
    }
    
    vvl G(n, vl(n));  // G[i][j] : 頂点iと頂点jを結ぶ辺の距離
    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;  b--;
        G[a][b] = G[b][a] = c;
        if(dist[a][b] > c) {
            dist[a][b] = dist[b][a] = c;
        }
    }

    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    ll ans = 0;
    rep(u, n-1) {
        exrep(v, u+1, n-1) {
            rep(w, n) {
                if(u != w && v != w && dist[u][w] + dist[w][v] < G[u][v]) {
                    ans++;
                    break;
                }
            }
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
N = int(input())
MAX = 12
ecg = ['']*MAX
#max: 724GO7J0OAD
for i in range(MAX):
  sho = N % 26
  if(sho == 0):
    sho = 26
  ecg[i] = chr(sho + 96)
  N //= 26
  if(sho == 26):
    N -= 1
  if(N == 0):
    break

print((''.join(ecg))[::-1])


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

#pragma GCC target ("arch=ivybridge", "tune=ivybridge")
#pragma GCC optimize ("-O3", "unroll-loops")

using namespace std;

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

  size_t n;
  cin >> n;
  vector<int> av; av.reserve(n);
  vector<int> bv; bv.reserve(n);
  while ( av.size() < n ) {
    int tmp;
    cin >> tmp;
    av.push_back(tmp);
  }
  while ( bv.size() < n ) {
    int tmp;
    cin >> tmp;
    bv.push_back(tmp);
  }

  for ( size_t i = 0; i + 3 < n; i += 4 ) {
    av[i + 3] -= av[i + 2];
    av[i + 2] -= av[i + 1];
    av[i + 1] -= av[i];
  }

  const int buf_size = 8192;

  int ret = 0;
  for ( size_t i = 0; i < n; i += buf_size ) {
    int i_max = min(n, i + buf_size);
    size_t j = 0;
    for ( ; j + 3 < n; j += 4 ) {
      int a0 = av[j];
      int a1 = av[j + 1];
      int a2 = av[j + 2];
      int a3 = av[j + 3];
      for ( int ii = i; ii < i_max; ++ii ) {
        int b = bv[ii];
        b += a0;
        ret ^= b;
        b += a1;
        ret ^= b;
        b += a2;
        ret ^= b;
        b += a3;
        ret ^= b;
      }
    }
    for ( ; j < n; ++j ) {
      int a = av[j];
      for ( int ii = i; ii < i_max; ++ii ) {
        ret ^= a + bv[ii];
      }
    }
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 1792
A,B,K = map(int,input().split(" "))
count = 0

nums = list(range(101))
nums.reverse()

for i in nums:
    a = A%i
    b = B%i
    
    if a == 0 and b == 0:
        count += 1
    
    if count == K:
        print(i)
        break

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

int main() {
  int N, a,b=0, sum;
  cin >> N;
  a=1;
  for(int i=0;i<8;i++){
    a*=10;
    b=N%a/(a/10);
    sum+=b;
  }
  if(N%sum==0)
    cout << "Yes"<< endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scn = Scanner(System.`in`)
    val N = scn.nextInt()

    var map = mutableMapOf<Int, Int?>()
    var ans = true
    for(i in 1..N){
        val A = scn.nextInt()
        if(map.containsKey(A)){
            map[A] = map[A]?.plus(1)
            ans = false
        }else{
            map.put(A,1)
        }
    }

    if(ans) {
        println("YES")
    }else{
        println("NO")
    }
}

Measured memory_bytes: 86604
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	//数値の入力
		int n = sc.nextInt();
      	//配列
        int a[] = new int[n];
        for(int i = 0; i < n; i++){
        	a[i] = sc.nextInt();
        }
      	double he = 0;
      	for(int i = 0; i < n; i++){
          he += a[i];
        }
      	he = he/n;
      	double min = Math.abs(a[0]-he);
      	int index= 0;
      	for(int i = 1; i < n; i++){
          double diff = Math.abs(a[i] - he);
          if(diff<min){
            min = diff;
            index= i;
          }
        }
        System.out.println(index);
     }
}

Measured memory_bytes: 36180
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

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

int main()
{
    int n, k;
    cin>>n>>k;
    int arr[n];
    int dp[n];
    for(int i = 0; i < n; i++) {
        cin>>arr[i];
        dp[i] = INT_MAX;
    }
    dp[0] = 0;
    for(int i = 0; i < n; i ++) {
        for(int j = 1; j <= k; j++) {
            if(i + j < n) {
                dp[i + j] = min(dp[i + j], dp[i] + abs(arr[i] - arr[i + j]));
            }
        }
    }
    cout<<dp[n - 1]<<"\n";

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <set>

using namespace std;

int mp[60];
const int MAXN=2000;
struct node
{
    int x,y;
}g[MAXN];

int findest(int k)
{
    if(mp[k]!=k)
        mp[k]=findest(mp[k]);
    return mp[k];
}
void connect(int a,int b)
{
    mp[findest(a)]=findest(b);
}

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
        scanf("%d %d",&(g[i].x),&(g[i].y));

    int num=0;
    for(int i=0;i<m;i++)
    {
        for(int k=1;k<=n;k++)
            mp[k]=k;

        for(int j=0;j<m;j++)
        {
            if(j!=i)
            {
                connect(g[j].x,g[j].y);
            }
        }
        int t=0;
        for(int k=1;k<=n;k++)
        {
            if(mp[k]==k)
                t++;
        }
        if(t>1)
            num++;
    }
    printf("%d\n",num);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define itr(a) begin(a), end(a)
#define pb push_back
#define x first
#define y second
#define endl '\n'

#define FAST cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

#ifndef __LOCAL
#define FILES(namein, nameout) freopen(namein, "r", stdin); freopen(nameout, "w", stdout); FAST;
#else
#define FILES(namein, nameout) FAST;
#endif //__LOCAL

using namespace std;
using namespace __gnu_pbds;
using python = void;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned short uss;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type> ordered_set;

const ll M = 1e9+7;
const ll N = 1e5+228;
constexpr ll inf = 0x3f3f3f3f3f3f3f3f;
vector<ll> d[N];
bool was[N];
ll dp[N];
void dfs(ll v){
	ll mx = -1;
	was[v] = 1;
	for(auto i : d[v]){
		if(!was[i]) dfs(i);
		mx = max(mx, dp[i]);
	}
	dp[v] = mx+1;
}
python solve(){
	FAST;
	ll n, m;
	cin >> n >> m;
	for(ll i = 0;i<m;i++){
		ll a, b;
		cin >> a >> b;
		d[a].pb(b);
		//d[b].pb(a);
	}
	for(ll i = 1;i<=n;i++){
		if(!was[i]) dfs(i);
	}
	ll mv = 0;
	for(ll i =1;i<=n;i++) mv=max(mv, dp[i]);
	cout << mv << '\n';
}

signed main(){
	FAST;
	ll q = 1;
	//cin >> q;
	while(q--){
		solve();
	}
}

Measured memory_bytes: 8704
#include<stdio.h>
static const int N_MAX=100010;

int search(int A[],int n,int left,int right,int key){
    int mid;
    while(left+1<right){
	mid=(left+right)/2;
	if(A[mid]>=key) right=mid;
	else left=mid;
    }
    return right;
}

void trace(int A[],int n){
    int i;
    for(i=0;i<n;i++){
	if(i) printf(" ");
	printf("%d",A[i]);
    }
    printf("\n");
}

int main(void){
    int n,A[N_MAX],L[N_MAX];
    int i,j,idx;
    int num;

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

    num=0;
    L[num++]=A[0];
    for(i=1;i<n;i++){
	if(A[i]>L[num-1]) L[num++]=A[i];
	else {
	    idx=search(L,num,-1,num,A[i]);
	    L[idx]=A[i];
	}
//	trace(L,num);
    }

    printf("%d\n",num);
    return 0;
}

Measured memory_bytes: 1372
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D,L,R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  if(L > R)
    cout << "Left" <<endl;
  else if(L == R)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
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; }
using namespace std;

int n;
const int V=100010;
vector<int> a[V*2];
vector<int> cnt;
bool used[V*2];

void dfs(int v){
    if(used[v])return;
    used[v]=true;
    cnt[v/V]++;
    for(int i:a[v])dfs(i);
}

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

    cin>>n;
    rep(i,n){
        int x,y; cin>>x>>y;
        a[x].push_back(y+V);
        a[y+V].push_back(x);
    }

    int ans=0;
    rep(i,V*2){
        cnt=vector<int>(2);
        dfs(i);
        ans+=cnt[0]*cnt[1];
    }

    cout<<ans-n<<endl;
    return 0;

}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, k, res = -INF, l, r;
    pair<int,pair<int,int>> p;
    cin>>n>>k;
    int a[222222], f[222222];
    rep(i, n){
        cin>>a[i];
    }
    rep(i, n){
        cin>>f[i];
    }
    sort(a, a + n);
    sort(f, f + n);
    reverse(f, f + n);

    l = -1, r = INF;
    while(r - l > 1){
        int mid = (l + r) / 2;
        int cnt = 0;
        rep(i, n){
            if(a[i] * f[i] > mid) cnt += (a[i] * f[i] - mid + f[i] - 1) / f[i];
        }
        if(cnt > k) l = mid;
        else r = mid;
    }
    cout<<r;
}


Measured memory_bytes: 3584
let nextVal seed =
  if seed % 2 = 0 then seed / 2 else 3 * seed + 1

let rec solve l seed = 
  let n = nextVal seed
  match l with
  | [] -> solve [seed; n] n
  | l -> if List.exists (fun x -> x = n) l then (List.length l) + 1 else solve (n::l) n

stdin.ReadLine() 
|> int 
|> solve [] 
|> printfn "%d"

Measured memory_bytes: 29960
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String numStr = sc.next();
        char[] numChar = new char[numStr.length()];

        for(int i = 0; i<numStr.length(); i++){
            numChar[i] = numStr.charAt(i);
        }

        int count = 0;
        for(int j = 0; j<numStr.length(); j++){
            if(numChar[j] == '1'){
                count++;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 35488
#include<bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    string t;
    cin>>t;
    sort(t.begin(),t.end());
    sort(t.rbegin(),t.rend());
    if(s<t)
    cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i=1,x=0;
  while (1) {
    scanf("%d\n", &x);
    if(x == 0){
      break;
    }else if (1 <= x || x <= 10000) {
      printf("Case %d: %d\n", i, x);
    }else{
      break;
    }
    i++;
  }
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
  ll Q, H, S, D;
  cin >> Q >> H >> S >> D;
  ll N;
  cin >> N;
  
  // 1リットル作るのに最小額を求める
  ll minOneL = 1e9;
  minOneL = min(4*Q, 2*H);
  minOneL = min(minOneL, S);
  
  ll ans = 0;
  // Dを使う価値があるか考える
  if(D < 8*Q && D < H*4 && D < S*2 && 2 <= N){
    ans += (N/2)*D;
    if(N%2 == 1) ans += minOneL;    
  }else{
    ans += N*minOneL;
  }
  cout << ans << endl;
  return 0;
}

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

vector<vector<int>> p_fac(int n) {
    vector<vector<int>> arr;
    int tmp = n;
    for(int i = 2; i * i <= n; i++) {
        if(tmp % i == 0) {
            int cnt = 0;
            while(tmp % i == 0) {
                cnt++;
                tmp /= i;
            }
            arr.push_back({i, cnt});
        }
    }
    if(tmp != 1)
        arr.push_back({tmp, 1});
    if(arr.size() == 0)
        arr.push_back({n, 1});
    return arr;
}

int main() {
    int ans;
    int X;
    cin >> X;
    ans = X;
    while (p_fac(ans).size() != 1 || p_fac(ans).at(0).at(1) != 1)ans++;

    cout << ans << endl;
}

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

int main()
{
	int n, m;
	cin >> n >> m;
	int votes[n];
	int sum = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> votes[i];
		sum += votes[i];
	}
	// int min_votes = sum / (4 * m);
	sort(votes, votes + n, greater<int>());
	if(votes[m - 1] * 4 * m >= sum)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

rrn = lambda n: [ rr() for _ in xrange(n)]

N, M,K = rrm()
arr = rrn(N)
ans = 0
cum = 0
for i in range(N):
    for j in range(M):
        if arr[i][j] =='#':
            cum +=1
for i in range(2**(N)):
    for j in range(2**(M)):
        total = 0
        for x in range(N):
            for y in range(M):
                if ((1<<x) &i ==0)  and ((1<<y) &j==0) and arr[x][y] =='#':
                    total +=1
        if total == K:
            ans+=1
                
print(ans)
   

Measured memory_bytes: 72848
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm> 
#include <cmath>

using namespace std;

typedef long long LL;

const int MAXN = 55;
LL dp[MAXN * MAXN][MAXN][MAXN]; // sum, prv, num
int N, A;
int x[MAXN];
int main() {
	cin >> N >> A;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
		dp[x[i]][i][1] = 1;
	}
	for (int num = 1; num <= N; num++) {
		for (int prv = 0; prv < N; prv++) {
			for (int sum = 1; sum < MAXN * MAXN; sum++) {
				if (!dp[sum][prv][num]) continue;
				int nxt = prv + 1;
				if (nxt < N) {
					dp[sum + x[nxt]][nxt][num + 1] += dp[sum][prv][num];
					dp[sum][nxt][num] += dp[sum][prv][num];
				}
			}
		}
	}

	LL ans = 0;
	for (int num = 1; num <= N; num++) {
		for (int sum = 1; sum < MAXN * MAXN; sum++) {
			if (sum % num == 0 && sum / num == A) {
				ans += dp[sum][N - 1][num];
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 57600
N = int(input())
W = list(map(int,input().split()))
SUM = sum(W)
S1 = 0
L =[]
for i in range(1,N):
    for x in range(i):
        S1+= W[x]
    L.append(abs(2*S1 - SUM))
    S1 = 0
print(min(L))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <cstdio>
#include <cmath>

using namespace std;
using ll = long long;
const int INF = 999999999;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> a;

    for (int i = 1; i <= n; ++i) {
        int inp;
        cin >> inp;
        a.emplace_back(inp, i);
    }

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

    for (auto i : a) {
        cout << i.second << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1780
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	int X, t;
	cin >> X >> t;

	cout << (X - t > 0 ? X - t : 0) << endl;
}

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

int main() {
    int N;
    cin >> N;
    
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());

    int sum = 0;
    for (int i = 0; i < N-1; i++) {
            sum += A[i];
    }
    cout << (A[N-1] < sum ? "Yes" : "No") << endl;
}

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

void bubbleSort(int A[], int n, int & count);

int main(void) 
{
    int n, i;
    cin >> n;
    int *A = new int[n];
    for (i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    int count = 0;
    bubbleSort(A, n, count);
    
    for (i = 0; i < n - 1; i++)
        cout << A[i] << " ";
    cout << A[i] << endl << count << endl;
}

void bubbleSort(int A[], int n, int & count)
{
    int i = 0, j;
    bool flag = true;
    while (flag)
    {
        flag = false;
        for (j = n - 1; j > i; j--)
        {
            if (A[j] < A[j - 1])
            {
                flag = true;
                swap(A[j], A[j - 1]);
                count++;
            }
        }
        i++;
    }
}


Measured memory_bytes: 3100
N = int(input())

xn = []
yn = []
hn = []

for i in range(N):
    xi, yi, hi = map(int, input().split())
    if hi:
        xn.append(xi)
        yn.append(yi)
        hn.append(hi)

if len(xn) == 1:
    print(xn[0], yn[0], hn[0])
else:
    for Cx in range(101):
        for Cy in range(101):

            last = None
            flg = False

            for i in range(len(xn)):
                H = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]

                if H < 0:
                    continue
                if last:
                    if (H != last):
                        break

                last = H
            else:
                flg = True
                print(Cx, Cy, H)
                break

        if flg:
            break


Measured memory_bytes: 3064
#include<iostream>

using namespace std;
int n, q, mi, A[25];
bool judge(int i, int m, int sum = 0){
    if (sum == m) return true;
    if (i == n) return false;
    return (judge(i+1, m, sum+A[i]) || judge(i+1, m, sum));
}

int main(){
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> A[i];
    cin >> q;
    for (int i = 0; i < q; i++){
        cin >> mi;
        cout << (judge(0, mi) ? "yes" : "no") << endl;
    }
    
}


Measured memory_bytes: 3116
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

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

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    if(n % 2 == 0) n--;
    cout << n / 2 << endl;

    return 0;
}

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

#include <iostream>
#include <shared_mutex>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#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 long long ll;

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

    if (S == "SSS") {
        cout << "0" << endl;
    } else if (S == "SSR") {
        cout << "1" << endl;
    } else if (S == "SRS") {
        cout << "1" << endl;
    } else if (S == "SRR") {
        cout << "2" << endl;
    } else if (S == "RSS") {
        cout << "1" << endl;
    } else if (S == "RSR") {
        cout << "1" << endl;
    } else if (S == "RRS") {
        cout << "2" << endl;
    } else if (S == "RRR") {
        cout << "3" << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}
ll MAX(ll a,ll b){return a>b?a:b;}
ll MAX(ll a,ll b,ll c){return max(max(a,b),c);}
ll MIN(ll x,ll  y){return x+y-max(x,y);}
ll MIN(ll x,ll y,ll z){return min(min(x,y),z);}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}

ll pmod(ll a, ll b)//a^b%mod1
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod1;
        b/=2;
        a=(a*a)%mod1;
    }
    return ans;
}



vll adj[100001];
ll vis[100001];
ll sssp[100001];






void solve(){
  ll n,k;
  cin>>n>>k;
  fo(i,1,k+1){
      ll t;
      cin>>t;
      fo(j,0,t){
          ll m;
          cin>>m;
          vis[m]++;

      }

  }

ll c=0;
  fo(i,1,n+1){
      if(vis[i]==0)c++;
  }

  cout<<c;
}




int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin) ;
    freopen("output.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
#endif

    ll t;
    t=1;
    //cin>>t;
    while(t--){

        solve();
    }

    return 0;


}

Measured memory_bytes: 6012
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
    int n,a,b;
    cin>>n;
    vector<pair<int,int>>vec;
    int ct=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a>>b;
        vec.push_back({a,b});
    }
    for(int i=0;i<n;i++)
    {
        if(vec[i].first==vec[i].second)
            ct++;
        else
            ct=0;
        if(ct >= 3)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3628
N,K = map(int, input().split())
R,S,P = map(int,input().split())
T = list(input())

ans = 0
d = {'s':R , 'p':S, 'r':P}
for i,t in enumerate(T):
    if i<K:
        ans += d[t]
    else:
        if T[i-K]!=T[i]:
                ans += d[t]
        else:
            T[i]=''

print(ans)


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

using namespace std;

struct SegmentTree{
  typedef pair<int, int> Pi;
  const int INF = (1 << 30);
  vector<Pi> data;
  int sz;
  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz *= 2;
    data.resize(2*sz-1, Pi(-1, -1));
  }
  void update(int k, int x)
  {
    int id = -k;
    k += sz - 1;
    data[k].first += x;
    data[k].second = id;
    while(k > 0){
      k = (k - 1) / 2;
      data[k] = max(data[2*k+1], data[2*k+2]);
    }
  }
};

int main()
{
  int N, R, L;
  cin >> N >> R >> L;
  SegmentTree seg(N);
  for(int i = 0; i < N; i++) seg.update(i, 1);
  vector<int> tv(N, 0);
  int cur = 0, elp = 0;
  while(R--){
    int d, t, x;
    cin >> d >> t >> x;
    --d;
    seg.update(d, x);
    tv[cur] += t - elp;
    cur = -seg.data[0].second;
    elp = t;
  }
  tv[cur] += L - elp;
  cout << max_element(tv.begin(), tv.end()) - tv.begin() + 1 << endl;
  return 0;
}

Measured memory_bytes: 5196
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    A = tuple(tuple(map(int, input().split())) for _ in range(n))

    # O(n^2 * 2^n)
    state_to_score = [0] * (1 <<  n)
    for U in range(1 << n):
        for i in range(n):
            if not U >> i & 1:
                continue
            for j in range(i):
                if U >> j & 1:
                    state_to_score[U] += A[i][j]

    # O(n^3)
    dp = [-INF] * (1 << n)
    dp[0] = 0
    for U in range(1, 1 << n):
        V = U
        while V:
            W = U ^ V
            dp[U] = max(dp[U], dp[W] + state_to_score[V])
            V = (V - 1) & U

    print(dp[-1])
resolve()

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
using Graph = vector<vector<ll>>;
#define all(x) (x).begin(), (x).end() //string の sort とかはこれ
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18
const double PI = 3.14159265;

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

const ll MAX = 1e6;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() //MODは素数じゃないとだよ！！
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  // COMinit();
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l, ans = 0;
  ll x;
  cin >> x;

  for (i = -1000; i <= 1000; i++)
  {
    for (j = -1000; j <= 1000; j++)
    {
      if (powll(i, 5) - powll(j, 5) == x)
      {
        cout << i << ' ' << j;
        return 0;
      }
    }
  }
  cout << ans << endl;
}


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

namespace ABC163_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var i = int.Parse(Console.ReadLine());

            Console.WriteLine(2 * i * Math.PI);
        }
    }
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9


int main(){ 
  int N;
  string S;
  cin >> N >> S;
  REP(i, S.size()){
    char next = S[i] + N;
    if(next > 'Z'){
      next-= 'Z' - 'A'+1;;
    }
    S[i] = next;
  }
  cout << S << endl;
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main(void) {
  int a, b;
  scanf("%d%d", &a, &b);
  if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) {
    puts("Possible");
  } else {
    puts("Impossible");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <set>
#include <utility>
#include <climits>

#define ll long long
#define ull unsigned long long
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	bool yes = false;
	for (int i = 0; i <= 2; ++i) {
		if (s[i] == '7')
			yes = true;
	}
	cout << (yes ? "Yes" : "No");
}

Measured memory_bytes: 3652
import itertools
n, m, q = map(int, input().split())
a = []
b = []
c = []
d = []
for i in range(q):
	aa, bb, cc, dd = map(int, input().split())
	a.append(aa)
	b.append(bb)
	c.append(cc)
	d.append(dd)
ary = [i+1 for i in range(m)]
ans = 0
for i in itertools.combinations_with_replacement(ary,n-1):
	x = list(i)
	x.append(1)
	x.sort()
	cnt = 0
	for j in range(q):
		if x[b[j]-1] - x[a[j]-1] == c[j]:
			cnt += d[j]
	ans = max(ans,cnt)
print (ans)


Measured memory_bytes: 9220
/****************************
*  Developer : joshi08
*  Date  :  22-06-2020
*  Year  :  2020
****************************/

#include <bits/stdc++.h>

#define lli long long int
#define mod 1000000007
#define fi first
#define se second
#define ii pair<lli, lli>
#define mp make_pair
#define endl '\n'
const double PI = 3.141592653589793238460;
lli gcd(lli a, lli b) { if (a == 0) return b; return gcd(b % a, a);}
lli max(lli a, lli b) {if (a > b) return a; else return b;}
lli min(lli a, lli b) {if (a < b) return a; else return b;}
lli power(lli a,lli b) {lli i,p=1; for(i=0;i<b;i++){p*=a;} return p;}

using namespace std;

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

	double a,b,k1,k2;
	
	lli i,p1,p2;
	
	cin>>a>>b;
	
	for(i=4;i<=1251;i++)
	{
		k1 = i*0.08;
		k2 = i*0.1;
		
		p1 = (int) k1;
		if(p1>k1)
			p1--;
			
		p2 = (int) k2;
		if(p2>k2)
			p2--;
		
		if(p1==a && p2==b)
		{
			break;
		}
	}
	if(i!=1252)
	{
		cout<<i;
	}
	else
	{
		cout<<-1;
	}
	

    return 0;
}



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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

struct N {
  ll l, r;
};

bool operator<(const N &l, const N &r) {
  if (l.l == r.l) {
    return l.r < r.r;
  }
  return l.l < r.l;
}

struct M {
  vector<N> ns;
  ll d;

  void add(N &n) {
    ns.push_back(n);
  }

  ll count() {
    ll ans = 0;
    sort(ns.begin(), ns.end());
    ll l = ns[0].l, r = ns[0].r;
    ns.push_back(N{1LL << 62, 1LL << 62});
    for (auto &n : ns) {
      if (n.l <= r) {
        r = max(r, n.r);
      } else {
        ans += (r - l) / d + 1;
        l = n.l;
        r = n.r;
      }
    }
    return ans;
  }
};

ll solve(ll n, ll a, ll d) {
  vector<ll> v(n);
  vector<ll> lsum(n + 1), rsum(n + 1);
  v[0] = a;
  for (int i = 1; i < n; i++) v[i] = v[i - 1] + d;
  for (int i = 0; i < n; i++) lsum[i + 1] = lsum[i] + v[i];
  for (int i = 0; i < n; i++) rsum[i + 1] = rsum[i] + v[n - 1 - i];
  if (d == 0) {
    if (a == 0) {
      return 1;
    } else {
      return n + 1;
    }
  }
  ll ans = 0;
  map<ll, M> mp;
  for (ll i = 0; i <= n; i++) {
    ll dr = ((a * i) % d + d) % d;
    N base{lsum[i], rsum[i]};
    mp[dr].d = d;
    mp[dr].add(base);
  }
  for (auto &pr : mp) {
    ans += pr.second.count();
  }

  return ans;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n, a, d;
  cin >> n >> a >> d;
  if (d < 0) {
    cout << solve(n, -a, -d) << endl;
  } else {
    cout << solve(n, a, d) << endl;
  }
  return 0;
}


Measured memory_bytes: 36224
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
    string s, t;
    cin >> s >> t;
    int res = 0;
    for (int i = 0; i < 3; ++i) {
        res += (s[i] == t[i]);
    }
    cout << res << endl;
}

int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    
    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	private final static int DATASET = 100;

	public static void main(String[] args) {
		try {
			//Input
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			int[] stock = new int[DATASET];
			int input, ST, output;

			while ((str = br.readLine()) != null) {
				input = Integer.parseInt(str);
				if (input == 0) {
						ST = search_terminal(stock);
						output = stock[ST-1];
						System.out.println(output);
						stock[ST-1] = 0;
				} else {
					ST = search_terminal(stock);
					stock[ST] = input;
				}
			}
		} catch (Exception e) {
			System.out.println("error");
		}
	}

	private static int search_terminal(int[] stock) {
		int k=0;
		for (int i =0; i < stock.length; i++) {
			if (stock[i] == 0) {
				k = i;
				return k;
			}
		}
		return k;
	}

}

Measured memory_bytes: 24132
// std::set を用いた解
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    int d[110];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> d[i];

    set<int> values; // insertするときに重複を取り除く
    for (int i = 0; i < N; i++) {
        values.insert(d[i]); // 挿入する
    }

    cout << values.size() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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;
}
///////////////////////////////////////////////
/*（๑•﹏•๑｀) */


int main() {
    int N;
    ll ans = 1;
    cin >> N;

    FORq(i,1,N){
        ans = (ans * i) % MOD;
    }

    PRINTLLD(ans);


}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  cout << (m * 1900 + (n - m) * 100) * pow(2, m) << '\n';
  return 0;
}

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

int main() {
    int a, b, bl;
    double ans;
    cin >> a >> b;

    bl = (a + b) % 2;
    ans = (a + b) / 2;
    if (bl == 0) cout << ans << endl;
    else cout << ans + 1 << endl;

    return 0;
}

Measured memory_bytes: 256