akhauriyash/Code-Regression huggingface dataset:
#define MOD_TYPE 2

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9 + 10;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr istream &operator>>(istream &is, pair<T, U> &p) noexcept
{
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void solve()
{
  int n;
  cin >> n;
  int a = 0;
  while (a < n)
    a += 1000;
  cout << a - n << "\n";
}

int main()
{
  init_main();
  solve();

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define li long long int
using namespace std;

int main() {
	li n,sum=0;
	cin>>n;
	n=2*n;
	li a[n],i;
	for(i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	
	for(i=0;i<n-1;i=i+2){
	    li aa,b;
	    aa=a[i];
	    b=a[i+1];
	    sum+=min(aa,b);
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  string S;
  string T;
  int sum = 0;
  cin>>S;
  cin>>T;
  for(int i = 0;i < S.size();i++){
    if(S[i] != T[i]){
      sum += 1;
    }
  }
  cout<<sum<<'\n';
}

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

int gcd(int x,int y){
    int r;
    if(x<y) swap(x,y);
    while(y>0){
        r = x%y;
        x = y;
        y = r;
    }
    return x;
}

int main(){
    int K;
    cin >> K;
    int sum = 0;
    for(int a=1;a<=K; ++a){
        for(int b=1;b<=K; ++b){
            for(int c=1; c<=K; ++c){
                sum+=gcd(a,gcd(b,c));
            }
        }
    }
    cout << sum << endl;
}


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

void solve()
{
    int A[32] = {1,
                 1,
                 1,
                 2,
                 1,
                 2,
                 1,
                 5,
                 2,
                 2,
                 1,
                 5,
                 1,
                 2,
                 1,
                 14,
                 1,
                 5,
                 1,
                 5,
                 2,
                 2,
                 1,
                 15,
                 2,
                 2,
                 5,
                 4,
                 1,
                 4,
                 1,
                 51};
    int c;
    cin >> c;
    cout << A[c - 1];
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
#define please return
constexpr auto AC = 0;
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	vector<char> s(a);
	rep(i, a)cin >> s[i];
	s[b - 1] += 32;
	rep(i, a)cout << s[i];
	cout << endl;

	

		please AC;
}

Measured memory_bytes: 256
// +build ignore
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func gcd(x, y int) int {
	if x%y != 0 {
		return gcd(y, x%y)
	}
	return y
}

const D = 60

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	N := sc.nextInt()
	K := sc.nextInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = sc.nextInt() - 1
	}

	T := make([][]int, D)
	T[0] = make([]int, N)
	for i := 0; i < N; i++ {
		T[0][i] = A[i]
	}

	for i := 1; i < D; i++ {
		T[i] = make([]int, N)
		for j := 0; j < N; j++ {
			T[i][j] = T[i-1][T[i-1][j]]
		}
	}

	p := 0
	for i := D; i >= 0; i-- {
		if K&(1<<i) != 0 {
			p = T[i][p]
		}
	}

	fmt.Println(p + 1)

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 100280
loop do
  m, f, r = gets.split(' ').map(&:to_i)
  break if [m, f, r]==[-1, -1, -1]
  sum = m + f
  if m==-1 || f==-1
    puts "F"
  elsif sum >= 80
    puts "A"
  elsif sum >= 65
    puts "B"
  elsif sum >= 50
    puts "C"
  elsif sum >= 30
    puts r >= 50 ? "C" : "D"
  else
    puts "F"
  end
end

Measured memory_bytes: 8636
@cnt = 0
def merge(a, left, right)
  left.upto(right-1) do |k|
    @cnt += 1
  end
end

def merge_sort(a, left, right)
  if left + 1 < right
    mid = (left + right) / 2
    merge_sort(a, left, mid)
    merge_sort(a, mid, right)
    merge(a, left, right)
  end
end

n = gets.to_i
nums = gets.split.map(&:to_i)
merge_sort(nums, 0, n)
puts nums.sort * ' '
puts @cnt

Measured memory_bytes: 72620
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;

struct Customer {
	int M, L, K;
};

bool simulate(const vector<Customer> &customers, int ops, int T){
	int N = customers.size();
	priority_queue< int, vector<int>, greater<int> > opfree;
	for(int i = 0; i < ops; ++i){ opfree.push(0); }
	bitset<1000> done;
	int doneCount = 0;
	while(!opfree.empty()){
		int t = opfree.top();
		opfree.pop();
		int minCustomer = -1, minTime = T + 1;
		for(int i = 0; i < N; ++i){
			if(done[i]){ continue; }
			int cycle = customers[i].L + customers[i].K;
			int nextTime = 0;
			if(t % cycle <= customers[i].L){
				nextTime = t;
			}else{
				nextTime = (t / cycle + 1) * cycle;
			}
			if(nextTime < minTime){
				minTime = nextTime;
				minCustomer = i;
				if(minTime == t){ break; }
			}
		}
		int doneTime = minTime + customers[minCustomer].M;
		if(doneTime > T){ return false; }
		done[minCustomer] = true;
		opfree.push(doneTime);
		if(++doneCount == N){ break; }
	}
	return true;
}

int main(){
	ios_base::sync_with_stdio(false);
	while(true){
		int N, T;
		cin >> N >> T;
		if(N == 0 && T == 0){ break; }
		vector<Customer> customers(N);
		for(int i = 0; i < N; ++i){
			cin >> customers[i].M;
			cin >> customers[i].L;
			cin >> customers[i].K;
		}
		int answer = 1;
		while(!simulate(customers, answer, T)){ ++answer; }
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 924
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}


using ll = long long;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int clamp(int n, int a, int b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

bool f(vector<int> a, vector<int> b) {
    int d = 0;
    REP(i, a.size()) {
        d += (a[i] - b[i]) * (a[i] - b[i]);
    }
    double sq = floor(sqrt(1.0 * d));
    return sq * sq == d;
}

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

    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    REP(i, N) {
        REP(j, D) {
            cin >> X[i][j];
        }
    }

    int ans = 0;
    REP(i, N) {
        FOR(j, i + 1, N) {
            if (f(X[i], X[j])) {
                ans++;
            }
        }
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int A,B,C,D;
LL ans;
int main()
{
	scanf("%d%d%d%d",&A,&B,&C,&D);
	ans=(LL)A*C;
	ans=max(ans,(LL)A*D);
	ans=max(ans,(LL)B*C);
	ans=max(ans,(LL)B*D);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3788
#include<algorithm>
#include<cstdio>
#include<cstring>
#define N 500000
#define NN 200005
using namespace std;
struct ahh{
	int u,v,next;
	long long w;
}a[N];
int fa[NN],head[NN],n,m,tot,x,y;
long long sum,best[NN],v;
void add(int u,int v,long long w){
	tot++;
	a[tot].u=u;a[tot].v=v;a[tot].w=w;
}
bool cmp(ahh x,ahh y){return (x.w<y.w);}
int find(int x){
	if (fa[x]!=x)fa[x]=find(fa[x]);
	return fa[x];
}
void Union(int x,int y){
	int x1=find(x);
	int y1=find(y);
	if (x1!=y1)fa[y1]=x1;
}
void kruskal(){
	for (int i=0;i<n;i++)fa[i]=i;
	sort(a+1,a+tot+1,cmp);
	for (int i=1;i<=tot;i++)
		if (find(a[i].u)!=find(a[i].v))Union(a[i].u,a[i].v),sum+=a[i].w;
}
int main(){
//	freopen("L.in","r",stdin);
	tot=0;
	sum=0;
	memset(best,127,sizeof(best));
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++){
		scanf("%d%d%lld",&x,&y,&v);
		add(x,y,v);
		best[x%n]=min(best[x%n],v+1);
		best[y%n]=min(best[y%n],v+2);
	}
	for (int t=0;t<2;t++)
		for (int i=0;i<n;i++)
			best[(i+1)%n]=min(best[(i+1)%n],best[i]+2);
	for (int i=0;i<n;i++){
		add(i,(i+1)%n,best[i]);
	}
	kruskal();
	printf("%lld",sum);
}


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

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

    int sum = 0;
    int M = N;
    while (true) {
        if (M / 10 < 10) {
            sum = sum + (M / 10) + (M % 10);
            break;
        }
        else {
            sum += (M % 10);
            M /= 10;
        }
    }

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

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            long k = sc.nextLong();
            boolean[] v = new boolean[n];
            long[] s = new long[n];
            int[] a = new int[n];
            for(int i=0; i<n; i++) {
                a[i] = sc.nextInt() - 1;
            }
            v[0] = true;
            long t = 0;
            int pos = 0;
            while(true) {
                t++;
                pos = a[pos];
                if(k == t) {
                    System.out.println(pos + 1);
                    return;
                }
                if(v[pos]) {
                    long p = t - s[pos];
                    k -= t;
                    k %= p;
                    while(k > 0) {
                        pos = a[pos];
                        k--;
                    }
                    System.out.println(pos + 1);
                    return;
                } else {
                    s[pos] = t;
                    v[pos] = true;
                }
            }

    }



}


Measured memory_bytes: 62688
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll x;
    cin>>x;
    ll ans=0;
    ll buf=0;
    buf=x/500;
    buf*=1000;
    ans+=buf;

    x%=500;

    buf=x/5;
    buf*=5;
    ans+=buf;
    
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cctype>

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max)) 

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef pair<int,int> PII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n,m,ans;
	char ch;
	cin >> n >> m;
	VI A(m),B(m),C(m),D(m),cost(n + 1,INT_MAX);
	rep(i,m)
		cin >> A[i] >> ch >> B[i] >> ch >> C[i] >> ch >> D[i];
	int x1,x2,y1,y2;
	cin >> x1 >> ch >> x2 >> ch >> y1 >> ch >> y2;
	priority_queue< PII, vector< PII >,greater< PII > > que;
	que.push(mp(0,x1));
	cost[x1] = 0;
	while(!que.empty()){
		int d = que.top().first,u = que.top().second;
		que.pop();
		if(cost[u] < d) continue;
		rep(i,m){
			if(u == A[i] && cost[u] + C[i] < cost[B[i]]){
				cost[B[i]] = cost[u] + C[i];
				que.push(mp(cost[B[i]],B[i]));
			}
			if(u == B[i] && cost[u] + D[i] < cost[A[i]]){
				cost[A[i]] = cost[u] + D[i];
				que.push(mp(cost[A[i]],A[i]));
			}
		}
	}
	ans = cost[x2];
	rep(i,n + 1){
		cost[i] = INT_MAX;
	}
	que.push(mp(0,x2));
	cost[x2] = 0;
	while(!que.empty()){
		int d = que.top().first,u = que.top().second;
		que.pop();
		if(cost[u] < d) continue;
		rep(i,m){
			if(u == A[i] && cost[u] + C[i] < cost[B[i]]){
				cost[B[i]] = cost[u] + C[i];
				que.push(mp(cost[B[i]],B[i]));
			}
			if(u == B[i] && cost[u] + D[i] < cost[A[i]]){
				cost[A[i]] = cost[u] + D[i];
				que.push(mp(cost[A[i]],A[i]));
			}
		}
	}
	ans += cost[x1];
	ans = y1 - y2 - ans;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1204
#include<stdio.h>
int main(void)
{
	int A,B,C;

	scanf("%d%d%d", &A, &B, &C);

	if (A < B && A < C) {
		if (B < C) {
			printf("No");
		}
		else
			printf("Yes");
	}
	else if (B < A && B < C) {
		if (A < C) {
			printf("No");
		}
		else
			printf("Yes");
	}

	else
		printf("No");





	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K, C = mapint()
S = list(input())
r_S = S[::-1]

pos = [0]*N
neg = [0]*N
ok = 0
cnt = 0
for i in range(N):
    if S[i]=='o':
        if ok<=i:
            pos[i] = cnt + 1
            cnt += 1
            ok = i + C + 1
            if cnt==K:
                break

    else:
        pass
ok = 0
cnt = 0
for i in range(N):
    if r_S[i]=='o':
        if ok<=i:
            neg[i] = cnt + 1
            cnt += 1
            ok = i + C + 1
            if cnt==K:
                break

    else:
        pass

ans = []
neg = neg[::-1]

for i in range(N):
    if pos[i]+neg[i]-1==K:
        ans.append(i)
for a in ans:
    print(a+1)

Measured memory_bytes: 102412
#define rep(i,n) for (int i = 0; i < (int)(n); i++)

#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, M, sum = 0;
    vector<int> A;
    
  cin >> N >> M;
    rep(i, M){
        A.push_back(0);
        cin >> A[i];
        sum += A[i];
    }
    
    if(N-sum >= 0){
    cout << N - sum;
    }else{
        cout << -1;
    }
    
  
}

Measured memory_bytes: 3728
package main

import (
	"fmt"
	"math"
)

func main() {
	var N int
	fmt.Scan(&N)
	h := make([]int, N)
	dp := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&h[i])
	}

	for i := 1; i < N; i++ {
		dp[i] = dp[i-1] + Abs(h[i]-h[i-1])
		if i > 1 {
			dp[i] = Min(dp[i], dp[i-2]+Abs(h[i]-h[i-2]))
		}
	}
	fmt.Println(dp[N-1])
}
func Abs(a int) int {
	return int(math.Abs(float64(a)))
}
func Min(a, b int) int {
	if b < a {
		return b
	}
	return a
}


