akhauriyash/Code-Regression huggingface dataset:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N, K = getNM()
query = [getList() for i in range(N - 1)]

dist = [[] for i in range(N)]
for a, b in query:
    dist[a - 1].append(b - 1)
    dist[b - 1].append(a - 1)

fact =[1] #階乗
for i in range(1, K + 1):
    fact.append(fact[i - 1] * i % mod)

facv = [0] * (K + 1) #階乗の逆元
facv[-1] = pow(fact[-1], mod - 2 , mod)

for i in range(K - 1, -1, -1):
    facv[i] = facv[i + 1] * (i + 1) % mod

def cmb(n, r):
    if n < r:
        return 0
    return fact[n] * facv[r] * facv[n - r] % mod

max_root = 0
max_root_index = 0
for i in range(N):
    if len(dist[i]) >= max_root:
        max_root = len(dist[i])
        max_root_index = i

pos = deque([max_root_index])

ans = 1
ignore = [-1] * N
ignore[max_root_index] = 1
ans *= cmb(K, max_root + 1) * math.factorial(max_root + 1)

while len(pos) > 0:
    u = pos.popleft()
    for i in dist[u]:
        if ignore[i] == -1:
            ignore[i] = 1
            if len(dist[i]) >= 2:
                ans *= cmb(K - 2, len(dist[i]) - 1) * math.factorial(len(dist[i]) - 1)
                ans %= mod
            pos.append(i)

print(ans % mod)

