akhauriyash/Code-Regression huggingface dataset:
class UnionFind():                                                                                             
    def __init__(self, n):
        self.__parent = [i for i in range(n)]
        self.__rank = [0 for i in range(n)]
        self.size = [1 for _ in range(n)]

    def union(self, x, y):
        pX, pY = self.find(x), self.find(y)
        if pX != pY: 
            if self.__rank[pX] > self.__rank[pY]:
                self.__parent[pY] = pX
                self.size[pX] += self.size[pY]
                self.__rank[pX] += 1
            else:
                self.__parent[pX] = pY
                self.size[pY] += self.size[pX]
                self.__rank[pY] += 1

    def find(self, x): 
        if self.__parent[x] != x:
            self.__parent[x] = self.find(self.__parent[x])
        return self.__parent[x]

N, M = map(int, input().split())
bridge = [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(M)]
uf = UnionFind(N)
num_disconnect = int(N*(N-1)/2)
ans = []
for a, b in reversed(bridge):
    ans.append(num_disconnect)
    pA, pB = uf.find(a), uf.find(b)
    if pA != pB:
        num_disconnect -= uf.size[pA] * uf.size[pB]
        uf.union(a, b)

for i in reversed(ans): print(i)

Measured memory_bytes: 26140
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N;
	if (N == 3) {
		cout << "2 5 63\n";
		return 0;
	}
	vector<int>bag({ 2,3,4,6,8,9,10,12 });
	vector<int>v((N / 8) * 8);
	int box = 0;
	for (int i = 0; i + 8 <= N; i += 8) {
		for (int j = 0; j < 8; j++) {
			v[i + j] = box + bag[j];
		}
		box += 12;
	}
	switch (N % 8) {
	case 1:
		v.push_back(box + 6);
		break;
	case 2:
		v.push_back(box + 6);
		v.push_back(box + 12);
		break;
	case 3:
		v.push_back(box + 2);
		v.push_back(box + 4);
		v.push_back(box + 6);
		break;
	case 4:
		v.push_back(box + 2);
		v.push_back(box + 4);
		v.push_back(box + 3);
		v.push_back(box + 9);
		break;
	case 5:
		v.push_back(box + 2);
		v.push_back(box + 4);
		v.push_back(box + 3);
		v.push_back(box + 9);
		v.push_back(box + 6);
		break;
	case 6:
		v.push_back(box + 2);
		v.push_back(box + 4);
		v.push_back(box + 3);
		v.push_back(box + 9);
		v.push_back(box + 6);
		v.push_back(box + 12);
		break;
	case 7:
		v.push_back(box + 2);
		v.push_back(box + 3);
		v.push_back(box + 4);
		v.push_back(box + 8);
		v.push_back(box + 9);
		v.push_back(box + 10);
		v.push_back(box + 12);
		break;
	}
	for (auto i : v) {
		cout << i << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
using System;
class Program {

    static void Main (string[] args) {
        string[] input = Console.ReadLine ().Split (' ');
        long n = long.Parse(input[0]);
        long a = long.Parse(input[1]);
        long b = long.Parse(input[2]);
        if ((b - a) % 2 == 0) {
            Console.WriteLine ((b - a) / 2);
        } else {
            if (a + b < n + 1) {
              Console.WriteLine ((b - a - 1) / 2 + a);
            } else {
              Console.WriteLine ((b - a - 1) / 2 + n - b + 1);
            }
        }
    }
}

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

int H[305];
int sortedH[305];

long long memo[305][305];

// j: k left unclaimed
long long dp(int i, int j){
    if(i == 0){
        return 0;
    }else if(i == 1){
        return H[1];
    }else if(memo[i][j] != -1){
        return memo[i][j];
    }else{
        long long ans = max(H[i]-H[i-1], 0)+dp(i-1, j);
        int min1 = 2147483647;
        // pivot at indx i
        int jPen = 0;
        // x is beginning of continuous strip of at least min1
        // 9 14 5 8 9
        for(int x = i-1; x >= max(i-j, 1); x --){
            jPen ++;
            if(jPen > j){break;}
            min1 = min(min1, H[x]);
            if(1){
                ans = min(ans, max(H[i]-H[x-1], 0) + dp(x-1, j-jPen));
            }
        }
        //printf("%d %d %lld\n", i, j, ans);
        return memo[i][j] = ans;
    }
}

int main(){
    int N, K;
    scanf("%d%d", &N, &K);

    sortedH[0] = H[0] = 0;
    for(int i = 1; i <= N; i ++){
        scanf("%d", &H[i]);
        sortedH[i] = H[i];
    }
    memset(memo, -1, sizeof(memo));
    printf("%lld", dp(N+1, K));
    return 0;
}


Measured memory_bytes: 1024
main=do
 n<-readLn;a<-map read.words<$>getLine
 print((maximum.map(\(a,b)->if(a==0||b==0)then(max a b)else(gcd a b)))(zip(reverse(f n (reverse a) 0))(f n a 0)))
  where f 0 _ _ =[]
        f n (b:a) 0 =0:(f(n-1)a b)
        f n (b:a) g =g:(f(n-1)a(gcd g b))

Measured memory_bytes: 84348
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()

ll calcDuration(ll n, ll div) {
  if (n % div == 0) return n / div;
  return n / div + 1;
}

int main() {
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  ll total = 4;
  ll duration = calcDuration(n, a);
  duration = max(duration, calcDuration(n, b));
  duration = max(duration, calcDuration(n, c));
  duration = max(duration, calcDuration(n, d));
  duration = max(duration, calcDuration(n, e));
  cout << total + duration << endl;
  return 0;
}


Measured memory_bytes: 384
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


N, X = map(int, input().split())

clist = [X]
diff = []

a = list(map(int, input().split()))
clist.extend(a)

clist.sort(reverse = False)

for s in range(1, N+1):
    diff.append(clist[s] - clist[s-1])

print(gcd_list(diff))

Measured memory_bytes: 16280
N, M = map(int, input().split())

def diviser(n):
  i = 1
  ret = []
  while i * i <= n:
    if n % i == 0:
      ret.append(i)
      if n // i != i:
        ret.append(n // i)
    i += 1
  return ret

ans = 0
for i in sorted(diviser(M)):
  if i * N <= M:
    ans = max(ans, i)

print(ans)

Measured memory_bytes: 3064
//@winlere
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>

using namespace std;  typedef long long ll;
inline int qr(){
	int ret=0,f=0,c=getchar();
	while(!isdigit(c))f|=c==45,c=getchar();
	while(isdigit(c)) ret=ret*10+c-48,c=getchar();
	return f?-ret:ret;
}

const int maxn=5e5+5;
const int inf=0x3f3f3f3f;
vector<int> e[maxn];
int data[maxn],arc[maxn],dr[maxn],n,k;
int seg[maxn<<2],ans[maxn];
void pp(int pos){seg[pos]=min(seg[pos<<1],seg[pos<<1|1]);}
void add(int fr,int to){
	e[to].push_back(fr);++dr[fr];
	//fprintf(stderr,"<%d %d>\n",fr,to);
}

#define mid ((l+r)>>1)
#define lef l,mid,pos<<1
#define rgt mid+1,r,pos<<1|1
int que(int L,int R,int l,int r,int pos){
	if(L>r||R<l) return inf;
	if(L<=l&&r<=R) return seg[pos];
	return min(que(L,R,lef),que(L,R,rgt));
}
void upd(int p,int v,int l,int r,int pos){
	if(p<l||p>r) return;
	if(l==r) return seg[pos]=v,void();
	upd(p,v,lef); upd(p,v,rgt);
	pp(pos);
}
#undef mid
#undef lef
#undef rgt

int main(){
	n=qr(); k=qr();
	for(int t=1;t<=n;++t) data[t]=qr(),arc[data[t]]=t;
	memset(seg,0x3f,sizeof seg);
	for(int t=n;t;--t){
		int t1=que(arc[t]-k+1,arc[t]-1,1,n,1);
		int t2=que(arc[t]+1,arc[t]+k-1,1,n,1);
		if(t1<=n) add(arc[t],arc[t1]);
		if(t2<=n) add(arc[t],arc[t2]);
		upd(arc[t],t,1,n,1);
	}
	static priority_queue<int> q;
	for(int t=1;t<=n;++t)
		if(!dr[t]) q.push(t);
	int cnt=0;
	while(q.size()){
		int now=q.top();
		//cerr<<"now="<<now<<endl;
		ans[now]=++cnt;
		q.pop();
		for(auto t:e[now])
			if(--dr[t]==0)
				q.push(t);
	}
	for(int t=1;t<=n;++t) printf("%d\n",n-ans[t]+1);
	return 0;
}



Measured memory_bytes: 47104
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <map>
# include <stack>
using namespace std;
# define M_PI 3.141592
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 

int m, n;
vector<int> a[21];
int main()
{
	cin >> m >> n;
	FOR(i, n)
	{
		int x, y; cin >> x >> y;
		a[y].push_back(x);
	}
	queue<int> q;
	q.push(2);
	vector<int> ans;
	while (!q.empty())
	{
		int now = q.front();
		q.pop();
		ans.push_back(now);
		for (int i = 0; i < a[now].size();i++)
		{
			int next = a[now][i];
			a[now].erase(a[now].begin() + i);
			i--;
			bool ok = true;
			for (int j = 1; j <= m; j++)
			{
				for (int k = 0; k < a[j].size(); k++)
				{
					if (a[j][k] == next)
						ok = false;
				}
			}
			if (ok)
			{
				q.push(next);
			}
		}
	}
	reverse(all(ans));
	int h[21] = {};
	for (int i = 0; i < ans.size(); i++)h[ans[i]] = 1;
	for (int i = 1; i <= m; i++)
	{
		if (h[i] == 0)cout << i << endl;
	}
	for (int i = 0; i < ans.size(); i++)cout << ans[i] << endl;
}

Measured memory_bytes: 1224
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def rui(x):
  if x<3:
    return 1
  elif x<6:
    return 2
  elif x<10:
    return 3
  elif x<15:
    return 4
  elif x<21:
    return 5
  elif x<28:
    return 6
  elif x<36:
    return 7
  else:
    return 8
  
N=int(input())
A=factorization(N) 
ans=0
for i in range(len(A)):
  ans+=rui(A[i][1])
if N==1:
  print(0)
else:
  print(ans)

Measured memory_bytes: 9516
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=1 ; i<=(n) ; ++i)
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <ll, ll> P;


int main(){
  int n,m;
  cin >> n >> m;
  vector<ll> h;
  vector<ll> ma(n+1,0);
  rep(i,n){
    int h_y;
    cin >> h_y;
    h.push_back(h_y);
  }
  for(int i=0; i<m ; i++){
    int a,b;
    cin >> a >> b;
    ma[a] = max(ma[a], h[b-1]);
    ma[b] = max(ma[b], h[a-1]);
  }
  int ans = 0;
  rep(i,n){
    if(h[i-1]>ma[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5076
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int count = 0;
        int[] ans = new int[k*2];
		
		for(int i=0; i<k; i++){
		    if(a+i<=b){
		        ans[i] = a+i;
		        System.out.println(ans[i]);
		        count++;
		    }
		}
		
		int flg = 0;
		
		for(int i=k-1; i>=0; i--){
		    if(b-i>=a && flg==0){
		        for(int j=0; j<count; j++){
		            if(b-i-ans[j]==0){
		                flg = 1;
		            }
		        }
		        if(flg == 0){
		            System.out.println(b-i);
		        }
		    }
		    flg = 0;
		}
    }
}


Measured memory_bytes: 36004
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};


signed main(){
	int n,m,sum=0;
	cin>>n>>m;
	int cost[20][20]={0};
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		cost[a][b]=cost[b][a]=c;
		sum+=c;
	}
	vvi memo(1<<n,vi(n));
	rep(i,1<<n){
		int s=0;
		rep(j,n)rep(k,n)if((i&1<<j)&&(i&1<<k)&&j<k)s+=cost[j][k];
		rep(j,n)memo[i][j]=s;
	}
	vvi dp(1<<n,vi(n,-inf));
	dp[1][0]=0;
	rep(i,1<<n)rep(j,n)if(i&1<<j){
		rep(k,n)if(cost[j][k]&&(i&1<<k)==0)cmax(dp[i|1<<k][k],dp[i][j]+cost[j][k]);
		int t=(1<<n)-i-1;
		for(int k=t;k>0;k=(k-1)&t)
			cmax(dp[i|k][j],dp[i][j]+memo[k|1<<j][j]);
	}
	cout<<sum-dp[(1<<n)-1][n-1]<<endl;
}















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

using namespace std;

const int N=404, MOD=1e9+7;
int n, a[N], b[N], dp[N][N], pref[N][N], c;
signed main()
{
	cin >> n >> c;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	for(int i = 1; i <= n; i++)
	{
		cin >> b[i];
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = a[i]; j<=b[i]; j++)
		{
			int curr=1;
			for(int k = 0; k <= c; k++)
			{
				pref[i][k]+=curr;
				pref[i][k]%=MOD;
				curr*=j;
				curr%=MOD;
			}
		}
		// for(int k = 0; k <= c; k++)
		// {
		// 	cout << i << " " << k << " - " << pref[i][k] << endl;
		// }
	}
	for(int j = 0; j <= c; j++)
	{
		dp[1][j]=pref[1][j];
	}
	for(int i = 2; i <= n; i++)
	{
		dp[i][0]=(dp[i-1][0]*pref[i][0])%MOD;
		for(int j = 1; j <= c; j++)
		{
			for(int k = 0; k <= j; k++)
			{
				dp[i][j]+=(dp[i-1][k]*pref[i][j-k])%MOD;
				dp[i][j]%=MOD;
			}
		//	cout << i << " - " << j << " " << dp[i][j] << endl; 
		}
	}
	cout << dp[n][c];
}

