akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>

int main(){
  int n,i,j;
  double x[4],y[4],r,a1,a2,b1,b2,c1,c2;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<3;j++)scanf("%lf%lf",&x[j],&y[j]);
    a1=2*(x[1]-x[0]);b1=2*(y[1]-y[0]);c1=x[0]*x[0]-x[1]*x[1]+y[0]*y[0]-y[1]*y[1];
    a2=2*(x[2]-x[0]);b2=2*(y[2]-y[0]);c2=x[0]*x[0]-x[2]*x[2]+y[0]*y[0]-y[2]*y[2];

    x[3]=(b1*c2-b2*c1)/(a1*b2-a2*b1);
    y[3]=(c1*a2-c2*a1)/(a1*b2-a2*b1);

    r=sqrt((x[3]-x[0])*(x[3]-x[0])+(y[3]-y[0])*(y[3]-y[0]));

    printf("%.3f %.3f %.3f\n",x[3],y[3],r);
  }
  return 0;
}

Measured memory_bytes: 664
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define W V<long long>
#define R(i,n) for(int i=0;i<n;i++)
W S(V<W>&p,int E){if(!E){return{1,0};}V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1){T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}}V<W>c(3,W(2));R(i,2){for(W x:T[i]){int Q=(2*x[0]+x[1])%3;if((Q+1)%2){c[i][0]^=1;}if(Q){c[i][1]^=1;}}}R(i,2){if(c[1-i]==c[2]){W ans=S(T[i],E-1);ans[0]*=2;ans[1]*=2;ans[1]+=i;return ans;}}for(W&v:p){v[0]++;}W A=S(p,E);A[0]--;return A;}
int main(){long long M=2e17;int n;cin>>n;V<W>p(n);R(i,n){long long a,b;cin>>a>>b;p[i]={a+M,b+M};}W Q=S(p,70);cout<<Q[0]-M<<" "<<Q[1]-M;}

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

int main(){
    int N,A; cin >> N >> A;
    vector<int> X(N+1);
    for(int i=0;i<N;i++){
        cin >> X[i];
    }
    ll dp[N+10][N+10][A*N+100];
    rep(i,N+1){
        rep(j,N+1){
            rep(k,A*N+1){
                dp[i][j][k] = 0;
            }
        }
    }
    dp[0][0][0] = 1;
    for(int i=0;i<N;i++){
        for(int j=0;j<=i;j++){
            for(int k=0;k<=N*A;k++){
                dp[i+1][j+1][k+X[i]] += dp[i][j][k];
                dp[i+1][j][k] += dp[i][j][k];
            }
        }
    }

    ll res=0;
    for(int i=1;i<=N;i++){
        res += dp[N][i][A*i];
    }
    cout << res << endl;
}

Measured memory_bytes: 56500
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
struct node{char op;int x,y,z;};
int now=199999,p[63],a[31],b[31],tmp;
int New(){return now--;}
vector<node>ans;
int Add(int x,int y){
    int p=New();ans.pb(node{'+',x,y,p});
    return p;
}
void Add2(int x,int y){ans.pb(node{'+',x,y,x});}
void Shift(int x,int y){
    for(int i=0;i<y;i++)
        ans.pb(node{'+',x,x,x});
}
int cmp(int x,int y){
    int p=New();ans.pb(node{'<',x,y,p});
    return p;
}
void get(int *a,int pp){
    tmp=New();
    for(int i=30;~i;i--){
        a[i]=cmp(Add(tmp,p[i]),pp);
        int q=cmp(Add(tmp,p[i]),pp);
        Shift(q,i);Add2(tmp,q);
    }
}
int main(){
    // freopen("data.txt","w",stdout);
    p[0]=cmp(2,Add(0,1));
    ans.pb(node{'+',0,p[0],0});
    ans.pb(node{'+',1,p[0],1});
    for(int i=1;i<31;i++)
        p[i]=Add(p[i-1],p[i-1]);
    get(a,0);get(b,1);
    for(int i=60;~i;i--){
        Add2(2,2);
        for(int j=max(0,i-30);j<=min(30,i);j++)
            Add2(2,cmp(p[0],Add(a[j],b[i-j])));
    }
    printf("%d\n",ans.size());
    for(int i=0;i<ans.size();i++)
        printf("%c %d %d %d\n",ans[i].op,ans[i].x,ans[i].y,ans[i].z);
    return 0;
}

