akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = null;
		while ((line = br.readLine()) != null) {
			String[] splited = line.trim().split(",");

			int[] cards = new int[5];
			for (int i = 0; i < 5; i++) {
				cards[i] = Integer.parseInt(splited[i]);
			}
			Arrays.sort(cards);

			int same = 0;
			int pear = 0;
			boolean straight = true;
			for (int i = 0; i < 4; i++) {
				if (cards[i] != cards[i + 1] - 1
						&& cards[0] != cards[1] - 9) {
					straight = false;
					break;
				}
			}

			for (int i = 0; i < 4; i++) {
				for (int j = i + 1; j < 5; j++) {
					if (cards[i] == cards[j])
						same++;
				}
				i += same;
				if (pear == 0) {
					pear = same;
					same = 0;
				}
			}

			if (straight == true) {
				System.out.println("straight");
			} else if (same != 0) {
				if (same == pear)
					System.out.println("two pair");
				else
					System.out.println("full house");
			} else {
				switch (pear) {
				case 1:
					System.out.println("one pair");
					break;
				case 2:
					System.out.println("three card");
					break;
				case 3:
					System.out.println("four card");
					break;
				case 0:
					System.out.println("null");
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 16928
#include <iostream>
#include <cmath>
using namespace std;
typedef long long int ll;
ll h[1000000];
ll n;
ll dp[1000001];
int main()
{
    scanf("%lld",&n);
    for(int i = 0; i < n; i++)scanf("%lld",&h[i]);
    //start dp
    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);
    for(int i =2; i < n; i++)
    {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    printf("%lld\n",dp[n-1]);
}


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

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
    int K, T;
    cin >> K;
    ll ans = 0;

    for(int i = 1; i < K + 1; i++) {
        for(int j = 1; j < K + 1; j++) {
            for(int l = 1; l < K + 1; l++) {
                ans += euclidean_gcd(euclidean_gcd(i, j), l);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) { if (!b)return a; return gcd(b, a%b); }
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
int main() {
	ll a;
	while (scanf("%lld", &a), a) {
		vector<ll>v;
		for (ll i = 1; i*i <= a; i++) {
			if (a%i == 0) {
				v.push_back(i);
				if (i != a / i)v.push_back(a / i);
			}
		}
		if (v.size() > 3000)abort();
		sort(v.begin(), v.end());
		int cnt = 0;
		rep(i, v.size())for (int j = i; j < v.size(); j++) {
			if (lcm(v[i], v[j]) == a)cnt++;
		}
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

string s;
int cur;
int dfs(int k){
    int ret=0;
    if(isdigit(s[cur])){
        while(isdigit(s[cur])){
            ret*=10;
            ret+=s[cur]-'0';
            ++cur;
        }
        return (ret+1)/2;
    }
    vector<int> v;
    while(s[cur]=='['){
        ++cur;
        v.pb(dfs(k+1));
        ++cur;
    }
    sort(v.begin(),v.end());
    int n=(1+v.size())/2;
    rep(i,n) ret+=v[i];
    return ret;
}
int main(){
    int n;
    cin>>n;
    while(n--){
        cin>>s;
        cur=0;
        cout<<dfs(0)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3228
import numpy as np

n,W = map(int,input().split())
w,v = [0] * n, [0] * n
for i in range(n):
    w[i] , v[i] = map(int,input().split())
 

dp = np.zeros((W + 1), dtype=np.uint64)

for _w, _v in zip(w, v):
	np.maximum(dp[_w:], dp[:-_w] + _v, out=dp[_w:])
print(dp[-1])


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

#define REP(i, x) for (int i = 0, i##_len = (int)(x); i < i##_len; i++)
#define REP1(i, x) for (int i = 1, i##_len = (int)(x); i <= i##_len; i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
const int MOD = (int)1e9 + 7;
const int INF = 1145141919;
using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using l_l = pair<ll, ll>;
using d_d = pair<double, double>;
using vint = vector<int>;
using vll = vector<ll>;
using vbool = vector<bool>;

struct unionfindtree {
    vector<int> parent;
    unionfindtree(int n) : parent(n) {
        REP(i, n) {
            parent[i] = i;
        }
    }
    int root(int x) {
        if (parent[x] == x)
            return x;
        return parent[x] = root(parent[x]);
    }
    void unite(int x, int y) {
        int rootx = root(x), rooty = root(y);
        if (rootx != rooty)
            parent[rootx] = rooty;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int getnparent() {
        set<int> p;
        REP(i, parent.size()) {
            p.insert(root(i));
            // cout << root(i) << " ";
        }
        // for (auto x : parent) {
        // if (x >= parent.size() / 2)
        //     x -= parent.size() / 2;
        // cout << x << " ";
        //     p.insert(x);
        // }
        // cout << endl;
        return (int)p.size() / 2;
    }
};

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

    unionfindtree uft(N * 2);

    REP(i, M) {
        int X, Y, Z;
        cin >> X >> Y >> Z;
        X -= 1, Y -= 1;
        //(A[X]+A[Y])%2==0
        if (Z % 2 == 0) {
            uft.unite(X, Y);
            uft.unite(X + N, Y + N);
        } else {
            uft.unite(X, Y + N);
            uft.unite(X + N, Y);
        }
    }

    //[0|1]2

    //[0|1] 2345
    //[0|12] 345
    //[0|12] 345
    //[0|12] [34|] 5
    //[0|12] [34|5]
    cout << uft.getnparent() << endl;
}

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

#define ran 111

char s[ran];
int len;

int main() {
	scanf("%s", s);
	len = strlen(s);
	
	int ans = 0;
	for(int l=0, r=len-1; l<r; l++, r--)
		if(s[l]!=s[r]) ans++;
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int N;
ll A,B,inf = 1e9+7;

int main(){
	cin >> N >> A >> B;
	vector<ll> S(N+1,0),dp(N+1,0);
	if(A>B) swap(A,B);
	bool judge = true;
	for(int i=1;i<=N;i++){
		cin >> S[i];
		if(i>2 && S[i]-S[i-2]<A) judge = false;
	}
	S[0] = -1;
	if(!judge){
		cout << 0 << endl;
		return 0;
	}
	dp[0] = 1;
	int id = 0;//S[i]-S[i+1]<Aとなるi
	for(int i=1;i<=N;i++){
		int s = lower_bound(S.begin(),S.end(),S[i]-B)-S.begin();
		if(S[i]-B>=0 && S[s]>S[i]-B) s--;
		if(s>=id){
			if(id>=1) (dp[i] += dp[s]-dp[id-1]+inf)%=inf;
			else (dp[i] += dp[s])%=inf;
		}
		if(S[i]-S[i-1]<A) id = i-1;
		(dp[i] += dp[i-1])%=inf;
	}
	if(id>=1) cout << (dp[N]-dp[id-1]+inf)%inf << endl;
	else cout << dp[N] << endl;
}

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

int main() {
    while (true) {
        int h1;
        cin >> h1;
        
        if (h1==0) {
            break;
        }
        
        int h2, h3, h4, h5;
        cin >> h2 >> h3 >> h4 >> h5;
        
        int l[5] = {h1, h2, h3, h4, h5};
        set<int> s{h1, h2, h3, h4, h5};
        
        if (s.find(1)!=s.end() && s.find(2)!=s.end() && s.find(3)!=s.end()) {
            for (int i=0; i<5; i++) {
                cout << 3 << endl;
            }
        }
        else if (s.find(1)!=s.end() && s.find(2)!=s.end()) {
            for (int i=0; i<5; i++) {
                if (l[i]==1) {
                    cout << 1 << endl;
                }
                else {
                    cout << 2 << endl;
                }
            }
        }
        else if (s.find(2)!=s.end() && s.find(3)!=s.end()) {
            for (int i=0; i<5; i++) {
                if (l[i]==2) {
                    cout << 1 << endl;
                }
                else {
                    cout << 2 << endl;
                }
            }
        }
        else if (s.find(3)!=s.end() && s.find(1)!=s.end()) {
            for (int i=0; i<5; i++) {
                if (l[i]==3) {
                    cout << 1 << endl;
                }
                else {
                    cout << 2 << endl;
                }
            }
        }
        else {
            for (int i=0; i<5; i++) {
                cout << 3 << endl;
            }
        }
    }
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,m; cin >> n >> m;
    ll ans;
    if(min(n,m) == 1){
        if(max(n,m) == 1)ans = 1;
        else ans = max(n,m) - 2;
    }
    else if(min(n,m) == 2)ans = 0;
    else{
        ans = (min(n,m) - 2) * (max(n,m) - 2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, Y = map(int,input().split())
for x in range(N+1):
    for y in range(N-x+1):
        if Y - 1000*(N-(x+y)) == 5000*y + 10000*x:
            print(x,y,N-(x+y))
            exit(0)
print("-1 -1 -1")


Measured memory_bytes: 2940
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(a+1):
    y = x-(500*i)
    for j in range(b+1):
        z = y-(100*j)
        for k in range(c+1):
            ans = z-(50*k)
            if ans==0:
                count = count+1

print(count)

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

typedef long long ll;

const int Maxn = 400015;
const int nil = 200005;

int BIT[Maxn];
int n;
int a[Maxn];
vector <int> un;

void Insert(int x)
{
	x += nil;
	for (int i = x; i < Maxn; i += i & -i)
		BIT[i]++;
}

int Get(int x)
{
	int res = 0;
	x += nil;
	for (int i = x; i > 0; i -= i & -i)
		res += BIT[i];
	return res;
}

bool Okay(int x)
{
	fill(BIT, BIT + Maxn, 0);
	int cur = 0; Insert(cur);
	ll res = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] <= x) cur++;
		else cur--;
		res += Get(cur - 1);
		Insert(cur);
	}
	return 2 * res > ll(n) * (n + 1) / 2ll;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		un.push_back(a[i]);
	}
	sort(un.begin(), un.end()); un.erase(unique(un.begin(), un.end()), un.end());
	int lef = 0, rig = int(un.size()) - 1;
	while (lef <= rig) {
		int mid = lef + rig >> 1;
		if (Okay(un[mid])) rig = mid - 1;
		else lef = mid + 1;
	}
	printf("%d\n", un[rig + 1]);
	return 0;
}

Measured memory_bytes: 2680
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i ++) cin >> a.at(i);

    int allxor = 0;
    for(int i = 0;i < n;i ++) allxor = allxor ^ a.at(i);

    vector<int> ans(n);
    for(int i = 0;i < n;i ++) ans.at(i) = allxor ^ a.at(i);

    for(int i = 0;i < n;i ++) cout << ans.at(i) << " ";
    cout << endl;
}

Measured memory_bytes: 6244
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
#define vc vector
#define sz(v) (int)(v).size()
#define pb push_back
#define FF first
#define SS second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define pll pair<ll,ll>
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
typedef long double f80;
#define endl '\n'

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);

	int m, d;
	cin >> m >> d;
	int tot = 0;
	fr(i, 10, d) {
		int val1 = i / 10, val2 = i % 10;
		if(val1 * val2 >= 1 && val1 * val2 <= m && val1 >= 2 && val2 >= 2) {
			tot++;
		}
	}
	cout << tot;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,i,j,k;
  double d[100][100],max;
  while(1){
    scanf("%d %d",&n,&m);
    if(!(n||m))break;
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	scanf("%lf",&d[i][j]);
      }
    }
    double r[102][102]={0};
    for(i=0;i<n;i++){
      r[0][i]=1.0;
    }
    for(i=1;i<m;i++){
      for(j=0;j<n;j++){
	for(k=0;k<n;k++){
	  if(r[i][k]<r[i-1][j]*d[j][k]){
	    r[i][k]=r[i-1][j]*d[j][k];
	  }
	}
      }
    }
    max=-1.0;
    for(i=0;i<n;i++){
      if(max<r[m-1][i])max=r[m-1][i];
    }
    printf("%.2f\n",max);
  }
  return 0;
}

Measured memory_bytes: 824
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; cin >> N;
    map<int,int> mp;
    bool ok = true;
    REP(i,N){
        int a; cin >> a;
        mp[a]++;
        if(mp[a] > 1) ok = false;
    }
    if(ok){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}


Measured memory_bytes: 9600
package main

import(
	"fmt"
)

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

	for i:= 0; i < len(s); i++ {
		c:=s[i]
		c = c + byte(n)
	
		if c > 'Z' {
			c = c - 26
		}
		fmt.Printf("%c",c)
	}
}


Measured memory_bytes: 768
n = int(input())
ls = sorted(list(map(int,input().split())))

ans = 0
for i in range(len(ls)-2) :
  a = ls[i]
  for j in range(len(ls)-i-2) :
    b = ls[i+1+j]
    for k in range(len(ls)-i-j-1) :
      c = ls[i+j+k+1]
      if b-a < c < b+a and a!=b!=c!=a :
        ans += 1
print(ans)

Measured memory_bytes: 9184
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int h,w,a[2010][2010],whomax,whomin;
int R[2010],L[2010];
bool F(int k){
  int maxi=-1;
  lol(i,h){
    for(int j=0;j<w;j++){
      if(a[i][j]<whomax-k){R[i]=j-1;break;}
      if(j==w-1)R[i]=w-1;
    }
    for(int j=w-1;j>=0;j--){
      if(a[i][j]<whomax-k){L[i]=j+1;break;}
      if(j==0)L[i]=0;
    }
    for(int j=R[i]+1;j<=L[i]-1;j++)maxi=max(maxi,a[i][j]);
  }
  if(maxi>whomin+k)return false;

  int mini=mod,lim;
  
  maxi=-1,lim=mod;
  lol(i,h){
    lim=min(lim,R[i]);
    for(int j=lim+1;j<w;j++)maxi=max(maxi,a[i][j]);
  }mini=min(mini,maxi);
  
  maxi=-1,lim=mod;
  for(int i=h-1;i>=0;i--){
    lim=min(lim,R[i]);
    for(int j=lim+1;j<w;j++)maxi=max(maxi,a[i][j]);
  }mini=min(mini,maxi);

  maxi=-1,lim=-1;
  lol(i,h){
    lim=max(lim,L[i]);
    for(int j=0;j<lim;j++)maxi=max(maxi,a[i][j]);
  }mini=min(mini,maxi);

  maxi=-1,lim=-1;
  for(int i=h-1;i>=0;i--){
    lim=max(lim,L[i]);
    for(int j=0;j<lim;j++)maxi=max(maxi,a[i][j]);
  }mini=min(mini,maxi);

  if(mini>whomin+k)return false;
  return true;
}

int main(){
  cin>>h>>w;
  whomax=-1,whomin=mod;
  lol(i,h)lol(j,w){
    cin>>a[i][j];
    whomax=max(whomax,a[i][j]);
    whomin=min(whomin,a[i][j]);
  }
  int left=0,right=mod,mid;
  while(left<right-1){
    mid=(left+right)/2;
    if(F(mid))right=mid;
    else left=mid;
  }
  cout<<right<<endl;
  return 0;
}



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

int main(){
    int cnt;
    string s;
    cnt = 0;
    while(cin >> s){
        string c = s;
        reverse(c.begin(),c.end());
        if(c == s) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1188
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define ms(a,v) memset(a,v,sizeof(a))
#define mp make_pair
#define write(x) cout<<(x)<<endl
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; }return 0; }
const int INF = 1 << 28; const ll LINF = 1ll << 60;
const int MAX = 1e5 + 5; const int MOD = 1e9 + 7; const double EPS = 1e-6;
const int dy[4] = { 0,1,0,-1 }; const int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N, M, H, W;
int ans;
vll A;
vi B;

int main() {
    cin >> N >> M;
    A.resize(N);
    B.resize(N);
    vector<pair<ll, int>> AB;
    
    rep(i, N) {
        cin >> A[i] >> B[i];
        AB.emplace_back(A[i], B[i]);
    }

    sort(all(AB));

    int m = 0;
    ll ans = 0;
    rep(i, N) {
        if (m + AB[i].second < M) {
            ans += AB[i].first * AB[i].second;
            m += AB[i].second;
        }
        else {
            ans += AB[i].first * (M - m);
            break;
        }
    }
    
    write(ans);
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define li long
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pli pair<li,li>
#define pll pair<ll,ll>
#define pb push_back
#define fori(i,k,n) for(int i = k;i<n; i++)
#define rfori(i,k,n) for(int i = k; i>=n; i--)
#define tc int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define inf INT_MAX
#define ninf INT_MIN
#define W(x) cout<<x<<endl
#define WW(x,y) cout<<x<<' '<<y<<endl;
#define in(x) cin>>x
const ll mod1 = 998244353;
const ll mod2 = 1e9+7;
template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

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

ll power(ll x,ll y){
    ll res = 1;
    
    while(y>0){
        if(y&1)res = (res*x);
        y>>=1;
        x = (x*x);
    }
    return res;
}

ll power(ll x,ll y,ll p){
    ll res = 1;
    x%=p;
    while(y>0){
        if(y&1)res = (res*x)%p;
        y>>=1;
        x = (x*x)%p;
    }
    return res;
}

int main(){
	fastio();
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a+b)cout<<min(a,k)<<"\n";
	else{
		cout<<a-(k-(a+b))<<"\n";
	}
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
#define CL(a,x) memset(x, a, sizeof(x));
const int MOD = 1000000007;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n-1)&n)+1 : 0; }

