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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

int main() {
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int app[2] = {0, 0};
    fori(i, 1, n + 1) {
        if(i % k == 0) {
            app[0]++;
        }
        if(k % 2 == 0 && i % k == k / 2) {
            app[1]++;
        }
    }
    ll ans = 1LL * app[0] * app[0] * app[0] + 1LL * app[1] * app[1] * app[1];
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
def swap(dice,i,j,k,l):#diceの目をi→ｊ→ｋ→ｌ→iの順に入れ替える
    x=dice[l]
    dice[l]=dice[k]
    dice[k]=dice[j]
    dice[j]=dice[i]
    dice[i]=x
    return dice

def Sroll(dice):
    dice=swap(dice,0,1,5,4)
    return dice

def Eroll(dice):
    dice=swap(dice,0,2,5,3)
    return dice

def Wroll(dice):
    dice=swap(dice,0,3,5,2)
    return dice

def Nroll(dice):
    dice=swap(dice,0,4,5,1)
    return dice




dice=list(map(int,input().split()))
n=int(input())
for i in range(0,n):
    top,fro=map(int,input().split())
    for j in range(0,8):
        if(fro==dice[1]):
            break
        if(j==3):
            dice=Eroll(dice)
        dice=Sroll(dice)
    while(top!=dice[0]):
        dice=Eroll(dice)
    print(dice[2])


Measured memory_bytes: 5604
import java.util.*;
import java.io.*;

public class Main {	
	private static void solve(){
		//Implement solution here.
		int N = ni();
		int[] P = na(N);
		int min = P[0];
		int result = 1;
		for(int i = 1; i < N; i++) {
			min = Math.min(min, P[i]);
			if(P[i] <= min)result++;
		}
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 44516
n,v,u = map(int,input().split())
dist_taka = [100000 for i in range(n)]
dist_aoki = [100000 for i in range(n)]
dist_taka[v-1] = 0
dist_aoki[u-1] = 0
M = [[] for i in range(n)]
for i in range(n-1):
  a,b = map(int,input().split())
  M[a-1].append(b-1)
  M[b-1].append(a-1)
stack = []
check = [0]*n
for i in range(len(M[v-1])):
  stack.append([v-1,M[v-1][i]])
while len(stack) != 0:
  cur = stack.pop()
  check[cur[0]] = 1
  dist_taka[cur[1]] = dist_taka[cur[0]]+1
  for i in range(len(M[cur[1]])):
    if check[M[cur[1]][i]] == 0:
      stack.append([cur[1],M[cur[1]][i]])

check = [0]*n
for i in range(len(M[u-1])):
  stack.append([u-1,M[u-1][i]])
while len(stack) != 0:
  cur = stack.pop()
  check[cur[0]] = 1
  dist_aoki[cur[1]] = dist_aoki[cur[0]]+1
  for i in range(len(M[cur[1]])):
    if check[M[cur[1]][i]] == 0:
      stack.append([cur[1],M[cur[1]][i]])
ans = 0
for i in range(n):
  if dist_taka[i] < dist_aoki[i]:
    ans = max(ans,dist_aoki[i])
print(max(0,ans-1))

Measured memory_bytes: 81132
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
int main()
{
    int n = 0;
    cin>>n;
    string s;
    cin>>s;
    for(int i = 0; i < s.size(); i++){
        s[i] = (s[i] - 'A' + n) % 26 + 'A';
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
	f = 0; _T fu = 1; char c = getchar();
	while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
	while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
	f *= fu;
}

template <typename T>
void print(T x) {
	if (x < 0) putchar('-'), x = -x;
	if (x < 10) putchar(x + 48);
	else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
	print(x); putchar(t);
}

const int N = 2e5 + 5, M = 8e5 + 5;

struct edge_t { int u, v, next, cap, flow; } G[M];

vector <int> adj[N];
queue <int> q;
int head[N], nowhead[N], d[N];
int n, m, s, t, tot = 1;

inline void addedge(int u, int v, int cap) {
	G[++tot] = (edge_t) {u, v, head[u], cap, 0}, head[u] = tot;
	G[++tot] = (edge_t) {v, u, head[v], 0, 0}, head[v] = tot;
}

int bfs() {
	memset(d, 0, sizeof(d));
	d[s] = 1; q.push(s);
	while (!q.empty()) {
		int u = q.front(); q.pop();
		for (int i = head[u]; i; i = G[i].next) {
			int v = G[i].v;
			if (!d[v] && G[i].cap > G[i].flow) {
				d[v] = d[u] + 1;
				q.push(v);
			}
		}
	}
	return d[t];
}

int dfs(int u, int Flow) {
	if (u == t || !Flow) return Flow;
	int f, flow = 0;
	for (int &i = nowhead[u]; i; i = G[i].next) {
		int v = G[i].v;
		if (d[v] == d[u] + 1 && (f = dfs(v, min(Flow, G[i].cap - G[i].flow))) > 0) {
			G[i].flow += f; G[i ^ 1].flow -= f;
			flow += f; Flow -= f;
			if (!Flow) break;
		}
	}
	return flow;
}

int dinic() {
	int ans = 0;
	while (bfs()) {
		memcpy(nowhead, head, sizeof(nowhead));
		ans += dfs(s, 0x7fffffff);
	}
	return ans;
}

int fa[N], vis[N], match[N], cnt;

void dfs1(int u) {
	for (auto v : adj[u]) {
		if (!vis[match[v]]) {
			vis[match[v]] = 1;
			fa[match[v]] = u;
			++cnt;
			dfs1(match[v]);
		}
	}
}

int main() {
	read(n); s = 0; t = 2 * n;
	for (int i = 1; i < n; i++) {
		read(m);
		for (int j = 1; j <= m; j++) {
			int x; read(x);
			adj[i].push_back(x + n - 1);
			adj[x + n - 1].push_back(i);
			addedge(i, x + n - 1, 1);
		}
	}
	for (int i = 1; i < n; i++) addedge(s, i, 1);
	for (int i = n; i < 2 * n; i++) addedge(i, t, 1);
	if (dinic() != n - 1) {
		puts("-1");
		return 0;
	}
	int rt = 0;
	for (int i = head[n * 2]; i; i = G[i].next) {
		if (G[i].flow == 0) {
			rt = G[i].v;
			break;
		}
	}
	for (int u = 1; u < n; u++) {
		for (int i = head[u]; i; i = G[i].next) {
			int v = G[i].v;
			if (n <= v && v < n * 2 && G[i].flow) match[u] = v;
		}
	}
	vis[rt] = 1; dfs1(rt);
	if (cnt != n - 1) {
		puts("-1");
		return 0;
	}
	for (int i = 1; i < n; i++) {
		print(match[i] - n + 1, ' ');
		print(fa[match[i]] - n + 1, '\n');
	}
	return 0;
}

Measured memory_bytes: 38824
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

vector<int> PrimeFactorization(int n) {
    vector<int> factors(n + 1, 0);
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            n /= i;
            factors[i]++;
        }
    }
    if (n > 1) factors[n]++;
    return factors;
}

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

    vector<int> factors(N + 1, 0); 
    for (int i = N; i > 1; i--) {
        vector<int> f = PrimeFactorization(i);
        REP(j, 0, i + 1) {
            factors[j] += f[j];
        }
    }
    
    ll ans = 1;
    for (auto f : factors) {
        ans = (ans * (f + 1)) % MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr ll mod = 1000000007;

constexpr ll maxn = 100001;

ll m13[maxn];
ll dp[maxn][13];

int main() {
    m13[0] = 1;
    for (int i = 1; i < maxn; i++) m13[i] = (m13[i - 1] * 10) % 13;
    string s;
    cin >> s;
    dp[0][0] = 1;
    for (int i = 1; i <= s.length(); i++) {
        int w = m13[s.length() - i];
        if (s[i-1] == '?') {
            for (int t = 0; t < 10; t++) {
                for (int j = 0; j < 13; j++) {
                    dp[i][(j + t * w) % 13] = (dp[i][(j + t * w) % 13] + dp[i - 1][j]) % mod;
                }
            }
        } else {
            int t = s[i-1] - '0';
            for (int j = 0; j < 13; j++) {
                dp[i][(j + t * w) % 13] = dp[i - 1][j];
            }
        }
    }
    cout << dp[s.length()][5] << endl;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

vi32 prime_list(i32 n) {
  vi32 primes;
  vector<bool> f(n, true);
  f[0] = f[1] = false;
  repi(i, 2, n) {
    if (!f[i]) continue;
    primes.push_back(i);
    for (int j = i * 2; j < n; j += i) {
      f[j] = false;
    }
  }
  return primes;
}

void solve() {
  auto primes = prime_list(1000000);
  i64 N, P; cin >> N >> P;
  map<i64, i64> ma;
  {
    i64 p = P;
    each(pri, primes) {
      while (p % pri == 0) p /= pri, ma[pri]++;
    }
    if (p != 1) ma[p]++;
  }
  map<i64, i64> re;
  each(m, ma) {
    re[m.first] = m.second / N;
  }
  i64 ans = 1;
  each(r, re) {
    ans *= power(r.first, r.second);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 1020
def backtrack(nums, N, cur_state, result):
    if len(cur_state) == N:
        result.append(cur_state[:])
    else:
        for i in range(len(nums)):
            cur_state.append(nums[i])
            backtrack(nums[i:], N, cur_state, result)
            cur_state.pop()

def solve():
    N,M,Q = [int(i) for i in input().split()]
    quads = []
    for i in range(Q):
        quads.append([int(i) for i in input().split()])
    candidates = []
    backtrack(list(range(1, M+1)), N, [], candidates)

    ans = 0
    for candidate in candidates:
        score = 0
        for a,b,c,d in quads:
            if candidate[b-1] - candidate[a-1] == c:
                score += d
        ans = max(score, ans)
    print(ans)

if __name__ == "__main__":
    solve()

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

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

	int current_t = 0;
	int num = 0;
	current_t += a;

	while(current_t <= t){
		num += b;
		current_t += a;
	}

	cout << num << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    ll n;
    cin>>n;
    lvec h(n);
    rep(i,n) cin>>h[i];
    ll ans=0,cnt=0;
    rep(i,n-1){
        if(h[i]<h[i+1]){
            if(cnt>ans){
                ans=cnt;
            }
            cnt=0;
        }
        else cnt++;
    }
    if(cnt>ans) ans=cnt;
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  string s; cin>>s;
  for(int i=0; i<5; i++){
    cout<<s[i];
  }
  cout<<" ";
  for(int i=6; i<13; i++){
    cout<<s[i];
  }
  cout<<" ";
  for(int i=14; i<19; i++){
    cout<<s[i];
  }
  cout<<endl;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
last_num = 2
ans_count = 0
while last_num < n:
	if p[last_num - 2] < p[last_num - 1] and p[last_num - 1] < p[last_num]:
		ans_count += 1
	elif  p[last_num - 2] > p[last_num - 1] and p[last_num - 1] > p[last_num]:
		ans_count += 1
	last_num += 1
print(ans_count)

Measured memory_bytes: 3060
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

######################################################

N=intput()
data1=[]
data2=[]
for _ in range(N):
    x,y,h=mint()
    if h>0:
        data1.append([x,y,h])
    else:
        data2.append([x,y])
for cx,cy in product(range(0,101),repeat=2):
    sup=INF
    for x,y in data2:
        sup=min(sup,abs(x-cx)+abs(y-cy))
    x,y,h=data1[0]
    H=abs(x-cx)+abs(y-cy)+h
    tmp=True
    for x,y,h in data1[1:]:
        if abs(x-cx)+abs(y-cy)+h!=H:
            tmp=False
            break
    if tmp and H<=sup:
        print(cx,cy,H)
        exit()

Measured memory_bytes: 74808
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
c = Counter(s)
a = max([c[i] for i in set(s)])
r = []
for i in set(s):
    if c[i] >= a:
        r.append(i)
r.sort()
[print(i) for i in r]


Measured memory_bytes: 46052
s=input()
K=int(input())
N=len(s)

A=[]

for i in range(N):
    for j in range(K):
        r=i+j+1
        if r>N:
            break
        A.append(s[i:r])
        
AA=list(set(A))
AA.sort()
print(AA[K-1])




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

void solve(long long N)
{
    vector<int> v;

    while (N > 0) {
        int m = N % 26;
        if (m != 0) {
            v.push_back(m);
            N /= 26;
        } else {
            v.push_back(26);
            N = N / 26 - 1;
        }
        
    }

    reverse(v.begin(), v.end());

    for (auto it = v.begin(); it != v.end(); it++) {
        char c = 'a' + (*it - 1);
        cout << c;
    }
    cout << endl;
}

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


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

int main() {
    int i, j, k, n;
    vector<int> dp(3);
    vector<int> newdp(3);
    vector<int> act(3);
    cin >> n;
    for(i=0; i<n; i++) {
        for(j=0; j<3; j++) {
            cin >> act[j];
            newdp[j] = 0;
        }
        // choose jth activite
        for(j=0; j<3; j++) {
            for(k=0;k<3;k++) {
                if(j != k) {
                    newdp[j] = max(newdp[j], dp[k]+act[j]);
                }
            }
        }
        dp = newdp;
    }
    for(i=0;i<3;i++) {
        if(dp[0] < dp[i])
            dp[0] = dp[i];
    }
    cout << dp[0] << endl;
    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);
		int player = sc.nextInt();
		int[][] n = new int[player][3];
		int[][] flag = new int[player][3];

		int[] score = new int[player];
		int cnt = 0;
		int buf = 0;
		for(int i = 0;i < player;i++){
			for(int j = 0;j < 3;j++){
				n[i][j] = sc.nextInt();
				flag[i][j] = 1;
			}
		}
		for(int i = 0;i < player;i++){
			for(int j = 0;j < 3;j++){
				for(int k = i+1;k < player;k++){
					if(n[i][j] == n[k][j]){
						flag[i][j] = 0;
						flag[k][j] = 0;
					}
				}
			}
		}
		for(int i = 0;i < player;i++){
			for(int j = 0;j < 3;j++){
			//	System.out.print(flag[i][j]+":");
				n[i][j] = n[i][j] * flag[i][j];
			}
			//System.out.println();
		}

		for(int i = 0;i < player;i++){
			for(int j = 0;j < 3;j++){
				score[i] = score[i]+n[i][j];
			}
		}
		for(int i = 0;i < player;i++){
			System.out.println(score[i]);
		}


	}
}

Measured memory_bytes: 28548
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
vector<int>v[100100];
int n,m,siz[100100],Ans;
inline void dfs(int x,int fa){
	siz[x]=1;
	for(int i=0;i<v[x].size();i++)
	  if(v[x][i]!=fa){
	  	dfs(v[x][i],x);
	  	siz[x]=max(siz[x],siz[v[x][i]]+1);
	  }
	if(fa!=1&&siz[x]==m)siz[x]=0,Ans++;
}
int main(){
    int i,j,k;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++){
      int x;
      scanf("%d",&x);
      if(i==1&&x!=1)Ans=1;
      if(i>1)v[x].push_back(i),v[i].push_back(x);
    }
    for(i=0;i<v[1].size();i++)dfs(v[1][i],1);
    printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 9984
#include<bits/stdc++.h>
#define mod 1000000007;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
using namespace std;
int main()
{
	fast_io;
	int m,d;
	li c=0,i,j,x;
	cin>>m>>d;
	li a=min(m/2,9);
	li b=min(m/2,d/10);
	for(x=4;x<=m;x++)
	{a=min(m/2,9);
		for(i=2;i<=b;i++)
	{if(i==b)
	 a=d%10;
	for(j=2;j<=a;j++)
	{
		if((i*j==x))
	    {c++;
	    break;
	    }
	}
	}
	}
	cout<<c;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	
	int r,c,a[100][100],yoko[100]={0},tate[100]={0},total=0,i,j;
	cin>>r>>c;
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			cin>>a[i][j];
			total += a[i][j];
			yoko[i] += a[i][j];
			tate[j] += a[i][j];
		}
	}
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			cout<<a[i][j]<<" ";
			if(j==c-1){
				cout<<yoko[i]<<endl;
			}
		}
	}
	for(int k=0;k<c;k++){
			cout<<tate[k]<<" ";
		}
	cout<<total<<endl;		
			
	return 0;
}