Measured memory_bytes: 120612
#include <iostream>
#include <numeric>

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;
int main(void){
    int n;
    cin >> n;
    int mon[n];
    for(int i=0;i<n;i++){
        cin >> mon[i];
    }
    int ok=0;
    while(ok==0){
        int minm=1000000001;
        int mini=0;
        for(int i=0;i<n;i++){
            if(minm>mon[i] && mon[i]!=0){
                minm=mon[i];
                mini=i;
            }
        }
        for(int i=0;i<n;i++){
            if(i!=mini){
                mon[i]%=mon[mini];
            }
        }
        int sum=accumulate(mon, mon + SIZE_OF_ARRAY(mon), 0);
        if(mon[mini]==sum){
            cout << mon[mini] << endl;
            ok=1;
        }
    }
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int a[55],b[55],c[55],d[55],n,m,q,A[55],ans=0;
void dfs(int step,int pre){
    if(step==n){
        int sum=0;
        for(int i=0;i<q;i++){
            if(A[b[i]]-A[a[i]]==c[i])
                sum+=d[i];}
        ans=max(ans,sum);
        return ;
    }
    for(int i=pre;i<=m;i++){
        A[step]=i;
        dfs(step+1,i);
    }
}
int main(){
    cin>>n>>m>>q;
    for(int i=0;i<q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        --a[i];--b[i];
    }
    dfs(0,1);
    cout<<ans;
    return 0;}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<ll>
#define vvint vector<vint>
#define P pair<ll,ll>
#define INT_MAX 2147483647
#define MOD 998244353
#define PI 3.14159265358979323846
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

#define MAX 1000000000000


int main(void) {
	string s; cin >> s;
	char bf=' ';
	bool flag = false;
	int cnt = 0;
	rep(i, s.size()) {
		if (flag) {
			cnt++;
			flag = false;
			continue;
		}
		if(s[i] == bf) {
			bf = ' ';
			flag = true;
		}
		else {
			bf = s[i];
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18;
const int iINF=1e9,MOD=1e9+7;
int mh[4]={1,0,-1,0},mw[4]={0,1,0,-1};

int main(){
    ll a,b;
    cin>>a>>b;
    vector<ll>k;
    unordered_map<ll,ll>mp;
    if(a==1||b==1){
        cout<<1<<endl;
        return 0;
    }
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            mp[i]++;
            mp[a/i]++;
        }
    }
    for(ll i=1;i*i<=b;i++){
        if(b%i==0){
            if(mp[i]!=0){
                k.push_back(i);
            }
            if(mp[b/i]!=0){
                k.push_back(b/i);
            }
        }
    }
    sort(all(k));
    for(ll i=1;i<k.size();i++){
        for(ll j=i+1;j<k.size();j++){
            if(k[j]%k[i]==0){
                k.erase(k.begin()+j);
                j--;
            }
        }
    }
    cout<<k.size()<<endl;
}



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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = TEN(6) + 3;
const int MX = MOD + 10;
ll inv[MX], fact[MX], ifact[MX];

ll powmod(ll x, ll k) {
	ll res = 1;
	for (; k; k /= 2, x = x * x % MOD) {
		if (k & 1) {
			res = res * x % MOD;
		}
	}
	return res;
}

void init() {
    inv[1] = 1;
    for (int i = 2; i < MX; ++i) {
        inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
    }
    fact[0] = ifact[0] = 1;
    for (int i = 1; i < MX; ++i) {
        fact[i] = fact[i-1] * i % MOD;
        ifact[i] = ifact[i-1] * inv[i] % MOD;
    }
}

ll comb(int n, int r) {
    if (n < 0 || r < 0 || r > n) return 0;
    return fact[n] * ifact[r] % MOD * ifact[n - r] % MOD;
}

int main() {
	init();
	int Q; scanf("%d", &Q);
	rep(i, Q) {
		int x, d, n;
		scanf("%d%d%d", &x, &d, &n);
		ll ans;
		if (d == 0) {
			ans = powmod(x, n);
		} else if (n >= MOD) {
			ans = 0;
		} else {
			ll a = powmod(d, MOD-2) * x % MOD;
			if (a + n-1 >= MOD) {
				ans = 0;
			} else {
				ans = fact[a + n - 1] * ifact[a - 1] % MOD;
				ans = ans * powmod(d, n) % MOD;
			}
		}

		printf("%lld\n", ans);
	}

	return 0;
}

Measured memory_bytes: 24320
def trick_or_treat():
    condition = input()
    c_list = condition.split()
    N = int(c_list[0])
    K = int(c_list[1])
    get_list = []
    for k in range(0, K):
        d = int(input())
        A_str = input()
        A_list_s = A_str.split()
        #A_list = []
        for i in A_list_s:
            #A_list.append(int(i))
            get_list.append(int(i))
    
    get_list.sort()
    sunuke_list = []
    for i in range(1, N+1):
        sunuke_list.append(i)
    
    get_list = list(set(get_list))
    num = len(sunuke_list) - len(get_list)
    print(num)
    return      

trick_or_treat()

Measured memory_bytes: 9232
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;


int main()
{
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    int before = -1;
    int score = 0;
    vector<int> a;
    for (int i = 0; i < n; i++) {
        if (s[i] == s[i+1]) {
            score++;
        }
    }
    int res = min(score + 2 * k, n - 1);
    cout << res << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;


int main() {
	int a, b, c; cin >> a >> b >> c;
	if (a + b + c > 21) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}
	return 0;
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);


#define kr f++,cout << "TBD" << endl;

int f;
string s;

main() {
    cin >> s;
    if (s[0]-'0' > 2) kr
    else if (s[0]-'0' == 2) {
        if (s[1]-'0') kr
        else {
            if (s[2]-'0' > 1) kr
            else if (s[2]-'0' == 1) {
                if (s[3]-'0' == 9) {
                    if (s[5]-'0') kr
                    else {
                        if (s[6]-'0' > 4) kr
                        else if (s[6]-'0' == 4) {
                            if (s[8]-'0' == 3) {
                                if (s[9]-'0') kr
                            }
                        }
                    }
                }
            }
        }
    }
    if (!f) cout << "Heisei" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    vi list;
    int chk=6;
    int n;

    for(chk=1; chk*7-1<300000 ; chk++){
        bool t=true;
        int n=chk*7-1;
        REP(i, list.size()){
                if(n%list[i]==0){
                    t=false;
                    break;
                }
        }
        if(t)
            list.push_back(n);
        t=true;
        n=chk*7+1;
        REP(i, list.size()){
                if(n%list[i]==0){
                     t=false;
                     break;
                }
        }
        if(t)
            list.push_back(n);
    }

    while(cin >> n, n != 1){
        printf("%d:",n);
        REP(i, list.size()){
            if(n%list[i]==0)
                printf(" %d",list[i]);
        }
        puts("");
    }

    return 0;
}

Measured memory_bytes: 1328
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

const int MOD = 1000000007;

struct Edge {
    int to;
    int weight;

    Edge(int t, int w) : to(t), weight(w) {}
};

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

    vector<int> X(N);
    vector<int> Y(N);
    for (int i = 0; i < N; ++i) {
        cin >> X[i];
        Y[i] = X[i];
    }

    sort(begin(Y), end(Y));

    for (int i = 0; i < N; ++i) {
        if (X[i] < Y[N/2]) cout << Y[N/2] << endl;
        else cout << Y[N/2-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-7
//#define endl "\n"
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; 

int main() 
{
    fastio
    ll k;
    cin>>k;
    ull sum = 0;
    for(int i = 1; i<=k; ++i)
        for(int j = 1; j<=k; ++j)
            for(int l = 1; l<=k; ++l)
                sum += __gcd(__gcd(i, j), l);

    cout<<sum<<endl;
}


Measured memory_bytes: 3652
import Control.Applicative
import Control.Monad

myGCD :: Int -> Int -> Int -> (Int, Int)
myGCD a b c
  | b == 0    = (a, c)
  | otherwise = myGCD b (a `mod` b) (c + 1)


solver :: Int -> Int -> String
solver a b = show x ++ " " ++ show y
  where (x, y) = if a > b then myGCD a b 0 else myGCD b a 0

main :: IO()
main = do
  (a:b:_) <- map (read :: String -> Int) . words <$> getLine
  unless (a == 0 && b == 0) $ do
    putStrLn $ solver a b
    main

Measured memory_bytes: 4104
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  vector<ii> b(m);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &b[i].second, &b[i].first);
  }
  sort(b.begin(), b.end(), greater<ii>());
  vector<int> c(n);
  for (int i = 0, k = 0; i < m && k < n; ++i) {
    int len = min(n - k, b[i].second);
    while (len--) c[k++] = b[i].first;
  }
  int64 ret = 0;
  for (int i = 0; i < n; ++i) {
    ret += max(a[i], c[i]);
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
	os << "[ "; for(auto v : V) os << v << " "; return os << "]";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1> void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << endl;
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1<<" | ";
	__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define mems(x, y) memset(x, y, sizeof(x))
#define rep(i, n) for (int i = 0; i < n; ++i)
#define irep(i, n) for (int i = 1; i <= n; ++i)
#define print(x) cout << x << '\n'
#define err(x) clog << x << '\n'
typedef long long ll;
#define int ll
typedef long double ld;
#define double ld
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 0x3f3f3f3f;
//const int M = 1e9+7;
const int N = 1e5+5;

int M;
vi t[N];
int f[N], g[N];

void df(int v, int p) {
	for (int u: t[v]) if (u != p) df(u, v);
	f[v] = 1;
	for (int u: t[v]) if (u != p) f[v] *= f[u]+1, f[v] %= M;
}

void dg(int v, int p) {
	int n = t[v].size();
	int pre[n+1], suf[n+1];
	pre[0] = suf[0] = 1;
	rep(i, n) {
		int u = t[v][i];
		if (u == p) pre[i+1] = pre[i];
		else pre[i+1] = pre[i] * (f[u]+1), pre[i+1] %= M;
	}
	rep(i, n) {
		int u = t[v][n-1-i];
		if (u == p) suf[i+1] = suf[i];
		else suf[i+1] = suf[i] * (f[u]+1), suf[i+1] %= M;
	}
	rep(i, n) {
		int u = t[v][i];
		if (u != p) g[u] = pre[i] * suf[n-1-i] % M * (g[v] + 1) % M;
	}
	for (int u: t[v]) if (u != p) dg(u, v);
}

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

	int n; cin >> n >> M;
	rep(i, n-1) {
		int x, y; cin >> x >> y;
		t[x].pb(y); t[y].pb(x);
	}
	t[1].pb(0);

	df(1, 0); dg(1, 0);
	irep(v, n) print(f[v] * (g[v]+1) % M);
}


Measured memory_bytes: 19968
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    typedef vector<int> vint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
    int dx[4] ={1,0,-1,0},dy[4] = {0,1,0,-1};
    int MOD = 1e9+7;
int main(){
    int N,K;
    cin >> N >> K;
    vint p(N);
    vector<lint> q;
    rep(i,N)cin >> p[i];
    lint ans=0,sum=0;
    rep(i,K){
        sum += p[i]+1;
        ans = sum;
    }
    rep(i,N-K){
        sum += p[i+K]-p[i];
        if(ans < sum)ans =sum;
    }
    cout << setprecision(10) <<(double)ans/2;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

ll n,q;
queue<pair<ll,ll> > que;
char name[100001][20];

int main(void){
    ll now;
    scanf("%lld%lld",&n,&q);
    REP(i,n){
        ll a;
        scanf("%s%lld",&name[i][0],&a);
        que.push(pair<ll,ll>(i,a));
    }

    now = 0;
    while(que.empty() == false){
        pair<ll,ll> a;
        a = que.front();
        que.pop();
        if(a.second <= q){
            now += a.second;
            printf("%s %lld\n",&name[a.first][0],now);
        }else{
            now += q;
            a.second -= q;
            que.push(a);
        }
    }
    return 0;
} 

Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int n = size(s);
    int m = size(t);
    V<string> can; 
    drepn(i, n-m) {
        bool flag = true;
        rep(j, m) {
            if(s[i+j] == '?') continue;
            if(s[i+j] != t[j]) {
                flag = false;
                break;
            }
        }
        if(flag) {
            string ans = s;
            rep(j, m) {
                ans[i+j] = t[j];
            }
            rep(j, n) {
                if(ans[j] == '?') ans[j] = 'a';
            }
            can.push_back(ans);
        }
    }
    if(size(can)) {
        sort(all(can));
        cout << can[0] << endl;
    }else{
        cout << "UNRESTORABLE" << endl;
    }
}

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


int main() {
  int n ; cin >> n ;
  
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  
  for ( int i = 0 ; i < n ; i++ ) 
    cin >> a[i] ;
    
  for ( int i = 0 ; i < n ; i++ ) 
    cin >> b[i] ;
  
  for ( int i = 0 ; i < n - 1 ; i++ ) 
    cin >> c[i] ;
  
  int ans = 0;
  
  for ( int i = 0 ; i < n ; i++ ) {
  	ans += b[(a[i] -1)];
      if (i >= 1 && (a[i] == a[i-1]+1) )
        ans += c[a[i-1]-1];
    //cout << ans << endl;
  }
  cout <<  ans << endl ; 
}





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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 100010;

int main(){
	int n,counter[maxn],a[maxn],i,j;
	scanf("%d",&n);
	memset(counter,0,sizeof counter);
	for(i=0;i<n;i++){scanf("%d",&a[i]); counter[a[i]]++;}
	int maks = -inf;
	for(i=0;i<=100000;i++){
		if(i==0 || i==100000){
			if(i==0){maks = max(maks,counter[i] + counter[i+1]);}
			else{maks = max(maks, counter[i] + counter[i-1]);}
		}else{
			maks = max(maks, counter[i] + counter[i-1] + counter[i+1]);
		}
	}
	printf("%d\n",maks);
	return 0;
};

Measured memory_bytes: 1024
#pragma region template
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)
#define pb push_back
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vbl = vector<bool>;
using vint = vector<int>;
using vstr = vector<string>;
const string Yes = "Yes\n";
const string No = "No\n";
static inline void ignore_ret(int x) {x++;}
template<class T> inline bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> inline T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> inline T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> inline T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> inline T nCr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}
template<class T> inline T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> inline T sum(vector<T>v){return reduce(all(v),0LL);}
#pragma endregion template