int i, j, k, m, n, l, last1[10001], last2[10001];
string s1, s2;

int solve() {
    int c1 = 0, c2 = 0;
    F0(i, n) {
        if (s1[i]=='1') c1++;
        if (s2[i]=='1') c2++;
    }
    if (!c1 && !c2) return 0;
    if (!c2) return -1;
    
    int ret = 1e9;
    
    F0(i, n) {
        last1[i] = 0;
        while (s2[(i + n - last1[i])%n] == '0') last1[i]++;

        last2[i] = 0;
        while (s2[(i + n + last2[i])%n] == '0') last2[i]++;
    }
    
    F0(j, n) {
        int curr = j;
        int maxs = 0;
        vector<pii> v;
        F0(i, n) {
            char u = s1[(i + j)%n];
            if (u == s2[i]) continue;
            curr++;
            if (u == '1') {
                if (last2[i] > j && last1[i] > 0) {
                    v.push_back(pii(last2[i] - j, last1[i]));
                }            
            }
        }
        if (SZ(v)) {
            sort(v.rbegin(), v.rend());
            maxs = 1e9;
            int side2 = 0;
            F0(i, SZ(v)) {
                maxs = min(maxs, side2 + v[i].first);
                side2 = max(side2, v[i].second);
            }
            maxs = min(maxs, side2);
        }
                
        curr += 2 * maxs;
        ret = min(ret, curr);
    }

    return ret;
}