Measured memory_bytes: 5504
#include <iostream>
#include <algorithm>
#include <functional>
#include <utility>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <cmath>
#include <climits>
using namespace std;

#define rep(i,end)          rep2(i,0,(end))
#define rep2(i,beg,end)   for (int i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
#define inf                   LLONG_MAX
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef list<ll> li;
typedef pair<ll, ll> pii;
typedef pair<ll, string> pis;
typedef pair<string, ll> psi;

int main(void);

string gets(bool skipnewline);
vi get_n_array(int n);

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a*b}) << endl;
    return 0;
}

string gets(bool skipToNextline)
{
    if (skipToNextline) gets(false);
    const int BUFF_MAX = 1024;
    char buf[BUFF_MAX];
    cin.getline(buf, sizeof(buf));
    return buf;
}

vi get_n_array(int n)
{
    vi v;
    while (n-- > 0) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    return v;
}

Measured memory_bytes: 256
n = int(input())
al = [0] + list(map(int, input().split())) + [0]
sum_cost = 0
for i in range(n+1):
    sum_cost += abs(al[i]-al[i+1])

for i in range(1, n+1):
    print(sum_cost - (abs(al[i]-al[i+1])+abs(al[i]-al[i-1])) + abs(al[i-1]-al[i+1]))




