akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main(){
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  for (int i=0; i < N; ++i) {
    cin >> p.at(i);
  }
  sort(p.begin(),p.end());
  int ans = 0;
  for (int i=0; i < K; ++i){
    ans += p.at(i);
  }
  cout << ans << endl;
  return 0;
}


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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (long long )(1e18+1)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');
    cerr.write(names, name-names) << " = " << arg1 << endl;
    _F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){
    in >> q.F >> q.S; return in;
}
template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}

void solve(){
    int n;
    cin >> n;
    int h[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    int ans[n];
    ans[0] = 0;
    for(int i = 1; i < n; i++){
        ans[i] = inf;
        for(int j = -2; j < 0; j++){
            if(i+j >= 0)
                ans[i] = min(ans[i], ans[i+j]+abs(h[i]-h[i+j]));
        }
    }
    cout << ans[n-1] << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(12);

    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    //freopen("error.txt", "w", stderr);
    //#endif

    //cin >> t;

    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": "; 
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
const ll INF = 1000000007;


//くみあわせ
ll P [10]={0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,2};
ll Q [10]={1 ,1 ,1 ,2 ,2 ,3 ,2 ,2 ,3 ,3};
ll R [10]={2 ,3 ,4 ,3 ,4 ,4 ,3 ,4 ,4 ,4};


int main()
{
    ll N;
    string tmp;
    cin >> N;
    ll res = 0;

    vector <ll> cnt(5,0);

    REP(i,N)
    {
        cin >> tmp;
        if(tmp[0] == 'M')cnt[0]++;
        if(tmp[0] == 'A')cnt[1]++;
        if(tmp[0] == 'R')cnt[2]++;
        if(tmp[0] == 'C')cnt[3]++;
        if(tmp[0] == 'H')cnt[4]++;
    }

    ll wa = 0;

    //waC3だけど、かぶってる場合はできませんよと

    REP(i,10)
    {
        res += cnt[P[i]]*cnt[Q[i]]*cnt[R[i]];
    }

    cout << res << endl;
    return 0;
}

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

int main() {
  string s;
  int k;
  cin >> s >> k;
  int dp[s.size()][k + 1][2];
  for (int i = 0; i <= k; ++i) {
    dp[0][i][0] = 0;
    dp[0][i][1] = 0;
  }
  dp[0][0][0] = 1;
  dp[0][1][0] = s[0] - '0' - 1;
  dp[0][1][1] = 1;
  for (int i = 1; i < s.size(); ++i) {
    dp[i][0][0] = 1;
    dp[i][0][1] = 0;
    for (int j = 1; j <= k; ++j) {
      dp[i][j][0] = dp[i - 1][j][0] + dp[i - 1][j - 1][0] * 9;
      if (s[i] == '0') {
        dp[i][j][1] = dp[i - 1][j][1];
      } else {
        dp[i][j][1] = dp[i - 1][j - 1][1];
        dp[i][j][0] += dp[i - 1][j - 1][1] * (s[i] - '0' - 1) + dp[i - 1][j][1];
      }
    }
  }
  cout << dp[s.size() - 1][k][0] + dp[s.size() - 1][k][1];
  return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main(N):
    x = 0
    for a in range(1, N+1):
        for b in range(a, N+1, a):
            x += b
    return x

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc_export(main, (i8, ))
    cc.compile()

from my_module import main

N = int(read())
print(main(N))


Measured memory_bytes: 27408
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M = 2e5+5;
int seg[4*M][2];
void build(int i,int s,int e,int n)
{
	seg[i][0] = n;
	seg[i][1] = n;
	if(s==e)
		return;
	int m = (s+e)/2;
	build(2*i,s,m,n);
	build(2*i+1,m+1,e,n);
}
int query(int i,int s,int e,int l,int r,int f)
{
	if(s > r || l > e)
		return M;
	if(s>=l && e<=r)
		return seg[i][f];
	int m = (s+e)/2;
	return min(query(2*i,s,m,l,r,f),query(2*i+1,m+1,e,l,r,f));
}
void update(int i,int s,int e,int id,int val,int f)
{
	if(s == e)
	{
		seg[i][f] = min(seg[i][f], val);
		return;
	}
	int m = (s+e)/2;
	if(id<=m)
		update(2*i,s,m,id,val,f);
	else
		update(2*i+1,m+1,e,id,val,f);
	seg[i][f] = min(seg[2*i][f], seg[2*i+1][f]);
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;
	int q;
	cin>>n>>q;
	build(1,1,n,n);
	ll res = (n-2)*(n-2);
	while(q--)
	{
		int type,x;
		cin>>type>>x;
		if(type == 1)
		{
			ll z = query(1,1,n,x,n,0);
			res -= (z-2);
			update(1,1,n,z,x,1);
			// cout<<z<<"---"<<res<<endl;
		}
		else
		{
			ll z = query(1,1,n,x,n,1);
			res -= (z-2);
			update(1,1,n,z,x,0);
			// cout<<z<<"---"<<res<<endl;
		}
	}
	cout<<res<<"\n";
	return 0;
}

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

int main(){
    int m[50],f[50],r[50],students;
    int i,j;

    i=0;
    students=0;

    while(1){
        std::cin>>m[i]>>f[i]>>r[i];
        if(m[i]==-1&&f[i]==-1&&r[i]==-1){
            break;
        }
        students+=1;
        i++;
    }

    for(i=0;i<students;i++){
        
        if(m[i]==-1||f[i]==-1){
            std::cout<<"F"<<std::endl;
        }
        else if(m[i]+f[i]>=80){
            std::cout<<"A"<<std::endl;
        }
        else if(65<=(m[i]+f[i])&&(m[i]+f[i])<80){
            std::cout<<"B"<<std::endl;
        }
        else if(50<=(m[i]+f[i])&&(m[i]+f[i])<65){
            std::cout<<"C"<<std::endl;
        }
        else if(30<=(m[i]+f[i])&&(m[i]+f[i])<50){
           
            if(r[i]>=50){
                std::cout<<"C"<<std::endl;
            }else{
                std::cout<<"D"<<std::endl;
            }

        }
        else{
            std::cout<<"F"<<std::endl;
        }

    }

    return 0;

}   




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

using namespace std;

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

    vector<int>a(n+1,0);
    /*累積和 */
    for(int i = 0; i < n+1; i++) {
        if(i +1 < n && s[i] == 'A' && s[i+1]=='C'){
            a[i+1] = a[i] + 1;
        }
        else{
            a[i+1] = a[i];
        }
    }

    for(int i = 1; i <= q; i++) {
        int l, r;
        cin >> l >> r;
      r--;
      l--;
        cout << a[r] - a[l]  << endl;
    }


    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}



signed main(){
	int N,A,B;
	cin>>N>>A>>B;
	cout<<min(A*N,B)<<endl;
}

Measured memory_bytes: 764
int main(void){
  int a, b, v, w, t;
  scanf("%d%d%d%d%d", &a, &v, &b, &w, &t);
  int d=a>b?a-b:b-a;
  if(d<=(long)(v-w)*t){
    puts("YES");
  }else{
    puts("NO");
  }
}


Measured memory_bytes: 1644
N, M = gets.split.map &:to_i
edges = []
$<.map{|s|
  from, to = s.split.map(&:to_i).map &:pred
  edges << [from, to]
  edges << [to, from]
}
# p edges
p M.times.count{
  e = edges.shift(2)
  visited = [false] * N
  dfs = ->pos{
    visited[pos] = true
    edges.select{|from, to| from == pos && !visited[to] }.each{|from, to|
      dfs[to]
    }
  }
  dfs[0]
  edges += e
  !visited.all?
}


Measured memory_bytes: 6012
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()

int main() {
  ll a,b,c; cin >> a >> b >> c;
  cout << max(c-(a-b),0LL) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int s;
int main()
{
    cin>>s;
    for (int i=1; ;i++)
    {
    	if (s==4 || s==2 || s==1)
    	{
    		cout<<i+3;
    		break;
		}
		s=s%2==0?s/2:s*3+1;
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
int n;	cin>>n;
		string sd;cin>>sd;
		int mi=INT_MAX,f=0;
		int z=0,o=0;
	for(int i=0;i<sd.length();i++)
	{
	if(sd[i]=='.')z++;
	else o++;
	}

	mi=min(mi,min(z,o));
	int one=0,zero=0;
	for(int i=0;i<sd.length();i++)
	{
		if(sd[i]=='#')one++;
		else zero++;
		
		mi=min(mi,one+z-zero);
	}
	cout<<mi<<"\n";
	
	
	
	
	
}
	
	
	

Measured memory_bytes: 640
#include<stdio.h>

int gcd(int p,int q);

int main() {
   int a,b,c,n,i,j,k,ans;
   long long sum = 0;
   scanf("%d", &n);

   for(i = 1; i <= n; i++) {
      for(j = 1; j <= n; j++) {
         for(k = 1; k <= n; k++) {
            ans = gcd(i,j);
            sum += gcd(ans,k);
         }
      }
   }
   printf("%lld\n", sum);
   return 0;
}

int gcd(int p,int q) {
   if(p % q == 0) {
      return q;
   }else {
      return gcd(q, p % q);
   }
}


Measured memory_bytes: 1716
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val xy = 0.until(n).map {
        readLine()?.split(" ")?.map(String::toDouble) ?: return
    }

    fun dfs(routes: List<Int>, candidates: List<Int>, distances: MutableList<Double>) {
        if (candidates.isEmpty()) {
            // 計算する
            val distance = 0.until(n - 1).sumByDouble {
                val i = xy[routes[it]]
                val j = xy[routes[it + 1]]
                Math.sqrt(Math.pow(i[0] - j[0], 2.0) + Math.pow(i[1] - j[1], 2.0))
            }
            distances.add(distance)
        } else {
            candidates.forEach {
                dfs(
                    routes + it,
                    candidates - it,
                    distances
                )
            }
        }
    }

    val distances = mutableListOf<Double>()
    dfs(emptyList(), 0.until(n).toList(), distances)
    println(String.format("%.10f", distances.average()))
}


Measured memory_bytes: 42976
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define for1(i,n) for(int i = 1;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define REP(a,i,b) for (int i = a;i<b;i++);

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

void solve()
{
	ll n;
	cin >> n;
	if (n % 2)
	{
		cout << 0;
		return;
	}
	ll ans = 0;
	ll temp = 5;

	while (temp <= 1000000000000000000)
	{
		ans += n / temp/2;
		temp *= 5;
	}

	cout << ans;
}


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


#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	//freopen("journey.in", "r", stdin);
	//freopen("journey.out", "w", stdout);


	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();


}

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

using namespace std;

#define ll long long

int n;

double factorial(int n) {
  double ans = 1;
  for (int i = 1; i <= n; i++) {
    ans *= i;
  }
  return ans;
}

void solve() {
  cin >> n;
  int x[n];
  int y[n];
  int p[n];
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    p[i] = i;
  }

  double ans = 0;
  double count = factorial(n);

  do {
    for (int i = 0; i < n-1; i++) {
      ans += sqrt(pow(abs(x[p[i+1]]-x[p[i]]), 2)+pow(abs(y[p[i+1]]-y[p[i]]), 2));
    }
  } while (next_permutation(p, p+n));
  
  cout << setprecision(20) << ans/count<< '\n';
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}


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

int main() {
    ll n,y;
    std::cin >> n>>y;
    y /= 1000;
    
    for (int i = 0; i <= n; i++) {
        if(i*10>y)continue;
        ll now = y-i*10;
        for (int j = 0; j <= n-i; j++) {
            if(now == j*5+n-i-j){
                std::cout << i<<" "<<j<<" "<<n-i-j << std::endl;
                return 0;
            }
        }
    }
    std::cout << -1<<" "<<-1<<" "<<-1 << std::endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(){
    int n,T,c,t,i,min_cost,f=0;

    scanf("%d %d",&n,&T);
    for(i=0;i<n;i++){
        scanf("%d %d",&c,&t);
        if((T>=t)&&(f==0)){
            min_cost = c;
            f=1;
        }
        if((T>=t)&&(min_cost>c)){
            min_cost=c;
        
        }
    }
    if(f==0){
        printf("TLE");
    }else{
        printf("%d",min_cost);
    }

    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

nodd = 0
neven = 0
n4 = 0

for i in range(0,n):
  if a[i]%4==0:
    n4=n4+1
  elif a[i]%2==0:
    neven=neven+1
  else:
    nodd=nodd+1

res = 'No'

if neven==0 and n4+1 >= (nodd):
  res = 'Yes'
elif n4+1 >= (nodd+1):
  res = 'Yes'
elif nodd==0:
  res = 'Yes'

print(res)


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

using namespace std;

int read() {
  int res = 0; char c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)) res = res * 10 + c - '0', c = getchar();
  return res;
}

void read(char *S) {
  char *s = S, c = getchar();
  while(c != '0' && c != '1') c = getchar();
  while(c == '0' || c == '1') *s = c, s++, c = getchar();
}

typedef long long ll;
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;

int head[maxn], nxt[maxn << 1], to[maxn << 1], e_cnt;
void link(int u, int v) {
  nxt[++e_cnt] = head[u], head[u] = e_cnt, to[e_cnt] = v;
  nxt[++e_cnt] = head[v], head[v] = e_cnt, to[e_cnt] = u;
}

int mx[maxn], se[maxn], d[maxn], sz[maxn], n;
char S[maxn];
long long Ans;

void dfs_1(int x, int fa) {
  if(S[x] == '1') d[x] = 0, sz[x] = 1;
  else d[x] = inf;
  for(int i = head[x]; i; i = nxt[i]) {
    int y = to[i];
    if(y == fa) continue;
    dfs_1(y, x), sz[x] += sz[y];
    if(mx[y] + 1 > mx[x]) se[x] = mx[x], mx[x] = mx[y] + 1;
    else if(mx[y] + 1 > se[x]) se[x] = mx[y] + 1;
    if(sz[y]) d[x] = min(d[x], mx[y] + 1);
  }
}

void dfs_2(int x, int fa) {
  int R = min(se[x] + 1, mx[x] - 1);
  if(d[x] <= R) Ans += 1LL * (R - d[x] + 1);
  for(int i = head[x]; i; i = nxt[i]) {
    int y = to[i];
    if(y == fa) continue;
    int kl = (mx[y] + 1 == mx[x] ? se[x] + 1 : mx[x] + 1);
    if(kl > mx[y]) se[y] = mx[y], mx[y] = kl;
    else if(kl > se[y]) se[y] = kl;
    if(sz[1] - sz[y]) d[y] = min(d[y], kl);
    dfs_2(y, x);
  }
}

int main() {
  n = read();
  for(int i = 2; i <= n; i++) link(read(), read());
  read(S + 1);
  dfs_1(1, 0);
  dfs_2(1, 0);
  printf("%lld\n", Ans + 1);
}


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

int main() {
    int N; cin >> N;
    int num = 1;
    int ans = 0;
    rep(i, N) {
        int a; cin >> a;
        if(a == num) ++num;
        else ++ans;
    }
    if(ans == N) ans = -1;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = list(input())
ansl = []
for i in range(1,n):
    ans = 0
    count = 0
    for j in range(n-i):
        #print(s[j],s[j+i])
        if s[j] == s[j+i]:
            count += 1
        else:
            if count > 0:
                if count > ans:
                    ans = min(count,i)
                count = 0
    if count > ans:
        ans = min(count,i)
    ansl.append(ans)
print(max(ansl))

Measured memory_bytes: 42732
#import numpy as np
#import math
#from fractions import gcd

def main():

    ##get int
    first_input = list(map(lambda x:int(x), input().split(" ")))
    #second_input = list(map(lambda x:int(x), input().split(" ")))

    ##get float
    #first_input = list(map(lambda x:float(x), input().split(" ")))
    #second_input = list(map(lambda x:float(x), input().split(" ")))

    ##get string
    #first_input = input().split(" ")

    X = first_input[0]
    Y = first_input[1]

    if Y%2==0 and X*2<=Y and Y<=X*4:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61812
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

bool solve(int k, ll d, vector<ll> &a) {
  int n = a.size();
  vector<ll> b(n);
  for (int i = 0; i < n; i++) {
    b[i] = a[i] % d;
  }
  sort(b.begin(), b.end());
  int i = 0, j = n - 1;
  // ソート済みのやつの両端から足し引き
  // 降順なので、初めは減らしたい、後は増やしたい
  ll now = 0;
  // 現在の増減量
  ll num = 0;
  // 操作回数
  while (i <= j) {
    if (now <= 0) {
      now += b[i];
      num += b[i];
      i++;
    } else {
      now -= (d - b[j]);
      j--;
    }
  }
  return num <= k;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  ll ans = 0;
  for (ll i = 1; i * i <= sum; i++) {
    if (sum % i == 0) {
      if (solve(k, i, a)) {
        ans = max(ans, i);
      }
      if (solve(k, sum / i, a)) {
        ans = max(ans, sum / i);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N=int(input())
S=input()

#O(N)で累積和が求められる

ruiseki=[[0 for i in range(2)] for j in range(N)]

for i in range(0,N):
    if i!=0:
        if S[i]=='W':
            ruiseki[i][0]=1
        else:
            ruiseki[i][1]=1
    else:
        if S[i]=='W':
            ruiseki[i][0]=1
        else:
            ruiseki[i][1]=1

    ruiseki[i][0]+=ruiseki[i-1][0]
    ruiseki[i][1]+=ruiseki[i-1][1]







mn = 10**6

for i in range(0,N):
    if i>=1 and i<=N-2:
        m = ruiseki[i-1][0]+ruiseki[N-1][1]-ruiseki[i][1]
    elif i==0:
        m = ruiseki[N-1][1]-ruiseki[0][1]
    else:
        m = ruiseki[N-2][0]

    if mn>m:
        mn = m


print(mn)




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

int main()
{
	long long int x;
	long long int a = 100;
	cin >> x;
	for (int i = 1;;i++)
	{
		a += a / 100;
		if (a >= x)
		{
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3580
#coding:utf-8
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

def search_banpei(array, target, cnt):
    tmp = array[len(array)-1]
    array[len(array)-1] = target

    n = 0
    while array[n] != target:
        n += 1

    array[len(array)-1] = tmp
    if n < len(array) - 1 or target == tmp:
        cnt += 1
    return cnt        

def linear_search():  
    cnt = 0
    for t in T:
        for s in S:
            if t == s:
                cnt += 1
                break

def linear_banpei_search():
    cnt = 0
    for target in T:
        cnt = search_banpei(S, target, cnt)
    return cnt

cnt = linear_banpei_search()

print(cnt)



Measured memory_bytes: 6552
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<queue>
#include<set>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define ft first
#define sd second
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
ll MOD = 1e9 + 7;
int main(){
  int H, W, K;cin>>H>>W>>K;
  ll dp[110][W];
  fr(i,W){
    if(i == 0)dp[0][i]=1;
    else dp[0][i] = 0;
  }
  ll memo[W+1];
  memo[0] = 1,memo[1] = 1;
  for(int i = 2;i<=W;i++){
    memo[i] = memo[i-1] + memo[i-2];
    memo[i] %= MOD;
  }
  fr(h,H){
    fr(w,W){
      dp[h+1][w] = dp[h][w]*memo[w]*memo[W-w-1];
      if(w-1>=0) dp[h+1][w] += dp[h][w-1]*memo[w-1]*memo[W-w-1];
      if(w+1<W) dp[h+1][w] +=dp[h][w+1]*memo[w]*memo[W-w-2];
      dp[h+1][w] %=MOD;
    }
  }
  cout << dp[H][K-1] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int N,c=2;

	cin >> N;
	
	while (c < N){
		c *= 2;
	}
	if (c == N){

	}
	else{ c /= 2; }

	cout << c << endl;
	return 0;
}




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

int main() {
    int A, B, T;
    cin >> A >> B >> T;
    cout << T/A*B << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma warning(disable: 4996)
#include <stdio.h>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>

using namespace std;
using ll = long long;

ll r, D, x;



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

	int i, j;
	cin >> r >> D >> x;
	
	for(int i = 0; i < 10; i++) {
		cout << r * x - D << "\n";
		x = r * x - D;
	}



}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <stack>
typedef long long int llint;

bool check(const std::vector<int>& a,
	   const std::vector<std::vector<int> >& info){
  for(int i=0; i<a.size(); i++){
    if(a[i] != 1) continue;
    for(int j=0; j<a.size(); j++){
      if(info[i][j] == 0) continue;
      //std::cout << " " << i << " " << j << " " << info[i][j] << " " << a[j] << std::endl;
      if(info[i][j] != a[j]) return false;
    }
  }
  return true;
}
int main(void){
  int n;
  std::cin >> n;
  std::vector<std::vector<int> > info(n, std::vector<int>(n, 0));

  for(int i=0; i<n; i++){
    int a;
    std::cin >> a;
    for(int j=0; j<a; j++){
      int x, y;
      std::cin >> x >> y;
      info[i][x-1] = y*2-1;
    }
  }

  int n_patterns = 1<<n;
  int best = 0;
  for(int i=1; i<n_patterns; i++){
    std::vector<int> test(n);
    for(int j=0; j<n; j++){
      test[j] = ((i>>j)%2)*2-1;
      //std::cout << j << " " << test[j] << std::endl;
    }
    //std::cout << check(test, info) << std::endl;
    if(check(test, info)){
      int count = 0;
      for(int j=0; j<n; j++){
	if(test[j] == 1) count++;
      }
      if(best < count) best = count;
    }
  }


  std::cout << best << std::endl;
  return 0;
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(buffer.readLine());
        String [] inp = buffer.readLine().split(" ");
        Integer []arr = new Integer[n];
        int [] arr2 = new int[n];
        for (int pos = 0; pos < n; pos++) {
            arr[pos] = Integer.parseInt(inp[pos]);
        }
        inp = buffer.readLine().split(" ");
        for (int pos = 0; pos < n; pos++) {
            arr2[pos] = Integer.parseInt(inp[pos]);
        }
        Queue<Integer>balancedPos = new LinkedList<>();
        for (int pos = 0; pos < n; pos++) {
            if (arr[pos] == arr2[pos]){
                if (!balancedPos.isEmpty() && arr[balancedPos.peek()]!=arr2[pos]){
                    int i = balancedPos.poll();
                    arr2[i] = arr2[pos]^arr2[i]^(arr2[pos] = arr2[i]);
                }
                else
                    balancedPos.add(pos);
            }
        }
        int size = 0;
        while (!balancedPos.isEmpty() && balancedPos.size()!=size){
            size = balancedPos.size();
            for (int pos = 0; pos < n; pos++) {
                if (arr[pos]!=arr2[pos] && !balancedPos.isEmpty() && arr[balancedPos.peek()]!=arr2[pos] && arr2[balancedPos.peek()]!=arr[pos]){
                    int i = balancedPos.poll();
                    arr2[i] = arr2[i]^arr2[pos]^(arr2[pos] = arr2[i]);
                }
            }
        }
        if (!balancedPos.isEmpty())
            System.out.println("No");
        else {
            System.out.println("Yes");
            for (int num : arr2) {
                System.out.print(num + " ");
            }
        }
    }
}


Measured memory_bytes: 81140
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    ll A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;

    ll maxw = 100*A,maxs = 0;
    for(int i = 0;i*A <= F/100;i++){
        for(int j = 0;(i*A + j*B) <= F/100;j++){
            //100b / (a+b)
            ll water = (i*A + j*B) * 100;
            //cout << i << "," << j << endl;
            if(!water)continue;
            for(int k = 0;(k*C*100 <= (E*water)) && (water + k*C) <= F;k++){
                //cout << "k " << k << endl;
                for(int l = 0;((k*C+l*D)*100 <= (E*water)) && (water + (k*C+l*D) <= F);l++){
                    ll sugar = (k*C+l*D);

                    //cout << "s " << sugar << endl;                    
                    if((maxs * (water+sugar)) < (sugar * (maxw+maxs))){
                        maxw = water;
                        maxs = sugar;
                    }
                    //cout << maxw << " " << maxs << endl;
                }
            }
        }
    }
    cout << maxw+maxs << " " << maxs << endl;

}

Measured memory_bytes: 256
#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};

int main(){
    ll h, w, m;
    cin >> h >> w >> m;
    VP hor(h), ver(w);
    rep(i, 0, h) hor[i] = {0, i};
    rep(i, 0, w) ver[i] = {0, i};
    set<PL> st;
    rep(i, 0, m) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        hor[u].first++;
        ver[v].first++;
        st.insert({u, v});
    }
    sort(ALL(hor), greater<PL>());
    sort(ALL(ver), greater<PL>());

    ll ans = hor[0].first + ver[0].first;
    rep(i, 0, h) {
        if(hor[i].first != hor[0].first) break;
        rep(j, 0, w) {
            if(ver[j].first != ver[0].first) break;
            if(st.count({hor[i].second, ver[j].second}) == 0) {
                cout << ans << endl;
                return 0;
            }
        }
    }
    ans--;
    cout << ans << endl;
    return 0;
}

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

int main() {
    int k;
    int sum = 0;

    cin >> k;

    for (int n = 1;n <= k;n++) {
        for (int m = 1;m <= k;m++) {
            for (int l = 1;l <= k;l++) {
                sum += __gcd(__gcd(n, m), l);
            }
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
using namespace std;
using ll = int64_t;

// gcd(x, y) == gcd(x, y-x). Flip once y becomes smaller.
ll gcd(ll x, ll y) { return x==0 ? y : gcd(y%x, x); }

int main() {
  ll L = static_cast<ll>(1e6);
  ll n;
  cin >> n;
  vector<ll> A(n, 0);
  vector<ll> C(L+1, 0);
  for(ll i=0; i<n; i++) {
    cin >> A[i];
    C[A[i]]++;
  }
  ll A_gcd = A[0];
  for(ll i=1; i<n; i++) {
    A_gcd = gcd(A_gcd, A[i]);
  }

  bool pairwise = true;
  for(ll ans=L; ans>=2; ans--) {
    ll score = 0;
    for(ll mult=ans; mult<=L; mult+=ans) {
      score += C[mult];
    }
    if(score >= 2) {
      pairwise = false;
      break;
    }
  }
  if(pairwise) {
    cout << "pairwise coprime" << endl;
  } else if(A_gcd == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
}


Measured memory_bytes: 18832
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()

    R = 2**(N.bit_length())
    st = [0] * (R*2)

    def update(i,s):
        x = 2 ** (ord(s) - ord('a'))
        i += R-1
        st[i] = x
        while i > 0:
            i = (i-1) // 2
            st[i] = st[i*2+1] | st[i*2+2]

    def query(l,r):
        l += R-1
        r += R-2
        ret = 0

        while l+1 < r:
            if l % 2 == 0:
                ret |= st[l]
            if r % 2 == 1:
                ret |= st[r]
                r -= 1
            l = l // 2
            r = (r-1) // 2
        if l == r:
            ret |= st[l]
        else:
            ret |= st[l] | st[r]

        return ret

    for i,s in enumerate(sys.stdin.readline().rstrip()):
        update(i+1,s)
    Q = NI()
    for _ in range(Q):
        c,a,b = sys.stdin.readline().split()
        if c == '1':
            update(int(a),b)
        else:
            ret = query(int(a),int(b)+1)
            cnt = 0
            b = 1
            for i in range(26):
                cnt += (b & ret) > 0
                b <<= 1
            print(cnt)


if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll L, R; cin >> L >> R;
  ll ans = 2018;
  if(R - L <= 2019){
    repi(l, L, R) repi(r, l+1, R+1) ans = min(l * r % 2019, ans);
  }
  else ans = 0;
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n;cin>>n;
  vector<int>a(n+1);
  vector<pair<int,int>> pr(n+1);
  for(int i=1;i<=n;i++){
    cin>>a[i];
    pr[i]=make_pair(a[i],i);
  }
  sort(all(pr));
  for(int i=1;i<=n;i++){
    cout<<pr[i].second<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 4292
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][][] buildings = new int[4][3][10];
        int n = sc.nextInt();

        for(int i=0; i<n; i++){
            int b = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int v = sc.nextInt();
            buildings[b-1][f-1][r-1] += v;
        }

        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                for(int k=0; k<10; k++){
                    System.out.print(" " + buildings[i][j][k]);
                }
                System.out.println("");
            }
            System.out.println("####################");
        }
        for(int j=0; j<3; j++){
            for(int k=0; k<10; k++){
                System.out.print(" " + buildings[3][j][k]);
            }
            System.out.println("");
        }

    }
}


Measured memory_bytes: 29496
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <sstream>
#include <queue>

using namespace std;

const int INF = 1001001001;

int main()
{
    int N, M ;
    cin >> N >> M;
    vector<vector<int>> to(N);
    for (int i = 0; i < M; ++i)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    queue<int> q;
    vector<int> dist(N, INF);
    vector<int> pre(N, -1);
    q.push(0);
    dist[0] = 0;
    while(!q.empty())
    {
        int v = q.front();
        q.pop();
        for (int u : to[v])
        {
            if(dist[u] == INF)
            {
                dist[u] = dist[v] + 1;
                pre[u] = v;
                q.push(u);
            }
        }
    }

    cout << "Yes" << endl;
    for (int i = 1; i < N; i++)
    {
        cout << pre[i] + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 10768
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
using Graph = vector<vector<pair<int, int> > >;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

int w[200];
ll v[200];

ll dp[110][100010];

int main() {
	int N, W; cin >> N >> W;
	for (int i = 0; i < N; i++) {
		cin >> w[i+1] >> v[i+1];
	}
	//init
	for (int i = 0; i <= N; i++) {
		dp[i][0] = 0;
	}
	for (int weight = 1; weight <= W; weight++) {
		for (int i = 0; i <= N; i++) {
			if (i == 0) {
				dp[i][weight] = 0;
				continue;
			}
			if (w[i] <= weight) {
				dp[i][weight] = max(dp[i - 1][weight], dp[i - 1][weight - w[i]] + v[i]);
			}
			else {
				dp[i][weight] = dp[i - 1][weight];
			}
		}
	}
	cout << dp[N][W] << endl;



	return 0;
}


Measured memory_bytes: 80128
A, B = map(int, input().split())
lists = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
if lists.index(A) > lists.index(B):
    print("Alice")
elif lists.index(A) == lists.index(B):
    print("Draw")
else:
    print("Bob")


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

bool cmp(int a,int b)
{
	return abs(a)>abs(b);
}

int main()
{
	int n,l;
	cin >> n >> l;
	vector<int> v(n);
	for(int i = 0;i<n;i++)
	{
		v[i] = l++;
	}
	sort(v.begin(),v.end(),cmp);
	int ans = 0;
	for(int i = 0;i<n-1;i++)
	{
		///cout<<v[i]<<endl;
		ans += v[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_output(v) for(auto it=v.begin();it!=v.end();it++){if(it!=v.begin())cout<<" ";cout<<*it;}cout<<endl;
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);
long long int combination(long long int,long long int);
long long int series_sum(long long int);

int main(){
    vector<int> vec(10);
    vec_input(vec);
    sort(rall(vec));
    rep(i,3){
        cout<<vec[i]<<endl;
    }
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n;cin>>n;
  if(n==1){int a;cin>>a;cout<<1<<endl;}
  else{
  vector<int>A(n);
  for(int i=0;i<n;i++)
    cin>>A[i];
  sort(A.begin(),A.end());
  int ans=0;
  for(int i=0;i<n-1;i++){
    int cnt=1;
    while(i!=n-1&&A[i]==A[i+1]){
      cnt++;
      i++;
    }
    if(cnt%2)ans++;
  }
  if(A[n-2]!=A[n-1])ans++;
  cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {

		try (Scanner scan = new Scanner(System.in)) {

			int N = scan.nextInt();
			int M = scan.nextInt();

			int[] dp = new int[1 << N];

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

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

			for (int i = 0; i < M; i++) {
				int v = scan.nextInt();
				int keyNum = scan.nextInt();
				int s = 0;
				for (int j = 0; j < keyNum; j++) {
					int c = scan.nextInt();
					c--;
					s |= 1 << c;
				}
				List<Integer> a = Arrays.asList(v, s);
				key.add(a);
			}

			dp[0] = 0;
			for (int s = 0; s < 1 << N; s++) {
				for (int i = 0; i < M; i++) {
					int t = s | key.get(i).get(1);
					int v = key.get(i).get(0);
					dp[t] = Math.min(dp[t], v + dp[s]);
				}
			}

			int ans = dp[(1 << N)-1];

			if (ans == 1001001) {
				System.out.println(-1);
			} else {
				System.out.println(ans);
			}

		}
	}
}

Measured memory_bytes: 31280
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int hotel[4][3][10],i,j,k,test,b,f,r,v;
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                hotel[i][j][k]=0;
            }
        }
    }
    scanf("%d",&test);
    for(i=0;i<test;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        hotel[b-1][f-1][r-1]+=v;
    }
    for(j=0;j<3;j++){
        for(k=0;k<10;k++){
            printf(" %d",hotel[0][j][k]);
        }
        printf("\n");
    }
    for(i=1;i<4;i++){
        printf("####################\n");
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d",hotel[i][j][k]);
            }
            printf("\n");
        }
    }
    return 0;
    
}


Measured memory_bytes: 2104
//#include "stdafx.h"
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>
#include "random"
#include "chrono"
#include "cstring"

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target_ans("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++)
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;

#define int long long
//#define int unsigned int
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;
typedef vector<vi> vvi;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

vi xx = { 0, 0, -1, 1 };
vi yy = { -1, 1, 0, 0 };
string dir = "LRUD";

const int N = 3e5 + 50, oo = 3e18 + 500;
const int mod = 998244353;
//const int mod = 1e9 + 7;
//const int mod = 1e9 + 9;
const double eps = 1e-9, PI = 2 * acos(0.0);
int n, m, k;
long long cnt = 0;
int lg = 18;
vi g[N];
vi rg[N];
vi visit(N, 0);



signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("abbreviation.in", "r", stdin);
	freopen("abbreviation.out", "w", stdout);*/
	//ПРОВЕРЯЙ ДЕФАЙНЫ ТУПОЙ!!!

	
	cin >> k;
	string s;
	cin >> s;

	if (SZ(s) <= k)
	{
		cout << s;
	}
	else
	{
		cout << s.substr(0, k) + "...";
	}
}

Measured memory_bytes: 18992
#include <bits/stdc++.h>
#define int long long 

using namespace std;
const int N = 1e5 + 5;

int a[N], b[N];
int n;

int32_t main()
{
    cin >> n;
    for (int i=1; i<=n; i++) 
    {
        cin >> a[i];
        a[i]<<=1;
    }
    for (int i=1; i<=n; i++)
    {
        if (i&1) b[1] += a[i]/2;
        else b[1] -= a[i]/2;
    }
    for (int i=2; i<n; i++)
    {
        b[i] = a[i - 1] - b[i - 1];
    }
    b[n] = a[n] - b[1];
    for (int i=1; i<=n; i++) cout << b[i] << " ";
    return 0;
}


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

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

    ll n, ans = 0LL; cin >> n;
    vector<ll> f(n+1, 0LL);
    for(ll i = 1LL; i <= n; ++i) for(ll l = 1LL; l*i <= n; ++l) ++f[l*i];
    for(ll i = 1LL; i <= n; ++i) ans += i*f[i];
    cout << ans << endl;
}


Measured memory_bytes: 81348
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    T = iss()

    tmp = S[len(S) - 1:], S[0:len(S) - 1]
    for s in range(len(S)):
        t = S[s - 1:] + S[0:s - 1]
        if t == T:
            print('Yes')
            exit()

    print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>
int main(){
	int a[4];
	int m=0,n;
scanf("%d",&n);
a[3]=n%10;
a[2]=n/10%10;
a[1]=n/100%10;
a[0]=n/1000;
	for(int i=0;i<3;i++)
	if(a[i]==a[i+1])
	m++;
	if(m>0)
	printf("Bad\n");
	else
	printf("Good\n");
	return 0;
}

Measured memory_bytes: 760
#include<iostream>
#include<algorithm>
#include<string.h>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
int main() {
	int n; string s;
	int x, y, z, ans; ans = x = y = z = 0;
	cin >> n;
	while (n--) {
		cin >> s; int l = s.length();
		for (int i = 0; i < l - 1; i++) {
			if (s[i] == 'A' && s[i + 1] == 'B') ans++;
		}
		if (s[0] == 'B' && s[l - 1] == 'A') z++;
		else if (s[0] == 'B') x++;
		else if (s[l - 1] == 'A') y++;
	}
	if (x == 0 && y == 0) ans = ans + max(0,z - 1);
	else if (y == 0) {
		ans = ans + z;
	}
	else if (x == 0) {
		ans = ans + z;
	}
	else {
		ans = ans + min(x, y) + z;
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main 
{
	static boolean[][] edge;
	static int n, m;
	static long c = 0;
	
	static void go(String s)
	{
//		System.out.println(s);
		if(s.length() == n)
		{
			c++;
			return;
		}
		boolean[] vis = new boolean[n];
		for(int i = 0; i < s.length(); i++)
		{
			vis[s.charAt(i)-'0'] = true;
		}
		int cur = s.charAt(s.length()-1)-'0';
		for(int i = 0; i < n; i++)
		{
			if(!vis[i] && edge[cur][i])
				go(s + ((char)('0'+i)));
		}
	}

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		edge = new boolean[n][n];
		
		for(int i = 0; i < m; i++)
		{
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			edge[a][b] = true;
			edge[b][a] = true;
		}
		
		go("0");
		System.out.println(c);
	}
		

}



Measured memory_bytes: 24276
N,K = map(int,input().split())
H = list(map(int,input().split()))

dp = [0 for i in range(N)]

if N <= K :
    ans = abs(H[0] - H[N-1])
else :
    for i in range(1,K+1) :
        dp[i] = abs(H[0] - H[i])

    for i in range(K+1,N) :
        cost = float("inf")
        for j in range(1,K+1) :
            cost = min(cost, dp[i-j] + abs(H[i-j] - H[i]))

        dp[i] = cost

    ans = dp[N-1]

print(ans)


Measured memory_bytes: 56544
module DoublyLinkedList = struct
  type t = {
    mutable data : int;
    mutable next : t;
    mutable prev : t;
  }

  let make () =
    let rec head = { data = 0; next = head; prev = head } in
    head

  let insert data head =
    let x = { data = data; next = head.next; prev = head } in
    head.next.prev <- x;
    head.next <- x

  let delete x =
    x.next.prev <- x.prev;
    x.prev.next <- x.next

  let delete_first head = delete head.next

  let delete_last head = delete head.prev

  let delete_node data head =
    let rec doit ite =
      if ite == head then None
      else if ite.data = data then Some ite
      else doit ite.next
    in
    match doit head.next with
    | None -> ()
    | Some ite -> delete ite

  let iteri head f =
    let rec doit i ite =
      if ite != head then (f i ite.data; doit (i + 1) ite.next)
    in
    doit 0 head.next
end

module L = DoublyLinkedList

let split str delim =
  let rec doit s acc =
    match
      try Some (String.rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s1 (s2 :: acc)
  in
  doit str []

let () =
  let n = read_int () in
  let head = L.make () in
  let rec read i =
    if i < n then begin
      match split (read_line ()) ' ' with
      | ["insert"; n] -> (L.insert (int_of_string n) head; read (i + 1))
      | ["delete"; n] -> (L.delete_node (int_of_string n) head; read (i + 1))
      | ["deleteFirst"] -> (L.delete_first head; read (i + 1))
      | ["deleteLast"] -> (L.delete_last head; read (i + 1))
      | _ -> exit 1
    end
  in
  read 0;
  L.iteri head (fun i n -> if i <> 0 then print_string " "; print_int n);
  print_newline ()

Measured memory_bytes: 39164