akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int n, MOD;
vector<int> g[100055];

int dp[100055][2];
int res[100055];

void dfs(int v, int par = -1) {
	dp[v][0] = dp[v][1] = 1;
	
	for (auto u : g[v]) if (u != par) {
		dfs(u, v);
		
		dp[v][1] = (1ll * dp[v][1] * (dp[u][0] + dp[u][1])) % MOD;
		dp[v][0] = (1ll * dp[v][0] * dp[u][0]) % MOD;
	}
}

int temp[100055][2];

void rdfs(int v, int par = -1, int painted = 1, int notPainted = 1) {
	res[v] = 1ll * dp[v][1] * (painted + notPainted - (par == -1)) % MOD;
	
//	cerr << v + 1 << " " << dp[v][0] << " " << dp[v][1] << " " << temp[v][0] << " " << temp[v][1] << endl;
	
	{
		int lPainted = (painted + notPainted - (par == -1)) % MOD;
		int lNotPainted = notPainted;
		
		for (auto u : g[v]) if (u != par) {
			temp[u][0] = lNotPainted;
			temp[u][1] = lPainted;
			
			lPainted = (1ll * lPainted * (dp[u][0] + dp[u][1])) % MOD;
			lNotPainted = (1ll * lNotPainted * dp[u][0]) % MOD;
		}
	}
	
	reverse(g[v].begin(), g[v].end());
	
	{
		int rPainted = 1;
		int rNotPainted = 1;
		
		for (auto u : g[v]) if (u != par) {
			temp[u][0] = 1ll * temp[u][0] * rNotPainted % MOD;
			temp[u][1] = 1ll * temp[u][1] * rPainted % MOD;
			
			rPainted = (1ll * rPainted * (dp[u][0] + dp[u][1])) % MOD;
			rNotPainted = (1ll * rNotPainted * dp[u][0]) % MOD;
		}
	}
	
	for (auto u : g[v]) if (u != par) {
		rdfs(u, v, temp[u][1], temp[u][0]);
	}
}
int main() {
	cin >> n >> MOD;
	
	for (int i = 0; i + 1 < n; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		x--, y--;
		
		g[x].push_back(y);
		g[y].push_back(x);
	}
	
	dfs(0);
	rdfs(0);
	
	for (int i = 0; i < n; i++) {
		printf("%d\n", res[i]);
	}
}


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

int main() {
  int N; cin >> N;
  vector<int> v(N);
  for(int i=0;i<N;i++) cin >> v.at(i);
  
  sort(v.begin(),v.end());
  
  int sum = 0;
  for(int i=0;i<N-1;i++){
    sum += v.at(i);
  }
  
  int longest = v.at(N-1);
  if(longest < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


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

#define pb(a) push_back(a)

typedef long long ll;
const ll inf = 1e9+7;
const int dsize = 1e5+5;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
vector<ll> prime;

ll inv[dsize],fac[dsize];

inline ll GCD(ll a,ll b){ll c;while(b!=0){c=a%b;a=b;b=c;}return a;}
inline ll LCM(ll a,ll b){return a*b/GCD(a,b);}
inline ll POW(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%inf;}a=a*a%inf;b>>=1;}return c;}
inline void _nCr(){fac[0]=1;for(int i=1;i<dsize;i++){fac[i]=fac[i-1]*i%inf;}for(int i=0;i<dsize;i++){inv[i]=POW(fac[i],inf-2);}}
inline ll nCr(ll n,ll r){return (fac[n]*inv[r]%inf)*inv[n-r]%inf;}
inline void PRI(ll n){bool a[n+1];for(int i=0;i<n+1;i++){a[i]=1;}for(int i=2;i<n+1;i++){if(a[i]){prime.pb(i);ll b=i;while(b<=n){a[b]=0;b+=i;}}}}

int main() {
	int n,k;
	cin >> n >> k;
	ll ans = 0;
	for (int i = 1;i <= n;i++) {
		int p = n/i;
		ans += p * max(0,i-k);
		ans += max(0,n%i-k+1);
	}
	if (k == 0) ans -= n;
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
T,A = map(int,input().split())

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

diff=999
I=999
for i in range(N):
  if abs(T-H[i]*0.006-A)<diff:
    diff=abs(T-H[i]*0.006-A)
    I=i
print(I+1)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int n,m,fa[100005],dis[100005];
bool ok=1;
int find(int x){
	if(fa[x]!=x){
		int nf=fa[x];
		fa[x]=find(fa[x]);
		dis[x]+=dis[nf];
	}
	return fa[x];
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)fa[i]=i;
	for(int i=1;i<=m;i++){
		int l,r,d;
		cin>>l>>r>>d;
		int rl=find(l),rr=find(r);
		if(rl==rr)if(dis[l]-dis[r]!=d)ok=0;
		if(rl!=rr){
			fa[rl]=rr;
			dis[rl]=d+dis[r]-dis[l];
		}
	}
	if(ok)cout<<"Yes";
	else cout<<"No";
	return 0;
} 

Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int[] a = sc.nextIntArray(3);
    Arrays.sort(a);
    int result = 0;
    for (int i = 1; i < 3; i++) {
      result += a[i] - a[i - 1];
    }
    System.out.println(result);
  }
}