Measured memory_bytes: 3104
program Project1;
         
    {$APPTYPE CONSOLE}
         
    uses
      SysUtils;
    var
      a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,min:Integer;
      l:array of string;
      s,s123,s1,s2,s3:string;
      al:string = 'abcdefghijklmnopqrstuvwxyz';
      tf,tfl,tfr:Boolean;
    begin
      try
        { TODO -oUser -cConsole メイン : ここにコードを記述してください }
        Readln(a);
        count:=0;
        max  :=0;
        min  :=100;
     
        if a=2 then begin
          Writeln('No');
          Readln;
          exit;
        end;
        
        SetLength(l,a);
        for i := 0 to a-1 do begin
          Readln(l[i]);
          if not((i=0)or(i=a-1)) then begin
            if l[i-1][Length(l[i-1])]<>l[i][1] then begin
              //Writeln(l[i-1][Length(l[i-1])]);
              //Writeln(l[i][1]);
              Writeln('No');
              Readln;
              exit;
            end;     
          end;
        end;
     
        for i := 0 to a - 2 do
          for j := i to a - 2 do begin
            if l[i]=l[j+1] then begin
              Writeln('No');
              Readln;
              exit;
            end;
          end;
     
        Writeln('Yes');
        Readln;
      except
        on E: Exception do
          Writeln(E.ClassName, ': ', E.Message);
      end;
    end.

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