Measured memory_bytes: 2816
import java.util.Scanner;

public class Main 
{
	public static void main(String[] args) 
	{
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		
		int a  = sc.nextInt();
		int b  = sc.nextInt();
		
		if(a < 1 || a > 9)
		{
			System.out.println("-1");
          	return ;
		}
		
		if(b < 1 || b > 9)
		{
			System.out.println("-1");
          	return ;
		}
		
		System.out.println(a * b);
		

	}

}


Measured memory_bytes: 23764
import java.util.Scanner;
  
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int S = sc.nextInt();
            int S1 = S % 3600;
            int se = S1 % 60;
            int m = (S1 - se)/60;
            int h = (S - S1)/3600;
              
            System.out.println( h + ":" + m +":" + se);
        }
    }
}
 

Measured memory_bytes: 26100
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define INF 1e17+9;
#define rep(i,n) for(int i=0;i<n;i++)

const long long MOD = 1e9+7;
const double PI=acos(-1);

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<long long> x(n),temp(n);
	rep(i,n){
		cin >> x[i];
		temp[i]=x[i];
	}
	sort(temp.begin(),temp.end());
	map<int,long long> mp;
	rep(i,n){
		if(i<n/2)mp[temp[i]]=temp[n/2];
		else mp[temp[i]]=temp[n/2-1];
	}
	rep(i,n){
		cout << mp[x[i]] << endl;
	}
	return 0;
}