Measured memory_bytes: 20488
import numpy as np
A=[]
for i in range(3):
    l=[int(a) for a in input().split()]
    A.extend(l)
for i in range(int(input())):
    b=int(input())
    if b in A:
        A[A.index(b)]=0
na=np.array(A)
ra=na.reshape(3,3)
flg=False
fa=np.all(ra==0,axis=0)
fb=np.all(ra==0,axis=1)
if any(fa) or any(fb):
    flg=True
flg2=flg3=True    
for i in range(3):
    if ra[i][i]!=0:
        flg2=False
    if ra[i][-1-i]!=0:
        flg3=False
if flg or flg2 or flg3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14444
N, A, B, C, D =  map(int, input().split())
S = input()
S = [False] + [s == '.' for s in S] + [False]
def check(s, t):
    i = s
    for _ in range(s, t+1):
        if i + 1 == t or i + 2 == t:
            return True
        if S[i+2]:
            i += 2
            continue
        if S[i+1]:
            i += 1
            continue
        return False

def checki(s, t):
    for i in range(s, t+1):
        if S[i-1] and S[i] and S[i+1]:
            return True
    return False



if A < B < D < C:
    if not check(B, D) or not check(A, C):
        print('No')
    elif checki(B, D):
        print('Yes')
    else:
        print('No')