Measured memory_bytes: 32756
import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static long fun1(BigInteger a){
        String r=a+"";
        if(a.compareTo(BigInteger.TEN)<=0)
            return Long.valueOf(r);
        else{
            long p=0;
            p+=(r.length()-1)*9;
            p+=Integer.parseInt(r.charAt(0)+"");
            return p;
        }
    }

    public static long fun2(BigInteger a){
        String r=a+"";
        if(a.compareTo(BigInteger.TEN)<=0)
            return 0;
        else{
            long p = (Integer.parseInt(r.charAt(0) + "") - 1) * 9 * (r.length() - 1);
            p += (r.length() - 2) * (r.length() - 1) / 2 * 9 * 9;
            r=r.substring(1);
            a=new BigInteger(r);
            p+= Main.fun1(a);
            return p;
        }
    }


    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        BigInteger a=sc.nextBigInteger();
        BigInteger c=new BigInteger("110");
        String r=a+"";
        int k=sc.nextInt();
        if(k==1)
            System.out.println( Main.fun1(a));
        if(k==2)
            System.out.println( Main.fun2(a));
        if(k==3){
            if(a.compareTo(c)==-1)
                System.out.println("0");
            else{
                long q = 0;
                long v = (r.length() - 1) * (r.length() - 2) * (r.length() - 3) / 6 * 9 * 9 * 9;
                v += 9 * 9 * (Integer.parseInt(r.charAt(0) + "") - 1) * (r.length() - 1) * (r.length() - 2) / 2;
                r = r.substring(1);
                a=new BigInteger(r);
                v+= Main.fun2(a);
                System.out.println(v);
            }
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)

