akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
 
ull B=10000007;
int n,d,len;
char s[200][17];
ull t[200];
int G[200][200];
bool f[200][200];
map<ull,bool> mp[200];
vector<ull> L[200];

struct data{
  int fi,se;
  bool operator < (const data &d)const{
    return (G[fi][d.fi]!=0?G[fi][d.fi]<0:G[se][d.se]<0);
  }
};
 
vector< data > v;
 
ull Deleting(int x,char* ch){
  ull res=0;
  for(int i=0;i<len;i++)
    if(i!=x)res=res*B+ch[i];
  return res;
}
 
ull Inserting(int x,char y,char* ch){
  ull res=0;
  for(int i=0;i<=len;i++){
    if(i==x)res=res*B+y;
    if(i<len)res=res*B+ch[i];
  }
  return res;
}
 
ull Replacing(int x,char y,char* ch){
  ull res=0;
  for(int i=0;i<len;i++){
    if(i==x)res=res*B+y;
    else res=res*B+ch[i];
  }
  return res;
}
 
ull Swapping(int x,char* ch){
  ull res=0;
  for(int i=0;i<len;i++){
    if(i==x)res=res*B+ch[i+1];
    else if(i==x+1)res=res*B+ch[x];
    else res=res*B+ch[i];
  }
  return res;
}
 
void init(){
  for(int i=0;i<200;i++){
    mp[i].clear();
    L[i].clear();
  }
  v.clear();
  memset(f,false,sizeof(f));
}
 
int main(){
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    init();
    scanf("%d",&d);
 
    for(int i=0;i<n;i++){
      scanf("%s",s[i]);
      len=strlen(s[i]);
 
      t[i]=Swapping(-10,s[i]);
      ull key;
      for(int j=0;j<len;j++){
        key=Deleting(j,s[i]);
        mp[i][key]=true;
        L[i].push_back(key);
      }
       
      for(int j=0;j<=len;j++){
        for(char k='a';k<='z';k++){
          key=Inserting(j,k,s[i]);
          mp[i][key]=true;
          L[i].push_back(key);
        }
      }
       
      for(int j=0;j<len;j++){
        for(char k='a';k<='z';k++){
          if(s[i][j]!=k){
            key=Replacing(j,k,s[i]);
            mp[i][key]=true;
            L[i].push_back(key);
          }
        }
      }
       
      for(int j=0;j+1<len;j++){
        key=Swapping(j,s[i]);
        mp[i][key]=true;
        L[i].push_back(key);
      }
    }
 
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
        G[i][j]=strcmp(s[i],s[j]);
     
    for(int i=1;i<n;i++){
      for(int j=0;j<i;j++){
        int a=i,b=j;
        if(G[a][b]>0)swap(a,b);
        if( mp[a].count(t[b]) && !f[a][b] ){
          v.push_back( (data){a,b} );
          f[a][b]=true;
        }
        if(d==1)continue;
        vector<ull> :: iterator it;
        for(it=L[b].begin();it!=L[b].end();it++){
          if( mp[a].count(*it) && !f[a][b] ){
            v.push_back( (data){a,b} );
            f[a][b]=true;
          }
        }
      }
    }
    sort( v.begin() , v.end() );
    for(int i=0;i<(int)v.size();i++){
      printf("%s,%s\n",s[v[i].fi],s[v[i].se]);
    }
    printf("%d\n",(int)v.size());
  }
  return 0;
}