int main() {
    unordered_map<int, int> mp;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (mp.find(a) == mp.end())
            mp[a]++;
        else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 8520
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;

int main(){

  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  vector<int> w(31, 0);
  w[0] = 1;
  for (int i = 0; i < 31; i++){
    if (w[i] == 1) {
      if (i+a < 31) w[i+a] = 1;
      if (i+b < 31) w[i+b] = 1;
    }
  }
  vector<int> s(1501, 0);
  s[0] = 1;
  for (int i = 0; i < 1501; i++){
    if (s[i] == 1){
      if (i+c < 1501) s[i+c] = 1;
      if (i+d < 1501) s[i+d] = 1;
    }
  }

  double m = 0;
  int mw = a * 100;
  int ms = 0;
  for (int i = 1; i < 31; i++) {
    if (w[i] == 0) continue;
    for (int j = 0; j < 1501; j++) {
      if (i * 100 + j > f) break;
      if (j > i * e) break;
      if (s[j] == 0) continue;
      double v = (double) 100 * j / (i*100+j);
      if (v > m) {
        m = v;
        mw = i * 100;
        ms = j;
      }
    }
  }


  printf("%d %d\n", mw+ms, ms);

  return 0;
}


Measured memory_bytes: 256
import sys
from operator import itemgetter
input = sys.stdin.readline
N = int(input())
tasks = [tuple(map(int, input().split())) for _ in range(N)]
tasks.sort(key=itemgetter(1))
start = 0

for task in tasks:
    if start + task[0] > task[1]:
        print('No')
        sys.exit()
    start += task[0]

print('Yes')

Measured memory_bytes: 31864
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<int>;


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

	vec yama(N, 0);
	vec mizu(N, 0);

	for (int i = 0; i < N; ++i)cin >> mizu[i];

	for (int i = 1; i <= N / 2; ++i)
	{
		yama[i] =  mizu[i-1] - yama[i - 1];
	}

	for (int i = N - 1; i > N / 2; --i)
	{
		yama[i] = mizu[i] - yama[(i + 1) % N];
	}

	yama[0] = mizu[N / 2] - (yama[N / 2] + yama[N / 2 + 1]);
	yama[0] = abs(yama[0]);
	yama[0] /= 2;

	
	for (int i = 1; i <= N / 2; ++i)
	{
		if (i % 2 == 1)
			yama[i] -= yama[0];
		else
			yama[i] += yama[0];
	}

	for (int i = N - 1; i > N / 2; --i)
	{
		if (i % 2 == 0)
			yama[i] -= yama[0];
		else
			yama[i] += yama[0];
	}
	
	for (int i = 0; i < N; ++i)
	{
		cout << 2*yama[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,l[ohara],r[ohara];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n)cin>>l[i]>>r[i];
    //0から0の範囲を初期と最後原点に戻る行為としてとらえる
    sort(l,l+n+1);
    reverse(l,l+n+1);
    sort(r,r+n+1);
    rep(i,n+1){
        ans+=max(l[i]-r[i],0LL)*2;
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

using ll = long long;

int f(ll a, ll b) {
	return max(to_string(a).size(), to_string(b).size());
}

int main() {
	ll n; cin >> n;
	int ans = 10;
	for (ll i = 1; i*i <= n; i++) {
		if (n%i == 0) ans = min(ans, f(i, n / i));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#include<queue>
#define ll long long
int main()
{
	int a,b,c;
	int k;
	int temp;
	cin>>a>>b>>c>>k;
	for(;k>0&&b<=a;k--)
	{
		b*=2;
	}
	for(;k>0&&c<=b;k--)
	{
		c*=2;
	}
	if(c>b&&b>a&&k>=0)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Edge {
  const int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

vector<vector<Edge>> ReadDirectedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(Edge({v1, v2}));
  }
  return graph;
}

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

  int n, m;
  cin >> n >> m;
  auto graph = ReadDirectedGraph(n, m, true);

  vector<int> shortest_cycle;
  auto process_root_fn = [&](int r) {
    deque<int> queue;
    queue.push_back(r);
    vector<int> ds(n, INT_MAX);
    vector<int> ps(n, -1);
    ds[r] = 0;
    while (!queue.empty()) {
      int v = queue.front();
      queue.pop_front();
      for (const auto& e : graph[v]) {
        if (e.to == r) {
          int c = v;
          vector<int> cycle({c});
          while (true) {
            c = ps[c];
            cycle.push_back(c);
            if (c == r) break;
          }
          if (shortest_cycle.empty()
              || cycle.size() < shortest_cycle.size()) {
            shortest_cycle = cycle;
          }
        }
        if (ds[e.to] < INT_MAX) continue;
        ds[e.to] = ds[v] + 1;
        ps[e.to] = v;
        queue.push_back(e.to);
      }
    }
  };

  for (int r = 0; r < n; r++) {
    process_root_fn(r);
  }

  if (shortest_cycle.empty()) {
    cout << -1 << endl;
  } else {
    cout << shortest_cycle.size() << endl;
    for (int v : shortest_cycle) {
      cout << v + 1 << endl;
    }
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans=0;
	string s;
	cin>>n>>s;
	for(int i=2;i<n;i++)
	{
		if(s[i]=='C'&&s[i-1]=='B'&&s[i-2]=='A')ans++;
	}
	cout<<ans;
	return 0;
}


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

int main(){
   std::string S, T;
   std::cin >> S >> T;
   int cnt = 0;
   for (int i=0; i<S.size(); i++){
      if (S.at(i) != T.at(i)){
         cnt++;
      }
   }
   std::cout << cnt << std::endl;
}


Measured memory_bytes: 3912
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#define INF 0x3f3f3f3f;

using namespace std;

string s[200005];

bool cmp(string a,string b) {
        return a.compare(b)<0;
}

int main() {
    int n,i;
    scanf("%d",&n);
    for(i=0; i<n; i++)
        cin>>s[i];
    sort(s,s+n,cmp);
    int m=1,cnt=1;
    for(i=1; i<n; i++) {
        if(s[i].compare(s[i-1])==0)
            cnt++;
        else
            cnt=1;
        m=max(cnt,m);
    }
    cnt=1;
    if(m==1)
        cout<<s[0]<<endl;
    for(i=1; i<n; i++) {
        if(s[i].compare(s[i-1])==0)
            cnt++;
        else
            cnt=1;
        if(cnt==m)
            cout<<s[i]<<endl;
    }
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<string> U(N);
  for (int i = 0; i < N; i++){
    cin >> U[i];
  }
  bool lock = true;
  int M;
  cin >> M;
  for (int i = 0; i < M; i++){
    string T;
    cin >> T;
    bool ok = false;
    for (int j = 0; j < N; j++){
      if (T == U[j]){
        ok = true;
      }
    }
    if (ok){
      if (lock){
        cout << "Opened by " << T << endl;
        lock = false;
      } else {
        cout << "Closed by " << T << endl;
        lock = true;
      }
    } else {
      cout << "Unknown " << T << endl;
    }
  }
}


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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int cnt = 0;
    if (i % 2 == 0) continue;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) cnt++;
    }
    if (cnt == 8) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll N;
    cin>>N;
    ll wamax=0, wamin=2000000000, samax=-10000000000, samin=10000000000;
    rep(i, N){
        ll x, y;
        cin>>x>>y;
        wamax=max(wamax, x+y);
        samax=max(samax, x-y);
        samin=min(samin, x-y);
        wamin=min(wamin, x+y);
    }
    cout<<max(wamax-wamin, samax-samin)<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

int main(){
	int N,K;
	cin >> N >> K;
	int H[N];
	for(int i=0;i<N;i++){
		cin >> H[i];
	}

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

	dp[0]=0;
	for(int i=1;i<N;i++){
		int minCost=-1;
		for(int k=1;k<=K;k++){
			if(i-k>=0){
				int cost=abs(H[i]-H[i-k])+dp[i-k];
				if(minCost==-1 || cost<minCost){
					minCost=cost;
				}
			}
		}
		dp[i]=minCost;
	}
	cout << dp[N-1] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
using namespace std;

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

    string a, b, c; cin >> a >> b >> c;
    int al = a.length();
    int bl = b.length();
    int cl = c.length();

    auto f = [](char c1, char c2) {
        return c1 != '?' && c2 != '?' && c1 != c2;
    };

    vector<bool> ab(al+bl+cl*2+1);
    vector<bool> ac(al+bl*2+cl+1);
    vector<bool> bc(al*2+bl*3+cl*3+1);
    for (int i = 0; i < al; i++) {
        for (int j = 0; j < bl; j++)
            if (f(a[i], b[j])) ab[i-j+bl+cl] = true;
        for (int k = 0; k < cl; k++)
            if (f(a[i], c[k])) ac[i-k+bl+cl] = true;
    }
    for (int j = 0; j < bl; j++) {
        for (int k = 0; k < cl; k++) {
            if (f(b[j], c[k]))
                bc[j-k+al+bl+cl*2] = true;
        }
    }

    int ans = al + bl + cl;
    for (int x = -(bl+cl); x <= al+cl; x++) {
        for (int y = -(bl+cl); y <= al+bl; y++) {
            if (ab[x+bl+cl]) continue;
            if (ac[y+bl+cl]) continue;
            if (bc[y-x+al+bl+cl*2]) continue;
            int l = min(0, min(x, y));
            int r = max(al, max(bl+x, cl+y));
            ans = min(ans, r - l);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 384
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b, c, d = M()
print(max(min(b, d) - max(a, c), 0))

Measured memory_bytes: 74548
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string>
 
using namespace std;
typedef long long ll;


int main()
{
	int N;
	int X[100];
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%d", &X[i]);
	}
	
	ll min = 999999999;
	for(int i = 1; i <= 100; i++){
		int sum = 0;
		for(int j = 0; j < N; j++){
			sum += (X[j]-i)*(X[j]-i);
		}
		if(sum < min){
			min = sum;
		}
	}
	
	printf("%lld\n", min);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <complex>
#include <vector>
#include <iomanip>
#include <cassert>
using namespace std;

typedef complex<double> P;
#define REP(i,n) for(int i=0; i<n; ++i)
#define EPS 1e-12

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}

P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}

bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}

double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}

P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}

P rotateP(P a, P b, double rad)
{
	double x0=a.real(), x=b.real();
	double y0=a.imag(), y=b.imag();
	double xx=x0+(x-x0)*cos(rad)-(y-y0)*sin(rad);
	double yy=y0+(x-x0)*sin(rad)+(y-y0)*cos(rad);
	
	return P(xx,yy);
}

P a[3], Cp[3];
double Cr[3];

bool putC(int n, L fl)
{
	double rad=arg( (a[(n+2)%3]-a[n]) / (a[(n+1)%3]-a[n]) );
	rad/=2.0;
	
	P d=rotateP(a[n], a[(n+1)%3], rad);	
	P c = crosspoint(fl, L(a[n], d));
	
	if(abs(a[n]-c) < EPS) c=d;
	
	P hi=c, lo=a[n], mi;
	while(abs(hi-lo) > EPS)
	{
		mi=(hi+lo)/2.0;
		double r=distanceSP(L(a[n], a[(n+1)%3]) , mi);
		if(abs(Cp[0]-mi) < r+Cr[0]) hi=mi;
		else lo=mi;
	}
	
	Cr[n]=distanceSP(L(a[n], a[(n+1)%3]), mi);
	Cp[n]=mi;
	
	if(n==2)
	{
		if(abs(Cp[2]-Cp[1]) > Cr[2]+Cr[1]) return false;
		return true;
	}
	
	return putC(n+1, fl);
}

int main()
{
	
	cout << setiosflags(ios::fixed) << setprecision(5);
	while(1)
	{
		bool e=true;
		REP(i,3)
		{
			double x,y;
			cin >> x >> y;
			
			a[i]=P(x,y);
			
			if(x||y) e=false;
		}
		if(e) break;
		
		double rad=arg( (a[2]-a[0]) / (a[1]-a[0]) );
		rad/=2.0;
		P d=rotateP(a[0], a[1], rad);
		
		double rad2=arg( (a[1]-a[2]) / (a[0]-a[2]) );
		rad2/=2.0;
		P g=rotateP(a[2], a[0], rad2);
		
		P c = crosspoint(L(a[2], g), L(a[0], d));
		if(abs(a[0]-c) < EPS) c=d;
		
		P hi=c, lo=a[0];
		while(abs(hi-lo) > EPS)
		{
			P mi=(hi+lo)/2.0;
			
			Cr[0]=distanceSP(L(a[0], a[1]), mi);
			Cp[0]=mi;
			
			bool ret=putC(1, L(a[0], c));
			
			if(!ret) hi=mi;
			else lo=mi;
		}
		cout << Cr[0] << " " << Cr[1] << " " << Cr[2] << endl;
	}
}

Measured memory_bytes: 1020
N, Ma, Mb = map(int, input().split())
e = [tuple(map(int, input().split())) for _ in range(N)]

N_max = 40
a_max = 10
b_max = 10
c_max = 100

inf = N_max * c_max + 1
dp = [[[inf for _ in range(N_max * b_max + 1)] for _ in range(N_max * a_max + 1)] for _ in range(N_max + 1)]
dp[0][0][0] = 0

# print(dp[N])

for i, (aa, bb, cc) in enumerate(e, 1):
    for a in range(a_max * i + 1):
        for b in range(b_max * i + 1):
            dp[i][a][b] = min(dp[i][a][b], dp[i - 1][a][b])
            if a + aa < N_max * a_max + 1 and b + bb < N_max * b_max + 1:
                dp[i][a + aa][b + bb] = min(dp[i][a + aa][b + bb], dp[i - 1][a][b] + cc)

# print(dp[N])

ans = inf
for a in range(N_max * a_max + 1):
    for b in range(N_max * b_max + 1):
        # a:b=Ma:Mb
        # b*Ma=a*Mb
        if b * Ma == a * Mb and a * b > 0:
            ans = min(ans, dp[N][a][b])

print(ans if ans < inf else -1)


Measured memory_bytes: 97372
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <functional>
#include <random>

using namespace std;

const int N = 1000;

int ind[N][N];

vector<pair<int, int>> apply(vector<pair<int, int>> v, int x) {
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            ind[i][j] = -1;
        }
    }
    vector<pair<int, int>> vecs;
    for (int i = 0; i * i <= x; i++) {
        for (int j = 0; j * j <= x; j++) {
            if (i * i + j * j == x) {
                vecs.push_back({-i, j});
                vecs.push_back({i, -j});
                vecs.push_back({i, j});
                vecs.push_back({-i, -j});
            }
        }
    } 
    int n = (int)v.size();
    for (int i = 0; i < n; i++) {
        ind[v[i].first][v[i].second] = i;
    }
    vector<vector<int>> g(n);
    for (int i = 0; i < n; i++) {
        int f, s;
        tie(f, s) = v[i];
        for (auto t : vecs) {
            int dx, dy;
            tie(dx, dy) = t;
            if (f + dx > N || f + dx < 0) continue;
            if (s + dy > N || s + dy < 0) continue;
            if (ind[f + dx][s + dy] != -1) {
                g[i].push_back(ind[f + dx][s + dy]);
            }
        }
    }
    vector<int> used(n);
    vector<int> cl(n);
    vector<int> lol(2);
    function<void(int, int)> dfs = [&](int cur, int c) {
        used[cur] = 1;
        cl[cur] = c;
        lol[c]++;
        for (auto t : g[cur]) {
            if (!used[t]) {
                dfs(t, c ^ 1);
            }
        }
    };
    for (int i = 0; i < n; i++) {
        if (!used[i]) {
            dfs(i, 0);
        }
    }
    int mx = 0;
    if (lol[1] > lol[0]) mx = 1;
    vector<pair<int, int>> tk;
    for (int i = 0; i < n; i++) {
        if (cl[i] == mx) {
            tk.push_back(v[i]);
        }
    }
    return tk;
}

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

    int n;
    cin >> n;
    n *= 2;
    int d1, d2;
    cin >> d1 >> d2;
    if (d1 % 2 < d2 % 2) {
        swap(d1, d2);
    }
    if (d2 % 2 == 1) {
        for (int i = 0; i < n; i += 2) {
            for (int j = 0; j < n; j += 2) {
                cout << i << ' ' << j << endl;
            }
        }
        exit(0);
    }
    vector<pair<int, int>> v;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (d1 % 2) {
                if ((i + j) % 2 == 0) {
                    v.push_back({i, j});
                }
            } else {
                v.push_back({i, j});
            }
        }
    }
    if (d1 % 2 == 0) {
        v = apply(v, d1);
    }
    v = apply(v, d2);
    for (int i = 0; i < n * n / 4; i++) {
        cout << v[i].first << ' ' << v[i].second << '\n';
    }
}   