signed main()
{
  int N;

  cin >> N;

  cout << N * 800 - (N / 15) * 200 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N=5010;
int n,k,l[N*2];
char s[N*2],mc='z';
int cmp(int i,int j){
	for (;s[i]==s[j];i++,j++);
	return s[i]<s[j];
}
int main(){
	scanf("%d%d%s",&n,&k,s);
	for (int i=0;i<n;i++)(s[n*2-i-1]=s[i])<mc?mc=s[i]:1;
	if (k>15)k=15;
	int ml=0;
	for (int i=0;i<n*2;i++){
		l[i+1]=s[i]==mc?l[i]+1:0;
		l[i+1]>ml?ml=l[i+1]:1;
	}
	int r=n-(ml<<k-1);
	if (r<0)r=0;
	int p=-1;
	for (int i=n;i<=n*2;i++)
		if (l[i]==ml&&(p<0||cmp(n*2-i+ml,p)))p=n*2-i+ml;
	for (int i=n-r;i--;)putchar(mc);
	for (int i=0;i<r;i++)putchar(s[p+i]);
	puts("");
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100

int n,sum;
int l[2*MAXN+3];

int main() {
	scanf("%d",&n);
	for(int i=0;i<2*n;i++)
		scanf("%d",&l[i]);
	sort(l,l+2*n);
	for(int i=0;i<2*n;i+=2)
		sum+=l[i];
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
N, K = map(int, input().split())
x = list(map(int, input().split()))
answer = float('inf')
for l, r in zip(x, x[K - 1:]):
    # print(l, r)
    cost = r - l + min(abs(l), abs(r))
    answer = cost if cost < answer else answer

print(answer)

Measured memory_bytes: 14224
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {

	var str [][]string

	for sc.Scan() {
		tmp := strings.Split(sc.Text(), " ")

		if tmp[1] == "?" {
			break
		}

		str = append(str, tmp[:])

	}

	for _, v := range str {
		a, _ := strconv.Atoi(v[0])
		b, _ := strconv.Atoi(v[2])

		switch v[1] {
		case "+":
			fmt.Println(a + b)
		case "-":
			fmt.Println(a - b)
		case "*":
			fmt.Println(a * b)
		default:
			fmt.Println(a / b)
		}
	}

}

//a, _ := strconv.ParseFloat(tmp[0], 64)



Measured memory_bytes: 1104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		sc.close();
		int s = N%500;
		if(s<=A) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");

	}

}

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

template <typename T>
class RangeCountExact {
    map<T, int> mp;
    vector<vector<int>> idxs;

    int get(int r, T x) {
        if (mp.count(x) == 0) return 0;
        int a = mp[x];
        return lower_bound(idxs[a].begin(), idxs[a].end(), r) - idxs[a].begin();
    }

public:
    RangeCountExact(const vector<T> &as) {
        for (auto &a : as) mp[a];
        int N = 0;
        for (auto &p : mp) {
            p.second = N++;
        }
        idxs.resize(N);
        for (int i = 0; i < as.size(); i++) {
            idxs[mp[as[i]]].push_back(i);
        }
    }

    // [l, r)
    int get(int l, int r, T x) { return get(r, x) - get(l, x); }
};

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

    int n;
    cin >> n;
    vector<int> as(n);

    for (int i = 0; i < n; i++) cin >> as[i];
    for (int i = 1; i < n; i++) as[i] -= i;

    RangeCountExact cnt(as);

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        ans += cnt.get(i + 1, n, -as[i] - 2 * i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 22712
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;

int main(){
    long long n, k, a, b;
    long long num = 0;
    vector< pair<long long, long long> > v;
    long long ans;

    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> a >> b;
        v.push_back(make_pair(a,b));
    }
    sort(v.begin(), v.end());
    for(int i = 0; num < k; i++){
        num += v[i].second;
        ans = v[i].first;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define MOD 10000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const ull B=100000007;
const int INF=1e9;
struct edge{int to,cost;};
int N,city;
vector<edge> G[100];
int dijkstra(int s){
      int d[city];
      REP(i,city)d[i]=INF;
      d[s]=0;
      priority_queue<P,vector<P>,greater<P> > Q;
      Q.push(P(0,s));
      while(!Q.empty()){
            P p=Q.top();Q.pop();
            int v=p.second;
            if(d[v]<p.first)continue;
            REP(i,G[v].size()){
                  edge e=G[v][i];
                  if(d[e.to]==-1||d[e.to]>d[v]+e.cost){
                        d[e.to]=d[v]+e.cost;
                        Q.push(P(d[e.to],e.to));
                  }
            }
      }
      int sum=0;
      REP(i,city)sum+=d[i];
      return sum;
}
int main(){
      while(cin>>N&&N){
            REP(i,10)G[i].clear();
            city=-1;
            REP(i,N){
                  int a,b,c;
                  cin>>a>>b>>c;
                  G[a].PB((edge){b,c});
                  G[b].PB((edge){a,c});
                  city=max(city,max(a,b));
            }
            city++;
            ll ans=INF,pos=-1;
            REP(i,city){
                  int sum=dijkstra(i);
                  if(ans>sum){
                        ans=sum;
                        pos=i;
                  }
            }
            cout<<pos<<" "<<ans<<endl;
      }
}

Measured memory_bytes: 1212
require 'pp'

N = readline.to_i
H = readline.chomp.split.map(&:to_i)

dp = Array.new(N,0)
dp[0] = 0
dp[1] = (H[1]-H[0]).abs

(2..(N-1)).each do |i|
  dp[i] = [ dp[i-2]+(H[i]-H[i-2]).abs, dp[i-1]+(H[i]-H[i-1]).abs ].min
end

puts dp[N-1]


Measured memory_bytes: 12168
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, m;
  
  cin >> a >> b;
  m = a * b;
  
  if ( (m % 2) == 0 ) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int n;
    cin >> n;
    vector<int> l(n);

    for(int i=0; i<n; i++)
        cin >> l[i];

    int maxVal = *max_element(l.begin(), l.end());
    int sum = accumulate(l.begin(), l.end(), 0);

    cout << (maxVal < sum - maxVal ? "Yes" : "No") << endl;

    return 0;
}



Measured memory_bytes: 256
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [10**10] * n
dp[0] = 0

for i in range(n-1):
    for j in range(1, k+1):
        if i+j < n:
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]))
print(dp[-1])


Measured memory_bytes: 52448
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define lint long long

using namespace std;
int n,m;
lint a[100];
lint b[100];
lint c[100];
lint d[100];

int main(){
  cin >> n >> m;
  REP(i,n){
    cin >> a[i] >> b[i];
  }
  REP(i,m){
    cin >> c[i] >> d[i];
  }

  REP(k,n){
    lint s = a[k];
    lint t = b[k];
    lint t2 = 1000000000;
    int ans = -1;
    REP(i,m){
      if(t2>abs(s-c[i])+abs(t-d[i])) ans = i+1;
      t2 = min(abs(s-c[i])+abs(t-d[i]),t2);
    }
    cout << ans << endl;
  }
  return 0;
}


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


int solve() {
  int N, M; cin >> N >> M;
  vector<int> X(M);
  if (N >= M) return 0;
  for (int i = 0; i < M; i++) cin >> X.at(i);
  sort(X.begin(), X.end());
  vector<int> D(M-1);
  for (int i = 0; i < M-1; i++) D.at(i) = X.at(i+1) - X.at(i);
  sort(D.begin(), D.end(), greater<int>());
  int y = 0;
  for (int i = 0; i < N-1; i++) y += D.at(i);
  return X.at(M-1) - X.at(0) - y;
}  