Measured memory_bytes: 12180
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string A,B,C;
  cin >> A >> B >> C;
  if(A[A.size()-1] == B[0] && B[B.size()-1] == C[0]){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[5];
        for (int i=0; i<5; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        int k = sc.nextInt();
        if (arr[4]-arr[0]>k) {
            System.out.println(":(");
        } else {
            System.out.println("Yay!");
        }
    }
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
int n;
string s;
ll ans = 0;

void solve(ll x,ll y){
    if(x==n+1){
        ans += y;
        return;
    }
    ll cur = 0;
    for(ll i=x;i<=n;i++){
        cur = (10*cur) + (s[i]-'0');
        solve(i+1,y+cur);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    vector<pair<ll,ll> >v;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        v.push_back({x,y});
    }
    sort(v.begin(),v.end());
    ll y=0;
    for(int i=0;i<v.size();i++){
        ll x=v[i].first;
        ll cpy=v[i].second;
        y+=cpy;
        if(y>=k){
            cout<<x<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 2420
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  while(cin >> str){
    for(int i=0;i<str.size();i++){
      if(str[i]=='@'){
	for(int k=0;k<str[i+1]-'0';k++){
	  cout << str[i+2];
	}
	i = i+2;
      }else {
	cout << str[i];
      }
      

    }
    cout << endl;
  }

}

Measured memory_bytes: 1172
#include<stdio.h>
int main()
{
    int n,a[200010],i,c,m;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    m=a[0];
    c=1;
    for(i=1;i<n;i++)
    {
        if(a[i]<=m)
        {
        c++;
        m=a[i];
        }
    }
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 2512
s = list(input())
cnt = 0
list = []
for i in range(len(s)):
    if s[i] == "A" or s[i] == "T" or s[i] == "C" or s[i] == "G":
        cnt += 1
        list.append(cnt)
    else:
        cnt = 0
        list.append(cnt)
print(max(list))

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BUF_SIZE 20

struct process {
  char name[12];
  int time;
};

#define min(a, b) ((a) > (b) ? (b) : (a))

#define QUEUE_SIZE 100001
static int queue[QUEUE_SIZE];
static int start = 0;
static int end = 0;

void enqueue(int idx) {
  end = (end+1)%QUEUE_SIZE;
  queue[end] = idx;
}

int dequeue(void) {
  start = (start+1)%QUEUE_SIZE;
  return queue[start];
}

int is_empty(void) {
  return start == end;
}

int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int num, quantum;
  sscanf(line, "%d %d", &num, &quantum);
  struct process *ps = malloc(sizeof(struct process)*num);

  int i, j;
  for(i = 0; i < num; i++) {
    if(!fgets(line, BUF_SIZE, fp)) return 0;
    sscanf(line, "%s %d", ps[i].name, &ps[i].time);
    enqueue(i);
  }

  int sum = 0;
  while(!is_empty()) {
    int idx = dequeue();
    struct process *proc = &ps[idx];
    int consume = min(quantum, proc->time);
    proc->time = proc->time - consume;
    sum += consume;
    if(!proc->time) {
      printf("%s %d\n", proc->name, sum);
    } else {
      enqueue(idx);
    }
  }
  return 0;
}


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

int main(){
  ll x,y,ans=0;cin>>x>>y;
  while(x<=y){
    x*=2;
    ans++;
  }
  cout<<ans;
}

Measured memory_bytes: 256
// AtCoder Beginner Contest 115 - Problem D: Christmas (https://atcoder.jp/contests/abc115/tasks/abc115_d)
#include <bits/stdc++.h>

using namespace std;

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

#define REP(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define REPN(i, N) for (int (i) = 0; (i) < N; (i)++)
#define DEC(i, b, a) for (int (i) = (b); (i) >= (a); (i)--)
#define DECN(i, N) for (int (i) = N - 1; (i) >= 0; (i)--)

#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))
#define LOGM(msg) (cerr << (msg))
#define LOGV(vec, sep) { cerr << #vec << " ="; for (const auto& v : (vec)) cerr << " " << v; cerr << (sep); }
#define LOGA(arr, N, sep) { cerr << #arr << " ="; for (int i = 0; i < N; ++i) cerr << " " << (arr)[i]; cerr << (sep); }
#define LOGA2(arr, N, M, sep) { cerr << #arr << " =\n"; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cerr << (arr)[i][j] << " "; cerr << endl; } cerr << (sep); }

ostream& operator<<(ostream& os, const ii& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

const int MAXN { 60 };

ll size[MAXN], ps[MAXN];

ll patties(ll N, ll X)
{
    // Corner case
    if (X == size[N])
        return ps[N];

    // A bun
    if (X == 1)
        return 0;

    --X;

    // A N - 1 burger
    ll res = 0;

    if (X > size[N - 1])
    {
        res += ps[N - 1];
        X -= size[N - 1];
    } else
        return res + patties(N - 1, X);

    // A pattie
    ++res;

    if (X == 1)
        return res;
    
    --X; 

    // Another N - 1 burger
    if (X > size[N - 1])
    {
        res += ps[N - 1];
        X -= size[N - 1];
    } else
        return res + patties(N - 1, X);

    // Another bun
    --X;

    return res;

}

void precomp()
{
    // O tamanho e o número de patties no nível i é precomputado
    size[0] = 1;
    ps[0] = 1;

    for (int i = 1; i < MAXN; ++i)
    {
        size[i] = 1 + size[i - 1] + 1 + size[i - 1] + 1;
        ps[i] = 2*ps[i - 1] + 1;
    }
}

void solve(ll N, ll X)
{
    auto ans = patties(N, X);

    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    precomp();

    ll N, X;
    cin >> N >> X;

    solve(N, X);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int c[9],a[9],ans;
bool used[9];
void DFS(int len){
    if(len==9){
        if(!(2+a[0]+a[2]+a[5]-a[8]+10*(1+a[1]+a[4]-a[7])+100*(a[3]-a[6])))ans++;
        return;
    }
    if(c[len]==-2){
        for(int i=0;i<9;i++){
            if(!used[i]){
                a[len]=i,used[i]=true;
                DFS(len+1);
                used[i]=false;
            }
        }
    }
    else {
        a[len]=c[len];
        DFS(len+1);
    }
}
int main(){
    for(int i=0;i<9;i++)used[i]=0;
    for(int i=0;i<9;i++){
        cin>>c[i];c[i]--;
        if(c[i]>=0)used[c[i]]=true;
    }
    ans=0;
    DFS(0);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3040
x = int(input())
a = [i for i in range(120)] + [-i for i in range(1,119)]
b = [i for i in range(119)] + [-i for i in range(1,120)]

for i in a:
  for j in b:
    if i**5 - j**5 == x:
      print(i,j)
      exit()


Measured memory_bytes: 9084
// AOJ 2913 Prime Routing
// 2019.4.5 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

//// 高速入力
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}


//// 優先度付きキュー（ダイクストラ法のため）
#define MAX 1000000
typedef struct { int t, node; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int n, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].node = n, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}


//// ダイクストラ法で最短距離
int N;
int hi[100002], *to[100002];
char vis[100002][2];

int dijkstra(int start, int goal)
{
	int i, s, e, t, f;

//	memset(vis, 0, N * sizeof(int));
	qsize = 0, f = 0;
	enq(start, 0);
	while (qsize) {
		s = que[0].node, t = que[0].t, deq();
		if (s == goal) {
			if (t == 1) f = 1;
			else if (t == 2 || (t & 1)) return t;
		}
		if (vis[s][t & 1]) continue;
		vis[s][t & 1] = 1;

		t++;
		for (i = 0; i < hi[s]; i++) {
			e = to[s][i];
			if (!vis[e][t & 1]) enq(e, t);
		}
	}
	if (f) return 3;
	return -1;
}

int isPrime(int n)
{
	int i, b;
	if (n == 2) return 1;
	if (n <= 1 || (n & 1) == 0) return 0;
	b = (int)sqrt(n);
	for (i = 3; i <= b; i += 2) {
		if (n % i == 0) return 0;
	}
	return 1;
}

int main()
{
	int i, k, M, S, T, a, b;
	int *memo, sz;

	N = in(), M = in(), S = in() - 1, T = in() - 1;

	memo = malloc(M * 2 * sizeof(int));
	sz = 0;	for (i = 0; i < M; i++) {
		memo[sz++] = a = in() - 1, memo[sz++] = b = in() - 1;
		hi[a]++, hi[b]++;
	}
	for (i = 0; i < N; i++) if (hi[i]) to[i] = malloc(hi[i] * sizeof(int));
	memset(hi, 0, N * sizeof(int));

	i = 0; while (i < sz) {
		a = memo[i++], b = memo[i++];
		k = hi[a]++, to[a][k] = b;
		k = hi[b]++, to[b][k] = a;
	}
//	free(memo);

	k = dijkstra(S, T);
	if (k > 0 && k & 1)	while (!isPrime(k)) k += 2;
	printf("%d\n", k);
	return 0;
}



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

int main() {
  int N;
  cin >> N;
  int A, B, C, D, E, F, G, H, I, X;
  
  A = N / 100000000;
  B = N / 10000000 - N / 100000000 * 10;
  C = N / 1000000 - N / 10000000 * 10;
  D = N / 100000 - N / 1000000 * 10;
  E = N / 10000 - N / 100000 * 10;
  F = N / 1000 - N / 10000 * 10;
  G = N / 100 - N / 1000 * 10;
  H = N / 10 - N / 100 * 10;
  I = N / 1 - N / 10 * 10;
  
  X = A + B + C + D + E + F + G + H + I;
    
    if (N % X == 0)
      cout << "Yes" << endl;
    else if (N % X != 0)
      cout << "No" << endl;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  int N; cin >> N;
  int A[N+2]; A[0] = 0; A[N+1] = 0;
  int dist = 0;
  for(int i = 0; i <= N; ++i) {
    if(i != N)cin >> A[i+1];
    dist += abs(A[i] - A[i+1]);
  }
  for(int i = 1; i <= N; ++i) {
    int ans = dist + abs(A[i-1] - A[i+1]) - (abs(A[i-1] - A[i]) + abs(A[i] - A[i+1]));
    cout << ans << endl;
  }

  return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC145A()
{
	int r;
	cin >> r;
	cout << r * r << endl;
}

int main()
{
	ABC145A();
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramA
    {
        static void Main()
        {
            int h1 = NextInt, m1 = NextInt, h2 = NextInt, m2 = NextInt, k = NextInt;
            System.Console.WriteLine(
                h2 * 60 + m2 - (h1 * 60 + m1) - k
            );
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


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

int main(){
  int count = 0;
  string str;
  cin >> str;

  int len = str.length();

  for(int i = 0; i < (len-1)/2+1; i++){
    if(str[i] != str[len-1-i]){
      if(str[i] == 'x'){
	str.insert(len-i, "x");
	count++;
      }else if( str[len-1-i] == 'x'){
	str.insert(i, "x");
	count++;
      }else{
	cout << -1 << endl;
	return 0;
      }
    }
    len = str.length();
  }
  //cout << str << endl;
  cout << count << endl;
}

  


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  string s;
  cin >> s;

  cout << s[0] << (s.size()-2) << s[s.size()-1] << endl;
  return 0;
} 

Measured memory_bytes: 3584
a, b, c, d = list(map(int, input().split()))
import fractions
a_amount =  (a-1) - ((a-1) // d) - ((a-1)//c) + ((a-1) // ((c*d)//fractions.gcd(c,d)))
b_amount =  b - (b // d) - (b//c) + (b // ((c*d)//fractions.gcd(c,d)))
print(b_amount - a_amount)

Measured memory_bytes: 5688
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int n;
double t, a;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> t >> a;
  double mi = iinf;
  int ans = -1;
  FOR(i, 0, n){
    double h;
    cin >> h;
    h = abs(a - t + h * 0.006);
    if(h < mi){
      mi = h;
      ans = i;
    }
  }
  cout << ans + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        10000000070000
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

ll n,dp[404][404],a[404];
int main()
{
	ios
	ll i,j,k;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=0;i<=n+1;i++){
		for(j=0;j<=n+1;j++)
			dp[i][j]=hell;
	}
	for(i=1;i<=n;i++)
		dp[i][i+1]=0;
	for(i=2;i<=n;i++)a[i]+=a[i-1];
	for(ll len=2;len<=n;len++){
		for(i=1;i+len<=n+1;i++){
			for(k=1;k<len;k++){
				dp[i][i+len]=min( dp[i][i+k]+dp[i+k][i+len]+a[i+len-1]-a[i-1] , dp[i][i+len]);
			}
		}
	}
	cout<<dp[1][n+1];
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef unsigned long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
//---------------------------------------------
 
int main(void)
{

float n,m;
cin>>n>>m;

vector<float> a(n+3);
float suma =0;
for(int i=1;i<=n;i++)
{
	cin>>a[i];
	suma += a[i];
}


sort(a.begin(),a.end(),greater<float>());

if(a[m-1]<suma/4/m) cout<<"No"<<endl;

else cout<<"Yes"<<endl;


}

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

#define w cout
#define e '\n'
#define int long long
#define sz(x) (int)x.size()
#define re return 
#define vi vector<int>
#define vii vector<pair<int ,int > >
#define F first
#define S second
#define pussy push_back
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

const int N = 1e6 , mod = 1e9 + 7;



signed main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	int n ; cin >> n;
	vi a(n); cin >> a;
	vi ans(n);
	int t = 0;
	t = a[0];
	for(int i = 1 ;i <n ;i ++){
		t ^= a[i];
	}
	for(int i = 0;i < n ;i ++ ){
		ans[i] = t ^ a[i];
	}
	for(int i : ans) {
		w << i << " ";
	}
}


Measured memory_bytes: 6336
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cctype>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
const int maxn = 1e6+7;

int main(){
	string a,b;
	cin>>a>>b;
	string str=a+b;
	ll sum=0;
	ll n=1;
	for(ll i=str.length()-1;i>=0;i--){
		sum+=n*(str[i]-'0');
		n*=10;
	}
	if(sqrt(sum)-(int)sqrt(sum)!=0){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans = 0;
  cin >> n;
  vector<int> nums(n + 1);
  for(int i = 1;i <= n;i++){
    cin >> nums[i];
    if(i%2 == 1 && nums[i] % 2 == 1)ans++;
  }
  cout << ans << endl;
}

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

int main() {
  int n;
  cin>>n;
  int a=0;
  int b=0;
  int c=0;
  int d=0;
  vector<string> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  for(int i=0;i<n;i++){
    if(vec.at(i)=="AC") a++;
    else if(vec.at(i)=="WA") b++;
    else if(vec.at(i)=="TLE") c++;
    else if(vec.at(i)=="RE") d++;
  }
  cout<<"AC"<<" "<<"x"<<" "<<a<<endl;
  cout<<"WA"<<" "<<"x"<<" "<<b<<endl;
  cout<<"TLE"<<" "<<"x"<<" "<<c<<endl;
  cout<<"RE"<<" "<<"x"<<" "<<d<<endl;
}

Measured memory_bytes: 6352
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

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

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

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

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

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

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

// Sort
type RuneSlice []rune

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

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

type Path struct {
	to, id, d int
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, M := sc.nextInt(), sc.nextInt()
	D := make([]int, N)
	for i := 0; i < N; i++ {
		D[i] = INF
	}
	G := make([][]Path, N)
	for i := 0; i < M; i++ {
		l, r, d := sc.nextInt()-1, sc.nextInt()-1, sc.nextInt()
		G[l] = append(G[l], Path{r, i, d})
		G[r] = append(G[r], Path{l, i, -d})
	}
	ok := true
	done := make([]bool, M)
	var search func(cur, count int)
	search = func(cur, count int) {
		for i := 0; i < len(G[cur]); i++ {
			path := G[cur][i]
			if done[path.id] {
				continue
			}
			done[path.id] = true
			next := path.to
			nc := count + path.d
			if D[next] == INF {
				D[next] = nc
				search(next, nc)
			} else {
				if D[next] != nc {
					ok = false
				}
			}
		}
	}
	for i := 0; i < N; i++ {
		if D[i] == INF {
			D[i] = 0
		} else {
			continue
		}
		search(i, 0)
	}
	//fmt.Fprintln(wtr, "D is", D)
	//fmt.Fprintln(wtr, "done is", done)

	if ok {
		fmt.Fprintln(wtr, "Yes")
	} else {
		fmt.Fprintln(wtr, "No")
	}
}


Measured memory_bytes: 64640
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O20")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << x << "\n")
using ll = uint16_t; using ld = long double; using namespace std;

class CountOrder
{
	ll N{0};
	vector<ll> p, q;
	void inp( ) {
		iss >> N; p.resize(N); q.resize(N);
		rep(n, N) { iss >> p[n]; }
		rep(n, N) { iss >> q[n]; }
		//for_each(begin(p), end(p), [](auto x) { cout << x << "\n"; });
	}
	void change( ) {
		long long sa{0};
		if (p > q) swap(p, q);
		do {
			if (p == q) break;
			++sa;
		} while (next_permutation(begin(p), end(p)));
		p(sa);
	}
public:
	void procedures( ) {
		inp( );
		change( );
	}
};
//https://atcoder.jp/contests/abc145/tasks/abc145_c
int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	cout << fixed << setprecision(15);
	class CountOrder a; a.procedures( );
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    long long n,a,b;
    cin>>n>>a>>b;
    long long ans=(n/(a+b))*a+min(n%(a+b),a);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3604
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
#include<math.h>
typedef long long ll;
#define N (1000000000+7)
using namespace std;
typedef pair<int, int> P;

int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

ll prime[100010];
ll kaijo[200010];
void init() {
	kaijo[0] = 1;
	for (ll i = 1;i <= 200000;i++)kaijo[i] = (kaijo[i - 1] * i) % N;
}

ll inv(ll x) {
	ll res = 1;
	ll k = N - 2;
	ll y = x;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N*y%N) % N;
		k /= 2;
	}
	return res;
}

ll Comb(ll n, ll k) {
	ll b = kaijo[n];
	ll c = kaijo[n - k];
	ll d = kaijo[k];
	ll cd = (c*d) % N;
	return ((b%N)*(inv(cd)%N) + N) % N;
}

int main(void) {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5 12
0 1 4
0 2 3
1 1 2
1 3 4
1 1 4
1 3 2
0 1 3
1 2 4
1 3 0
0 0 4
1 0 2
1 3 0

output:
0
0
1
1
1
0
1
1
"""

import sys


class UnionFind(object):
    __slots__ = ('size', 'height_rank', 'ancestors')

    def __init__(self, size):
        self.size = int(size)
        self.height_rank = [0] * self.size
        self.ancestors = [i for i in range(self.size)]

    def __find(self, x):
        if x != self.ancestors[x]:
            self.ancestors[x] = self.__find(self.ancestors[x])
        return self.ancestors[x]

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

    def __link(self, x, y):
        if self.height_rank[x] > self.height_rank[y]:
            self.ancestors[y] = x
        else:
            self.ancestors[x] = y
            if self.height_rank[x] == self.height_rank[y]:
                self.height_rank[y] += 1

    def union(self, x, y):
        self.__link(self.__find(x), self.__find(y))


def cmd_exec(cmd_list, e_num):
    case = UnionFind(size=e_num)

    for each in cmd_list:
        cmd, ele_1, ele_2 = map(int, each)
        if cmd == 0:
            case.union(ele_1, ele_2)
        elif cmd == 1:
            print(int(case.same(ele_1, ele_2)))
    return None


def solve():
    _input = sys.stdin.readlines()
    e_num, c_num = map(int, _input[0].split())
    c_list = map(lambda x: x.split(), _input[1:])

    cmd_exec(c_list, e_num)

    return None


if __name__ == '__main__':
    solve()

Measured memory_bytes: 16596
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <time.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define FOR(i, a) for(i = 0; i < (a); i++)
#define FORM(i, a) for(i = (a) i >= 0; i--)
#define INF 100000
using namespace std;

int D[50][50], MAP[50][50];
char M[50];



int main(){
int i, j, W, H;
 cin >> H >> W;

   for(i = 0; i < H; i++){
	   cin >> M;
      for(j = 0; j < W; j++){
		  MAP[i][j] = M[j] - '0';
	  }

   }
 

 for(i = H-1; i >= 0; i--){
  for(j = W-1; j >= 0; j--){

	  if(i == H-1 && j == W-1){

	  }

	  else if(i == H-1){
		  D[i][j] = D[i][j+1] + MAP[i][j]; 

	  }

	  else if(j == W-1){
		  D[i][j] = D[i+1][j] + MAP[i][j];
	  }

	  else{

		  D[i][j] = min(D[i+1][j] + MAP[i][j], D[i][j+1] + MAP[i][j]);
	  }
  }
 }

   cout << D[0][0] << endl;


return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    int n,d,x;
    cin >> n >> d >> x;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    int sum = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j <= d ; j+=a[i]) {
            sum++;
        }
    }
    cout << sum + x << endl;

    return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int N, Y;
    cin >> N >> Y;

    int x = 0; // 1000
    int y = 0; // 5000

    bool found(false);
    for (int x = 0; x <= 2000; x++) {
        for (int y = 0; y <= 2000; y++) {
            int z = N - x - y; // 10000
            int sum = (10000 * z) + (5000 * y) + (1000 * x);
            if (z >= 0 && sum == Y) {
                found = true;
                cout << z << " " << y << " " << x << endl;
                break;
            }
        }
        if (found) {
            break;
        }
    }

    if (!found) {
        cout << -1 << " " << -1 << " " << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    for (int i = 0; i < M; i++) {
        int A, B; cin >> A >> B; A--, B--;
        G[A].push_back(B);
    }
    vector<bool> visited(N), inloop(N);
    vector<int> loop;
    function<bool(int)> rec = [&](int node) {
        if (visited[node] && inloop[node]) {
            loop.push_back(node);
            return true;
        }
        if (visited[node]) return false;
        visited[node] = true;
        inloop[node] = true;
        for (auto next : G[node]) {
            if (rec(next)) {
                loop.push_back(node);
                return true;
            }
        }
        inloop[node] = false;
        return false;
    };
    for (int i = 0; i < N; i++) {
        if (rec(i)) break;
    }
    if (loop.empty()) {
        cout << -1 << endl;
        return 0;
    }
    vector<int> ans, order(N, -1);
    int ord = 0;
    for (int i = 0; i < loop.size(); i++) {
        if (!ans.empty() && ans[0] == loop[i]) break;
        ans.push_back(loop[i]);
    }
    reverse(begin(ans), end(ans));
    for (int i = 0; i < ans.size(); i++) {
        order[ans[i]] = ord++;
    }
    for (;;) {
        bool modify = false;
        for (int i = 0; i < ans.size(); i++) {
            int node = ans[i];
            if (order[node] == -1) continue;
            int next = -1, score = -1;
            for (auto n : G[node]) if (order[n] != -1) {
                int s = order[n] + (order[n] <= order[node] ? ans.size() : 0);
                if (s > score) {
                    next = n, score = s;
                }
            }
            for (int j = 1; j < ans.size(); j++) {
                int node2 = ans[(i + j) % ans.size()];
                if (order[node2] == -1) continue;
                if (node2 == next) break;
                order[node2] = -1;
                modify = true;
            }
        }
        if (!modify) break;
    }
    vector<int> ans2;
    for (auto a : ans) if (order[a] != -1) ans2.push_back(a);
    cout << ans2.size() << '\n';
    for (auto a : ans2) cout << a + 1 << '\n';
    return 0;
}


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

int GCD(int a, int b){
	if(b == 0){
		return a;
	}
	return GCD(b, a % b);
}

int main(){
	int a, b;
	int i;
	int k;

	while(cin >> a >> b){

		if(a > b){
			i = GCD(a, b);
		}
		else{
			i = GCD(b, a);
		}

		a = a / i;
		b = b / i;

		k = a * b * i;

		cout << i << " " << k << endl;
	}
}

Measured memory_bytes: 0
n,m=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
dp=[[0]*m for _ in range(n)]
sum=[[0]*m for _ in range(n)]
mod=10**9+7
for i in range(n):
  if s[i]==t[0]:
    dp[i][0]=1
  else:
    dp[i][0]=0
for i in range(m):
  if t[i]==s[0]:
    dp[0][i]=1
  else:
    dp[0][i]=0
sum[0][0]=dp[0][0]
for i in range(1,n):
  sum[i][0]=sum[i-1][0]+dp[i][0]
for i in range(1,m):
  sum[0][i]=sum[0][i-1]+dp[0][i]
for i in range(1,n):
  for j in range(1,m):
    if s[i]==t[j]:
      dp[i][j]=(sum[i-1][j-1]+1)%mod
    else:
      dp[i][j]=0
    sum[i][j]=(sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j])%mod
ans=0
for i in range(n):
  for j in range(m):
    ans+=dp[i][j]
    ans=ans%mod
print((ans+1)%mod)

Measured memory_bytes: 105692
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
T = [INT() for _ in range(N)]

tmp = T[0]
for i in range(1, len(T)):
    tmp = (tmp * T[i]) // gcd(tmp, T[i])
print(tmp)


Measured memory_bytes: 9964
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }

void main() {
    int n, m; readf("%d %d\n", &n,&m);
    int[] ps = readints();

    auto uf = new UnionFind(n);
    foreach (_; iota(m)) {
        int[] xy = readints();
        uf.unite(xy[0] - 1, xy[1] - 1);
    }

    iota(n).filter!(i => uf.same(i, ps[i] - 1)).array.length.writeln;
    string _ = readln;
}

class UnionFind {
    import std.algorithm.mutation;
    int[] p;
    this(int n) {
        p.length = n;
        p[0..$] = -1;
    }
    bool unite(int u, int v){
        u = root(u); v = root(v);
        if (u == v) return false;
        if (p[u] > p[v]) swap(u, v);
        p[u] += p[v]; p[v] = u;
        return true;
    }
    bool same(int u, int v){ return root(u) == root(v); }
    int root(int u){ return p[u] < 0 ? u : (p[u] = root(p[u])); }
    int size(int u){ return -p[u]; }
}

Measured memory_bytes: 4540
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
using namespace std;


int main() {
	
	int size;

	cin >> size;

	int b, f, r, v;
	int build[4][3][10];


	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < 4; k++) {
				build[k][i][j] = 0;
			}
		}
	}

	for (int i = 0; i < size; i++) {
		cin >> b >> f >> r >> v;
		build[b - 1][f - 1][r - 1] += v;
	}

	for (int k = 0; k < 4; k++) {
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 10; j++) {
				printf(" %d", build[k][i][j]);
				//if (j + 1 != 10)printf(" ");
			}
			printf("\n");
		}
		if(k != 3)printf("####################\n");
	}


	//system("pause");
	return 0;
}


Measured memory_bytes: 3196
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
struct unionfind{
  int par[100010];
  int rank[100010];
  unionfind(int n){
    init(n);
  }
  void init(int n){
    for(int i=0;i<=n;i++){
      par[i]=i;
      rank[i]=1;
    }
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    }
    else {
      return par[x] = root(par[x]);
    }
  }
  int size(int x){
    return rank[root(x)];
  }
  bool same(int x,int y) {
    return root(x) == root(y);
  }
  void unite(int x,int y) {
    x=root(x);
    y=root(y);
    if(x==y){
      return;
    }
    if(rank[x]<rank[y]){
      swap(x,y);
    }
    rank[x]=rank[x]+rank[y];
    par[y]=x;
  }
};
struct edge{
  int from;
  int to;
  int cost;
  edge(ll f,ll t,ll w) : from(f),to(t),cost(w){}
};
bool comp(const edge& e1,const edge& e2){
  return e1.cost < e2.cost;
}
int main(){
  unionfind tree(10010);
  int i,v,e,s,t,w;
  vector<edge> g;
  scanf("%d %d\n",&v,&e);
  for(i=0;i<e;i++){
    scanf("%d %d %d\n",&s,&t,&w);
    g.push_back(edge(s,t,w));
  }
  sort(g.begin(),g.end(),comp);
  int ans=0;
  for(i=0;i<e;i++){
    if(!tree.same(g[i].from,g[i].to)){
      tree.unite(g[i].from,g[i].to);
      ans+=g[i].cost;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 4592
#include <iostream>
#include <deque>

int main() {
  int k;
  std::cin >> k;
  std::deque<long long> que;
  for (int i = 1; i <= 9; i++)
    que.push_back(i);
  int cnt = 0;
  while (!que.empty()) {
    long long num = que.front();
    que.pop_front();
    cnt++;
    if (cnt == k) {
      std::cout << num << std::endl;
      return 0;
    }
    if (num%10 > 0) que.push_back(10*num + num%10 - 1);
    que.push_back(10*num + num%10);
    if (num%10 < 9) que.push_back(10*num + num%10 + 1);
  }
  return 0;
}

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

int main(){
  int n;cin>>n;
  vector<int> ans(4,0);
  REP(i,n){
    string t;cin>>t;
    if(t=="AC") ans.at(0)++;
    if(t=="WA") ans.at(1)++;
    if(t=="TLE") ans.at(2)++;
    if(t=="RE") ans.at(3)++;
  }

  cout<<"AC x "<<ans.at(0)<<endl;
  cout<<"WA x "<<ans.at(1)<<endl;
  cout<<"TLE x "<<ans.at(2)<<endl;
  cout<<"RE x "<<ans.at(3)<<endl;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      t: usize,
      aa: [usize; n],
    }

    use std::collections::BinaryHeap;
    let mut heap = BinaryHeap::new();

    let mut ans = 0;
    let mut best = 0;
    for i in (0..n).rev() {
        let a = aa[i];
        if let Some(&peek) = heap.peek() {
            if peek >= a {
                let temp = peek - a;
                // debug!(best, temp, a, peek);
                if temp > best {
                    best = temp;
                    ans = 1;
                } else if temp == best {
                    ans += 1;
                }
            }
        }
        heap.push(a);
    }
    puts!("{}\n", ans);
}


Measured memory_bytes: 6396
s=list(input())
sl=len(s)
ans=0
for i in range(1<<sl-1):
    temp=""
    for j in range(sl-1):
        if i&(1<<j):
            temp+=s[j]+"+"
        else:
            temp+=s[j]
    temp+=s[-1]
    ans+=eval(temp)
print(ans)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;

int main(){
  string s;
  int K;
  cin >> s >> K;
  REP(i,s.length()){
    if(K == 0) break;
    int d = (123 - (int)s[i])%26;
    if(d > K) continue;
    else{
      s[i] = 'a';
      K = K-d;
    }
  }
  s.back() = (char)((int)s.back() - 'a' + K%26)%26 + 'a';
  cout << s << endl;
  return 0;
}


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

using namespace std;

#define pb push_back
#define pp pop_back
#define mp make_pair
#define F first
#define S second
#define xmax(x,y) ((x) = max((x),(y)))
#define xmin(x,y) ((x) = min((x),(y)))
#define all(x) (x).begin(),(x).end()
#define mem(x) memset(x , 0 , sizeof(x))
#define _ ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define FP(a , b , c)  for(ll (a) = (b) ; (a) < (c) ; (a++));
#define FM(a , b , c)  for(ll (a) = (b) ; (a) >= (c) ; (a--));
#define connect(a , b , c) a[b].pb(c) , a[c].pb(b)

typedef long long int ll;
typedef unsigned long long int ull;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector <ll> vl;
typedef vector <int> vi;
typedef vector <string> vs;

const ll Maxn3 = 1e3 + 10;
const ll Maxn4 = 1e4 + 10;
const ll Maxn5 = 1e5 + 10;
const ll Maxn6 = 1e6 + 10;
const ll Maxn7 = 1e7 + 10;
const ll Maxn8 = 1e8 + 10;
const ll Maxn9 = 1e9 + 10;
const ll Maxn18 = 1e18 + 10;
const ll Mod1 = 1e7 + 7;
const ll Mod2 = 1e9 + 7;
const ll LLMax = LLONG_MAX;
const ll LLMin  = LLONG_MIN;
const ll INTMax = INT_MAX;
const ll INTMin  = INT_MIN;

ll mn = LLMax , mx = LLMin;

int main() 
{_
 int n, m, x, a, minL=0, minR=0;
 cin>>n>>m>>x;
 for(int i=0;i<m;i++) {
  cin>>a;
  if(a<x) minL++;
  else if(a>x) minR++;
 }
 if(minL<minR) cout<<minL;
 else cout<<minR;
}
///SAliB


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h> //mathライブラリの宣言

void Constraints(int a,int b)
{
  if(1<=a&&a<=pow(10,9)&&1<=b&&b<=pow(10,9)){}
  else
  {
    printf("条件を満たす入力をしてください。\n");
    exit(0);
  }
}


int main(void)
{
  int a,b,d,r;
  double f;
  scanf("%d %d",&a,&b);
  Constraints(a,b);
  d=a/b;
  r=a%b;
  f=(double)a/b; //int型からfloat型への型変換
  printf("%d %d %.6f\n",d,r,f); //小数点以下6桁のみ表示
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

int main() {
    string s;
    cin >> s;

    int n = (int)s.size();
    int m = 1 << (n - 1);

    int64_t r = 0;
    for (int i = 0; i < m; i++) {
        int64_t t = s[0] - '0';
        for (int j = 0; j < n; j++) {
            if (j == n - 1 || (i & 1 << j)) {
                r += t;
                t = 0;
                if (j == n - 1) break;
            }
            t *= 10;
            t += s[j + 1] - '0';
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256