else:
    if check(A, C) and check(B, D):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 58232
s = input()
t = input()

LS = len(s)
LT = len(t)
# 最長で何文字一致するか
max_match = 0
for i in range(LS - LT + 1):
    ss = s[i:i+LT]
    match = 0
    for a,b in zip(t, ss):
        if a==b:
            match += 1
            max_match = max(max_match, match)

print(LT - max_match)


Measured memory_bytes: 9056
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;

int n;
int lim[52], vol[52];
set<ll> no[52];

bool solve(int idx);

bool distribute(int idx, int next){
  if(idx == n){
    return false;
  }

  ll bit = 0;

  for(int i = idx; i < n; i++){
    bit <<= 1;
    if(vol[i] == lim[i]){
      bit++;
    }
  }

  if(no[idx].find(bit) != no[idx].end()){
    return false;
  }
  no[idx].insert(bit);

  for(int i = next; i < n; i++){
    if(vol[i] != 0) continue;
    if(vol[idx] < lim[i]) continue;
    if(i - 1 != idx && lim[i - 1] == lim[i] && vol[i - 1] == 0) continue;
    vol[idx] -= lim[i];
    vol[i] = lim[i];

    if(vol[idx] != 0 && distribute(idx, i + 1)) return true;
    if(vol[idx] == 0 && solve(idx + 1)) return true;

    vol[idx] += lim[i];
    vol[i] = 0;
  }

  return false;
}

bool solve(int idx){
  if(idx == n) return true;
  if(vol[idx] == 0) return false;

  if(solve(idx + 1)) return true;
  if(distribute(idx, idx + 1)) return true;

  return false;
}

int main(){
  while(cin >> n, n){
    for(int i = 0; i < n; i++){
      cin >> lim[i];
      no[i].clear();
      vol[i] = 0;
    }
    sort(lim, lim + n, greater<int>());

    vol[0] = lim[0];
    cout << (solve(0) ? "YES" : "NO") << endl;
  }
}

Measured memory_bytes: 0
# coding: utf-8
# Your code here!

EPS = 0.0000000001

COUNTER_CLOCKWISE = 1
CLOCKWISE = -1
ONLINE_BACK = 2
ONLINE_FRONT = -2
ON_SEGMENT = 0
                                                                      