void solve(string S, string T) {
  int N = S.size();
  string S1 = S;
  for (int i = 0; i < N; i++) {
    S1 = S1.substr(1, N - 1) + S1.at(0);
    if (S1 == T) {
      cout << Yes;
      return;
    }
  }
  cout << No;  
}

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

Measured memory_bytes: 256
count = 0
m = 0
G = []
def insertionSort(A, n, g):
    global count
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            count += 1
        A[j+g] = v

def shellSort(A, n):
    global count
    global m
    global G
    count = 0
    g = 1
    while g <= n:
        G.append(g)
        g = 3*g + 1
    G.reverse()
    m = len(G)
    for g in G:
        insertionSort(A, n, g)
A = []
n = int(input())
for _ in range(n):
    A.append(int(input()))

shellSort(A,n)

print(m)
print(" ".join(map(str, G)))
print(count)
for a in A:
    print(a)   
    



Measured memory_bytes: 45536
# coding: utf-8
import math
n, k = map(int,input().split())
A = list(map(int,input().split()))
for i in range(n):
    if A[i]==1:
        cnt=i

l = i
r = n - i - 1
r = max(r - math.ceil(l/(k-1)) * (k-1) + l, 0)
print(math.ceil(l/(k-1)) + math.ceil(r/(k-1)))