Measured memory_bytes: 71532
N = int(input())
P = [int(input()) for _ in range(N)]
dp = [0]*N
for i in range(N):
    if P[i] == 1:
        dp[P[i]-1] = 1
    else:
        if dp[P[i]-2] == 0:
            dp[P[i]-1] = 1
        else:
            dp[P[i]-1] = dp[P[i]-2]+1
print(N-max(dp))

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

int main() {
	
	vector<int> coord(5);
	
	for(int i=0; i<5; i++){
		
		cin >>coord.at(i);
		
	}
	
	int k;
	cin >>k;
	
	if(coord.at(4)-coord.at(0)>k){
		
		cout <<":(" <<endl;
		
	}
	else{
		
		cout <<"Yay!" <<endl;
	
	}
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
  string s;
  cin >> s;
  rep(i,s.length())
  {
    if(i%2 == 0) //guusu
    {
      if(s[i] == 'L')
      {
        cout << "No";
        return 0;
      }
    }
    else//kisuu
    {
            if(s[i] == 'R')
      {
        cout << "No";
        return 0;
      }
    }
  }
          cout << "Yes";
        return 0;
  
}




Measured memory_bytes: 256
lines = readlines.map{|line| line.split(' ').map(&:to_i)}
a=0
b=lines[0][0]
for i in 0..lines[0][0]-1
  f=0
  b = b <= lines[1][i] ? b : lines[1][i]
  if b>=lines[1][i] then
    a=a+1
  end