class Point:
    
    global EPS
    
    def __init__(self, x = 0, y = 0):
        self.x = x
        self.y = y
        
        
    def __add__(a, b):
        s = a.x + b.x
        t = a.y + b.y
        return Point(s, t)
        
    def __sub__(a, b):
        s = a.x - b.x
        t = a.y - b.y
        return Point(s, t)
            
    def __mul__(self, a):
        s = a * self.x
        t = a * self.y
        return Point(s, t)
        
    def __truediv__(self, a):
        s = self.x / a
        t = self.y / a
        return Point(s, t)
            
            
            
            
    def norm(self):
        return self.x * self.x + self.y * self.y
        
    def abs(self):
        return self.norm() ** 0.5
            
    
            
            
    def __eq__(self, other):
        return abs(self.x - other.y) < self.EPS and abs(self.y - other.y) < self.EPS
            
            
            
    def dot(self, b):
        return self.x * b.x + self.y * b.y
        
    def cross(self, b):
        return self.x * b.y - self.y * b.x
    
    
class Segment:
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

def project(s, p):
    base = s.p2 - s.p1
    hypo = p - s.p1
    r = hypo.dot(base) / base.norm()
    return s.p1 + base * r

def reflecton(s, p):
    return p + (project(s,p) - p) * 2


def getDistance(a, b):
    return (a-b).abs()

def getDistanceLP(l, p):
    return abs((l.p2-l.p1).cross(p-l.p1)) / ((l.p2-l.p1).abs())

def getDistanceSP(s, p):
    if (s.p2 - s.p1).dot(p-s.p1) < 0:
        return (p-s.p1).abs()
    elif (s.p1 - s.p2).dot(p-s.p2) < 0:
        return (p-s.p2).abs()
    return getDistanceLP(s,p)


def getDistanceSS(s1, s2):
    if intersectS(s1, s2):
        return 0
    return min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2), getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2))



def ccw(p0, p1, p2):
    a = p1-p0
    b = p2-p0
    
    if a.cross(b) > 0:
        return COUNTER_CLOCKWISE
    elif a.cross(b) <0:
        return CLOCKWISE
    elif a.dot(b) < 0:
        return ONLINE_BACK
    elif a.abs() < b.abs():
        return ONLINE_FRONT
    else:
        return ON_SEGMENT

def intersect(p1, p2, p3, p4):
    return ccw(p1, p2, p3) *ccw(p1, p2, p4) <=0 and ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0

def intersectS(s1, s2):
    return intersect(s1.p1, s1.p2, s2.p1, s2.p2)


def getCrossPoint(s1, s2):
    base = s2.p2-s2.p1
    a = s1.p1-s2.p1
    b = s1.p2-s2.p1
    
    d1 = abs(a.cross(base))
    d2 = abs(b.cross(base))
    
    t = d1 / (d1+d2)
    return s1.p1 + (s1.p2-s1.p1) * t


n = int(input())
for i in range(n):
    
    nums=list(map(int,input().split()))
    s1 = Segment(Point(nums[0], nums[1]), Point(nums[2], nums[3]))
    s2 = Segment(Point(nums[4], nums[5]), Point(nums[6], nums[7]))
    print(getCrossPoint(s1, s2).x, getCrossPoint(s1, s2).y)







Measured memory_bytes: 5668
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    while(true){
        cin >> x;
        cin >> y;
        if(x == 0 && y == 0){
            break;
        }
        if(x < y){
            cout << x << " " << y << endl;
        
        }
        else{
            cout <<y << " " << x << endl;
        }
    }
}




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

void solve(string dS, string T){
    bool rest = false;
    for(int i = dS.size() - T.size(); i >= 0; --i){
        bool flag = true;
        for(int j = 0; j < T.size(); ++j){
            //cout << "dS: " << dS[i+j] << endl;
            //cout << "T: " << T[j] << endl;
            if(dS[i+j] == '?' || dS[i+j] == T[j]) continue;
            else flag = false;
        }
        if(flag){
            for(int j = 0; j < T.size(); ++j){
                if(dS[i+j] == '?') dS[i+j] = T[j];
            }
            rest = true;
            break;
        }
    }
    if(rest){
        for(int i = 0; i < dS.size(); ++i){
            if(dS[i] == '?') cout << 'a';
            else cout << dS[i];
        }
        cout << endl;
    }
    else cout << "UNRESTORABLE" << endl;
    return;
}