int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  cout << solve() << endl;

  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#include <stack>

using namespace std;

typedef long long ll;
#define mem(a) (memset(a,0,sizeof(a)))
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define MAX(a, b) ((a)>(b)?(a):(b))
#define MIN(a, b) ((a)<(b)?(a):(b))

const int maxn = static_cast<const int>(1e5 + 5);
const int mod = static_cast<const int>(1e9);

char s[maxn];

int main() {
    scanf("%s",s);
    int len = strlen(s);
    int g=0,p=0,sum=0;
    rep(i,len){
        if(s[i]=='g'){
            if(g>p){
                sum++;
                p++;
            }else{
                g++;
            }
        }else{
            if(g>p){
                p++;
            } else{
                sum--;
                g++;
            }
        }
    }
    printf("%d\n",sum);

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

#define DEBUG if(0)

int main(){
    long long N, t[6], n[6];

    long long min, min_id;
    
    scanf("%lld", &N);
    for(int i=0; i<5; i++){
        scanf("%lld", &t[i]);
        if(i==0 || min>t[i]){
            min_id = i;
            min = t[i];
        }
    }

    long long answer = min_id + N/min + (N%min==0?0:1) + 4 -min_id;

    printf("%lld\n", answer);

    //一番遅い都市が処理を始めるまでの時間: min_id
    //一番遅い都市が処理する回数: N/min + (N%min==0?0:1)
    //一番遅い都市が終わったあとにかかる時間: 5-min_id




    return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	/**
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();



		scan.close();

		List<Integer> l = new ArrayList<>();

		for(int i=1; i<=100; i++) {
			if(A%i==0 && B%i==0) {
				l.add(i);
			}
		}
		
		l.sort(Comparator.reverseOrder());
		
		
		System.out.println(l.get(K-1));
		
	}

}

Measured memory_bytes: 21844
n = gets.chomp.to_i

a_arr = []
b_arr = []
n.times do
  a, b = gets.chomp.split(" ")
  a_arr << a.to_i
  b_arr << b.to_i
end

a_arr.sort!
b_arr.sort!

if n % 2 == 0
  median_a = (a_arr[n / 2 - 1] + a_arr[n / 2]).to_f / 2
  median_b = (b_arr[n / 2 - 1] + b_arr[n / 2]).to_f / 2
  puts ((median_b - median_a) * 2 + 1).to_i
else
  median_a = a_arr[(n - 1)/ 2]
  median_b = b_arr[(n - 1)/ 2]
  puts median_b - median_a + 1
end


Measured memory_bytes: 20456
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>

using namespace std;
using ll = long long;

int f_dir[2][4] = {{-1, 0, 0, 1}, {0, -1, 1, 0}};
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int a, b; cin >> a >> b;
  for(int i = 0; i < 2000; i++){
    if(int(i * 0.08) == a && int(i * 0.1) == b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << 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();
		int[] nums  = new int[n];
		for(int i=0;i<n;i++){
			nums[i] = sc.nextInt();
		}
		int count = 0;
		for(int x:nums){
			if(isPrime(x)){
				count++;
			}
		}
		System.out.println(count);
	}
	public static  boolean isPrime(int number){
		for(int i=2;i*i<=number;i++){
			if(number%i==0) return false;
		}
		return true;
	}
}

Measured memory_bytes: 42724
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1e18
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b,ll m){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a) % m;  a = (a * a) % m;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 2e5 + 2;
ll n,i,c;
string a;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a;
    n = a.length();
    a = "$" + a;
    for(i = 1;i <= n;i += 1) if(a[i] == 'o') c += 1;
    c += 15 - n;
    cout<<(c >= 8 ? "YES" : "NO"); 
    return 0;
}

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

int main() {
	int N, X[MAX];
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> X[i];
	int minc = INT_MAX;
	for (int P = 1; P <= 100; P++) {
		int c = 0;
		for (int i = 0; i < N; i++) {
			c += (X[i] - P) * (X[i] - P);
		}
		minc = min(minc, c);
	}
	cout << minc << endl;
	return 0;
}


Measured memory_bytes: 256
#define DEBUG(...) cerr << __VA_ARGS__ << endl;

#ifndef CDEBUG
#undef DEBUG
#define DEBUG(...) ((void)0);
#define NDEBUG
#endif

#define ran(i, a, b) for (auto i = (a); i < (b); i++)

#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;
#ifndef M_PI
const double M_PI = acos(-1.0);
#endif

const int nmax = 5005;
const ll two_inv = (mod+1)/2;

ll two_pow[nmax];
ll l_mult[nmax];
ll arr[nmax];
ll tmp[nmax];

int main() {
  two_pow[0] = 1;
  l_mult[0] = 1;
  ll two_inv_pow = (mod+1)/2;
  for(int i=1; i<nmax; ++i){
    two_pow[i] = two_pow[i-1]*2%mod;
    l_mult[i] = (i+1)*two_inv_pow%mod;
    two_inv_pow *= two_inv;
    two_inv_pow %= mod;
  }
  int n, m;
  cin>>n>>m;
  arr[m-1]=1;
  for(int i=0; i<n; ++i){
    ll par = 0;
    for(int j=m-1; j>=0; --j){
      tmp[j] = (par*l_mult[j] + arr[j]*(j+2))%mod;
      if(j){
        par += arr[j]*two_pow[j-1];
        par %= mod;
      }
    }
    swap(tmp, arr);
  }
  ll res = 0;
  for(int j=m-1; j>=0; --j){
    res += arr[j];
  }
  res %= mod;
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 3796
using System;

namespace ABC105_C___Base__2_Number
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var result = "";
            while (N != 0)
            {
                result = ((N % 2 == 0) ? "0" : "1") + result;
                N = (N >= 0) ? N / 2 * -1 : ((N * -1) + 1) / 2;
            }
            if(result=="")result = "0";
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13140
/***
 **   A S M Atikur Rahman
 **   Update: 14-11-2019
***/

//#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stdio.h>
#include<map>
#include<math.h>
#include<algorithm>
#include<string>
#include<utility>
#include<stack>
#include<cstring>
#include<iterator>
#include<unordered_map>
#include<unordered_set>
#include<set>
#include<iomanip> ///setprecision


#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sci(x) scanf("%d%*c", &(x))
#define scll(x) scanf("%lld%*c", &(x))
#define scd(x) scanf("%lf%*c", &(x))
#define scstr(x) scanf("%s", x)
#define pfi(x) printf("%d", (x))
#define pfll(x) printf("%lld", (x))
#define pfd(x) printf("%f", (x))
#define pfstr(x) printf("%s", (x))
#define ps printf(" ")
#define pn printf("\n")
#define pfdot printf("..")

#define For(i,a,n) for(int i=(a); i<(n); i++)
#define rFor(i,n,a) for(int i=n-1; i>=0; i--)
#define trav(a,x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define pi  (2*acos(0))


using namespace std;

using ll=long long;
using pii= pair<int,int>;
using pll= pair<long long, long long>;
using pcc= pair<char, char>;
using pdd= pair<double, double>;

#define V(a) vector<a>
using vi= vector<int>;
using vs= vector<string>;
using vll= vector<ll>;
using vpii= vector<pii>;
using vc= vector<char>;
using vd= vector<double>;

//ll POW(ll a,ll b){if(b==0)return 1;ll x=POW(a,b/2);x=(x*x);if(b&1)x=(x*a);return x;}




int main( int argc, char *argv[] )
{
//    fropen("input.txt", "r", stdin);
//    fropen("output.txt", "w", stout);

    int n;
    string s;
    cin>>n;
    cin>>s;
    for(int i=0; i<s.size(); i++)
    {
        s[i]=((s[i]-'A'+n)%26)+'A';
    }
    cout<<s<<endl;

    return 0;
}














Measured memory_bytes: 256
list_task = list(map(int,  input().split()))
N = len(list_task)
# ソートによってリストを降順
list_task.sort()
list_task.reverse()

# 最初のコストは0なので最大値を削除し、それを次の計算のために変数に格納
total_cost = 0
last_number = list_task[0]
list_task.pop(0)
for i in list_task:
    total_cost +=  abs(last_number - i)
    last_number  = i 
print(total_cost)



Measured memory_bytes: 2940
#include <stdio.h>
int main(void){
  
  int A,B;
  int sum,sa;
  1<=A<=B<=20;
  
  scanf("%d %d",&A,&B);
  if(B%A==0){
    sum=A+B;
  printf("%d",sum);
  }
    else if(B%A>=1){
      sa=B-A;
      printf("%d",sa);
    }
  return 0;
}

Measured memory_bytes: 128
import numpy as np
import math
ans=0
d=0
n,D = [int(i) for i in input().split()]
graph=np.zeros(n*D).reshape((n,D))
for i in range(n):
    graph[i:i+1,:] = np.array([int(i) for i in input().split()])
for i in range(n-1):
    for j in range(i+1,n):
        for k in range(D):
            d += abs(graph[i,k] - graph[j,k])**2
        if(math.sqrt(d).is_integer()):
            ans+=1
        d=0
print(ans)

Measured memory_bytes: 12452
#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 (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main(int argc, char const *argv[])
{
    ll n, y;
    cin >> n >> y;
    rep(i, n + 1) rep(j, n + 1 - i)
    {
        ll rem = y - 10000 * i - 5000 * j;
        rem /= 1000;
        if (rem < 0)
            continue;
        if (i + j + rem == n)
        {
            cout << i << " " << j << " " << rem << endl;
            return 0;
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<cstdio>
#include<set>
#include<cstdlib>
using namespace std;
long long solve(long long a, long long b)
{
    if(a>b)
        swap(a,b);
    if(a==0)
        return -b;
    long long x=b/a;
    return 2*x*a+solve(b-x*a,a);
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long n,x;
	cin>>n>>x;
	long long ans=n;
	ans+=solve(x,n-x);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);
int main(){
    int n,m;cin>>n>>m;
    map<int,int>ma;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        ma[a]++;ma[b]++;
    }
    bool f=true;
    for(auto x:ma){
        if(x.second%2)f=false;
    }
    if(f)cout<<"YES"<<endl;
    else
    {
         cout<<"NO"<<endl;
    }
    
}

Measured memory_bytes: 7600
#include<stdio.h>
#include<math.h>
int main(){
	double x[5],y[5],d[9],s,s1,s2;
	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3])!=EOF){
		d[0]=sqrt((x[0]-x[1])*(x[0]-x[1])+(y[0]-y[1])*(y[0]-y[1]));
		d[1]=sqrt((x[2]-x[1])*(x[2]-x[1])+(y[2]-y[1])*(y[2]-y[1]));
		d[2]=sqrt((x[2]-x[0])*(x[2]-x[0])+(y[2]-y[0])*(y[2]-y[0]));
		d[3]=sqrt((x[3]-x[0])*(x[3]-x[0])+(y[3]-y[0])*(y[3]-y[0]));
		d[4]=sqrt((x[3]-x[1])*(x[3]-x[1])+(y[3]-y[1])*(y[3]-y[1]));
		d[5]=sqrt((x[3]-x[2])*(x[3]-x[2])+(y[3]-y[2])*(y[3]-y[2]));
		s1=s2=0.0;
		s=(d[0]+d[1]+d[2])/2;
		s1+=sqrt(s*(s-d[0])*(s-d[1])*(s-d[2]));
		s=(d[0]+d[3]+d[4])/2;
		s2+=sqrt(s*(s-d[0])*(s-d[3])*(s-d[4]));
		s=(d[1]+d[4]+d[5])/2;
		s2+=sqrt(s*(s-d[1])*(s-d[4])*(s-d[5]));
		s=(d[2]+d[5]+d[3])/2;
		s2+=sqrt(s*(s-d[2])*(s-d[5])*(s-d[3]));
		//printf("%lf\n%lf\n",s1,s2);
		if(s2-s1>0.000001)printf("NO\n");
		else printf("YES\n");
	}
	return 0;
}

Measured memory_bytes: 0
package main

import (
	"bufio"
	"fmt"
	"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() []rune {
	return []rune(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
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	ans := 0
	for i := 0; i < N; i++ {
		ans += abs(sc.nextInt()-sc.nextInt()) + 1
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#define ll long long
using namespace std;
int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max(a*b,c*d)<<endl;
	return 0;
} 

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        s: [String; n],
    }
    let mut alpha = vec![std::u64::MAX; 26];
    for i in 0..n {
        let mut acc = vec![0; 26];
        for c in s[i].chars() {
            acc[(c as usize - 'a' as usize) as usize] += 1;
        }
        for j in 0..26 {
            alpha[j] = min(alpha[j], acc[j]);
        }
    }
    for i in 0..26 {
        let j = alpha[i];
        if j != std::u64::MAX || j != 0 {
            for _ in 0..j {
                print!("{}", ((i as u8 + b'a') as char));
            }
        }
    }
    println!("");
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;

struct aa {
	int now;
	int rest;
	int time;
};

class Compare {
public:
	//aa?????????????????¶
	bool operator()(const aa&l, const aa&r) {
		return l.time> r.time;
	}
};
int N, M;
int C;

bool check(const vector < vector<pair<int, int>>>&edges, int time) {
	int memo[100][101];
	for (int i = 0; i < 100; ++i) {
		for (int j = 0; j < 101; ++j) {
			memo[i][j] = 999999999;
		}
	}
	memo[0][time] = 0;
	priority_queue<aa, vector<aa>, Compare>que;
	que.push(aa{ 0,time });

	while (que.size()) {
		aa atop(que.top());
		if (atop.time > C)return false;
		if (atop.now == N - 1)return true;
		que.pop();
		for (const auto&e : edges[atop.now]) {
			if(atop.rest){
				int nexttime = atop.time;
				int nextplace = e.first;
				if (memo[nextplace][atop.rest - 1]>nexttime) {
					memo[nextplace][atop.rest - 1] = nexttime;
					que.push(aa{ nextplace,atop.rest - 1,nexttime });
				}
			}
			 {
				int nexttime = atop.time+e.second;
				int nextplace = e.first;
				if (memo[nextplace][atop.rest]>nexttime) {
					memo[nextplace][atop.rest] = nexttime;
					que.push(aa{ nextplace,atop.rest,nexttime });
				}
			}
		}
	}
	return false;
}
int main() {
	while (1) {
		 cin >> N >> M >> C;
		if (!N)break;
		vector<vector<pair<int,int>>>edges(N);
		for (int i = 0; i < M; ++i) {
			int f, t, c; cin >> f >> t >> c;
			f--; t--;
			edges[f].push_back(make_pair(t, c));
		}
		int amin = 0;
		int amax = 101;
		while (amin + 1 != amax) {
			int amid = (amin + amax) / 2;
			if (check(edges,amid)) {
				amax = amid;
			}
			else {
				amin = amid;
			}
		}
		if (check(edges, 0))amax = 0;
		cout << amax << endl;
	}
	return 0;
}

Measured memory_bytes: 3260
#include<stdio.h>
int main(void){
    int a, b, c;
    int Flag = 0;
    scanf("%d %d %d", &a, &b, &c);
    if (a < b)
    {
        if (b < c)
        {
            printf("Yes\n");
            Flag = 1;
        }
    }
    if (Flag == 0)
    {
        printf("No\n");
    }
    return 0;
}


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

int gcd(long long a, long long b){
  long long r = b;
  long long tmp;
  while(r > 0){
    tmp = a % r;
    a = r;
    r = tmp;
  }
  return a;
}

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

int nlcm(vector<int> a){
  long long l = 1;
  for(int i = 0; i < a.size(); i++){
    l = lcm(l, a[i]);
  }
  return l;
}

int main(){
  int n, m;
  cin >> n >> m;
  cin.ignore();

  vector <int> a;
  int tmp;
  for(int i = 0; i < n; i++){
    cin >> tmp;
    if(tmp %2 == 1){ // 奇数ならもうアウト
      cout << 0 << endl;
      return 0;
    }
    a.push_back(tmp/2);
  }

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

  long long d = nlcm(a);
  #ifdef DBG
  cout << "nlcm = " << d << endl;
  #endif

  for(int i = 0; i < n; i++){
    if((d / a[i]) % 2 == 0){
      cout << 0 << endl;
      return 0;
    }
  }

  long long ans = m / d;
  if(ans % 2 == 0) {
    cout << ans / 2 << endl;
    return 0;
  } else {
    cout << (ans / 2 + 1) << endl;
    return 0;
  }
  return 0;
}
  


Measured memory_bytes: 1144
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

v_c = []
for i in range(len(v)):
    v_c.append(v[i] - c[i])

s = 0
for vc in v_c:
    if vc > 0:
        s += vc

print(s)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

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

int main()
{
    int a, b;
    cin >> a >> b;

    if ((a * b) % 2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }

    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int K;
vi A;

ll get(ll mid) {
    for (int i: A) mid = (mid/i)*i;
    return mid;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> K; A.resize(K);
    F0R(i,K) cin >> A[i];
    ll lo = 0, hi = 1e18;
    while (lo < hi) {
        ll mid = (lo+hi)/2;
        if (get(mid) < 2) lo = mid+1;
        else hi = mid;
    }
    
    ll LO = 0, HI = 1e18;
    while (LO < HI) {
        ll mid = (LO+HI+1)/2;
        if (get(mid) > 2) HI = mid-1;
        else LO = mid;
    }
    if (lo <= LO) {
        cout << lo << " " << LO;
    } else cout << -1;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

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

//int nax = 3005;
long long dp[3005][3005];

int main(){

	int n;cin>>n;
	long long aa;
	vector<long long> arr(n);
	for(int i=0;i<n;i++){
		cin>>aa;
		arr[i] = aa;
	}
	
	for(int l=n-1;l>=0;l--){
		for(int r=l;r<n;r++){
			if(l==r) dp[l][r] = arr[l];
			else
			dp[l][r] = max(arr[l] - dp[l+1][r] ,arr[r] - dp[l][r-1]);
		}
	}
	cout<<dp[0][n-1];
	
	return 0;
	
	
	
}


Measured memory_bytes: 70016
#include <cstdio>
#include <iostream>

using namespace std;
typedef double db;
const int N = 110;
int n;
int a[N];
double ans;
int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%d",&a[i]);
	}
	for(int i=1; i<=n; i++){
		ans+=(double)1/(double)a[i];
	}
	ans=(double)1/(db)ans;
	printf("%lf\n",ans);
	return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		int k;

		if(a==b) {
			System.out.println("0");
		}else {
			if(a%2==b%2) {
				k=(a+b)/2;
				if((a-k<0&&b-k>0)||(a-k>0&&b-k<0)) {
					System.out.println(k);
				}
			}else {
				System.out.println("IMPOSSIBLE");
			}
		}
	}
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007LL;

ll solve() {
    ll N;
    string S;
    cin >> N >> S;
    ll ans = 1;
    for ( int i = 1; i <= N; i++ ) {
        ans = ans * i % MOD;
    }
    ll f = 0;
    for ( char s : S ) {
        bool up = (s == 'B') ^ (f % 2 != 0);
        if ( up ) {
            f++;
        } else {
            ans = ans * f % MOD;
            f--;
        }
    }
    if ( f != 0 ) return 0;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringJoiner;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		
		int x=sc.nextInt();
		System.out.println(x==0?1:0);
		
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long[] readLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 32564
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!=',')
        {
            cout<<s[i];
        }
        else
        {
           cout<<" ";
}
}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int n;
	cin >> n;
	vector<int> c(n), v(n);
	rep(i, n) cin >> v[i];
	rep(i, n) cin >> c[i];
	int ans = 0;
	for (int bit = 0; bit < (1 << n); bit++) {
		int cos = 0;
		int val = 0;
		for (int i = 0; i < n; i++) {
			if (bit & (1 << i)) {
				cos += c[i];
				val += v[i];
			}
		}
		ans = max(ans, val - cos);
	}
	pf(ans);

	return 0;
}