end
puts a

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

int main() {
    int N, Q;
    string S;
    cin >> N >> Q >> S;

    vector<int> l(Q), r(Q);
    rep(i, Q) cin >> l[i] >> r[i];

    vector<int> sum(N + 1, 0);
    for (int i = 1; i < N; i++) {
        if (S[i - 1] == 'A' && S[i] == 'C') {
            sum[i + 1] = sum[i] + 1;
        } else sum[i + 1] = sum[i];
    }
    
    rep(i, Q) {
        int ans = sum[r[i]] - sum[l[i]];
        cout << ans << endl;
    }
}

Measured memory_bytes: 2176
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;


int main()
{
	double x1, x2, y1, y2, D;
	cin >> x1 >> y1 >> x2 >> y2;
	D = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
	printf("%f\n", D);

    return 0;
}


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

int main(){
  int n;
  int a[100],b[100];
  long long dp[101][101];

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

  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++)dp[i][j] = 1e10;
  }

  for(int i=0;i<n;i++)dp[i][i+1] = 0;

  for(int len = 1;len<=n;len++){
    for(int l=0;l+len<=n;l++){
      int r = l + len;
      for(int m=l+1;m<r;m++){
	dp[l][r] = min(dp[l][r], dp[l][m] + dp[m][r] + a[l]*b[m-1]*a[m]*b[r-1]);
      }
    }
  }

  cout << dp[0][n] << endl;
}

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

using namespace std;

using ll = long long;

int main() {
    ll H, W; cin >> H >> W;
    ll x1, x2, y1, y2;

    if (H == 1 || W == 1) {
        cout << 1 << endl;
        return 0;
    }
    
    if (H % 2 == 1) {
        y1 = floor(H / 2) + 1;
        y2 = floor(H / 2); 
    } else if (H % 2 == 0) {
        y1 = H / 2;
        y2 = H / 2;
    }

    if (W % 2 == 1) {
        x1 = floor(W / 2) + 1;
        x2 = floor(W / 2);
    } else if (W % 2 == 0) {
        x1 = W / 2;
        x2 = W / 2;
    }

    cout << x1 * y1 + x2 * y2 << endl;

    return 0;

}

Measured memory_bytes: 256
n, k = map(int, input().split())
heights = []
for _ in range(n):
    heights.append(int(input()))

heights.sort()

ans = float('inf')
for i in range(len(heights)):
    if i + k - 1 >= len(heights):
        break
    ans = min(ans, heights[i + k - 1] -  heights[i])

print(ans)


Measured memory_bytes: 7384