int main(){
    string dS, T;
    cin >> dS;
    cin >> T;
    solve(dS, T);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>
#include<limits.h>
using namespace std;

int main()
{
    int n; cin >> n;
    vector<int>  a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    bool flag = true;
  
    while(flag){
      int tmp = INT_MAX;
      int min_index = 0;
      for(int i = 0; i < n; ++i){
        if(a[i] == 0) continue;
        if(tmp > a[i]) {
          tmp = a[i];
          min_index = i;
        }
      }
                 
      for(int i = 0; i < n; ++i){
        if(i != min_index) a[i] = a[i] % a[min_index];
      }
      
      int count = 0;
      for(int i = 0; i < n; ++i){
        if(a[i] != 0) ++count;
      }

      if(count == 1){
        flag = false;
        cout << a[min_index] << endl;
      }
    }
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>
#include <array>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mn(x) *min_element((x).begin(),(x).end())
#define mx(x) *max_element((x).begin(),(x).end())
#define sum(x) accumulate((x).begin(),(x).end(),0ll)
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

const ld pi=acos(-1);
const ll inf=(ll)1e9+1;
const int mod=1000000007;
//const int mod=998244353;

ll n,m,k;
const int N=1e6;






int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    int q,t,u,v,h;
    ll x,a,b,c,d,y,z;
    cin >> n;
    vi vv(n);
    for(int i=0; i<n; i++){
        cin >> vv[i];
    }
    a=0;
    for(int i=1; i<n; i++){
        if(vv[i]<vv[i-1]){
            a+=vv[i-1]-vv[i];
            vv[i]=vv[i-1];
        }
    }
    cout << a << el;
    
    return 0;
}



Measured memory_bytes: 3984
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

ll func(ll a,ll b,ll& ans_x,ll& ans_y){
    if(b == 0){
        ans_x = 1;
        ans_y = 0;
        return a;
    }else{
        ll ret = func(b,(a%b),ans_y,ans_x);
        ans_y -= (a/b)*ans_x;
        return ret;
    }
}


ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

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

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b,x,y;
    cin>>a>>b;
    func(a,b,x,y);
    cout<<x<<" "<<y<<endl;
    return 0;
}



Measured memory_bytes: 3176
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let w:Vec<char> = read::<String>().chars().collect();
    let mut cp = w.clone();
    cp.sort();
    cp.dedup();
    let ans = if cp.iter().all(|x| w.iter().filter(|&y| y == x).count() % 2 ==0) {
        "Yes"
    } else {
        "No"
    };
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<iomanip>
#include<sstream>
#include<cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long int ll;
typedef long double ld;
const ll INF = 1LL << 60;
const int inf = (1 << 30);
const int MOD = 1000000007;
int dx[4] = { 0,-1,0,1 }, dy[4] = { 1,0,-1,0 };
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
int main() {
    ll n, x,sum = 0; cin >> n >> x; vector<ll> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n - 1) {
        if (a[i] + a[i + 1] > x) {
            sum += a[i] + a[i + 1] - x;
            a[i + 1] = max(0LL, x- a[i]);
        }
    }cout << sum << endl;
}

Measured memory_bytes: 1024
n,m,x = map(int,input().split())
a = input().split()
c = 0
ans = []
if x == n:
  print(0)
  exit()
else:
  for i in range(x,n+1):
    if str(i) in a:
      c += 1
  ans.append(c)
  c = 0
  for i in range(x,-1,-1):
    if str(i) in a:
      c += 1
  ans.append(c)
print(min(ans))