Measured memory_bytes: 3680
using System;

class Lyoz{
	void Run(){
		for(;;){
			string[] mn=Console.ReadLine().Split();
			int m=int.Parse(mn[0]),n=int.Parse(mn[1]);
			if(m==0 && n==0)
				break;
			string[] fbs=new string[n];
			for(int i=0;i<n;i++)
				fbs[i]=Console.ReadLine();
			
			int[] ps=new int[m];
			for(int i=0;i<m;i++)
				ps[i]=i+1;
			
			int cur=0;
			for(int i=0;i<n;i++){
				if(Array.FindAll(ps,x=>x>0).Length==1)
					break;
				while(ps[cur]==-1)
					cur=(cur+1)%m;
				
				string ans=((i+1)%3==0?"Fizz":"")+((i+1)%5==0?"Buzz":"");
				if(ans=="")
					ans=(i+1).ToString();
				
				if(fbs[i]!=ans)
					ps[cur]=-1;
				cur=(cur+1)%m;
			}
			
			string res="";
			foreach(int p in Array.FindAll(ps,x=>x>0))
				res+=" "+p;
			Console.WriteLine(res.Substring(1));
		}
	}
	static void Main(){
		new Lyoz().Run();
	}
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=2e5+5;

bool cnt[31];
int a[mxn];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; cin >> n;
	for(int i=0; i<31; i++)cnt[i]=0;
	for(int i=0; i<n; i++){
		cin >> a[i];
		for(int j=0; j<31; j++){
			if(a[i]>>j&1)cnt[j]=!cnt[j];
		}
	}
	int tot = 0;
	for(int i=0; i<31; i++){
		if(cnt[i])tot+=1<<i;
	}
	for(int i=0; i<n; i++){
		cout << int(tot^a[i]) << ' ';
	}cout << '\n';
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


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

int main() {
  
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  cout << (a-c) * (b-d) << endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
 
#define ll long long
#define MOD 1000000007
 
using namespace std;
 
ll power(ll a, ll b)
{
    if(b == 0)
        return 1;
    ll ret = power(a, b / 2);
    ret = ((ret % MOD) * (ret % MOD)) % MOD;
    if(b & 1)
        ret = (ret * (a % MOD)) % MOD;
    return ret;
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
 
    int n, k;
    ll sum = 0;
    cin >> n >> k;
    ll a[n + 1];
    for(int i = 1 ; i <= n ; i++){
        cin >> a[i];
    }
    ll chooseK[n + 1];
    memset(chooseK, 0, sizeof(chooseK));
    chooseK[k - 1] = 1;
    for(ll i = k ; i <= n ; i++){
        ll a = chooseK[i - 1] * i;
        ll b = (i - k + 1);
        chooseK[i] = a % MOD * power(b, MOD - 2) % MOD;
    }
    sort(a + 1, a + n + 1);
    for(int i = 1 ; i <= n ; i++){
//        cout << chooseK[i - 1] - chooseK[n - i] << endl;
        sum += (((a[i] + MOD) % MOD) * ((chooseK[i - 1] - chooseK[n - i] + MOD) % MOD)) % MOD;
        sum %= MOD;
//        cout << sum <<endl;
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int t, a, b;
	cin >> t;
	if (t == 1)
		cout << "Hello World" << endl;
	else {
		cin >> a >> b;
		cout << a + b << endl;
	}
}

Measured memory_bytes: 256