Measured memory_bytes: 83940
#include <stdio.h>
 
int A[2000005],B[2000005];
 
int main(){
    int n,k=0,i,j;
    int C[10005]={0};
     
    scanf("%d",&n);

    for(i=1;i<=n;i++){
        scanf("%d",&A[i]);
        if(A[i]>=k)k=A[i];
    }
     
    for(i=0;i<k;i++){
        C[i]=0;
    }
     
    for(j=1;j<=n;j++){
        C[A[j]]++;
    }
     
    for(i=1;i<=k;i++){
        C[i]=C[i]+C[i-1];
    }
     
    for(j=n;j>=1;j--){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
     
    for(i=1;i<n;i++){
        printf("%d ",B[i]);
    }
    printf("%d\n",B[n]);
    return 0;
}

Measured memory_bytes: 16272
#include<stdio.h>

int main() {
    //元々の肉の温度、目的の温度、凍った肉を１温めるのにかかる時間、解凍、凍ってない肉を..
    int a, b, c, d, e;
    
    //入力  a =! 0
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);
    scanf("%d", &e);
    
    
    //処理
    if (a > 0) { //肉が凍っていない場合
        printf("%d\n", (b - a) * e);
    }else{  //肉が凍っている
        printf("%d\n", -a * c + d + b * e);
    }
    
    return 0;
}



