akhauriyash/Code-Regression huggingface dataset:
N, W = map(int, input().split())
mv = 10 ** 5
INF = 10 ** 10
dp = [INF] * (mv + 1)
dp[0] = 0
ans = 0
for i in range(N):
    w, v = map(int, input().split())
    for j in range(mv, v-1, -1):
        dp[j] = min(dp[j], dp[j-v] + w)
        if dp[j] <= W:
            ans = max(ans, j)
print(ans)

Measured memory_bytes: 42220
import java.util.*;

public class Main{

    public static void main(String args[]){

        // スキャナーの宣言
        Scanner sc = new Scanner(System.in);
        // 整数の入力
		int n = sc.nextInt();
        int[] num = new int[n];
        int ans = Integer.MAX_VALUE;

        for(int i = 0;i < n; i++){
            num[i] = sc.nextInt();
        }

        for(int i = 0;i < n; i++){
            int sum1 = 0;
            int sum2 = 0;
            for(int j = 0; j < i; j++){
                sum1 += num[j];
            }
            for(int j = i; j < n; j++){
                sum2 += num[j];
            }
            ans = Math.min(ans, Math.abs(sum1 - sum2));
        }

        // 出力
        System.out.println(ans);

    }

}

Measured memory_bytes: 24532
def fibonacci
	cache = {}
	fibo = lambda do |n|
		return 1 if n <= 1
		return cache[n] if cache.has_key?(n)

		cache[n] = fibo[n - 1] + fibo[n - 2]
	end
end

n = STDIN.gets.to_i
puts fibonacci.call(n)

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

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long;
using pll = pair<ll, ll>;

const ll MAXN = 1000001;
bool P[MAXN];

template<typename T> T gcdraw(T a, T b) { return a ? gcdraw(b%a, a) : b; }
template<typename T> T gcd(T a, T b)
{
    const auto aa = abs(a), bb = abs(b);
    return aa > bb ? gcdraw(aa, bb) : gcdraw(bb, aa);
}

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

    vector<ll> A(N);
    for (auto& a: A) { cin >> a; }

    bool isPairwise = true;
    ll setwise = A[0];

    for (ll i=0;i<N;++i)
    {
        if (isPairwise) for (ll j=1;j*j<=A[i];++j)
        {
            if ((A[i] % j) != 0) { continue; }

            const auto x = j;
            const auto y = A[i] / j;

            if (x != 1 && P[x]) { isPairwise = false; }
            if (y != 1 && P[y]) { isPairwise = false; }

            P[x] = true;
            P[y] = true;
        }

        setwise = gcd(setwise, A[i]);
    }

    if (isPairwise)        { cout << "pairwise coprime" << endl; }
    else if (setwise == 1) { cout << "setwise coprime" << endl; }
    else                   { cout << "not coprime" << endl; }

    return 0;
}


Measured memory_bytes: 11112
from collections import deque