Measured memory_bytes: 38256
import sys

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


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

    res = 0
    for i in range(60):
        cnt = 0
        for a in A:
            cnt += (a >> i) & 1
        res += (cnt * (n - cnt) % mod) * (1 << i) % mod
        res %= mod
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 123132
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;

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

    vector<vector<P>> xy(N);
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        for(int j=0; j<a; j++){
            int x, y;
            cin >> x >> y;
            x--;
            xy[i].push_back(P(x, y));
        }
    }

    int ans = 0;
    for(int i=0; i<pow(2,N); i++){
        int cnt = 0;
        bool fl = true;
        for(int j=0; j<N; j++){
            if(((i>>j)&1) == 0) continue;
            cnt++;
            for(int k=0; k<xy[j].size(); k++){
                int target = xy[j][k].first;
                int is_honest = xy[j][k].second;
                if(((i>>target)&1) != is_honest){
                    fl = false;
                }
            }
        }
        if(fl) ans = max(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define pb push_back
#define fi first
#define se second
 
const ll MOD = 1000000007;
 
int main() {
   int N; scanf("%d", &N);
   vector<long> fix;
   for (int i = 1; i <= N; ++i) {
      int p; scanf("%d", &p);
      if (p != i) fix.pb(p);
   }
   if (fix.size() == 0 || fix.size() == 2) {
      puts("YES");
   } else {
      puts("NO");
   }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

template<typename T> inline void Cin(T &x)
{
    char c;
    T sign = 1;
    x = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') sign = -1;
    for (; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}

const int N = int(1e5) + 2;
typedef tuple<int, int, int> TQuery;

int color[N][11], n, m, u, v, d, c;
TQuery q[N];
vector<int> a[N];

void Paint(int u, int d) {
    if(color[u][d]) return;
    color[u][d] = c;
    if(d == 0) return;
    Paint(u, d - 1);
    for(int& v: a[u]) Paint(v, d - 1);
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    Cin(n, m);
    while(m --) Cin(u, v), a[u].pb(v), a[v].pb(u);
    Cin(m);
    for(int i = 1; i <= m; ++i) {
        Cin(v, d, c);
        q[i] = make_tuple(v, d, c);
    }
    while(m) {
        tie(v, d, c) = q[m --];
        Paint(v, d);
    }
    for(int i = 1; i <= n; ++i) Cout(color[i][0], '\n');
}


Measured memory_bytes: 12024
#いい加減深さ優先探索, 幅優先探索をスムーズに実装してえなおい

H,W = map(int,input().split())

S = ["#"] * (H+2)
S[0] = ["#"] * (W+2)
S[H+1] = ["#"] * (W+2)
for i in range(1,H+1):
    S[i] = ["#"]+ list(input()) + ["#"]

inf = 10 ** 3
m = 0
mi = -1
mj = -1
mk = -1
ml = -1
  
for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j] == "#":
            continue
        data = [[inf]*(W+2) for k in range(H+2)]
        data[i][j] = 0
        stack = [[i,j,0]]
        while stack:
            x = stack.pop()
            if S[x[0]+1][x[1]] == "." and data[x[0]+1][x[1]]>x[2]+1:
                data[x[0]+1][x[1]] = x[2]+1
                stack.append([x[0]+1,x[1],x[2]+1])
            if S[x[0]][x[1]+1] == "." and data[x[0]][x[1]+1]>x[2]+1:
                data[x[0]][x[1]+1] = x[2]+1
                stack.append([x[0],x[1]+1,x[2]+1])
            if S[x[0]-1][x[1]] == "." and data[x[0]-1][x[1]]>x[2]+1:
                data[x[0]-1][x[1]] = x[2]+1
                stack.append([x[0]-1,x[1],x[2]+1])
            if S[x[0]][x[1]-1] == "." and data[x[0]][x[1]-1]>x[2]+1:
                data[x[0]][x[1]-1] = x[2]+1
                stack.append([x[0],x[1]-1,x[2]+1])
            #print(i,j,stack)

        for k in range(1,H+1):
            for l in range(1,W+1):
                if data[k][l] > m and data[k][l] != inf:
                    m = data[k][l]
                    mi = i
                    mj = j
                    mk = k
                    ml = l

#print(mi,mj,mk,ml)
print(m)

#DFSならワイの実装力でも割とスムーズにできそう？
#なんで昨日これやらなかったんや
#と言いつつWAするアホ

Measured memory_bytes: 60120
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		//int cnt = 0;
		int sum = 0;
		//int cnn = 0;
		int kuku[] = new int[100];
		for(int i=0;i<10;i++) {
			kuku[i]=i;
			for(int k=0;k<10;k++) {
				kuku[k]=k;
				sum = (kuku[i])*(kuku[k]);
				if(sum == N) {
					System.out.println("Yes");
					System.exit(0);
				}else {
					//System.out.println("No");
					//System.exit(0);
					continue;
				}
			}
		}
		//System.out.println(sum);
		  System.out.println("No");
		/*for(int j=0;j<82;j++) {
			cnn = cnn + 1;
		}
		System.out.println(cnn);*/
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<vector>
#include<tuple>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	int ans = -1;
	for (int i = 0; i <= 10000; i++) {
		if ((int)(i * 0.08) == A && (int)(i * 0.1) == B) {
			ans = i;
			break;
		}

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

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
   

    int N;
    
    // 整数の入力
    scanf("%d",&N);
  
  	int i=0;
  	int d[N];
  	for(i=0;i<N;i++){
		scanf("%d", &d[i]);
    }
  int t=0;
  int ans = 0;
  int num = 0;
  for(i=0;i<N;i++){
	for(t=i+1;t<N;t++){
		num = d[i]*d[t];
      	ans = ans + num;
    	}
    }
    // 文字列の入力
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  std::string s;
  std::cin >> s;
  int n = s.length();
  std::vector<char > notx;
  for (int i=0; i<n; i++){
    if (s[i]=='x') continue;
    notx.push_back(s[i]);
  }
  bool canreverse = true;
  int notxsize = notx.size();
  if (notxsize==0){
    printf("0\n");
    return 0;
  }
  for (int i=0; i<=(notxsize-1)/2; i++){
    if (notx[i]!=notx[notxsize-i-1]) {
      canreverse = false;
      break;
    }
  }
  if (!canreverse){
    printf("-1\n");
  } else {
    std::vector<int > gap(notxsize+1, 0);
    int counter = 0;
    for (int i=0; i<n; i++){
      if (s[i]!='x') {
        counter++;
      } else {
        gap[counter]++;
        //printf("gap[%d]++\n",counter);
      }
    }
    int ans = 0;
    for (int i=0; i<=notxsize/2; i++){
      //printf("ans+=|%d-%d|\n", gap[i],gap[notxsize-i]);
      ans += abs(gap[i]-gap[notxsize-i]);
    }
    printf("%d\n", ans);
  }
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  bool hasYellow = false;
  char color;
  for (int i = 0; i < n; i++) {
    cin >> color;
    if (color == 'Y'){
      hasYellow = true;
    }
  }
  string ans;
  if (hasYellow) {
    ans = "Four";
  }
  else {
    ans = "Three";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
A = [-1] + list(map(int,input().split()))

visit = [False for i in range(N+1)]
now = 1
cnt = 0
while True:
    if visit[now]:
        break
    visit[now] = True
    now = A[now]
    cnt += 1
cnt2 = 0
visit2 = [False for i in range(N+1)]
while True:
    if visit2[now]:
        break
    visit2[now] = True
    now = A[now]
    cnt2 += 1

if cnt >= K:
    ans = 1
    for i in range(K):
        ans = A[ans]

else:
    K -= cnt
    K = K%cnt2
    ans = now
    for i in range(K):
        ans = A[ans]
print(ans)



Measured memory_bytes: 109108
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    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;
}

int main(){

    int N;
    cin >> N;

    string S;
    cin >> S;

    string ans = S;

    int i;
    for(i=0; i<S.length(); i++){
        if(S.at(i) + N <= 'Z'){
            ans.at(i) = S.at(i) + N;
        }
        else{
            char diff = S.at(i) + N - 'Z' - 1;
            ans.at(i) = 'A' + diff;
        }
    }

    cout << ans << endl;

    return 0;
}



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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

int x, y, z;

int main()
{
  while(cin >> x >> y >> z){
    double P = 0.0;
    int mask = (1 << x) | (1 << y ) | (1 << z);
    rep(i, 10) if(!(mask & (1 << i)) && x + y + i + 1 <= 20) P += 1.0;
    P /= 8.0;
    puts(P >= 0.5 ? "YES" : "NO");
    //cerr << P << endl;
  }

  return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N;
  long long x,sum=0,cnt=0;
  cin>>N>>x;
  int a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
    sum+=a[i];
  }
  sort(a,a+N);
  if(sum<x) cout<<N-1<<endl;
  else if(sum==x) cout<<N<<endl;
  else{
    for(int i=0;i<N;i++){
      x-=a[i];
      if(x>=0) cnt++;
      else break;
    }
    cout<<cnt<<endl;
  }
}	


Measured memory_bytes: 256
n,m=map(int,input().split())
c=[]
for i in range(n):
  a,b=map(int,input().split())
  c.append([a,b])
c.sort()
ans=0
for i in range(n):
  b=c[i][1]
  if m>b:
    m-=b
    ans+=c[i][0]*b
  else:
    ans+=c[i][0]*m
    print(ans)
    exit()

Measured memory_bytes: 20048
#include <stdio.h>
char s[101];
int d;
int ans;
int main() {
	scanf(" %s", s);
	for (int i = 0; i < 101; i++) {
		if (s[i] == NULL)d = i;
	}
	for (int i = 0; i < d; i++) {
		if ((i % 2) && s[i] == 'R')ans = 1;
		if ((i % 2 - 1) && s[i] == 'L')ans = 1;
	}
	if (ans)printf("No\n");
	else printf("Yes\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define IO ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
using namespace std;
typedef long long LL;
const int maxn = 1e5+10;

LL a,b,c,x,y;

int main()
{
#ifndef ONLINE_JUDGE
//    freopen("test.in","r",stdin);
#else
    IO;
#endif // ONLINE_JUDGE

    while(cin>>a>>b>>c>>x>>y)
    {
        double mid = (a+b) / 2.0;
        LL ans = 0;
        if(c < mid)
        {
            LL mn = min(x,y);
            ans += 2 * c * min(x,y);
            x -= mn;
            y -= mn;
        }
        ans += min(2*c,a) * x;
        ans += min(2*c,b) * y;
        cout<<ans<<endl;
    }
    return 0;
}


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

char s[100005];

int main()
{
	int n;
	int slimes = 1;
	cin>>n;
	cin>>s;
	for (int i = 1; i < n; i++)
	{
		if (s[i] != s[i-1])
			slimes++;
	}
	cout<<slimes<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
using namespace std;

string cor = "CODEFESTIVAL2016";

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


	int ans = 0;
	for (int i = 0; i < input.size(); i++) {
		if (input[i] != cor[i]) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256