Measured memory_bytes: 2104
from heapq import*
n,m=map(int,input().split())
p=sorted(map(int,input().split()))
heapify(p)
q=sorted([list(map(int,input().split()))for i in range(m)],key=lambda x:x[1],reverse=1)

for s,t in q:
    for i in range(s):
        tmp=heappop(p)
        if t>tmp:
            heappush(p,t)
        else:
            heappush(p,tmp)
            print(sum(p))
            exit()
print(sum(p))
#    print(p,q)


Measured memory_bytes: 33784
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//







int main() {
    ll n; cin >> n;
    ll t[5]; rep(i,5) cin >> t[i];

    ll t_min = t[0];
    rep(i,5) {
        if (t[i] < t_min) {
            t_min = t[i];
        }
    }

    ll ans = 5;
    if (n % t_min == 0) ans += n / t_min - 1;
    else ans += n / t_min;

    out(ans);

    return 0;
}






Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    
    int p = a + b;
    int q = a - b;
    int r = a * b;
    
    if (p > q){
        if(r > p){
            cout << r << endl;
        }else{
            cout << p << endl;
        }
    }else{
        if(r > q){
            cout << r << endl;
        }else{
            cout << q << endl;
        }
    }

    return 0;
}


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

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}
bool sosuu_check(int num) {
	int i;
	for (i = 2; i <= sqrt(num); ++i) {
		if (num%i == 0)
			return false;
	}
	return (num < 2) ? false : true;
}
int main() {
	ll A, B, C, K;
	cin >> A >> B >> C >> K;
	if (A - B > 1000000000000000000) {
		cout << "Unfair" << endl;
		return 0;
	}
	if (K % 2 == 0) 
		cout << A - B << endl;
	else
		cout << B - A << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = int(1E5);
const int MAXL = int(1E9);
int x[MAXN + 5], nxt[MAXN + 5][20];
int N, L, Q;
int main() {
	scanf("%d", &N);
	for(int i=1;i<=N;i++)
		scanf("%d", &x[i]);
	scanf("%d%d", &L, &Q);
	for(int i=0;i<=19;i++)
		nxt[N+1][i] = N+1;
	for(int i=N;i>=1;i--) {
		nxt[i][0] = upper_bound(x+1, x+N+1, x[i]+L) - x - 1;
		if( x[i] + L > x[N] ) nxt[i][0] = N+1;
		for(int j=1;j<=19;j++)
			nxt[i][j] = nxt[nxt[i][j-1]][j-1];
	}
	for(int i=1;i<=Q;i++) {
		int le, ri;
		scanf("%d%d", &le, &ri);
		if( le > ri ) swap(le, ri);
		int ans = 0;
		for(int j=19;j>=0;j--) {
			if( nxt[le][j] <= ri ) {
				ans = ans + (1<<j);
				le = nxt[le][j];
			}
		}
		if( le != ri && nxt[le][0] > ri ) ans++;
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 8960
from collections import defaultdict
import sys

input = sys.stdin.buffer.readline

def scc(V, E):
    # g = defaultdict(list)
    g = [[] for _ in range(len(V))]
    # rg = defaultdict(list)
    rg = [[] for _ in range(len(V))]
    for u, v in E:
        g[u].append(v)
        rg[v].append(u)


    o = []
    done = set()
    for u in V:
        if u in done:
            continue

        s = [(u, True)]
        while s:
            u, f = s.pop()
            if f:
                if u in done:
                    continue
                done.add(u)
                s.append((u, False))
                for v in g[u]:
                    if v in done:
                        continue
                    s.append((v, True))
            else:
                o.append(u)

    done = set()
    ans = []
    while o:
        u = o.pop()
        if u in done:
            continue

        s = [u]
        vv = [u]
        done.add(u)
        while s:
            u = s.pop()
            for v in rg[u]:
                if v in done:
                    continue
                vv.append(v)
                s.append(v)
                done.add(v)
        ans.append(vv)


    return ans


def atcoder_practice2_g():
    N, M = map(int, input().split())

    E = []
    for _ in range(M):
        a, b = map(int, input().split())
        E.append((a, b))
    V = list(range(N))
    vv = scc(V, E)
    print(len(vv))
    for r in vv:
        print(len(r), *r)


def test():
    g = {
        1: [2],
        5: [2],
        2: [4, 3],
        3: [4, 7, 6],
        4: [5, 8],
        6: [9],
        7: [8],
        8: [9],
        9: [7, 10],
        10: []
    }

    V = list(range(1, 11))
    E = []
    for u, e in g.items():
        for v in e:
            E.append((u, v))

    vv = scc(V, E)
    for r in vv:
        print(r)


if __name__ == "__main__":
    # test()
    atcoder_practice2_g()


Measured memory_bytes: 317556
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string s[100];
int n,l;
int main(){
	cin>>n>>l;
	for(int i=0;i<n;i++)cin>>s[i];
	sort(s,s+n);
	for(int i=0;i<n;i++)cout<<s[i];
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 384
import itertools
n,m=map(int,input().split())
num=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    num[a-1].append(b)
    num[b-1].append(a)
cnt=list(itertools.permutations(list(range(2,n+1))))
ans=0
for i in range(len(cnt)):
    num1=1
    num2=cnt[i]
    yn=0
    for j in range(n-1):
        if num2[j] not in num[num1-1]:
            yn=1
            break
        num1=num2[j]
    if yn==0:
        ans+=1
print(ans)


Measured memory_bytes: 9364
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int mochi_num = 0;
	int mochi[101];
	cin >> mochi_num;
	for (int i = 0; i < mochi_num; ++i) cin >> mochi[i];
	sort(mochi, mochi + mochi_num);
	int temp = mochi[0];
	int cnt = 1;
	for (int i = 1; i < mochi_num; ++i){
		if (temp < mochi[i]){
			temp = mochi[i];
			++cnt;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

int main() {
    int n, h[110];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> h[i];

    int cnt = 1;
    for (int i = 1; i < n; i++) {
        bool flag = true;
        for (int j = i - 1; j >= 0; j--) {
            if (h[j] > h[i]) flag = false;
        }
        if (flag) cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import math
 
a, b, h, m = list(map(int, input().split()))
deg_a = (60 * h + m) * (360/(60*12))
deg_b = m * (360/60)
deg = abs(deg_a - deg_b)
rad = math.radians(deg)
 
c2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(rad)
print(c2 ** 0.5)

Measured memory_bytes: 9384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};
constexpr ll mod = 1000000007;

int main(){
    ll l, r, d;
    cin >> l >> r >> d;
    ll ans = 0;
    rep(i, l, r+1) if(i % d == 0) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0; i < n; i++)
#define REPR(i, n) for(long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(long long i = m; i <= n; i++)
#define FORR(i, m, n) for(long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;



int main(){FIN

    ll n,a,b,c,d,e; cin>>n>>a>>b>>c>>d>>e;
    ll mn = min({a,b,c,d,e});
    ll ans = 5;
    ans += (n%mn==0)? n/mn - 1  : n/mn ;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
	#define ll long long int
     ll gcd(ll a, ll b){ 
	if (a == 0) 
		return b; 
	return gcd(b % a, a); 
} 

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

int main()
        {
  ll a,b;
  cin>>a>>b;
  cout<<lcm(a,b);
  cout<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fo(i,n) for(int i=0;i<n;i++)
#define rfo(i,n) for(int i=n-1;i>=0;i--)
#define Fo(i,q,n) for(int i=q;i<n;i++)
#define rFo(i,q,n) for(int i=n-1;i>=q;i--)
#define fO(i,n,k) for(int i=0;i<n;i+=k)
#define FO(i,q,n,k) for(int i=q;i<n;i+=k)
#define zero(a,n) memset(a,0,sizeof(a[0])*n)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define Endl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
using namespace std;
const int MOD=1000000007;
void print(){cout <<endl;}
template <typename T, typename... Types> 
void print(T var1, Types... var2){cout << var1 << " " ;print(var2...) ;}
//ceil of a/b
template <typename T>
T fceil(T a,T b){return (T)(a+b-1)/b;}
//const int N=2e5;
//int arr[N+1];

 
int main(){
	int n,k;
	cin>>n>>k;
	vector<int> a(n,0);
	fo(i,n){
		cin>>a[i];	
	}
	int dp[n];
	fo(i,n){dp[i]=INT_MAX;}
	dp[0]=0;
	Fo(i,1,n){
		Fo(j,1,k+1){
			int val = (i-j>=0)?dp[i-j]+abs(a[i]-a[i-j]):INT_MAX;
			dp[i] = min(dp[i],val);	
		}	
	}
	cout<<dp[n-1]<<Endl;
}






/*NOTE: Take MOD after sorting and not before sorting!*/


Measured memory_bytes: 4028
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long n = Long.parseLong(sc.next());
		long a = Long.parseLong(sc.next());
		long b = Long.parseLong(sc.next());
		
		long ans1 = Math.floorDiv(n, a+b);
		long temp = n %(a+b);
		
		long ans2 = 0;
		if(temp <= a) {
			 ans2 = temp;
		}
		else {
			 ans2 = a;
		}
		
		System.out.println(ans1*a+ans2);

	}

}


Measured memory_bytes: 22868
n, k = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i).sort
f = gets.chomp.split.map(&:to_i).sort.reverse

list = a.zip(f).map{ |ai,fj| ai*fj }

min, max = 0, list.max

while min < max
  mean = (min+max)/2
  sum = 0
  n.times do |i|
    sum += (list[i]-mean+(f[i]-1))/f[i] if list[i] > mean
  end
  if sum <= k
    max = mean
  else
    min = mean + 1
  end
end

puts(max)

Measured memory_bytes: 45404
from collections import defaultdict

H, W, m = map(int, input().split())
h_s = [0 for _ in range(H)]
w_s = [0 for _ in range(W)]
dd = defaultdict(bool)
for _ in range(m):
    h, w = map(int, input().split())
    h_s[h - 1] += 1
    w_s[w - 1] += 1
    dd[str(h - 1) + "-" + str(w - 1)] = True

max_h = max(h_s)
max_w = max(w_s)
hh = []
ww = []
for i, h in enumerate(h_s):
    if h == max_h:
        hh.append(i)
for i, w in enumerate(w_s):
    if w == max_w:
        ww.append(i)
ans = max_h + max_w - 1
for h in hh:
    for w in ww:
        if not dd[str(h) + "-" + str(w)]:
            print(ans + 1)
            exit()
print(ans)

Measured memory_bytes: 194668
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int an = sc.nextInt() + 1;
		int bn = sc.nextInt() + 1;
		int maxmin = sc.nextInt();
		long[] a = new long[an];
		long[] b = new long[bn];
		int j = b.length - 1;
		int res = 0;
		for(int i = 0; i < an; i++){
			if(i == 0){
				a[i] = 0;
			}else{
				a[i] = a[i-1] +sc.nextLong();
			}
		}
		for(int i = 0; i < bn; i++){
			if(i == 0){
				b[i] = 0;
			}else{
				b[i] = b[i-1] + sc.nextLong();
			}
		}
		for(int i = 0; i < a.length; i++){
			for(; j >= 0; j --){
				if(a[i] + b[j] <= maxmin){
					if(res < i + j){
						res = i + j;
					}
					break;
				}
			}
		}
		System.out.println(res);


	}
}


Measured memory_bytes: 64596
#include <stdio.h>
int main ()
{
        int a, b, uncovered_part;
        scanf ("%d %d", &a, &b);
        uncovered_part = a - (2 * b);
        if(uncovered_part  <= 0)
              uncovered_part = 0;
       printf("%d\n", uncovered_part);
       return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(j, n) for (int j = 0; j < (n); j++)

typedef long long ll;

int main()
{
   int n;
   cin>>n;
   vector<int>t(n+1);
   vector<int>x(n+1);
   vector<int>y(n+1);
   string s="Yes";
   
   rep(i,n){
     cin>>t[i+1]>>x[i+1]>>y[i+1];
     int a=abs(t[i+1]-t[i]);
     int b=abs(x[i+1]-x[i]);
     int c=abs(y[i+1]-y[i]);
     if(a<b+c)s="No";
     if(a%2!=(b+c)%2)s="No";
     }
   cout<<s<<endl;
   return 0;
}


Measured memory_bytes: 1408
import Control.Applicative

main = do
    getLine
    a <- map read . words <$> getLine
    print $ solve a

solve :: [Integer] -> Integer
solve list = foldl (\acc elem -> acc + (f 0 elem)) 0 list

f ans n = if r == 0 
          then f (ans+1) q
          else ans
            where (q,r) = divMod n 2

Measured memory_bytes: 7548
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

// 10 mod 1 = 0
// 10 mod 2 = 0
// 10 mod 3 = 1
// 10 mod 4 = 2
// 10 mod 5 = 0
// 10 mod 6 = 4
// 10 mod 7 = 3

// 5 mod 1 = 0
// 5 mod 2 = 1
// 5 mod 3 = 2
// 5 mod 4 = 1
// 5 mod 5 = 0
// 5 mod 6 = 5
// 5 mod 7 = 5
// 5 mod 8 = 5

// 1 2 3 4 5
// 2 3 4 5 1

int main()
{
  int64 N;
  int64 i;
  int64 result = 0;

  get_N(&N);

  if (N == 1) {
    printf("0");
    return 0;
  }
  for (i=2; i<=(N-1); i++) {
    result += i;
  }
  result++;

  printf("%lld", result);

  return 0;
}



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

#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N;
int a[100010];
int main(){
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    ll ans=0;
    bool f=false;
    for(int i=0;i<N;i++){
        if(a[i]%2==1){
            if(f){
                ans+=(a[i]+1)/2;
                f=false;
            }else{
                ans+=a[i]/2;
                f=true;
            }
        }else{
            if(a[i]==0)f=false;
            ans+=a[i]/2;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  string S;
  cin >> S;
  
  int answer = 0;

  for (int i = 0; i < 4; i++) {
    if (S[i] == '+') {
      answer++;
    } else {
      answer--;
    }
  }

  cout << answer << endl;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
vector<long long> ans;
long long a[200020];
long long sum[200020] = { 0 };
int main() {
	long long n, ans1 = 0;
	long long co = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum[i] = a[i] + sum[i - 1];
	}
	ans.emplace_back(0);
	for (int j = 0; j < n; j++) {
		ans.emplace_back(sum[j]);
	}
	sort(ans.begin(), ans.end());
	for (int k = 0; k < ans.size(); k++) {
		if (k == ans.size() - 1||ans[k] != ans[k + 1]) {
			ans1 += co * (co + 1) / 2;
			co = 0;
		}
		else {
			co++;
		}
	}
	cout << ans1 << endl;
}

Measured memory_bytes: 5492
/*Code by Codercjh*/
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,a,b) for(int i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}
int n;
ll a[200005],sum,f[200005]; 
int main(){
    read(n);
	fr(i,1,n)read(a[i]);
	sum=a[1];
	f[1]=0,f[2]=0;
	fr(i,3,n+1)
	    if(i%2==0)f[i]=max(f[i-2]+a[i-1],f[i-1]);
	    else{
	    	f[i]=max(f[i-2]+a[i-1],sum);
	    	sum+=a[i];
		}
	cout<<f[n+1]<<endl;
	return 0;
}


Measured memory_bytes: 6744
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int l, r;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "cmath"
#include "cstdlib"

using namespace std;

int main()
{	
	int N, M, X;
	int A[101];

	cin >> N >> M >> X;
	for (int i = 0; i < M; i++) {
		cin >> A[i];
	}

	int cost_to_zero = 0;
	for (int j = X; j >= 0; j--) {
		for (int i = 0; i < M; i++) {
			if (j == A[i]) {
				cost_to_zero++;
			}
			else if (j < A[i]) {
				break;
			}
		}
	}
	
	int cost_to_N = 0;
	for (int j = X; j <= N; j++) {
		for (int i = 0; i < M; i++) {
			if (j == A[i]) {
				cost_to_N++;
			}
			else if (j < A[i]) {
				break;
			}
		}
	}

	cout << std::min(cost_to_zero, cost_to_N);

    return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


int main() {
    int n,r;
    cin>>n>>r;

    cout<<r+100*(max(0,10-n))<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	ll N;
	cin >> N;
	ll sum = 0;
	ll m = 0;
	for (ll n = 0; n < N; n++) {
		ll a;
		cin >> a;
		sum += a;
		m = max(m, a);
	}
	if (sum - m > m)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long N, P;
	cin >> N >> P;
	long long r = 1;
	if (N == 1) {
		r = P;
	} else {
		for (long long i = 2; i*i <= P; ++ i) {
			int c = 0;
			while (P % i == 0) {
				++ c;
				P /= i;
			}
			for (int j = 0; j < c/N; ++ j) r *= i;
		}
	}
	cout << r << endl;
}


Measured memory_bytes: 256