int main() {
    // freopen("x.in", "r", stdin);

    cin >> s1 >> s2;
    n = SZ(s1);
    
    int ans1 = solve();
    reverse(s1.begin(), s1.end());
    reverse(s2.begin(), s2.end());
    int ans2 = solve();
    
   // cout <<ans1 << " " << ans2 << endl;
    cout << min(ans1, ans2) << endl;
    
    return 0;
}

Measured memory_bytes: 256
package main
import (
    "fmt"
    "os"
    )
func main(){
    // Your code here!
    var a, b, c int
    fmt.Scanf("%d %d %d", &a,  &b, &c)
    if a - b >= c {
        fmt.Println(0)
        os.Exit(0)
    }
     fmt.Println(c + b - a)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(){
  int N;
  scanf("%d", &N);
  char **c = (char**)malloc(sizeof(char*)* N);
  for(int i = 0; i < N; i++) {
    c[i] = (char*)malloc(sizeof(char) * 10);
    scanf("%s", c[i]);
  }
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      if(strcmp(c[i], c[j]) == 0){
        printf("No\n");
        return 0;
      }
    }
  }
  for(int i = 0; i < N - 1; i++){
    char d = c[i][strlen(c[i]) - 1];
    if(d != c[i + 1][0]){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
}

Measured memory_bytes: 128
#include<vector>
#include<iostream>
#define F(A, B, M) for(int A=B; A<M; A++)
using namespace std;

int printall(vector<vector<int> > wall, int H){
	F(i, 0, H){
		F(j, 0, 5){
			cout << wall[i][j] << ' ';
		}
		cout << endl;
	}
}
			

int main(){
	int H;
	cin >> H;
	while(H != 0){
		vector<vector<int> > wall;
		vector<int> line;
		int score=0, tmp;

		F(i, 0, H){
			line.clear();
			F(j, 0, 5){
				cin >> tmp;
				line.push_back(tmp);
			}
			wall.push_back(line);
		}
		F(r, 0, 20){
			F(i, 0, H){
				int cnt=1;
				F(j, 1, 5){
					if(wall[i][j] == -1)continue;
					if(wall[i][j] == wall[i][j-1]){
						cnt++;
						if(j == 4 && cnt >= 3){
							score += wall[i][j]*cnt;
							F(k, j-cnt+1, j+1){
								wall[i][k] = -1;
							}
						}
					}else if(cnt >= 3){
						score += wall[i][j-1]*cnt;
						F(k, j-cnt, j){
							wall[i][k] = -1;
						}
						cnt = 1;
					}else{
						cnt = 1;
					}
				}
			}
			//printall(wall, H);

			//fall
			for(int i=H-1; i>=0; i--){
				F(j, 0, 5){
					if(wall[i][j] == -1){
						for(int k=i-1; k>=0; k--){
							if(wall[k][j] != -1){
								wall[i][j] = wall[k][j];
								wall[k][j] = -1;
								break;
								}
						}
					}
				}
			}
		}

		cout << score << endl;
		cin >> H;
	}

}

Measured memory_bytes: 1216
listA = [list(map(int, input().split())) for i in range(3)]
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if b == listA[j][k]:
                listA[j][k] = 0
for l in range(3):
    if listA[l].count(0) == 3:
        print('Yes')
        exit()
    elif listA[0][l] == 0 and listA[1][l] == 0 and listA[2][l] == 0:
        print('Yes')
        exit()
if listA[0][0] == 0 and listA[1][1] == 0 and listA[2][2] == 0:
    print('Yes')
elif listA[0][2] == 0 and listA[1][1] == 0 and listA[2][0] == 0:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
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;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int a, b;

signed main() {
	cin >> a >> b;
	cout << a*b/2 << endl;
}

Measured memory_bytes: 256
/**
 *    author        : Saurav Paul 
 *    created       : August 24, 2020 11:46 AM
 *    Problem Name  : D - Wizard in Maze
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc176/tasks/abc176_d
 *    @genarated by : ai-virtual-assistant
**/

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

const int nax = 1e3 + 10 ;
const int INF = 1e9 + 90 ;
int H , W ;
int sx , sy , fx , fy ;
char grid[nax][nax] ;
int dist[nax][nax] ;
int dx[] = {-1,1,0,0} ;
int dy[] = {0,0,-1,1} ;

class Prop{
    public :
        int x , y , cost ;
        Prop(){
            x = y = cost = 0 ;
        }
        void update(int a, int b,int c){
            x = a , y = b , cost = c ;
        }
}temp,curr;

class Compare{
    public :
        bool operator()(Prop a , Prop b){
            return a.cost > b.cost ;
        }

};
bool legal(int x , int y){
    if(x < 0 || x >= H || y < 0 || y >= W || grid[x][y] =='#') return false ;
    return true ;
}

void solve(){

    scanf("%d%d",&H,&W) ;
    scanf("%d%d%d%d",&sx,&sy,&fx,&fy) ;
    sx -- ; sy-- ; fx-- ; fy-- ;

    for(int i = 0 ; i < H ; i++){
        scanf("%s",grid[i]) ;
    }

    priority_queue<Prop,vector<Prop>,Compare> PQ ;
    temp.update(sx,sy,0) ;
    PQ.push(temp) ;

    for(int i = 0 ; i < H ;i++){
        for(int j = 0 ; j < W ; j++){
            dist[i][j] = INF ;
        }
    }

    dist[sx][sy] = 0 ;
    while(!PQ.empty()){
        curr = PQ.top() ;
        PQ.pop() ;
        int x = curr.x ;
        int y = curr.y ;
        int cost = curr.cost ;

        for(int d = 0 ; d < 4 ; d++){
            int nx = x + dx[d] ;
            int ny = y + dy[d] ;

            if(!legal(nx,ny)) continue ;

            if(dist[nx][ny] > dist[x][y]){
                dist[nx][ny] = dist[x][y] ;
                temp.update(nx,ny,dist[nx][ny]) ;
                PQ.push(temp) ;
            }
        }

        for(int nx = x - 2 ; nx <= x + 2 ; nx ++){
            for(int ny = y - 2 ; ny <= y + 2 ; ny ++){
                if(!legal(nx,ny)) continue ;
                if(dist[nx][ny] > dist[x][y] + 1){
                    dist[nx][ny] = dist[x][y] + 1 ;
                    temp.update(nx,ny,dist[nx][ny]) ;
                    PQ.push(temp) ;
                }
            }
        }
    }
    if(dist[fx][fy] == INF) puts("-1") ;
    else printf("%d\n",dist[fx][fy]) ;

}

int main(){

    int testcases = 1;
    for(int i = 1 ; i <= testcases ; i ++){
        solve();
    }

    return 0 ;
}


Measured memory_bytes: 8692
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int, int> int_p;

int main()
{

    int N;
    int_p red[100], blue[100];
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        cin >> red[i].first >> red[i].second;
    }
    for (int i = 0; i < N; ++i)
    {
        cin >> blue[i].first >> blue[i].second;
    }

    sort(blue, blue + N);
    vector<bool> used(N, false);

    for (int i = 0; i < N; ++i)
    {
        int ymax = -1;
        int index = -1;
        for (int j = 0; j < N; ++j)
        {
            if (used[j])
                continue;
            if (blue[i].first > red[j].first && blue[i].second > red[j].second && red[j].second > ymax)
            {
                ymax = red[j].second;
                index = j;
            }
        }
        if (index != -1)
        {
            used[index] = true;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; ++i)
    {
        if (used[i])
            ++ans;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int main(){
int num,height,before=0;
cin>>num;
if(num==1)cout<<"Yes";
else for(int i=1;i<=num;i++)
     {cin>>height;
     if(height==before&&i!=num){before==height;continue;}
     else if(height<before){cout<<"No";break;}
	      else if(height>before&&i!=num){before=height-1;continue;}
	           else if(i==num)cout<<"Yes";
	 }
	 return 0;
}




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

using namespace std;

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

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

int N;
vector<int> a;
int main() {
    cin >> N;
    int ai;
    for (int i = 0; i < N; i++) {
        cin >> ai;
        a.push_back(ai);
    }

    //long long l = -1;
    //for (int i = 1; i < N; i++) {
    //    if (l < 0) {
    //        l = lcm(a[i - 1], a[i]);
    //    } else {
    //        l = lcm(l, a[i]);
    //    }
    //    cout << l << endl;
    //}

    //l = l - 1;
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        ans += a[i] - 1;
    }

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


Measured memory_bytes: 256
# Aizu Problem 0188: Search
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def search(n, A, s):
    cnt = 0
    left, right = 0, n - 1
    while left <= right:
        mid = (left + right) // 2
        cnt += 1
        if A[mid] == s:
            return cnt
        elif A[mid] > s:
            right = mid - 1
        else:
            left = mid + 1
    return cnt

while True:
    n = int(input())
    if n == 0:
        break
    A = [int(input()) for _ in range(n)]
    s = int(input())
    print(search(n, A, s))

Measured memory_bytes: 7788
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < n; ++i)
using namespace std;
const int INF = 2147483647;
using ll = long long;


int main() {
    int n;
    cin >> n;
    map<int,bool> mp;
    for (int i=0;i<n;i++){
        int a;
        cin >> a;
        mp[a] ^=1;
    }
    int cnt=0;
    for (auto i:mp){
        if(i.second == true)
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N; cin >> N;
    VI H(N);
    REP(i,N) cin >> H[i];
    int ans = 1;

    FOR(i,1,N)
    {
        bool ok = 1;
        REP(j,i)
        {
            if(H[j] > H[i]) ok = 0;
        }
        if(ok)
        {
            ans++;
        }
    }
    cout << ans << endl;

}


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

fn main() {
    let input = read_string();
    let mut sc = Scanner::new(&input);
    let n: usize = sc.next();
    let x: i64 = sc.next();
    let mut xs: Vec<i64> = sc.next_vec(n);
    let d = xs.iter().map(|p| (p-x).abs()).fold(0, |ac,p| gcd(ac,p));
    println!("{}",d);
}

fn gcd(a: i64, b: i64) -> i64 {
    let mut m = cmp::min(a,b);
    let mut n = cmp::max(a,b);
    while m > 0 {
        let t = n % m;
        n = m;
        m = t;
    }
    n
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }

        pub fn next_mat<T: FromStr>(&mut self, w: usize, h: usize) -> Vec<Vec<T>> {
            (0..h).map(|_| self.next_vec(w)).collect()
        }

        pub fn next_vec_char(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }

        pub fn next_mat_char(&mut self, n: usize) -> Vec<Vec<char>> {
            (0..n).map(|_| self.next_vec_char()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 6396
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    
    mod=10**9+7
    N,K=MI()
    A=LI()
    
    for j in range(K):
        S=[0]*(N+1)
        for i in range(N):
            l=max(0,i-A[i])
            r=min(N-1,i+A[i])
            S[l]+=1
            S[r+1]-=1
            
        temp=0
        for i in range(N):
            temp+=S[i]
            S[i+1]+=S[i]
            A[i]=S[i]
            
        if temp==N*N:
            break
        
    print(' '.join(map(str,A)))
            
        
        

        
    
    
    

main()


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

nums = []
nums.append(s)

for i in range(2, 1000001):
    q, m = divmod(s, 2)
    
    if m:
        s = 3*s + 1
    else:
        s = q

    if s in nums:
        print(i)
        break
    else:
        nums.append(s)

  

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int a, b, c;
    cin >> a >> b >> c;

    if ( a + b == c || b + c == a || c + a == b ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().ToCharArray();

            for(var i =0; i<S.Length; i++)
            {
                for(var j=0; j<S.Length; j++)
                {
                    var newString = new string(Enumerable.Range(0, S.Length)
                        .Select(x => (x >= i && x <= j) ? ' ' : S[x]).ToArray()).Replace(" ", "");
                    if(newString=="keyence")
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                }
            }
            Console.WriteLine("NO");
        }

    }
}
//A

Measured memory_bytes: 17484
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){

  lll ii,jj,kk;
  vector<int> ret;

  int a,b;
  int x,y;
  cin >> a >> b;


  for(ii=0;ii<=1000;ii++){

    x = ii * 0.08;
    y = ii * 0.1;

    //cout << "ii:" << ii << "x:" << x << "y:" << y << endl;
    
    if(x == a && y == b){
      
      break;
    }
    
  }
    
  if(ii<=1000){
    cout << ii << endl;
  }
  else{
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>

#define rep(i,n) for (long long int i = 0; i < (n); i++)
#define rep1(i,n) for (long long int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

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

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

int main()
{
    vector<int> v(3);
    rep(i,3) cin >> v[i];
    sort(v.begin(), v.end());

    v[0] = v[2] - v[0];
    v[1] = v[2] - v[1];
    int ans = 0;
    if (v[0] % 2 == 0 && v[1] % 2 == 0) {
        ans = v[0]/2 + v[1]/2;
    }
    if (v[0] % 2 == 1 && v[1] % 2 == 1) {
        ans = 1 + (v[0]-1)/2 + (v[1]-1)/2;
    }
    if (v[0] % 2 != v[1] % 2) {
        ans = v[1] + (v[0]-v[1])/2 + 2;
    }
    cout << ans << endl;
    return 0;
}


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

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
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; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	const int N = inputVal<int>();
	vector<ll> A = inputVec<ll>(N + 1);
	vector<ll> B = inputVec<ll>(N);

	ll cnt = 0;
	for (ll i = N - 1; i >= 0; --i) {
		ll cntr = ((A[i + 1]- B[i]) > 0 ) ? B[i] : A[i+1];
		cnt += cntr;
		B[i] -= cntr;
		ll cntc = ((A[i]- B[i]) > 0 )? B[i] : A[i];
		cnt += cntc;
		A[i] -= cntc;
		B[i] -= cntc;
	}

	outputVal(cnt);
}

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

	double tmp;
	cin >> tmp;

	return 0;
}


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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
// #define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

const int N = 2e5 + 10;
const ll MOD = 1e9 + 7;

int n;
vector <int> adl[N];
pair<ll, ll> dp[N]; // chance, count
pair<ll, ll> prop[N];
ll ans[N];

int par[N];

ll perm[N];

ll fpow(ll a, ll b){
    if (b == 0) return 1;
    ll temp = fpow(a, b / 2);
    temp = temp * temp % MOD;
    if (b & 1) temp = temp * a % MOD;
    return temp;
}

ll inv(ll a){
    return fpow(a, MOD - 2);
}

void dfsPar(int node, int p){
    par[node] = p;
    for (auto x : adl[node]){
        if (x == p) continue;
        dfsPar(x, node);
    }
}

void dfs1(int node, int p){
    dp[node] = mp(1, 1);

    vector <ll> v;
    ll tot = 0;
    for (auto x : adl[node]){
        if (x == p) continue;
        dfs1(x, node);
        dp[node].fi = dp[node].fi * dp[x].fi % MOD;
        // if (node == 1){
        //     cout << dp[x].fi << el;
        // }
        dp[node].se += dp[x].se;
        v.pb(dp[x].se);
        tot += dp[x].se;
    }
    // cout << node << " " << dp[node].fi << " " << dp[node].se << " " << tot << el;
    ll temp = perm[tot];
    for (auto x : v){
        temp = temp * inv(perm[x]) % MOD;
    }
    dp[node].fi = dp[node].fi * temp % MOD;
}

void dfs(int node, int p){
    ans[node] = 1;
    vector <ll> v;
    ll tot = 0;

    if (node != p){
        // prop[node] = mp(ans[p] * inv(dp[node].fi) % MOD , (n - dp[node].se + 1LL + MOD) % MOD);
        // prop[node].fi = prop[node].fi * inv(perm[n - 1]) % MOD * perm[n - 1 - dp[node].se] * perm[dp[node].se] % MOD;
        prop[p] = mp(ans[p] * inv(dp[node].fi) % MOD , (n - dp[node].se) % MOD);
        prop[p].fi = ((prop[p].fi * inv(perm[n - 1]) % MOD) * perm[n - 1 - dp[node].se] % MOD) * perm[dp[node].se] % MOD;
    } else{
        prop[node].fi = 1;
        prop[node].se = n - dp[node].se + 1LL;
    }
    for (auto x : adl[node]){
        if (x == p){
            ans[node] = ans[node] * prop[x].fi % MOD;
            tot += prop[x].se;
            v.pb(prop[x].se);
        } else{
            ans[node] = ans[node] * dp[x].fi % MOD;
            tot += dp[x].se;
            v.pb(dp[x].se);
        }
    }
    ll temp = perm[tot];
    for (auto x : v){
        temp = temp * inv(perm[x]) % MOD;
    }
    ans[node] = ans[node] * temp % MOD;

    for (auto x : adl[node]){
        if (x != p) dfs(x, node);
    }
}

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

    cin >> n;
    for (int i=1;i<n;i++){
        int a, b;
        cin >> a >> b;
        adl[a].pb(b);
        adl[b].pb(a);
    }

    perm[0] = 1;
    for (ll i=1;i<=n;i++){
        perm[i] = perm[i - 1] * i % MOD;
    }

    dfsPar(1, 1);
    dfs1(1, 1);
    dfs(1, 1);

    for (int i=1;i<=n;i++){
        // cout << dp[i].fi << " " << dp[i].se << el;
        // cout << prop[i].fi << " " << prop[i].se << el;
        cout << ans[i] << el;
    }

    return 0;
}

Measured memory_bytes: 23764