x, y = deque(), deque()
s = deque(list(input()))
n = len(s)
m = s[n // 2]
ans = (n + 1) // 2
for _ in range((n + 1) // 2):
    x.appendleft(s.popleft())
for _ in range(n // 2):
    y.appendleft(s.pop())
if n % 2 == 1:
    x.popleft()
for i in range(n // 2):
    if x[i] == y[i] == m:
        ans += 1
    else:
        break
print(ans)

Measured memory_bytes: 4900
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int k = in.nextInt();
			long[] a = in.nextLongArray(n);

			out.println(1 + (n-2)/(k-1));

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

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

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

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 35672
#include<stdio.h>
int main() {
	char S[100002];
	scanf("%s", S);
	int len = strlen(S);
	int cnt = 0, ans = 0;
	for (int i = 0; i < len; i++)
	{
		if (S[i] == 'p') {
			cnt++;
		}
	}
	ans = len / 2 - cnt;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define MAX 100010

// int ans[MAX] = {};
 
int main() {
    int tmp;

    int A, B;

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

    tmp = A + B;

    if(A - B > tmp) {
        tmp = A - B;
    }

    if(A * B > tmp) {
        tmp = A * B;
    }

    printf("%d\n", tmp);

    return 0;
}

Measured memory_bytes: 128
# coding: utf-8
# Your code here!
n=int(input())
p = [float(i) for i in input().split()]

dp=[0]*(n+1)
dp[0]=1
for i in range(n):
    for j in range(n,-1,-1):
        dp[j] = dp[j]*(1-p[i]) + dp[j-1]*p[i]
#    print(dp)

print(sum(dp[(n+1)//2:]))        

Measured memory_bytes: 43484
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W, a, b;
    cin >> W >> a >> b;
    if(a <= b) {
        cout << max(0, b - a - W) << "\n";
    } else {
        cout << max(0, a - b - W) << "\n";
    }
}

Measured memory_bytes: 3612
#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()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

typedef pair<int, int> PII;
int main(int argc, char const *argv[])
{
    string s, t;
    cin >> s >> t;
    ll x[s.size() + 1];
    ll y[t.size() + 1];
    x[0] = 0;
    rep(i, s.size())
    {
        x[i + 1] = x[i] + (s[i] == 'A' ? 1 : 2);
        //cerr << x[i + 1] << endl;
    }

    y[0] = 0;
    rep(i, t.size())
    {
        y[i + 1] = y[i] + (t[i] == 'A' ? 1 : 2);
    }
    int q;
    cin >> q;
    rep(i, q)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        //cerr << x[b] - x[a - 1] << "," << y[d] - y[c - 1] << endl;
        if ((x[b] - x[a - 1]) % 3 == (y[d] - y[c - 1]) % 3)
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
    return 0;
}


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

#define ALL(a) (a).begin(), (a).end()

typedef long long ll;

using namespace std;

int main(){
	string str; cin >> str;
	ll c = 0,ans = 0;
	for(auto e : str){
		if(e == 'B'){
			c++;
		}
		else{
			ans += c;
		}
	}
	cout << ans << endl;


	return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,Q; string S; cin >> N >> S >> Q;
    vector<set<int>> pos(26);
    for (int i=0;i<N;++i)
        pos[S[i]-'a'].insert(i);
    for (;Q--;){
        int t; cin >> t;
        if (t==1){
            int k; char c; cin >> k >> c; --k;
            for (int i=0;i<26;++i)
                if (pos[i].count(k)) pos[i].erase(k);
            pos[c-'a'].insert(k);
        } else {
            int l,r,ans=0; cin >> l >> r; --l,--r;
            for (int i=0;i<26;++i)
                if (pos[i].upper_bound(r)!=pos[i].lower_bound(l))
                    ++ans;
            cout << ans << '\n';
        }
    }
}

Measured memory_bytes: 24220
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
const int MOD = 1e9 + 7;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    vector<vector<pair<int, bool>>> t(n + 1);
    for(int i = 1; i < n + 1; i++)
    {
        int a; cin >> a;
        for(int j = 0; j < a; j++)
        {
            int x, y; cin >> x >> y;
            t[i].push_back({x, y});
        }
    }
    int best = 0;
    for(int b = 0; b < (1<<n); b++)
    {
        vector<bool> honest(n + 1, 0);
        int cnt = 0;
        bool ok = 1;
        for(int i = 0; i < n; i++) if(b & (1<<i))
        {
            cnt++;
            honest[i + 1] = 1;
        }
        for(int i = 1; i < n + 1; i++) for(int j = 0; j < t[i].size(); j++)
        {
            if(honest[i] && honest[t[i][j].first] != t[i][j].second)
            {
                ok = 0;
                break;
            }
        }
        if(!ok) continue;
        best = max(best, cnt);
    }
    cout << best;
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

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

    int n, m;
    cin >> n >> m;

    int d0 = 0, d1 = 1, d2;
    int i = 1;

    for (int j = 0; j <= m; j++) {
        int i1;
        if (j < m) cin >> i1; else i1 = n + 1;

        for (; i < i1; i++) {
            d2 = d0 + d1;
            if (d2 >= P) d2 -= P;
            d0 = d1; d1 = d2;
        }

        d0 = d1; d1 = 0;
        i++;
    }

    cout << d0 << endl;

    return 0;
}

Measured memory_bytes: 384
import bisect,sys
from itertools import *
n=range(50001);a=list(n);a[1]=0
for i in range(2,224):a[i*2::i]=[0]*len(a[i*2::i])
p=list(compress(n,a))
for x in map(int,sys.stdin):
 if x:print(sum(1 for d in p[:bisect.bisect(p,x//2)]if a[x-d]))


Measured memory_bytes: 8452
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

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

int INF = 1000000007;
int MAXC = 200000;
int dp[30][200000]; // i???????????§????????????????????£???j???????????????????°??????????????????°

int main(){
  int n,m;
  int c[30];

  cin >> n >> m;
  rep(i,m){
    cin >> c[i] ;
  }
  
  rep(j,30){
    rep(i,200000){  
      dp[j][i] = INF;
    }
  }
  rep(j,30){
    dp[j][0] = 0;
  }
  for(int i = 1;i<m+1;i++){
    for(int j = 0;j<n+1;j++){
      if(j-c[i-1] >= 0 )
	dp[i][j] = min( dp[i][j-c[i-1]]+1, dp[i-1][j] );
      else 	dp[i][j] =  dp[i-1][j] ;
    }
  }
 
  cout << dp[m][n] << endl;
  
  


  return 0;
}

Measured memory_bytes: 24600
#include<iostream>
#include<math.h>
#include<algorithm>

#define long long long

using namespace std;

long n, m;
long w[101], v[101], dp[101][100000];

long cal(int idx, int weight) {
    if (idx > n) return 0;
    if (dp[idx][weight] != -1) return dp[idx][weight];
    dp[idx][weight] = 0;

    if (weight + w[idx] <= m) dp[idx][weight] = max(cal(idx + 1, weight), cal(idx + 1, weight + w[idx]) + v[idx]);
    else dp[idx][weight] = dp[idx][weight] = cal(idx + 1, weight);
    return dp[idx][weight];
}

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

void Input()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i ++) cin >> w[i] >> v[i];
    for (int i = 1; i <= n; i ++)
        for (int j = 0; j <= 100000; j ++) dp[i][j] = -1;
}

void Solve()
{
    cout << cal(1,0);
}

int main()
{
    FastInput();
    Input();
    Solve();
}



Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	char c;
	scanf("%d %c %d",&a,&c,&b );
	if(c=='+'){
		int ans=a+b;
		printf("%d\n",ans);
	}
	else{
		int ans=a-b;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;string s;
  cin >> n >> s;
  int ans = 0;
  char pre = 0;
  rep(i,n){
    if(s[i]!=pre)++ans;
    pre = s[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int A,B,C; cin >> A >> B >> C;
    if(A==B) cout << C << endl;
    else if(A==C) cout << B << endl;
    else cout << A << endl;
    return 0;
}


Measured memory_bytes: 3572
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

void add_sgt(int value, int index, vector<int> &sgt) {
    sgt[index] += value;
    if (index - 1 < 0) return;
    add_sgt(value, (index - 1) / 2, sgt);
}

int sum_sgt(int a, int b, const vector<int> &sgt, int i, int l, int r) {
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return sgt[i];
    int mid = l + (r - l) / 2;
    int vl = sum_sgt(a, b, sgt, 2*i+1, l, mid);
    int vr = sum_sgt(a, b, sgt, 2*i+2, mid, r);
    return vl + vr;
}

int main(int argc, const char * argv[]) {
    int N; cin >> N;
    string S; cin >> S;
    int Q; cin >> Q;

    int M = 1; while (M <= N) M *= 2;
    map<char, vector<int>> chs;
    for (int i = 0; i < 'z' - 'a' + 1; i++) chs['a'+i] = vector<int>(2*M - 1, 0);
    for (int i = 0; i < N; i++) add_sgt(1, i + M - 1, chs[S[i]]);

    for (int i = 0; i < Q; i++) {
        int t; cin >> t;
        if (t == 1) {
            int iq; cin >> iq; iq -= 1;
            char cq; cin >> cq;
            if (S[iq] != cq) {
                add_sgt(-1, iq + M - 1, chs[S[iq]]);
                S[iq] = cq;
                add_sgt(1, iq + M - 1, chs[S[iq]]);
            }
        } else {
            int lq, rq; cin >> lq >> rq; lq -= 1;
            int tmp_cnt = 0;
            for (int k = 0; k < 'z' - 'a' + 1; k++) {
                tmp_cnt += sum_sgt(lq, rq, chs['a'+k], 0, 0, M) > 0 ? 1 : 0;
            }
            cout << tmp_cnt << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 107524
import math
import numpy as np
n, d = map(int, input().split())
X = np.array([list(map(int, input().split())) for _ in range(n)])
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        dis = math.sqrt(np.sum((X[i] - X[j]) ** 2))
        if dis == int(dis):
            ans += 1
print(ans)


Measured memory_bytes: 27088
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
#a_ = np.array()

count=0
cont=1

#print(a)
#print(a[2])

while cont :
  a_ = np.unique(a % 2)
  if a_[0]==0 and len(a_) == 1 :
    count += 1
  else :
    break

  a = a / 2

print(count)

Measured memory_bytes: 12380
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    auto s = readln.chomp;
    auto t = readln.chomp;
    
    auto ans = zip(s, t).count!(t => t[0] == t[1]);
    
    ans.writeln;
}

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


using namespace std;

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

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

//#define int long long

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

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

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

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    int cnt[112345] = {};
    int add[112345] = {};
    int dat[112345] = {};

	for(int i=0;i<N;i++)
	{
		int z;
        cin >> z;
		cnt[z%M]++;
		dat[z]++;
	}
	for(int i=0;i<=100000;i++)
	{
		add[i%M]+=dat[i]/2;
	}

    int ans = 0;
    for(int i = 0; i+i <= M; i++){
        if(i == 0 || i+i == M){
            ans += cnt[i] / 2;
        }else{
            int s = cnt[i];
            int t = cnt[M-i];
            if(s < t) ans += s + min((t-s)/2,add[M-i]);
            else ans += t + min((s-t)/2, add[i]);
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 1664
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;
typedef long long ll;

int main() {
  int A, B;
  cin >> A>> B;
  int ans;
  if (A >= 13) {
    ans = B;
  } else if (6 <= A && A<= 12) {
    ans = B/2;
  } else {
    ans = 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
	int k;
	cin >> k;
	string a,p;
	cin >> a;
	int b;
	b = a.size();
	if (k >= b) {
		cout << a <<endl;
	}
	else {
		p = a.substr(0, k);
		cout << p <<"..."<< endl;
	}
	return (0);
}

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


def main():
    N = int(input())
    A = []
    for _ in range(N):
        x, y = map(int, input().split())
        A.append((x, y))
    if N == 1:
        print(1)
        return

    A.sort()
    import collections
    D = collections.defaultdict(int)
    import itertools
    for a, b in itertools.combinations(A, 2):
        p = a[0] - b[0]
        q = a[1] - b[1]
        D[(p, q)] += 1
    d = sorted(D.values())
    print(N - d[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3564
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N, D; cin >> N >> D;
  int X[N][D];
  rep(i,N) rep(j,D) cin >> X[i][j];
  
  int cnt = 0;
  for (int i=0;i<N;i++){
    for (int j=i+1;j<N;j++){
      int se = 0;
      rep(d,D) se += (X[i][d]-X[j][d])*(X[i][d]-X[j][d]);
      int dst = sqrt(se);
      if (dst*dst == se) cnt++;
    }
  }

  cout << cnt << endl;

  // cout << fixed << setprecision(6);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main() {
	int a, b, yy = 0, mm = 0;
	char s[5];

	scanf("%s", s);

	a = atoi(&s[0]) / 100;
	b = atoi(&s[2]);

	if (12 >= a && a >= 1) yy = 1;
	if (12 >= b && b >= 1) mm = 1;

	if (yy == 1 && mm == 1) printf("AMBIGUOUS\n");
	else if (yy == 1 && mm == 0) printf("MMYY\n");
	else if (yy == 0 && mm == 1) printf("YYMM\n");
	else printf("NA\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
#define rep(i,x,to) for(int i=x;i<to;i++)

int main() {
	int n,dp[31]={1,1,2};
	while(1){
		cin >> n;
		if(n==0) break;
		rep(i,3,31){
			dp[i] = dp[i-1]+dp[i-2]+dp[i-3];
		}
		cout << dp[n]/3650+(dp[n]%3650!=0) << endl;
	}
	return 0;
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = false;

int H, W;
int e[10][10];

int main() {
	while (cin >> H >> W, H || W) {
		REP(i, H) REP(j, W) scanf("%d", &e[i][j]);
		if (debug) putchar('@');

		int ans = 0;
		FOR(h, 3, H + 1) FOR(w, 3, W + 1) { // 1-index
			REP(y, H - h + 1) REP(x, W - w + 1) {
				int mi = INF, ma = 0;
				int sum = 0;
				REP(i, h) REP(j, w) {
					int ny = y + i, nx = x + j;
					if (i == 0 || j == 0 || i == h - 1 || j == w - 1) {
						chmin(mi, e[ny][nx]);
					}
					else {
						chmax(ma, e[ny][nx]);
						sum -= e[ny][nx];
					}
				}
				sum += (h - 2) * (w - 2) * mi;
				if (mi <= ma) continue;
				chmax(ans, sum);
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3144
import           Control.Monad
import qualified Data.Array.IO               as IO
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

main = do
  [l, r] <- getIntList
  let r'= min (l + 2020) r
      ans = minimum [x * y `mod` 2019 | x <- [l..(r'-1)], y <- [(x+1)..r']]
  print ans


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

int bit[MAX_N+1],n;

int sum(int i){
    int s=0;
    while(i>0){
        s+=bit[i];
        i-=i&-i;
    }
    return s;
}

void add(int i,int x){
    while(i<=n){
        bit[i]+=x;
        i+=i&-i;
    }
}

int main(){
    int q;
    cin>>n>>q;
    rep(i,q){
        int a,b,c;
        cin>>a>>b>>c;
        if(a==0)add(b,c);
        else cout<<sum(c)-sum(b-1)<<endl;
    }
}

Measured memory_bytes: 1548
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    B=LI()
    *A_c, = accumulate(A)
    *B_c, = accumulate(B[::-1])
    B_c = B_c[::-1]
    ans = 0
    for i in range(N):
        ans = max(ans, A_c[i] + B_c[i])
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 64620
import sys
import math
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, c, d = map(int, input().split())
    takahashi = math.ceil(c / b)
    aoki = math.ceil(a / d)

    if takahashi <= aoki:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 61988
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	int answer = 0;
	for (int C = 1; C <= N; C += 2) {
		int num_of_divisors = 0;
		for (int X = 1; X <= C; ++X) {
			if (C % X == 0) {
				++num_of_divisors;
			}
		}
		if (num_of_divisors == 8) {
			++answer;
		}
	}
	cout << answer << '\n';
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		
		String ans = s.equals(t.substring(0, s.length())) ? "Yes" : "No";
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 26856
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
typedef long long LL;
const int MAXN = 100000;
const int INF = 0x3f3f3f3f;
using namespace std;
 
inline void enableFileIO() {
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
}
 
inline int read() {
  int x = 0, w = 1;
  char c = ' ';
  
  while (c < '0' || c > '9') {
    c = getchar();
    if (c == '-') w = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return x * w;
}
 
int ans, n, a[MAXN + 5], sum[MAXN + 5];
int mn, mx;
 
void init() {
//  enableFileIO();
  
  n = read();
  mn = INF;
  mx = -INF;
  for (int i = 1; i <= n; ++i) {
    a[i] = read();
    mn = min(mn, a[i]);
    mx = max(mx, a[i]);
  }
}
 
struct BinaryIndexTree {
  int c[MAXN * 2 + 5];
  int lowbit(int x) {
    return x & (-x);
  }
  void init() {
    memset(c, 0, sizeof(c));
  }
  void update(int x) {
    for (; x <= 2 * n; x += lowbit(x)) ++c[x];
  }
  int query(int x) {
    int ret = 0;
    for (; x; x -= lowbit(x)) ret += c[x];
    return ret;
  }
}BIT;
 
int b[MAXN + 5];
 
inline bool chk(int mid) {
  BIT.init();
  memset(sum, 0, sizeof(sum));
  
  for (int i = 1; i <= n; ++i) {
    b[i] = a[i] >= mid ? 1 : -1;
    sum[i] = sum[i - 1] + b[i];
  }
  
  LL ret = 0;
  BIT.update(0 + n);
  for (int i = 1; i <= n; ++i) {
    ret += BIT.query(sum[i] + n);
    BIT.update(sum[i] + n);
  }
  return ret >= 1LL * n * (n + 1) / 4;
}
 
int main() {
  init();
  
  int l = mn, r = mx;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (chk(mid)) {
      l = mid + 1;
      ans = mid;
    } else {
      r = mid - 1;
    }
  }
  
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 2176
import math

N = int(input())
li = [list(map(int,input().split())) for i in range(N)]
ans = []
for i in range(N):
    for j in range(N):
        d = (li[i][0] - li[j][0])**2 + (li[i][1]-li[j][1])**2
        d = math.sqrt(d)
        ans.append(d)
print(sum(ans)/N)



Measured memory_bytes: 3060
package main

import (
	"fmt"
	"sort"
)

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

	a := make([]int, n)
	for i:= 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	m := int(1e6+10)
	cnt := make([]int, m)
	for _,x := range a {
		if cnt[x] != 0 {
			cnt[x] = 2
			continue
		}
		for i := x; i <m; i += x {
			cnt[i]++
		}
	}
	ans := 0
	for _,x := range a {
		if cnt[x] == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}



Measured memory_bytes: 14568
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define lim 100005
#define INF 1e13
int main()
 {
  
ll n;
cin>>n;
ll ans=10000000;
ll x;
while(n--)
{
  cin>>x;
  ll t=0;
  while(x%2==0)
  {
    x/=2;
    t++;
  }
  ans=min(ans,t);
}
cout<<ans<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n;cin>>n;
    int p[n];
    int tmpmin=200001;
    int cnt=0;
    rep(i,n){int tmp;cin>>tmp;if(tmpmin>tmp){cnt++;tmpmin=tmp;}}
    co(cnt);
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<28)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

int main() {
    int n, x, y, num[2005] = {};
    cin >> n >> x >> y;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int t;
            t = min(min(j - i, abs(x - i) + 1 + abs(y - j)), abs(i - y) + 1 + abs(x - j));
            num[t]++;
        }
    }
    for (int i = 1; i < n; i++)cout << num[i] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int max(int a, int b){
    return (a>b?a:b);
}
int main()
 {
	//code
	int t;
	t = 1;
	while(t--){
	    int n;
	    cin >> n;
	    int W;
	    cin >> W;
	    int wt[n], val[n];
	    for(int i = 0;  i < n;  i++)
	        cin >> wt[i]>> val[i];
	    long dp[n+1][W+1];
	    for(int i = 0;  i <= n;  i++)
	        for(int w = 0;  w <= W;  w++){
	            if(i == 0  ||  w == 0)
	                dp[i][w] = 0;
	            else if(w < wt[i-1])
	                dp[i][w] = dp[i-1][w];
	            else
	                dp[i][w] = max(val[i-1]+dp[i-1][w-wt[i-1]], dp[i-1][w]);
	        }
	    cout << dp[n][W] << endl;
	}
	return 0;
}

Measured memory_bytes: 82432
#include <iostream>
#include <algorithm>
#include <array>
using namespace std;
int main() {
	string s;
	int flag = 0;
	cin >> s;

		if (s[2] == s[3]) {
			if (s[4] == s[5]) {
			flag = 1;}
	}
		
	
	if (flag == 1) { cout << "Yes"; }
	else { cout << "No"; }
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 500000 
struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};
typedef struct node * Node ;
Node root;
void insert(int k){
  Node y = NULL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NULL;
  z->r = NULL;

  while(x != NULL){
    y = x;
    if((z->key) < (x->key)) x = x->l;
    else x = x->r;
  } 
  z->p = y;

  if(y == NULL){
    root = z;
  }
  else if((z->key) < (y->key)){
    y->l = z;
  }
  else y->r = z;
}
void inorder(Node u){
  if(u != NULL){
    inorder(u->l);
    printf(" %d",u->key);
    inorder(u->r);
  }
}

void preorder(Node u){
  printf(" %d",u->key);
  if(u->l != NULL){
    preorder(u->l);
  }
  if(u->r != NULL){
    preorder(u->r);
  }
}
int main(){
  int n,i,x;
  char c[10];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",c);
    if(c[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(c[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 24040
a=[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]
print(a[int(input())-1])

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

int main(){
  ll n, m;
  cin >> n >> m;
  vector<ll> vec(n);
  for(ll i=0; i<n; ++i){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int l=1, r=200001;
  while(l<r-1){
    int mid= (l+r)/2;
    ll ansnum=0;
    for(int i=0; i<n; ++i){
      ll l2=-1, r2=n;
      while(l2<r2-1){
        int mid2= (l2+r2)/2;
        if(vec.at(i)+vec.at(mid2) >= mid) l2=mid2;
        else r2=mid2;
      }
      ansnum += l2+1;
    }
    if(ansnum >= m) l=mid;
    else r=mid;
  }
  ll anspow = l;
  vector<ll> rui(n+1);
  for(int i=1; i<=n; ++i){
    rui.at(i) = rui.at(i-1) + vec.at(i-1);
  }
  ll ans=0, ansnum=0;
  for(int i=0; i<n; ++i){
    l=-1; r=n;
    while(l<r-1){
      int mid= (l+r)/2;
      if(vec.at(i)+vec.at(mid) >= anspow) l=mid;
      else r=mid;
    }
    ans += rui.at(l+1) + vec.at(i)*(l+1);
    ansnum += l+1;
  }
  ans -= (ansnum-m)*anspow;
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>

int main(int argc, char *argv[])
{
    std::string s;

    std::cin >> s;

    if (s == "AAA" || s == "BBB") {
        std::cout << "No" << std::endl;
    } else {
        std::cout << "Yes" << std::endl;
    }

    return 0;
}


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

int main()
{
	int n,m;
	cin>>n>>m;
	 char arr[n][m];
	 for(int i=0;i<n;i++)
	 {
	     for(int j=0;j<m;j++)
	     {
	         cin>>arr[i][j];
	     }
	 }
	 int ans[n][m];
	 memset(ans,0,sizeof(ans));
	 for(int i=0;i<n;i++)
	 {
	     for(int j=0;j<m;j++)
	     {
	         if(i==0 and j==0)
	         {  
	             ans[i][j]=1;
	           
	         }
	         else
	         if(i==0 and j>0)
	         {
	             if(arr[i][j]=='.')
	             {
	                 ans[i][j]=ans[i][j-1];
	             }
	         }
	         else
	         if(j==0 and i>0)
	         {
	             if(arr[i][j]=='.')
	             {
	                 ans[i][j]=ans[i-1][j];
	             }
	         }
	         else
	         {
	             if(arr[i][j]=='.')
	             {
	                 ans[i][j]=(ans[i-1][j]+ans[i][j-1])%max1;
	             }
	         }
	     }
	 }
	 cout<<ans[n-1][m-1]<<"\n";
}


Measured memory_bytes: 5120
#include<stdio.h>
#include<stdlib.h>
#define mymalloc(p,n) {p = malloc((n)*sizeof(*p));if ((p)==NULL) {printf("not enough memory?\n"); exit(1);};}
main(){
	int i,j,k,num,temp,count;
	int *A;
	scanf("%d", &num);
	mymalloc(A,num);
	for(i=0;i<num;i++){
		scanf("%d",&j);
		A[i]=j;
	}
	count=0;
	for(i=0;i<num;i++){
		for(j=num-1;j>i;j--){
			if(A[j]<A[j-1]){
				temp=A[j];
				A[j]=A[j-1];
				A[j-1]=temp;
				count++;
			}
		}
		
	}
	for(k=0;k<num;k++){
		printf("%d",A[k]);
		if(k<num-1){
			printf(" ");
		}
		else{printf("\n");}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 604
Q=gets.to_i
Q.times do
  c,a,n=gets.split.map &:to_i
  cca,ccc,can=0,c/3,0
  c-=ccc*3
  begin
    while n>0&&a>0&&c>0
      can+=1
      a-=1
      n-=1
      c-=1
    end
    if ccc>0&&n>0&&a>0 then
      ccc-=1
      c+=3
      redo
    end
  end while false
  begin
    while a>0&&c>1
      cca+=1
      c-=2
      a-=1
    end
    if ccc>0&&a>0 then
      ccc-=1
      c+=3
      redo
    end
  end while false
  puts cca+ccc+can
end

Measured memory_bytes: 6116
n = int(input())
h = list(map(int,input().split()))
dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
    dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main()
{
    int n,m,x,ans=-1;
    cin>>n>>m>>x;
    vector<vector<int>> c(n,vector<int>(m+1));
    rep(i,n) rep(j,m+1) cin>>c[i][j];
    rep(i,1<<n)
    {
        vector<int> sum(m+1);
        rep(j,n)
        {
            if(i>>j&1)
            {
                rep(k,m+1) sum[k]+=c[j][k];
            }
        }
        int hantei=0;
        for(int k=1;k<m+1;k++) if(sum[k]<x) hantei=1;
        if(hantei==1) continue;
        if(ans==-1) ans=sum[0];
        else ans=min(ans,sum[0]);
    }
    cout<<ans;
}

Measured memory_bytes: 3616
fun main(args: Array<String>) {
    val (a, b) = readIntegerList()
    for (i in 1..10000000) {
        if ((i * 8 / 100) == a && (i * 10 / 100) == b) {
            println(i)
            return
        }
    }

    println(-1)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 37876
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#define ll long long

using namespace std;
int a[10];
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    int x=max(a,c);
    int y=min(b,d);
    if(x<y)
    cout<<y-x<<endl;
    else cout<<"0"<<endl;
    return 0;
}


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

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

    // N行のうちa行を塗り、M列のうちb列を塗る

    // 黒いマスの個数は
    // (N * b) + (M * a) - (a * b) * 2

    for (int a = 0; a <= N; a++)
    {
        for (int b = 0; b <= M; b++)
        {
            int black_square = (N * b) + (M * a) - (a * b) * 2;

            if (black_square == K)
            {
                cout << "Yes" << endl;
                return 0;
            }
            else if (black_square > K) break;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys


class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return False
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return True

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)


readline = sys.stdin.readline
n, m, k = map(int, readline().split())
ab = tuple(tuple(map(int, readline().split())) for i in range(m))
cd = (map(int, readline().split()) for i in range(k))

friend_group = UnionFind(n)
for a, b in ab:
    friend_group.union(a-1, b-1)

ans = [friend_group.size(i) - 1 for i in range(n)]
for a, b in ab:
    ans[a-1] -= 1
    ans[b-1] -= 1
for c, d in cd:
    if friend_group.same(c-1, d-1):
        ans[c-1] -= 1
        ans[d-1] -= 1

print(*ans)


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}


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

  ll n, k;
  cin >> n >> k;
  if(n < k){
    cout << min(n, k-n) << endl;
    return 0;
  }

  while(n > k){
    n = n % k;
  }
  ll ans = min(k-n, n);
  cout << ans << endl;
}

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

template<typename T> T GCD(T a, T b) {
    if (b == 0) return a;
    if (a % b == 0) return b;
    return (GCD(b, a % b));
}

int main() {
    long long a, b;
    cin >> a >> b;
    cout << GCD(a, b) << endl;
    return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define mod 1000000007
#define inf 999999999999999ll


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll dis=inf;
    for(ll i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ll j=n/i;
            dis=min(dis,abs(i-1)+abs(j-1));
        }
    }
    cout<<dis<<endl;
}



Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			if(n==0)
				return;
			int a[][]=new int[n+1][31];//1次元目の人が空いている2次元目の日
			int b[][]=new int[n][n];//1次元目の人が持ってる2次元目の紙
			int ans=31;
			boolean judge;
			for(int i=0;i<n;i++)
			{
				b[i][i]=1;//自分の持ってる番号
				int f=in.nextInt();
				for(int j=0;j<f;j++)
					a[i][in.nextInt()]=1;
			}
//			for(int i=0;i<n;i++)
//			{
//				for(int j=1;j<30;j++)
//					System.out.print(a[i][j]);
//				System.out.println();
//			}
			int t;
			for(t=1;t<=30;t++)
			{
				LinkedList<Integer> LL=new LinkedList<Integer>();//人
				HashSet<Integer> HS=new HashSet<Integer>();//t日にいる人から集まる紙
				for(int i=0;i<n;i++)//tに空いている人をリストに格納
					if(a[i][t]==1)
						LL.add(i);
				for(int i=0;i<LL.size();i++)
				{
					int k=LL.get(i);//その日いる人のうちの一人
					for(int j=0;j<n;j++)
					{
						if(b[k][j]==1)
						{
							HS.add(j);//j番の紙が集まる
						}
					}
				}
				if(HS.size()==n)
					break;
				//t日にいる人にHSにある紙の情報を与える
				for(int i=0;i<LL.size();i++)
				{
				  	int k=LL.get(i);
				  	Iterator it = HS.iterator();
				  	while (it.hasNext()) 
				  	{
				  		int I=(Integer) it.next();
			            b[k][I]=1;
				  	}
				}
			}
			System.out.println(t>30 ? -1:t);
		}
	}
}

Measured memory_bytes: 83116
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2 << endl;
    } else {
        int64_t d1 = a + ((b - a) - 1) / 2;
        int64_t d2 = (n - b + 1) + (n - (a + n - b + 1)) / 2;

        cout << min(d1, d2) << endl;
    }
}

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

using LL = long long;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
 
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
// clang-format on

void solve(long long A, long long B) {
  // solver code

  for (int i = 1; i < 1010; i++) {
    int tax_A = i * 0.08;
    int tax_B = i * 0.1;

    if (tax_A == A && tax_B == B) {
      cout << i << endl;
      return;
    }
  }

  cout << -1 << endl;
}

int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(A, B);
  return 0;
}


Measured memory_bytes: 256