Measured memory_bytes: 3780
using System;
using System.Linq;
public class Program{
  public static void Main(){
    var ab = Console.ReadLine().Split().Select(a => int.Parse(a)).ToArray();
    if (ab[0] * ab[1] % 2 == 0) {
      Console.WriteLine("Even");
    } else {
      Console.WriteLine("Odd");
    }
  }
}

Measured memory_bytes: 13396
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		sc = null;
		int cnt=0;
		for(i=0; i<s.length(); i++) {
			if(s.charAt(i)=='1') cnt++;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
int main(){
int64_t N;
  cin>>N;
  vector<int64_t>A(N);
  for(int64_t i=1;i<=N;i++){
  int64_t a;
    cin>>a;
    a-=i;
    A.at(i-1)=a;
  
  }sort(A.begin(),A.end());
  int64_t b=A.at(N/2);
  int64_t ans=0;
  for(int64_t i=0;i<N;i++){
  ans+=abs(A.at(i)-b);
  
  }cout<<ans<<endl;

   return 0;
}

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

using namespace std;

inline int read()
{
    char ch=getchar(); int f=1,x=0;
    while (ch<'0' || ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
    while (ch>='0' && ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
    return f*x;
}

int n,s[2005];

signed main()
{
    n=read();
    for (int i=1;i<=n;i++) s[i]=read();
    sort(s+1,s+n+1);
    long long ans=0;
    for (int i=1;i<=n;i++)
    {
        for (int j=i+1;j<=n;j++)
        {
            int pos=lower_bound(s+1,s+n+1,s[i]+s[j])-s-1;
            ans+=max(0,pos-j);
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,l,s=0;
    cin>>n>>l;
    int mi=0;
    if(l<0)
    mi=min(0,l+n-1);
    else
    mi=l;
    for(int i=1;i<=n;i++)
        s+=l+i-1;
    cout<<s-mi<<endl;
    return 0;
}


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

using namespace std;

int sum, rad, nr, N, M, ap[100009], st[100009], to_count[100009];
vector < int > v[100009];
queue < int > cc;

/*void df2 (int nod)
{
    ap[nod] = 1, rad = nod;
    for (auto it = v[nod].begin (); it != v[nod].end (); it ++)
        if (ap[*it] == 0)
            df2 (*it);
}*/

void dfs (int nod)
{
    ap[nod] = 0, st[++nr] = nod, sum += to_count[nod];
    int cnt = 0;
    for (auto it = v[nod].begin (); it != v[nod].end (); it ++)
        if (ap[*it])
            cnt ++, dfs (*it);
    if (cnt == 0 && sum == v[rad].size ())
    {
        printf ("%d\n", nr);
        for (int i=1; i<=nr; i++)
            printf ("%d ", st[i]);
        printf ("\n");
        exit (0);
    }
    nr --, sum -= to_count[nod];
}

void Try (int x)
{
    rad = x;
    for (int i=1; i<=N; i++)
        ap[i] = 1, to_count[i] = 0;
    for (auto it = v[rad].begin (); it != v[rad].end (); it ++)
        to_count[*it] = 1;
    nr = sum = 0;
    dfs (rad);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M);
while (M --)
{
    int x, y;
    scanf ("%d %d", &x, &y);
    v[x].push_back (y);
    v[y].push_back (x);
}
cc.push (1), ap[1] = 1;
vector < int > order;
while (!cc.empty ())
{
    int nod = cc.front ();
    cc.pop ();
    order.push_back (nod);
    for (auto it = v[nod].begin (); it != v[nod].end (); it ++)
        if (ap[*it] == 0)
            cc.push (*it), ap[*it] = 1;
}
for (auto it = order.rbegin (); it != order.rend (); it ++)
    Try (*it);

return 0;
}


Measured memory_bytes: 12664
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

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

	int max = 0;
	FOR(i, N, 1)
	{
		int num = 0;
		bool c[30] = { false };
		REP(j, i)
		{
			c[(int)(S[j] - 'a')] = true;
		}
		bool u[30] = { false };
		FOR(j, N, i)
		{
			if (c[(int)(S[j] - 'a')] && !u[(int)(S[j] - 'a')])
			{
				u[(int)(S[j] - 'a')] = true;
				num++;
			}
		}
		max = std::max(max, num);
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a>=13)
    cout<<b<<endl;
  else if(a>=6&&a<=12)
    cout<<(b/2)<<endl;
  else if(a<=5)
    cout<<0<<endl;
  }


Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int mod=1e9+7;

int id[1005][1005];
vector<int>to[1000005];
bool visited[1000005];
int dp[1000005];
bool calculated[1000005];

int toid(int i,int j){
  if(i>j){swap(i,j);}
  return id[i][j];
}

int dfs(int v){
  if(visited[v]){
    if(!calculated[v]){
      return -1;
    }
    return dp[v];
  }
  visited[v]=1;
  dp[v]=1;
  for(int u:to[v]){
    int res=dfs(u);
    if(res==-1){return -1;}
    dp[v]=max(dp[v],res+1);
  }
  calculated[v]=1;
  return dp[v];
}

int main() {
  int N;
  cin>>N;
  vector<vector<int>>A(N,vector<int>(N-1));
  for(int i=0;i<N;i++){
    for(int j=0;j<N-1;j++){
      cin>>A[i][j];
      A[i][j]--;
    }
  }
  int v=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
       if(i<j){
         id[i][j]=v++;
       }
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N-1;j++){
      A[i][j]=toid(i,A[i][j]);
    }
    for(int j=0;j<N-2;j++){
      to[A[i][j+1]].push_back(A[i][j]);
    }
  }
  int ans=0;
  for(int i=0;i<v;i++){
    int res=dfs(i);
    if(res==-1){
      cout<<-1<<endl;return 0;
    }
    chmax(ans,res);
  }
  cout<<ans<<endl;
  return 0;  
}

Measured memory_bytes: 53452
#include <bits/stdc++.h>
using namespace std;
 
#define fio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
// #define double long double
// #define mp make_pair
// #define pb push_back
// Upper case English alphabet to lower case ch |= ' ';
// Lower case English alphabet to upper case ch &= '_’ ;
//__builtin_popcount(x)

int M=(int)1e9+1,t=0;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int digits(int n){return floor(log10(n))+1 ;}
bool ispoweroftwo (int x) { return x && (!(x&(x-1))); }
// vector<int> vis,parent,ti,tout,dis;
// vector<vector<int> > adj;
 
// void dfs(int v){
//     vis[v]=1;
//     for(int i:adj[v]){
//         if(vis[i]){
//             t=1;
//             return ;
//         }
//             //dis[i]=1+dis[v];
//             //parent[i]=v;
//             vis[i]=1;
//             dfs(i);

//     }
//     return ;
    
// }




signed main(){
    fio;
    int n,k;
    cin>>n>>k;
    vector<int> v(n+1);
    for(int i=1;i<=n;i++) cin>>v[i];
    int dp[n+1];
    dp[0]=dp[1]=0;
    //dp[2]=abs(v[1]-v[2]);
    for(int i=2;i<=n;i++){
        dp[i]=M;
        for(int j=1;j<=k;j++){
            if(i>j) dp[i]=min(dp[i-j]+abs(v[i]-v[i-j]),dp[i]);
        }
    }
    cout<<dp[n]<<endl;
    


    

    
    
}

Measured memory_bytes: 1792
#include <cstdio>
#include <utility>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
#define bs inline bool scan
ii(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
ii() {return in(gcu());}
bs(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bs(char &c){c=gcu();gcu();return c!=EOF;}
// bs(string &s){int c; s = "";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#undef ii
#undef bs
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
// vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T>
//vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

int main() {
	for (int c; (c = gcu()) != EOF;)
		if (c == '@')
			for (int i = gcu() - '0', r = gcu(); i; i--)
				pcu(r);
		else
			pcu(c);
}


Measured memory_bytes: 2628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;
  int ans=-1;
    cin >> s;
    for(int i=0; i<s.size(); i+=2){
      string a = s.substr(0, (s.size()-i)/2);
      string b = s.substr((s.size()-i)/2, (s.size()-i)/2);
      //cout << a << ' ' << b << endl;
      if(a==b && i!=0){
        ans = b.size()*2;
        break;
      }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
   int a,b,p;
   scanf("%d",&a);
   scanf("%d",&b);
   if(a>=b)
   p=a-b;
   else
   p=b-a;
 
   printf("%d\n",p+1);
   
 
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int Binary_Search(int a[], int l, int r, int key)
{
    int mid,ans=-1;
    while(l<=r)
    {
        mid=l+(r-l)/2;
        if(a[mid]>=key)
        {
            ans=mid;
            r=mid-1;
        }
        else
        {
            l=mid+1;
        }
    }
    return ans;
}
int main()
{
    int n;
    cin >> n;
    int a[n],i,j;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
    }
    int countr=0;
    sort(a, a+n);
    //int result=Binary_Search(a, 0, n-1, 10);
    //cout << result;
    for(i=0;i<n-2;i++)
    {
        for(j=i+1;j<n-1;j++)
        {
            int sum=a[i]+a[j];
            int result;
            result=Binary_Search(a,j+1, n-1, sum);
            if(result!=-1)
            {
                //cout << result << endl;
                countr+=(result-j-1);
            }
            else
            {
                countr+=(n-j-1);
            }
        }
    }
    cout << countr;
}


Measured memory_bytes: 3636
#151-D:BFS
from collections import deque
#スタート地点loc=(sx,sy)を決めたときのゴールをbfsで求める
def bfs(loc):
    global tem_ans
    d=[[float('inf')]*w for i in range(h)]

    #進む方向を決める
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]

    que=deque([])
    que.append(loc)
    d[loc[0]][loc[1]]=0

    #遷移していってこれ以上遷移できない状態まで埋める
    while que:
        p=que.popleft()
        for i in range(4):
            nx=p[0]+dx[i]
            ny=p[1]+dy[i]

            #遷移可能かどうか調べる
            if 0<=nx<h and 0<=ny<w and maze[nx][ny]=='.' and d[nx][ny]==float('inf'):
                #移動後の距離を保存
                d[nx][ny]=d[p[0]][p[1]]+1
                que.append([nx,ny])

                if tem_ans<d[nx][ny]:
                    tem_ans=d[nx][ny]
    return tem_ans



h,w=map(int,input().split())
maze=[list(input()) for i in range(h)]
ans=0
tem_ans=0

loc=[]
for i in range(h):
    for j in range(w):
        #通路をスタート地点に設定する
        if maze[i][j]!='#':
            loc=[i,j]
        else:
            continue
        ans=max(ans,bfs(loc))

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(), (a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
  return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main()
{
  int n;
  vector<int> a(100001,0);
  cin >> n;
  rep(i,n)
  {
    cin >> a[i];
  }
  int i = 0, cnt = 0;
  while(i != 1)
  {
    i = a[i] - 1;
    cnt++;
    if(cnt == n)
    {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << cnt << endl;
}

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


int main()
{
	int cnt = 0;
	string word, sentence;
	cin >> word;

	while (true)
	{
		cin >> sentence;

		if (sentence == "END_OF_TEXT") {
			break;
		}

		for (int i = 0;i < sentence.size();i++) {
			sentence[i] = tolower(sentence[i]);
		}

		if (sentence == word) {
			cnt++;
		}
	}

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



Measured memory_bytes: 3116
require 'pp'

class Array
  define_method(:sum){self.inject(:+)} unless method_defined?(:sum)
end

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N, K = gets_i_list
p_list = gets_i_list

e_list = p_list.map do |p|
  (p + 1) * 0.5
end

sum_list = [0]
(0...N).each do |i|
  sum_list[i+1] = sum_list[i] + e_list[i]
end

max = 0
0.upto(N - K) do |i|
  total = sum_list[i+K] - sum_list[i]
  max  = [max, total].max
end
puts sprintf("%.12f", max)


Measured memory_bytes: 23036
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;
long long a[501][501];

int main(){
	long long  H,W,h,w;
	cin >> H >> W >> h >> w;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if((i+1)%h==0&&(j+1)%w==0){
				a[i][j] = -(1000*h*w-999);
			}else{
				a[i][j] = 1000;
			}
		}
	}		
	if(H%h==0&&W%w==0){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
		for(int i=0;i<H;i++){
			for(int j=0;j<W-1;j++){
				cout << a[i][j] << " ";
			}
			cout << a[i][W-1] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int mm[2005];
const int mod=1e9+7;

signed main()
{

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++)  
    {
        cin>>a[i];
        mm[a[i]]++;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=a[i]-1;j>=1;j--)
        {
            ans+=(mm[j]*((((k-1)*(k))/2)%mod))%mod;
            ans%=mod;
        }
        int tt=0;
        for(int j=n;j>i;j--)
        {
            if(a[j]<a[i])
            {
                tt++;
            }
        }
        ans+=(tt*k)%mod;
        ans%=mod;
    }
    cout<<ans;


} 



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,d,y,n;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    y=a/d;
    n=c/b;
    if(a%d!=0)y++;
    if(c%b!=0)n++;
    if(y<n){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include<stdlib.h>
 
#define N 100000
#define INF 1000000
 
typedef struct{
    int go,back,cost;
}Date;
 
int n,d[N];
Date a[500000];
void root(int);
 
int main(void){
    int i,j,u,k,count=0;
    scanf("%d",&n);
    for(i=0;i<n;i++) {
        scanf("%d%d",&u,&k);
        for(j=0;j<k;j++){
            a[count].back=u;
            scanf("%d%d",&a[count].go,&a[count].cost);
            count++;
        }
    }
    root(count);
    for(i=0;i<n;i++) printf("%d %d\n",i,d[i]);
    return 0;
}
 
void root(int b){
    int i,flag=1;
     
    for(i=0;i<n;i++) d[i]=INF;
    d[0]=0;
     
    while(flag!=0){
        flag=0;
        for(i=0;i<b;i++){
            if(a[i].cost+d[a[i].back]<d[a[i].go]){
                d[a[i].go]=a[i].cost+d[a[i].back];
                flag=1;
            }
        }
    }
}

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

int main()
{
  string S;
  cin >> S;
  bool YYMM = false;
  bool MMYY = false;
  string substr1 = S.substr(0, 2);
  string substr2 = S.substr(2, 2);
  int num1 = stoi(substr1);
  int num2 = stoi(substr2);
  if (num1 >= 1 and num1 <= 12 and num2 >= 0)
  {
    MMYY = true;
  }
  if (num2 >= 1 and num2 <= 12 and num1 >= 0)
  {
    YYMM = true;
  }
  if (YYMM and MMYY)
    cout << "AMBIGUOUS" << endl;
  else if (YYMM and !MMYY)
    cout << "YYMM" << endl;
  else if (!YYMM and MMYY)
    cout << "MMYY" << endl;
  else
    cout << "NA" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,b,c,d;

	scanf("%d",&a);
  	scanf("%d",&b);
	scanf("%d",&c);
  	scanf("%d",&d);
  
  	if(a+b < c+d){
      printf("Right");
    }else if(a+b > c+d){
      printf("Left");
    }else{
      printf("Balanced");
    }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if(N / 1000 == N / 100 % 10 && N / 100 % 10 == N / 10 % 10){
    cout << "Yes" << endl;
  }else if(N / 100 % 10 == N / 10 % 10 && N / 10 % 10 == N % 10){
    cout << "Yes" << endl;
  }else{cout << "No" << endl;
       }
}

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

int main() {
  
  int N; cin >> N; int ans = 1000000;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) cin >> vec.at(i);
  
  for (int i = 1; i < 101; i++) {
    
    int tmp = 0;
    
    for (int j = 0; j < N; j++) {
      int dif = vec.at(j) - i;
      tmp += dif * dif;
    }
    
    ans = min(ans, tmp);
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n; cin >> n;
  vector<unsigned long long> a(n);
  rep(i,n) { cin >> a[i]; if(a[i]==0) { cout << 0 << endl; return 0; } }
  unsigned long long ret = 1;
  rep(i,n){
    unsigned long long ret_old = ret;
    ret *= a[i];
    if(ret/a[i]!=ret_old) {cout << -1 << endl; return 0;}
  }
  if(ret>1000000000000000000) cout << -1 << endl;
  else cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3948
// abc147_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif
    int A, B, C;
    cin >> A >> B >> C;

    if (A + B + C >= 22){
        print("bust");
    } else {
        print("win");
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

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

const int INF = 1e17;

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    int l = 0, r = 4e5;
    map<int, int> dep;
    while(r - l > 1) {
        int m = (r + l) / 2;
        dep.clear();
        bool fl = true;
        dep[a[0]] = 0;

        if(m == 1) {
            for(int i = 1; i < n; ++i) {
                if(a[i] <= a[i - 1]) {
                    fl = false;
                    break;
                }
            }
        }
        else {
            for(int i = 1; i < n; ++i) {
                if(!fl)
                    break;
                if(a[i] > a[i - 1])
                    dep[a[i]] = 0;
                else
                    dep[a[i]] += 1;
                while(!dep.empty()) {
                    auto d = dep.end();
                    --d;
                    if(d->first > a[i])
                        dep.erase(d);
                    else
                        break;
                }
                if(dep[a[i]] == m) {
                    int op = a[i];
                    while(dep[op] == m) {
                        dep[op] -= m;
                        --op;
                        dep[op] += 1;
                        if(op <= 0)
                            break;
                    }
                    if(op <= 0) {
                        fl = false;
                        break;
                    }
                }
            }
        }
        if(fl)
            r = m;
        else
            l = m;
    }
    cout << r;
    return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    string s;cin>>s;
    int ans = 0,res=0;
    for(auto c:s){
        if(c=='R') res++;
        else res=0;
        ans = max(ans,res);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
from bisect import insort, bisect_right, bisect_left


class IntSet:
    def __init__(self) -> None:
        self.total = 0
        self.ms: dict = dict()
        self.lr: list = []

    def insert(self, x: int) -> None:
        if x in self.ms:
            if self.ms[x] == 0:
                self.ms[x] = 1
                self.total += 1
        else:
            self.total += 1
            self.ms[x] = 1
            insort(self.lr, x)
        print(self.total)

    def find(self, x: int) -> None:
        print(self.ms.get(x, 0))

    def delete(self, x: int) -> None:
        if x in self.ms:
            self.total -= self.ms[x]
            self.ms[x] = 0

    def dump(self, l: int, r: int) -> None:
        lb = bisect_left(self.lr, l)
        ub = bisect_right(self.lr, r)
        for i in range(lb, ub):
            k = self.lr[i]
            v = self.ms[k]
            print(f'{k}\n' * v, end='')


if __name__ == "__main__":
    ms = IntSet()
    num_query = int(input())
    for _ in range(num_query):
        op, *v = map(lambda x: int(x), input().split())
        if 0 == op:
            ms.insert(v[0])
        elif 1 == op:
            ms.find(v[0])
        elif 2 == op:
            ms.delete(v[0])
        else:
            ms.dump(v[0], v[1])



Measured memory_bytes: 27712
# coding: utf-8
# Your code here!
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
F=int(input())

A,B,C,D=sorted([A,B,C,D])
E,F=sorted([E,F])

print(sum((B,C,D,F)))


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

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

    int N;
    int sum = 0;

    cin >> N;

    char S[N];

    rep(i, N)
    {
        cin >> S[i];

        if (i != 0 && S[i] == S[i-1])
        {
            ++sum;
        }
    }

    cout << N-sum;

    return 0;
}

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

int main(){
    int n; cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(),d.end());
    cout << d[n/2]-d[n/2-1] << endl;
}

Measured memory_bytes: 640
#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 DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
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;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vll a(n); for(auto& e : a) cin >> e;
    {
        int mi = max_element(_all(a)) - begin(a);
        vll b(n);
        rep(i, n){
            b[i] = a[(mi + i) % n];
        }
        a = b;
    }

    ll sum = 0LL;
    vll endnum(n);
    ll opnum = 0LL;
    rep(loop, n * 5){
        int i = (10 * n - loop) % n;
        int j = (i + 1) % n;

        sum -= opnum;
        a[i] -= sum;
        opnum -= endnum[i];
        endnum[i] = 0;

        if(a[i] != 0LL and a[i] >= a[j]){
            ll cnt = (a[i] - a[j] + n) / n;
            a[i] -= n * cnt;
            sum += n * cnt;
            endnum[i] += cnt;
            opnum += cnt;
        }
        if(a[i] < 0LL) break;
    }

    string res = "YES";

    int mi = min_element(_all(a)) - begin(a);
    ll base = a[mi];
    if(base < 0) res = "NO";
    rep(i, n){
        int j = (mi + i) % n;
        a[j] -= base * (i + 1);

        if(a[j] != 0LL){
            res = "NO";
            break;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    while(cin >> n){
        vector<double> dp(n + 1);
        dp[0] = 1;
        REPS(i, n) {
            double p; cin >> p;
            vector<double> nxt(n + 1);
            REP(j, i) {
                nxt[j] += (1 - p) * dp[j];
                nxt[j + 1] += p * dp[j];
            }
            swap(dp, nxt);
        }
        double ans = 0;
        REP(i, n + 1) {
            if (n - i < i) ans += dp[i];
        }
        printf("%.20f\n", ans);
    }
    return 0;
}


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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

int main(){
    int N;
    cin >> N;
    if(N <= 999){
        cout << "ABC" << endl;
    }else{
        cout << "ABD"<< endl;
    }
}


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

int main() {
     char s;
     cin >>s;
     if(s=='A'){
         cout << 'T' << endl;
     }
     if(s=='T'){
         cout << 'A' << endl;
     }
     if(s=='C'){
         cout << 'G' << endl;
     }
     if(s=='G'){
         cout << 'C' << endl;
     }
return 0;
}

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

bool isPrime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0)
            return false;
    }
    return x != 1;
}

int main() {
    int n;
    cin >> n;
    int res = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (isPrime(x)) res++;
    }
    cout << res << endl;
    return 0;
} 


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

#ifndef UNION_FIND_TREE
#define UNION_FIND_TREE
template<typename T>
class UnionFindTree{
	private:
		int N;
		vector<int> parent, rank, size;
		vector<T> diff_weight;

	public:
		void init(){
			for(int i = 0; i < (int) N; i++){
				parent[i] = i; rank[i] = 0; size[i] = 1; diff_weight[i] = 0;
			}
		}

		UnionFindTree(int N): N(N), parent(N), rank(N), size(N), diff_weight(N){
			init();
		}

		int root(int x){
			if(parent[x] == x){
				return x;
			}else{
				int r = root(parent[x]);
				diff_weight[x] += diff_weight[parent[x]];
				return parent[x] = r;
			}
		}

		T weight(int x){
			root(x);
			return diff_weight[x];
		}

		T diff(int x, int y){
			return weight(y) - weight(x);
		}

		// weight(y) = weight(x) + w となるようにmergeする
		bool unite(int x, int y, T w = 0){
			w += weight(x); w -= weight(y);
			x = root(x); y = root(y);
			if(x == y) return weight(y) - weight(x) == w;

			if(rank[x] < rank[y]){
				swap(x, y);
				w = -w;
			}

			parent[y] = x;
			size[x] += size[y];
			if(rank[x] == rank[y]) rank[x]++;
			diff_weight[y] = w;
			return true;
		}

		bool isSame(int x, int y){
			return root(x) == root(y);
		}
		
		int count(int x){
			return size[root(x)];
		}
};
#endif


int main(void){
	int n, q;
	cin >> n >> q;

	UnionFindTree<int> ut(n);
	vector<string> vec;
	for(int i = 0; i < q; i++){
		int k;
		cin >> k;
		if(k){
			int x, y;
			cin >> x >> y;
			vec.push_back(ut.isSame(x, y) ? to_string(ut.diff(x, y)) : "?");
		}else{
			int x, y, z;
			cin >> x >> y >> z;
			ut.unite(x, y, z);
		}
	}

	for(auto res: vec) cout << res << '\n';

	return 0;
}


Measured memory_bytes: 10100
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    int l, i=0, a[10];
    while(2 > i){
        cin >> a[i];
        i++;
    }
    if (a[0] > 8 || a[1] > 8) {
        cout << ":(" << "\n";
    } else {
        cout << "Yay!" << "\n";
    }
}

Measured memory_bytes: 3636
#include<stdio.h>
int main (void){
    int a,i,j,n;
    for(;;){
        scanf("%d",&n);
        if(n==0)break;
        int k[11]={0};
        for(i=0;i<n;i++){
            scanf("%d",&a);
            if(a==0)k[0]++;
            else if(a==1)k[1]++;
            else if(a==2)k[2]++;
            else if(a==3)k[3]++;
            else if(a==4)k[4]++;
            else if(a==5)k[5]++;
            else if(a==6)k[6]++;
            else if(a==7)k[7]++;
            else if(a==8)k[8]++;
            else if(a==9)k[9]++;
        }
        for(i=0;i<10;i++){
            if(k[i]==0)printf("-\n");
            for(j=0;j<k[i];j++){
                printf("*");
                if(j==k[i]-1)printf("\n");
            }
        }
    }
return 0;
}

Measured memory_bytes: 568
#[warn(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1}
};

#[fastout]
fn main() {
   input! {
      mut x: i64
   }
   for b in -150..150 {
      for a in b+1..150 {
         let c = f5(a) - f5(b);
         if c > x {
            break;
         }
         if c == x {
            println!("{} {}", a, b);
            return;
         }
      }
   }
}

fn f5(x: i64) -> i64 {
   x*x*x*x*x
}


Measured memory_bytes: 2204
n, a, b = map(int,input().split())
MOD = 10**9 + 7
ans = pow(2,n,MOD)-1

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
            result %= MOD

    return result
ans -= (cmb(n,a) + cmb(n,b))
print(ans%MOD)


Measured memory_bytes: 108236
/*
 *  author : Atul Anand   
 *  created on : Wed Apr 01 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        boolean flag = true;
        for(int i = 0; i < N; i++){
            int A = in.nextInt();
            if((A & 1) == 0){
                if(A % 3 != 0 && A % 5 != 0){
                    flag = false;
                }
            }
        }
        
        if(flag){
            println("APPROVED");
        }
        else{
            println("DENIED");
        }

        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 21076
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
long long disum(long long x,long long a){
    long long sum=0;
    while(x>0){
        sum++;
        x/=a;
    }
    return sum;
}
int main(){
    long long n,k;
    scanf("%lld %lld",&n,&k);
    printf("%lld",disum(n,k));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    ll K;
    cin >> K;
    vector<ll> used(K, false);
    int ans = 0;
    ll now = 0;
    while(true){
        ans++;
        now *= 10, now += 7, now %= K;
        if(used[now]){
            ans = -1;
            break;
        }
        if(now == 0) break;
        used[now] = true;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11172
#include<bits/stdc++.h>
using namespace std;
typedef long double ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
	cin>>a[i];
    }
    ll res = 0;
    for(int i=0;i<n;i++)res += ( (ll) 1.0)/a[i];
    printf("%0.7lf\n", (double)(1.0/res ));
    return 0;
}


Measured memory_bytes: 256
import sys
from io import StringIO
import unittest

def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    total = sum(a)
    ans = []
    x = 0
    for i in range(n - 1):
        x += a[i]
        y = total - x

        ans.append(abs(x - y))

    print(min(ans))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """6
1 2 3 4 5 6"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """2
10 -10"""
        output = """20"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 27340
#include <stdio.h>

int main(void) {
	static int room[4][3][10];
	int n, b, f, r, v;

	scanf("%d\n", &n);

	for (int i = 1; i <= n; i++) {
		scanf("%d %d %d %d\n", &b, &f, &r, &v);
		
		room[b - 1][f - 1][r - 1] += v;
	}

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

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

int main(){
    char alp[] = "abcdefghijklmnopqrstuvwxyz";
    char input;
    cin >> input;
    char ans;
    for (int i = 0; i < sizeof(alp); i++)
    {
        if (input == alp[i])
        {
            ans = alp[i + 1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256