Measured memory_bytes: 17536
x,n=map(int,input().split())

if n==0:
  print(x)
  
else:
  a=list(map(int,input().split()))

  for i in range(100):
    if x-i not in a:
      ans=x-i
      break
    elif x+i not in a:
      ans=x+i
      break
    
  print(ans)

Measured memory_bytes: 9016
import sys, math, collections, heapq, itertools
from bisect import bisect
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    X, Y = map(int, line_input())
    p = [0] * X

    total_cost = 0
    for x in range(X): 
        p[x] = int(single_input())
        total_cost += p[x]
    p.sort()    
    total_sum_p = [0] * (X + 1)
    for x in range(X):
        total_sum_p[x+1] = total_sum_p[x] + p[x]
    
    for y in range(Y): 
        q = int(single_input())
        total_cost += q
        x_smaller_than_y = bisect(p, q)
        total_cost += q * (X - x_smaller_than_y) + total_sum_p[x_smaller_than_y]

    return total_cost
  
if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 12192
#include <iostream>
#include <cstdlib>
#include <vector>

int bubbleSort(std::vector<int> &A, int N); 

int main(void) {
    int N;
    std::cin >> N;
    std::vector<int> A(N, 0);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
    }
    int trade = bubbleSort(A, N);

    std::cout << A[0];
    for (int i = 1; i < N; i++) {
        std::cout << " " << A[i];
    } 
    std::cout << std::endl;

    std::cout << trade << std::endl;
    return EXIT_SUCCESS;
}

int bubbleSort(std::vector<int> &A, int N) {
    int trade = 0;
    bool flag = 1;
    int temp;
    while (flag) {
        flag = 0;
        for (int j = N - 1; j >= 1; j--) {
            if (A[j] < A[j - 1]) {
                temp = A[j];
                A[j] = A[j - 1];
                A[j - 1] = temp;
                flag = 1;
                trade++;
            }
        }
    }
    return trade;
}

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

int main() {
  int input, output, hundred, ten, one;
  cin >> input;
  hundred = input / 100;
  ten = input / 10 - hundred * 10;
  one = input - hundred * 100 - ten * 10;
  output = hundred + ten + one;
  cout << output << endl;
}

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

int main(void) {
	int n; cin >> n;
	vector<int> A(n);
	for (int i = 0; i < n; i++) scanf("%d", &A[i]);

	bool flag = true;
	for (int i = 0; i < n; i++) {
		if (A[i] % 2 == 0) {
			if (A[i] % 3 == 0 || A[i] % 5 == 0) {
				continue;
			}
			else {
				flag = false;
				break;
			}
		}
	}

	cout << (flag == true ? "APPROVED" : "DENIED") << endl;
	
	return 0;
}

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

int main()
{
    int a, b, count = 1;
    cin >> a >> b;
    while (a + (a - 1) * (count - 1) < b)
        count++;
    if (b == 1)
    {
        cout << "0" << endl;
    }
    else
    {
        cout << count << endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main
import . "fmt"
func main() {
  var w,a,b int
  Scan(&w,&a,&b)
  Println(max(0,max(a,b)-(min(a,b)+w)))
}
func min(x int,y int) int {
  if x < y {
    return x
  } else {
    return y
  }
}
func max(x int,y int) int {
  return x+y-min(x,y)
}

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

int main () {
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  for(int i = 0; i < N; i++){
    cin >> H.at(i);
  }
  sort(H.begin(), H.end());
  
  long long ans = 0;
  if(K < N){
    for(int i = 0; i < (N - K); i ++){
      ans += H.at(i);
    }
    cout << ans << endl;
  }
  
  else{
    cout << 0 << endl;
  }
}

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


int main (int argc, char const *argv[])
{
    string N;
    cin>>N;
    
    if (N[0]=='9'||N[1]=='9') {
        cout<<"Yes"<<endl;
    }
    
    else
    {
        cout<<"No"<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int gi(){
	int x=0,w=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')w=0,ch=getchar();
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
#define ll long long
const int N=1e5+5;
int n,k,l[N],r[N],o[N<<1],len,tag[N<<2];
ll tot,f[N],ans=1ll<<60;
int cost(int s,int t){return s<=t?t-s:t+k-s;}
void down(int x){if(tag[x])tag[x<<1]=tag[x<<1|1]=tag[x],tag[x]=0;}
void modify(int x,int l,int r,int ql,int qr,int c){
	if(l>=ql&&r<=qr){tag[x]=c;return;}
	down(x);int mid=l+r>>1;
	if(ql<=mid)modify(x<<1,l,mid,ql,qr,c);
	if(qr>mid)modify(x<<1|1,mid+1,r,ql,qr,c);
}
int query(int x,int l,int r,int p){
	if(l==r)return tag[x];
	down(x);int mid=l+r>>1;
	if(p<=mid)return query(x<<1,l,mid,p);
	else return query(x<<1|1,mid+1,r,p);
}
int main(){
	n=gi();k=gi();
	for(int i=1,las=0;i<=n;++i){
		int a=gi(),b=gi();tot+=a;
		if(b==1&&2*a>k)return puts("-1"),0;
		a=(k-a%k<<1)%k;
		if(b==1)l[i]=las,r[i]=(las+a)%k;
		else l[i]=0,r[i]=k-1;
		las=(las+a)%k;
	}
	o[++len]=0;o[++len]=k-1;
	for(int i=1;i<=n;++i)o[++len]=l[i],o[++len]=r[i];
	sort(o+1,o+len+1);len=unique(o+1,o+len+1)-o-1;
	for(int i=n;i;--i){
		l[i]=lower_bound(o+1,o+len+1,l[i])-o;
		r[i]=lower_bound(o+1,o+len+1,r[i])-o;
		int x=query(1,1,len,l[i]);
		if(x)f[i]=f[x]+cost(o[l[i]],o[l[x]]);
		if(l[i]<=r[i]){
			if(l[i]>1)modify(1,1,len,1,l[i]-1,i);
			if(r[i]<len)modify(1,1,len,r[i]+1,len,i);
		}else if(r[i]+1<l[i])modify(1,1,len,r[i]+1,l[i]-1,i);
	}
	for(int i=1;i<=len;++i){
		int x=query(1,1,len,i);
		if(x)ans=min(ans,f[x]+cost(o[i],o[l[x]]));
		else ans=0;
	}
	printf("%lld\n",ans+tot*2);
	return 0;
}


Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main(){
	
	int n,x,i,j,k,count=0;
	cin>>n>>x;
	while(n!=0||x!=0){
		for(i=1;i<=n;i++){
			for(j=i+1;j<=n;j++){
				for(k=j+1;k<=n;k++){
					if(i+j+k==x){
						count++;
					}
				}
			}
		}
		cout<<count<<endl;
		count=0;
		cin>>n>>x;
	}
			
	return 0;
}

Measured memory_bytes: 3096
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

LOW, HIGH = 0, N
ans = 0

if 1 >= K:
    ans += (HIGH - LOW + 1)

for i in range(2, N + 2):
    LOW += i - 1
    HIGH += N - i + 1
    LOW %= MOD
    HIGH %= MOD
    if i >= K:
        ans += (HIGH - LOW + 1)
        ans %= MOD

print(ans)


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

int main() {
    vector<int> a(3);
    for(int i=0;i<3;i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    if(a.at(0)==5 && a.at(1)==5 && a.at(2)==7){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
}

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

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  vector<int> cnt(3,0);
  for(int i=0;i<N;i++){
    int p;
    cin >> p;
    if(p<=A)  cnt.at(0)++;
    else if(p<=B) cnt.at(1)++;
    else  cnt.at(2)++;
  }

  int ans=1e9;
  for(int i=0;i<3;i++)  ans=min(ans,cnt.at(i));
  cout << ans << endl;

  return 0;
}

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


public class Main {
    static ArrayList<Integer>[] graph;
    public static void main(String[] args) throws Exception {
        //Scanner sc = new Scanner(System.in);
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] buf = reader.readLine().split(" ");
        int n = Integer.parseInt(buf[0]), m = Integer.parseInt(buf[1]);
        int[] rec = new int[n+2];
        for(int i=0;i<m;i++){
            buf = reader.readLine().split(" ");
            int le = Integer.parseInt(buf[0]), ri = Integer.parseInt(buf[1]);
            rec[le]++; rec[ri+1]--;
        }
        int sum = 0, ans = 0;
        for(int i=1;i<=n;i++){
            sum += rec[i];
            if(sum==m) ans ++;
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 45524
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch 01Matrix | diff 01Matrix.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address 01Matrix.cpp && ./a.out

/*

 8/3/2020

 21:24-

 */

int H,W,A,B;

void solve() {
  REP(_,B) {
    REP(j,W) cout<<char('0'+(j<A));
    cout<<endl;
  }
  REP(_,H-B) {
    REP(j,W) cout<<char('0'+(j>=A));
    cout<<endl;
  }
}

bool ith(int mask, int i) { return (mask>>i)&1; }
void test() {
  set<II> ps;
  REP(mask, 1<<25) {
    VV<int> G(5,VI(5,0));
    REP(i,25) if(ith(mask,i)) {
      G[i/5][i%5]=1;
    }

    set<int> r,c;
    REP(i,5) {
      int cnt[2]={};
      REP(j,5) cnt[G[i][j]]++;
      r.emplace(min(cnt[0],cnt[1]));
    }
    REP(j,5) {
      int cnt[2]={};
      REP(i,5) cnt[G[i][j]]++;
      c.emplace(min(cnt[0],cnt[1]));
    }
    if(SZ(r)==1&&SZ(c)==1) {
      if(*r.begin()==2&&*c.begin()==1) {
        REP(i,5) dumpc(G[i]);
      }
      ps.emplace(*r.begin(), *c.begin());
    }
  }
  dumpc(ps);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>H>>W>>A>>B;
  solve();

  return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  vector<pair<string,pair<ll,ll>>> res(n);
  REP(i,n){
    string s;
    ll p;
    cin >> s >> p;
    res[i] = make_pair(s,make_pair(i+1,p));
  }
  sort(res.begin(),res.end(),[](pair<string,pair<ll,ll>> a,pair<string,pair<ll,ll>> b){return a.first<b.first || (a.first==b.first)&&(a.second.second>b.second.second);});
  REP(i,n){
    cout << res[i].second.first << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    N, K = list(map(int, input().split()))
    H = list(map(int, input().split()))

    count = 0
    for h in H:
        if h >= K:
            count += 1
    print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 11940
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	int ac = 0;
	int wa = 0;
	int tle = 0;
	int re = 0;
	for (int i = 0; i < N; i++) {
		string aa;
		cin >> aa;
		if (aa == "AC") ac++;
		if (aa == "WA") wa++;
		if (aa == "TLE") tle++;
		if (aa == "RE") re++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
	return 0;
}

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

using namespace std;

int main(){
	int N,M;
	int upl,lowl;
	
	cin >> N >> M;
	
	int L[M],R[M];
	
	for(int i=0; i<M; i++){
		cin >> L[i] >> R[i];
	}
	
	upl=0;
	lowl=N;
	for(int i=0; i<M; i++){
		if(L[i] > upl)	upl=L[i];
		if(R[i] < lowl)	lowl=R[i];
	}
	
	if(upl > lowl)	cout << "0" << endl;
	else	cout << lowl-upl+1 << endl;
	
	return 0;
}

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

int sgn(int x){
  if(0<=x)
    return x;
  else return -x;
}
int main(){
  int N;
  cin >> N;
  int h[N];
  for(int i=0;i<N;i++)
    cin >> h[i];
  int mcost[N];
  mcost[0] = 0;
  mcost[1] = sgn(h[1]-h[0]);
  if(N>2){
  	for(int k=0;k<N-2;k++){
    	mcost[k+2] = min(mcost[k+1]+sgn(h[k+2]-h[k+1]),mcost[k]+sgn(h[k+2]-h[k]));
  	}
  }
    cout << mcost[N-1] << endl;
}

Measured memory_bytes: 1024
using System;using static System.Console;class P{static void Main(){var d=new int[5,4,11];int i=int.Parse(ReadLine()),j,k;while(i-->0){var a=Array.ConvertAll(ReadLine().Split(),int.Parse);d[a[0],a[1],a[2]]+=a[3];}for(i=0;i++<4;){if(i>1)WriteLine(new string('#',20));for(j=0;j++<3;WriteLine())for(k=0;k++<10;Write($" {d[i,j,k]}"));}}}


Measured memory_bytes: 17996
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)

long long M = 1000000007;

int n;
vector<long long> dpw,dpb;
vector<vector<int>> G;

long long solve(int u){
    dpw[u] = 1;
    dpb[u] = 1;
    for(auto v:G[u]){
        if(dpw[v]==-1){
            solve(v);
            dpw[u] *= (dpw[v] + dpb[v]);
            dpw[u] %= M;
            dpb[u] *= dpw[v];
            dpb[u] %= M;
        }
    }
    return (dpw[u] + dpb[u])%M;
}

int main(int argc, char const *argv[]) {
    cin>>n;
    G = vector<vector<int>>(n);
    dpb = vector<long long>(n,-1);
    dpw = vector<long long>(n,-1);
    for(int i=0;i<n-1;++i){
        int u,v;cin>>u>>v;
        u--;
        v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    cout<<solve(0)<<endl;
    return 0;
}

Measured memory_bytes: 12800
from collections import defaultdict


def get_path(from_node, to_node, adj, nodes2edge):
    # from_nodeからto_nodeまでの最短パスで通るedgeを返す

    def dfs(node, parent, edges):
        if node == to_node:
            return edges
        min_path = None
        for child in adj[node]:
            if child == parent:
                continue
            path = dfs(child, node, edges + [nodes2edge[(node, child)]])
            if path is None:
                continue
            if min_path is None or len(min_path) > len(path):
                min_path = path
        return min_path

    return dfs(from_node, None, list())


def count_bits(n):
    return len([i for i in range(len('{:b}'.format(n))) if (n >> i) & 1 == 1])


def main():
    N = int(input())
    adj = defaultdict(list)
    nodes2edge = defaultdict(lambda :-1)
    for i in range(N - 1):
        a, b = list(map(lambda x: int(x) - 1, input().split(' ')))
        adj[a].append(b)
        adj[b].append(a)
        nodes2edge[(a, b)] = i
        nodes2edge[(b, a)] = i
    M = int(input())
    constraints = [list(map(lambda x: int(x) - 1, input().split(' '))) for _ in range(M)]
    # 各制約を「パス u->v 上の辺はすべて白」として扱い、包除原理で計算
    base = [0] * M  # 各制約で出てくる最短 u->v パス で通るedgeの2進表記
    for m, constraint in enumerate(constraints):
        u, v = constraint
        path = get_path(u, v, adj, nodes2edge)
        v = sum([2**e for e in path])
        base[m] = v
    dp = [0] * (2**M)  # 制約の集合で出てくる最短 u->v パスで通るedgeの和集合の2進表記
    ans = 2**(N - 1)
    for S in range(1, 2**M):
        lenbit_s = len('{:b}'.format(S))
        dp[S] = dp[S - (1 << (lenbit_s - 1))] | base[lenbit_s - 1]
        cnt_s = count_bits(S)
        cnt_dp = count_bits(dp[S])
        ans += (-1)**(cnt_s % 2) * 2**(N - 1 - cnt_dp)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 83532
n = int(input())
sl = ([int(input()) for _ in range(n)])
sl_min = sum(sl)
if sum(sl)%10 == 0:
    for i,s in enumerate(sl):
        if s%10 != 0:
            if sl_min > s:
                sl_min = s
    print(sum(sl) - sl_min)
else:
    print(sum(sl))


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

long long X, Y;

int main(){
	cin >> X >> Y;
	int ans = 0;
	while(X<=Y){
		X *= 2;
		ans++;
	}
	
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;


int main()
{
        string i, j;
        int a, b;

        cin >> i;
        cin >> j;

        a = stoi(i+j);
        b = sqrt(a);

        if (b*b == a) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }



        return 0;
}

Measured memory_bytes: 760
#include<bits/stdc++.h>
using namespace std;
long long h,ans;
int log_2(long long a)
{
	int ans=0;
	while(a)
	{
		a/=2;
		ans++;
	}
	return ans;
}
int main()
{
	cin>>h;
	long long cur=1;
	while(h)
	{
		h/=2;
		ans+=cur;
		cur*=2;
	}
	cout<<ans;
	return 0;
}


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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int maxn = 1e5+10;
const int mod = 1e9+7;

using namespace std;

void solve(){
	char s;
	cin>>s;
	if(islower(s))
		cout<<"a"<<endl;
	else
		cout<<"A"<<endl;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if ((a >= c && a - c <= d) || (a < c && c - a <= d) 
      || (a >= b && b >= c && a - b <= d && b - c <= d)
      || (a <= b && b <= c && b - a <= d && c - b <= d)) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
    int a,b;cin>>a>>b;
    if(a==1)a = 14;
    if(b==1)b = 14;
    if(a==b)cout<<"Draw";
    else cout<<(a>b?"Alice":"Bob");
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    int n;
    cin >> n;
    pair<pair<string,int>,int> p[110];
    rep(i,n){
        string s;
        int t;
        cin >> s >> t;
        p[i] = make_pair(make_pair(s,-t),i);
    }
    sort(p,p+n);
    rep(i,n) cout << p[i].second+1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
static const int INFTY = (1 << 20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int>> adj[100];
int *d;

void dijkstra() {
    priority_queue<pair<int, int>> PQ;
    int d[n], color[n];

    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        color[n] = WHITE;
    }
    d[0] = 0;
    PQ.push(make_pair(0, 0));

    while (!PQ.empty()) {
        pair<int, int> f = PQ.top();
        PQ.pop();

        int u = f.second;
        color[u] = BLACK;

        if (d[u] < f.first * (-1)) { continue; }

        for (int j = 0; j < adj[u].size(); j++) {
            int v = adj[u][j].first;
            if (color[v] == BLACK) { continue; }
            if (d[u] + adj[u][j].second < d[v]) {
                d[v] = d[u] + adj[u][j].second;
                // printf("d[%d] = %d\n", v, d[v]);
                PQ.push(make_pair(d[v] * (-1), v));
                color[v] = GRAY;
            }
        }
    }
    
    for (int i = 0; i < n; i++) {
        printf("%d %d\n", i, d[i]);
    }
}

int main() {
    int k, u, v, c;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            adj[u].push_back(make_pair(v, c));
        }
    }

    dijkstra();

    return 0;
}


Measured memory_bytes: 3220
#include <stdio.h>
#define N 100000
#define NIL -1
struct Node{
  int parent;
  int right;
  int left;
};
struct Node Tree[N];
int n,D[N];
int getDepth(int a){
  int dep=0;
  while(Tree[a].parent!=-1){
    a=Tree[a].parent;
    dep++;
  }
  return dep;
}
void print(int x){
  int i,j;
  printf("node %d: parent = %d, depth = %d, ",x,Tree[x].parent,D[x]);
  if(Tree[x].parent==-1) printf("root, ");
  else if(Tree[x].left==-1) printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i=0,j=Tree[x].left;j!=NIL;i++,j=Tree[j].right){
    if(i) printf(", ");
    printf("%d",j);
  }
  printf("]\n");
}
int main(){
  int a,b,i,j,l,m;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    Tree[i].parent=NIL;
    Tree[i].left=NIL;
    Tree[i].right=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&l,&m);
    for(j=0;j<m;j++){
      scanf("%d",&a);
      if(j==0)Tree[l].left=a;
      else Tree[b].right=a;
      b=a;
      Tree[a].parent=l;
    }
  }
  for(i=0;i<n;i++){
    D[i]=getDepth(i);
  }
  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}

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

int main(){
    int A, B, r = 0;
    cin >> A >> B;
    for(int i = A; i <= B; i++){
        int a, b, c, d;
        a = i % 10;
        b = i / 10000 % 10;
        c = i / 10 % 10;
        d = i / 1000 % 10;
        if(a == b && c == d)
            r++;
    }
    cout << r << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll n, m, aux, ans = 0; cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> aux;
        ans += aux;
    }
    n - ans < 0? cout << "-1\n" : cout << (n - ans) << "\n";
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
ll MOD = 1000000007;

int main() {
	ll N; cin >> N;
	ll a[100000];
	map<int, int> mp;
	rep(i, 0, N) {
		cin >> a[i];
		mp[a[i]]++;
	}
	ll cnt = 0;
	for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {
		if (it->first < it->second) {
			cnt += it->second - it->first;
		}
		else if (it->first > it->second) {
			cnt += it->second;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 5504
from itertools import product

N = int(input())

li = [[] for i in range(N)]
A = [0]*N
for i in range(N):
    a = int(input())
    A[i]=a
    li[i]=[list(map(int,input().split())) for i in range(a)]

counter = 0
for humen in product([0,1],repeat=N):
    flag = True
    for i in range(N):
        if humen[i]==1:
            for s in range(A[i]):
                if not li[i][s][1]==humen[li[i][s][0]-1]:
                    flag=False
                    break
        
                
    if flag :
        counter = max(counter,humen.count(1))


print(counter)

Measured memory_bytes: 74048
#include <iostream>
using namespace std;
typedef long long ll;

//最小公約数
int gcd(ll a,ll b){
    if( a==0 || b==0)
          return 0;
            while(a != b){
                  if(a > b) a= a-b;
                      else b=b-a;
                        }
                          return a;
}

//最小公倍数
int lcm(ll m,ll n){
    if(m==0 || n==0)
          return 0;
            return m/gcd(m,n)*n;
}

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

Measured memory_bytes: 1160
S = list(input())
answer = 0
index = len(S)
i = 0
s = 0
while(i < index):
    str = S[i]
    if(str == "A" or str == "C" or str == "G" or str == "T"):
        s += 1
    else:
        s = 0
    if(answer < s):
        answer = s
    i += 1
print(answer)


Measured memory_bytes: 3060
N, M = map(int, input().split())
isAC = [0]*N
ac = 0
WA = [0]*N
for _ in range(M):
    p, s = input().split()
    p = int(p)
    if not isAC[p-1]:
        if s == 'AC':
            isAC[p-1] = 1
            ac += 1
        else:
            WA[p-1] += 1
    
wa = sum([i*j for i, j in zip(isAC, WA)])
print(ac, wa)

Measured memory_bytes: 5528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e9+7;
const ll N = 9;
ll n,ans=INF,a,w;
int main(){
	cin>>n;
	FOR(i,0,n){
		cin>>a;
		w=0;
		while(a%2==0){
			w++;
			a/=2;
		}
		ans=min(ans,w);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
w = {}
ans = "Yes"
for i in range(0,n):
    W = input()
    w[W] = w.get(W,0) + 1
    if i >= 1:
        if e != W[0]:
            ans = "No"
    if w[W] >= 2:
        ans = "No"
    e = W[-1]
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e9;
using namespace std;

main() {
    int N,M; cin >> N >> M;
    map<int,int> m;
    rep(i,M){
        int a,b; cin >> a >> b;
        a--; b--;
        m[a]++; m[b]++;
    }
    bool can = true;
    rep(i,N){
        if(m[i]%2) can = false;
    }
    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 6528
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] input = sc.next().toCharArray();
        for (int i = 0; i < input.length; i++) {
            if (input[i] == '1')
                System.out.print('9');
            else
                System.out.print('1');
        }
        System.out.println("");
        
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < vi, int > a, pair < vi, int > b)//true for a before b
{
	if(a.F.empty())
		return 1;
	if(b.F.empty())
		return 0;
	int i;
	fo(i,0,min(sz(a.F),sz(b.F)))
	{
		if(a.F[i] < b.F[i])
			return 1;
		else if(a.F[i] > b.F[i])
			return 0;
	}
	return (sz(a.F) <= sz(b.F));
}

const int N = (1e3) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 900;
const int SQRT = BUCK+9;



void solve()
{
	ll a, b, c, d, n, ans = 0;
	cin >> a >> b >> c >> d;
	cin >> n;
	b = min(b,a+a);
	c = min(c,b+b);
	d = min(d,c+c);
	ans = (n/2LL)*d;
	n %= 2LL;
	ans += n*c;
	cout << ans << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(9);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

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

int main() {

    //変数の宣言：型␣変数名
	int x;
	
	//値の入力：cinを使う。例：cin >> 変数名(今回はx)　>>  別の変数名　>> …　;
	cin >> x; 
	
	//値の出力：coutを使う。発展：変数も出力できる。計算もできる。
	cout << x*x*x << endl;          

	return 0;
}


Measured memory_bytes: 3096