akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
typedef long double ld;
typedef unsigned long long ull;
#define X first
#define Y second
#define mp make_pair
template<class T> using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T, class X> using indexed_map = tree<T, X, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const long long M = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

long long modpow(long long n, long long k, long long MOD);

/**************** code starts here ****************/

int n;
vector<pair<int, int>> adj[100001];
vector<int> ans(100001);

void dfs(int now, int prev, int col) {
	ans[now] = col;
	for (auto u: adj[now]) {
		if (u.first != prev) {
			dfs(u.first, now, col ^ (u.second & 1));
		}
	}
}

void poppingfever() {
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v, w; cin >> u >> v >> w;
		adj[u].emplace_back(v, w);
		adj[v].emplace_back(u, w);
	}
	dfs(1, 0, 0);

	for (int i = 1; i <= n; i++) cout << ans[i] << '\n';
}

/**************************************************/

signed main() {
	#ifdef fastfurioustransform
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif

	ios::sync_with_stdio(0); cin.tie(0);
	//cout << fixed << setprecision(12);

	poppingfever();

	return 0;
}

long long modpow(long long n, long long k, long long MOD) {
	long long ans = 1; n %= MOD;
	while (k > 0) {
		if (k & 1) ans = (ans*n) % MOD;
		k >>= 1; n = (n*n) % MOD;
	}
	return ans; 
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  for(int i=0;i<n-k;i++){
    if(a.at(k+i)-a.at(i)>0){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n;
    double u[50];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>u[i];
    sort(u,u+n);
    double ans=(u[0]+u[1])/2;
    for(int i=2;i<n;i++)
        ans=(ans+u[i])/2;
    cout<<setprecision(20)<<ans<<endl;
}


Measured memory_bytes: 256
n,m,k;a[99],b[99],c[99];void push(x,y,z){a[m]=x;b[m]=y;c[m++]=z;}main(i){scanf("%d",&k);while((1<<n)<=k)n++;for(i=n;--i;push(i,i-1,0),push(i,i-1,1<<(i-1)));for(i=n-2;~i;i--)if((1<<i)&k)push(n-1,i,(k>>(i+1))<<(i+1));printf("%d %d\n",n,m);for(i=m;i--;printf("%d %d %d\n",n-a[i],n-b[i],c[i]));}

Measured memory_bytes: 128
num2alpha = lambda c: chr(c+64)


N = int(input())
degit = 0
temp_degit = 0
top=0

for i in range(1,50):
    temp_degit += 1
    under = top+1
    top += 26**i
    # print(temp_degit)
    # print(under,top)
    if under <= N and N <= top:
        degit = temp_degit
# print(degit)

# print(N%26)
arr =[]
for i in range(degit):
    if N%26==0:
        arr.append(26)
        N -=1
    else:  
        arr.append(N%26)
    N//=26
    # print(N)

rsl=""
# print(arr)
# print(num2alpha(10))
for i in reversed(arr):
    rsl += num2alpha(i)
print(rsl.lower())

Measured memory_bytes: 9208
#include <stdio.h>
int main(void){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
        
    
    if((r<=x&&x<=W-r)&&(r<=y&&y<=H-r))
    
    
    
    printf("Yes\n");
    else 
    printf("No\n");
    
    return 0;
}


Measured memory_bytes: 2108
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls int
#define give main()
const int mod = 1000000007;
#pragma endregion
const ll N = 200009;


pls give {
    AC;
    int arr[3];
    for (int i=0; i<3; i++) cin >> arr[i];
    int ans = 0;
    sort(arr, arr+3);
    for (int i=1; i<3; i++) ans += (arr[i] - arr[i-1]);
    cout << ans;

}

Measured memory_bytes: 256
m=input()
l=m[::-1]
n=int(l[0])

if n==2 or n==4 or n==5 or n==7 or n==9:
    print("hon")
if n==0 or n==1 or n==6 or n==8:
    print("pon")
if n==3:
    print("bon")

Measured memory_bytes: 9180
n = int(input())
a = list(map(int, input().strip().split()))

num_odd_minus = 0
res = 0
min_num = abs(a[0])
for num in a:
    if num < 0:
        num_odd_minus += 1
    abs_num = abs(num)
    res += abs_num
    if min_num > abs_num:
        min_num = abs_num

if num_odd_minus % 2 == 1:
    res -= min_num * 2

print(res)


Measured memory_bytes: 19956
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a,b;
int main(){
	scanf("%lld%lld",&a,&b);
	rep(i,b-a+1,b+a)printf("%d ",i);
}

Measured memory_bytes: 128
# 初期入力
import sys
input = sys.stdin.readline
N = int(input())
ans ={i:0 for i in range(1,N +1)}
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            a =x*x +y*y +z*z +x*y +y*z +z*x
            if a<= N:
                ans[a] +=1
for i in range(1,N+1):
    print(ans[i])

Measured memory_bytes: 9524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e6 + 5;
const ll maxm = 1e3 + 5;
const ll mod = 1e9 + 7;
ll n, m, tot;
ll qpow(ll x, ll y){
    ll res = 1;
    while(y){
        if(y & 1) res = res * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return res;
}
ll inv[maxn], md[maxn];
void init(){
    md[0] = 1;
    for(int i = 1;i <= m;i++){
        md[i] = md[i - 1] * i % mod;
    }
    inv[m] = qpow(md[m], mod - 2);
    for(int i = m - 1;i >= 0;i--){
        inv[i] = inv[i + 1] * (i + 1) % mod;
    }
    return ;
}
ll A(ll x, ll y){
    return md[x] * inv[x - y] % mod;
}
ll C(ll x, ll y){
    return md[x] * inv[x - y] % mod * inv[y] % mod;
}
int main(){
    cin >> n >> m;
    init();
    for(int i = 0;i <= n;i++){
        tot += C(n, i) * A(m - i, n - i) * ((i & 1) ? -1 : 1);
        tot %= mod;
    }
    tot *= A(m, n);
    tot = (tot % mod + mod) % mod;
    cout << tot << endl;
    return 0;
}

Measured memory_bytes: 11416
import sys
import collections

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

def dfs(n, used, cost):
    global c, mincost
    for i in range(10):
        if i == 1:
            if cost + c[n][i] < mincost:
                mincost = cost + c[n][i]
                continue
        if i not in used and cost < mincost:
            dfs(i, used+[i], cost+c[n][i])

def main():
    global c, mincost
    H, W = map(int, readline().split())
    c = []
    for _ in range(10):
        c.append(list(map(int, readline().split())))
    wall = []
    wallcount = collections.Counter([])
    for _ in range(H):
        tmp = list(map(int, input().split()))
        wall.append(tmp)
        wallcount += collections.Counter(tmp)
    
    wallitem = list(zip(*wallcount.items()))
    ans = 0
    for i, item in enumerate(wallitem[0]):
        if item in [-1, 1]:
            continue
        mincost = c[item][1]
        dfs(item, [item], 0)
        ans += mincost*wallitem[1][i]
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3700
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      int A=sc.nextInt();
      int B=sc.nextInt();
            
      if((A+B)%2==0){
      System.out.print((A+B)/2);
      }
      else{
      System.out.print("IMPOSSIBLE");
      }
    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int a, b;
    cin >> a >> b;
    
    int res = a*b;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>

using namespace std;

int x;
int const MAX_X = 100010;
bool a[MAX_X];

bool isprime(int n){
    for (int i = 2; i * i <= n; i++){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}

int main(){
    cin >> x;
    fill(a, a + MAX_X, true);
    a[0] = false;
    a[1] = false;
    for (int i = 2; i < MAX_X; i++){
        if (a[i]){
            for (int j = 2 * i; j < MAX_X; j += i){
                a[j] = false;
            }
        }
    }
    while(true){
        if (a[x]){
            cout << x << endl;
            return 0;
        }
        x++;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll inf=1e18;
ll p=1e9+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
   while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll i,j,h,x,y,n,m,k,t1,t2,t3;
    ll a,b,c;
    cin>>n>>m>>x;
    ll sum=0;
    ll price[n],val[m]={0};
    ll arr[n][m];
    for(i=0;i<n;i++)
    {
        cin>>price[i];
        for(j=0;j<m;j++)
        {
            cin>>arr[i][j];
            val[j]+=arr[i][j];
        }
    }
    for(i=0;i<m;i++)
    {
        if(val[i]<x)
        {
            cout<<"-1";
            return 0;
        }
    }
    ll curp=inf;
    for(i=1;i<pow(2,n);i++)
    {
        ll temp=i;
        ll cur=0;
        ll sum=0;
        ll tval[m]={0};
        while(temp!=0)
        {
            if(temp%2==1)
            {
             for(j=0;j<m;j++)
             tval[j]+=arr[cur][j];
             sum+=price[cur];   
            }
            temp/=2;
            cur++;
        }
        ll f=1;
        for(j=0;j<m;j++)
        {
            if(tval[j]<x)
            {
                f=0;
                break;
            }
        }
        if(f)
        curp=std::min(curp,sum);
    }
    cout<<curp;
    
    
    
}

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

int w[100];

int main(){
	int N;
	cin>>N;
	int sum=0;
	for(int i=0;i<N;i++){
		cin>>w[i];
		sum+=w[i];
		if(i>0)w[i]+=w[i-1];
	}
	int min=99999999;
	for(int i=0;i<N;i++){
		if(min>abs(sum-2*w[i]))min=abs(sum-2*w[i]);
	}
	cout<<min<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PA;
#define MAXN 102
#define MAXK 100005
#define INF 1000000009
#define pb push_back

int a, b;
int pows(int n, int m){
    int k = 1;
    for(int i = 0; i < m; i++){
        k *= n;
    }
    return k;
}

int main()
{
    cin >> a >> b;
    if(a != 0 && b != 100)printf("%d\n", pows(100, a) * b);
    else if(a != 0 && b == 100) printf("%d\n", pows(100, a) * b + pows(100, a));
    else if(b == 100) printf("%d\n", b + 1);
    else printf("%d\n", b);

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		int x=sc.nextInt();
		while (!Prime(x)) {
			x++;
		}
		System.out.println(x);
		sc.close();
	}
 
	//素数判定
	public static boolean Prime(int x) {
		if(x==1){
			return false;
		}
		for(int i= 2;i*i<=x;i++) {
			if (x%i==0) {
				return false;
			}
		}
		return true;
	}
}

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

using namespace std;

const int mod = (int) 1e9 + 7;

int mult(int a, int b) {
  long long A = a, B = b, M = mod;
  A %= M, B %= M;
  return int((A * B) % M);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> ee(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    int now = i;
    for (int j = 2; j * j <= now; j++) {
      if (now % j == 0) {
        while (now % j == 0) {
          now /= j;
          ++ee[j];
        }
      }
    }
    if (now > 1) {
      ++ee[now];
    }
  }
  int res = 1;
  for (int i = 2; i <= n; i++) {
    res = mult(res, ee[i] + 1);
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
 
using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x)	make_pair(x);
    
#define debug(x) 		cerr << #x << '=' << x << endl;
#define debug2(x, y)	cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(_a)		cerr << #_a << ": "; for (auto _x: _a) cerr << _x << ' '; cerr << endl;
#define debugm(a) 		cerr << #a << ":\n"; \
						for (auto v: a) { for(auto x: v) cout << x << ' '; cerr << "\n"; }
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long
 
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;
 
const int INF  = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 998244353;

int32_t main()
{
	FAST_IO;
	
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	
	string output;
	for (int i = 0; i < n; i++) {
		output.push_back(s[i]);
		output.push_back(t[i]);
	}
	cout << output << endl;
}


// g++ -Wall -Wextra -Wshadow -fsanitize=undefined 


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

int main()
{
	map<string, int> test;
	int count = 0;
	string verdict;
	cin >> count;
	for (int i = 0; i < count; i++)
	{
		test["AC"] = 0;
		
		test["WA"] = 0;
		
		test["TLE"] = 0;

		test["RE"] = 0;
	}

	for (int i = 0; i < count; i++)
	{
		cin >> verdict;
		
		if (verdict == "AC")
			test["AC"]++;
		else if (verdict == "WA")
			test["WA"]++;
		else if (verdict == "TLE")
			test["TLE"]++;
		else if (verdict == "RE")
			test["RE"]++;
	}
	cout << "AC"<< " x " << test["AC"] << endl;
	cout << "WA" << " x "<< test["WA"] << endl;
	cout << "TLE" << " x " << test["TLE"] << endl;
	cout << "RE" << " x " << test["RE"] << endl;
	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	vector<string> s(3);
	cin >> s[0] >> s[1] >> s[2];
	vector<int> index(3, 0);
	int turn = 0;
	while (true) {
		string t = s[turn];
		int i = index[turn];
		int n = t.size();
		if (i >= n) {
			char c = 'A' + turn;
			cout << c << endl;
			return;
		} else {
			index[turn]++;
			turn = t[i] - 'a';
		}
	}
}

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

Measured memory_bytes: 3612
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)
	diff := c - a - b
	if diff < 0 {
		fmt.Println("No")
		return
	}
	if 4*a*b < diff*diff {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b, c;
	cin >> a >> b;
	if (a >= b)
	{
		c = a;
		a--;
	}
	else
	{	
		c = b;
		b--;
	}
	if (a >= b)
	{
		c += a;
		a--;
	}
	else
	{
		c += b;
		b--;
	}
	cout << c << endl;
}

Measured memory_bytes: 3632
A,B = map(int,input().split())
a = A if A%2==0 else A+1
mod = 0 if (B-a)%4==0 else 1
if A==B:
    print(A)
elif A%2==0 and B%2==1:
    if (B-A+1)%4==0:
        print(0)
    else:
        print(1)
elif A%2==1 and B%2==1:
    mod = 0 if ((B-a)+1)%4==0 else 1
    print(mod^A)
elif A%2==0:
    print(mod^B)
elif B%2==1:
    print(mod^A)
else:
    print(A^B^mod)


Measured memory_bytes: 38384
n = int(input())
ts = [int(c) for c in input().split()]
vs = [int(c) for c in input().split()]

t = sum(ts)
dp = [[-10 ** 10 for _ in range(101)] for _ in range(t + 1)]
dp[0][0] = 0.

mvs = []
for dt, mv in zip(ts, vs):
    for st in range(dt):
        mvs.append(mv)
mvs.append(0)

for ct in range(t):
    mv = mvs[ct]
    for cv in range(mv + 1):
        endmv = min(mv, mvs[ct+1])
        for dv in [-1, 0, 1]:
            nv = cv + dv
            if 0 <= nv <= endmv:
                dp[ct + 1][nv] = max(dp[ct][cv] + (cv + nv) / 2, dp[ct + 1][nv])
        if mv >= cv + 1 and cv <= endmv:
            dp[ct + 1][cv] = max(dp[ct+1][cv], dp[ct][cv] + cv + 0.25)


print(dp[t][0])


Measured memory_bytes: 112732
import scala.io.StdIn

object Main extends App {
  val ballColors = StdIn.readLine.split(" ")
  val ballNum = StdIn.readLine.split(" ").map(_.toInt)
  val takeColor = StdIn.readLine

  if (ballColors(0) == takeColor) {
    ballNum(0) = ballNum(0)-1
    } else {
    ballNum(1) = ballNum(1)-1
  }
  println(ballNum.mkString(" "))
}


Measured memory_bytes: 25548
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
using namespace std;


int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, x, t; cin >> n >> x >> t;
    cout << ( ( n + (x-1) ) / x ) * t << '\n';
    return 0;
}

Measured memory_bytes: 3660
a, b, c = map(int, input().split())
ans = -1
for i in range(114514):
    if a % 2 == b % 2 == c % 2 == 0:
        a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
    else:
        ans = i
        break
print(ans)

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

int main() {
	int N;
	bool shurui = false;
	cin >> N;

	for (int i = 0; i < N; ++i){
		string s;
		cin >> s;

		if (s == "Y")
			shurui = true;
	}
	cout << (shurui ? "Four" : "Three") << endl;
}


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

using namespace std;

int main(){
	int N;
	string A;
	string B;
	string C;

	cin >> N;
	cin >> A;
	cin >> B;
	cin >> C;

	int ans = 0;

	for (int i=0; i<N; i++){
		set<char> st{};
		st.insert(A[i]);
		st.insert(B[i]);
		st.insert(C[i]);

		if (st.size() == 3){
			ans += 2;
		}
		else if (st.size() == 2){
			ans += 1;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int secs = sc.nextInt();
            int hh = secs / (60 * 60);
            int hs = secs % (60 * 60);
            int mm = hs / 60;
            int ss = hs % 60;
            System.out.println(String.format("%d:%d:%d", hh, mm, ss));
        }
    }
}



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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

struct UnionFind {
    vector<int> par;
    vector<int> size;

    UnionFind(int n) {
        par = vector<int>(n);
        for (int i = 0; i < n; i++) par[i] = i;
        size = vector<int>(n, 1);
    }

    int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (size[x] < size[y]) {
            par[x] = y;
            size[y] += size[x];
        } else {
            par[y] = x;
            size[x] += size[y];
        }
    }
};

ll ans[100000];

int main() {
    ll N, M;
    cin >> N >> M;
    UnionFind U(N);
    vector<P> edge;
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        edge.emplace_back(A, B);
    }
    ans[M - 1] = N * (N - 1) / 2;
    for (int i = M - 1; i > 0; i--) {
        int x = U.find(edge[i].first);
        int y = U.find(edge[i].second);
        ans[i - 1] = ans[i];
        if (x != y) {
            ll s1 = U.size[x];
            ll s2 = U.size[y];
            ans[i - 1] -= s1 * s2;
            U.unite(edge[i].first, edge[i].second);
        }
    }
    for (int i = 0; i < M; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3828
#include <stdio.h>

int main(void) {
  
  int a[4][13], n, x, i, j;
  char c, dummy;
  scanf("%d", &n);
  for(i = 0; i < 4; i++) {
    for(j = 0; j < 13; j++) {
      a[i][j] = 0;
    }
  }
  for(i = 0; i < n; i++) {
    scanf("%c",&dummy);
    scanf("%c%d", &c, &x);
    if(c == 'S') {
      a[0][x-1] = 1;
    } 
    if(c == 'H') {
      a[1][x-1] = 1;
    }
    if(c == 'C') {
      a[2][x-1] = 1;
    }
    if(c == 'D')  {
      a[3][x-1] = 1;
    }
  }
  for(i = 0; i < 4; i++) {
    for(j = 0; j < 13; j++) {
      if(a[i][j] == 0) {
	if(i == 0) {
	  printf("S %d\n", j+1);
	}
	if(i == 1) {
	  printf("H %d\n", j+1);
	}
	if(i == 2) {
	  printf("C %d\n", j+1);
	}
	if(i == 3) {
	  printf("D %d\n", j+1);
	}
      }
    }
  }

  return 0;

}

Measured memory_bytes: 596
n,m=map(int,input().split())
e=[list(map(int,input().split())) for _ in range(m)]
c=0
for x in e:
  l=list(range(n))
  for y in e:
    if y!=x:l=[l[y[0]-1] if l[i]==l[y[1]-1] else l[i] for i in range(n)]
  if len(set(l))!=1:c+=1
print(c)

Measured memory_bytes: 3064
use proconio::input;

fn main() {
    input! {
        n: usize,
        xy: [(i64, i64);n],
    };
    let mut dir1max = xy[0].0 + xy[0].1;
    let mut dir1min = xy[0].0 + xy[0].1;
    let mut dir2max = xy[0].0 - xy[0].1;
    let mut dir2min = xy[0].0 - xy[0].1;
    let mut dirmax = 0;
    for i in 1..n {
        let dir1 = xy[i].0 + xy[i].1;
        let dir2 = xy[i].0 - xy[i].1;

        let d = (dir1 - dir1max).abs();
        if d > dirmax { dirmax = d; }
        let d = (dir1 - dir1min).abs();
        if d > dirmax { dirmax = d; }
        let d = (dir2 - dir2max).abs();
        if d > dirmax { dirmax = d; }
        let d = (dir2 - dir2min).abs();
        if d > dirmax { dirmax = d; }

        if dir1 > dir1max {
            dir1max = dir1;
        }
        if dir1 < dir1min {
            dir1min = dir1;
        }
        if dir2 > dir2max {
            dir2max = dir2;
        }
        if dir2 < dir2min {
            dir2min = dir2;
        }
    }
    println!("{}", dirmax);
}


Measured memory_bytes: 8960
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var n int
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	fmt.Fscan(r, &n)
	flg := true
	if (n*100)%108 == 0 {
		fmt.Fprint(w, n*100/108)
	} else {
		for i := (n * 100 / 108); i <= (n+1)*100/108; i++ {
			if (i * 108 / 100) == n {
				fmt.Fprint(w, i)
				flg = false
				break
			}
		}
		if flg {
			fmt.Fprint(w, ":(")
		}

	}
}


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

int main(){
	string s,t,u;
	int a,b;
	cin >> s >> t >> a >> b >> u;
	if(u==s){
		a-=1;
	}
	else if(u==t){
		b-=1;
	}
	cout << a <<" "<< b; 
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define int long long
int n;
main()
{
	scanf("%lld",&n);
	int i,j,t1,t2;
	for(i=1;i<=4000;++i)
		for(j=1;j<=4000;++j)
		{
			t1=n*i*j;
			t2=4*i*j-n*i-n*j;
			if(t2>0&&t1%t2==0)
			{
				printf("%lld %lld %lld\n",i,j,t1/t2);
				return 0;
			}
		}
}

Measured memory_bytes: 128
#pragma GCC opimize (3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	int n, k;
	cin >> n >> k;
	vector<int> ans;
	while(n) {
		ans.push_back(n%k);
		n/=k;
	}
	cout << ans.size();
	return 0;
}

Measured memory_bytes: 256
#include <ext/pb_ds/assoc_container.hpp>
  #include <bits/stdc++.h>
  using namespace std;
  using namespace __gnu_pbds;
  template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
  #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  #define TRACE
  #ifdef TRACE
  #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
  template <typename Arg1>
  void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
  }
  template <typename Arg1, typename... Args>
  void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
  }
  #else
  #define trace(...) 
  #endif
  template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
  template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
  template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
  typedef long long int ll;
  const ll mod =1e18;
  const int maxn = 300002;
  #define endl '\n'
  #define int ll
  #define ld long double
  #define all(x) (x).begin(),(x).end()

vector<pair<int,int>> ga[maxn],gb[maxn];
vector<int> djikstra(ll src,ll n,bool curr)
{
  priority_queue< pair<int,int>, vector <pair<int,int>> , greater<pair<int,int>> > pq; 
  vector<ll> dist(n+1, 1e18),vis(n+1,0); 
  pq.push(make_pair(0, src)); 
  dist[src] = 0; 
  while (!pq.empty()) 
  { 
      ll u = pq.top().second; 
      pq.pop(); 
      if(vis[u])
        continue;
      vis[u] = 1;
      if(curr)
        for (auto i:ga[u]) 
        { 
            ll v = i.first; 
            ll weight = i.second; 
            if (dist[v] > dist[u] + weight) 
            { 
                dist[v] = dist[u] + weight; 
                pq.push(make_pair(dist[v], v)); 
            } 
        }
      else{
        for (auto i:gb[u]) 
        { 
            ll v = i.first; 
            ll weight = i.second; 
            if (dist[v] > dist[u] + weight) 
            { 
                dist[v] = dist[u] + weight; 
                pq.push(make_pair(dist[v], v)); 
            } 
        }
      } 
  } 
  return dist;

}
  int32_t main()
  { 
    IOS

    int n,m,s,t;
    cin>>n>>m>>s>>t;
     for(int i = 1;i<=m;i++){
       int u,v,a,b;
       cin>>u>>v>>a>>b;
       ga[u].push_back({v,a});
       ga[v].push_back({u,a});
       gb[u].push_back({v,b});
       gb[v].push_back({u,b});
    }


    auto distsa = djikstra(s,n,1);
    auto disttb = djikstra(t,n,0);
    int p = 1e18;
    vector<int> ans(n);
    for(int i = n;i>=1;i--){
      p = min(p,distsa[i]+disttb[i]);
      ans[i-1] = p;
    }
    int mxc = 1e15;
    for(int i = 0;i<n;i++) cout<<mxc - ans[i]<<"\n";

    

    
    
    
  }

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

int main() {
  int N;
  cin>>N;
  vector<string> s(N);
  vector<int> t(N);
  string X;
  int time=0;
  int xpassed=0;
  
  for(int i=0;i<N;i++){
   	cin>>s.at(i)>>t.at(i); 
  }
  
  cin>>X;
  
  for(int i=0;i<N;i++){
    if(xpassed==1){
     	time+=t.at(i);
    }
   	if(s.at(i)==X){
     	 xpassed=1;
    }
  }
  cout<<time<<endl;
  
  
  
}

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

int main(){
	int N,M;
	cin>>N>>M;
	
	int a[M],b[M];
	for(int i=0;i<M;i++){
		cin>>a[i];
		cin>>b[i];
	}
	
	
	int city[N+1]={};//都市iから出る道路がなんこあるか
	
	for(int i=1;i<=N;i++){
		for(int j=0;j<M;j++){
			if(a[j]==i)
				city[i]++;
			if(b[j]==i)
				city[i]++;
		}
	}
	
	for(int i=1;i<=N;i++)
		cout<<city[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 256
'use strict'
function main(input) {
    const std = input.split('\n')[0].split(' ').map(v => parseInt(v, 10));
    let participants = [...Array(std[0])].fill(std[1] - std[2]);
    let questions = input.split('\n');
    questions.shift();
    questions.forEach(q => participants[q-1]++);
    participants.forEach(v => v > 0 ? console.log("Yes") : console.log("No"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int max = 0;
		int min = 1 << 16;
		int[] num = new int[n];
		for (int i = 0; i < n; i++) {
			int t = scanner.nextInt();
			num[i] = t;
			max = Math.max(max, t);
			min = Math.min(min, t);
		}
		boolean[] b = new boolean[n];
		int[] sortnum = Arrays.copyOf(num, n);
		Arrays.sort(sortnum);
		List<Integer> list = new ArrayList<Integer>();
		for (int t : sortnum)
			list.add(t);
		int ans = 0;
		for (int i = 0; i < n; i++) {
			int s = 0;
			int an = 0;
			int cur = i;
			int m = max;
			while (true) {
				b[cur] = true;
				an++;
				int v = num[cur];
				m = Math.min(m, v);
				s += v;
				cur = list.indexOf(v);
				if (b[cur])
					break;
			}
			int aa = s + (an - 2) * m;
			int bb = s + m + (an + 1) * min;
			ans += Math.min(aa, bb);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21320
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int L;

int main(){
	vector<int> v;
	int base = 1;
	while(base < 1000000){
		v.push_back(base);
		base *= 3;
	}
	
	scanf("%d", &L);
	int N = 0; base = 1;
	while((2 * base) - 1 <= L){
		base *= 3;
		N++;
	}
	vector<int> va, vb, vc;
	base = 1;
	int max_3base = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < 3; j++){
			if(base * (j + 1) - 1 <= L - 1){
				va.push_back(i + 1);
				vb.push_back(i + 2);
				vc.push_back(base * j);
				max_3base = max(max_3base, base * (j + 1));
			}
		}
		base *= 3;
	}
	int diff = L - max_3base;
	for(int i = N - 1; i >= 0; i--){
		if(diff >= v[i]){
			for(int j = 0; j < diff / v[i]; j++){
				va.push_back(i + 1);
				vb.push_back(N + 1);
				vc.push_back(max_3base);
				max_3base += v[i];
			}
			diff -= diff / v[i] * v[i];
		}
	}
	printf("%d %d\n", N + 1, va.size());
	for(int i = 0; i < va.size(); i++){
		printf("%d %d %d\n", va[i], vb[i], vc[i]);
	}
	return 0;
}

Measured memory_bytes: 256
mod = 2019
l, r = map(int, input().split())
m = min(r, l + mod)
MN=[]
for i in range(l, m):
    for j in range(i+1, m+1):
        cand = i * j % mod
        if cand:
            MN.append(cand)
        else:
            print(0)
            exit()
print(min(MN))

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    // 3
    // 1 2
    // 1 3
    // 1 4
    // のようなタイプ
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
  }
fn main() {
    input! {
        n :usize,
        a :[usize;n]
    }

    let mut break_lenga = 0;
    let mut last_lenga_num = 1;

    for i in 0..n {
        if a[i] != last_lenga_num {
            break_lenga += 1;
        } else {
            last_lenga_num += 1;
        }
    }

    if last_lenga_num == 1 {
        break_lenga = -1;
    }

    println!("{}", break_lenga);
}


Measured memory_bytes: 6396
#include <vector>
#include <iostream>
#include <unordered_map>

using namespace std;

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

  int l = 0;
  int r = N - 1;

  unordered_map<int, string> m;
  cout << 0 << endl << flush;
  cin >> m[0];
  if (m[0] == "Vacant") return 0;
  cout << r << endl << flush;
  cin >> m[r];
  if (m[r] == "Vacant") return 0;
  while (1) {
    int mid = (l + r) / 2;
    cout << mid << endl << flush;
    cin >> m[mid];
    if (m[mid] == "Vacant") return 0;

    if ((r - mid) % 2 == 0 && m[r] != m[mid]) l = mid;
    else if ((r - mid) % 2 == 1 && m[r] == m[mid]) l = mid;
    else if ((mid - l) % 2 == 0 && m[mid] != m[l]) r = mid;
    else if ((mid - l) % 2 == 1 && m[mid] == m[l]) r = mid;
  }
}

Measured memory_bytes: 852
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] s = scan.next().split("/",3);
		scan.close();

		int year =Integer.valueOf(s[0]);
		int month =Integer.valueOf(s[1]);
		//int day =Integer.valueOf(s[2]);
		System.out.println((year==2019&&month>=5)? "TBD":"Heisei");
	}
}


Measured memory_bytes: 22740
#include <iostream>
#include <cstdio>
using namespace std;
long long gcd(long long a,long long b){
    long long t=1;
    while(b){
        t=b;
        b=a%b;
        a=t;
    }
    return t;
}
int main() {
    long long n,m;
    string s,t;
    while(scanf("%lld%lld",&n,&m)!=EOF){
        cin>>s>>t;
        long long L=n*m/gcd(n, m);
        if(n>=m)
            for(long long i=1;i<=m;i++)
                if((i-1)*(L/m)%(L/n)==0&&s[(i-1)*(L/m)/(L/n)]!=t[i-1]){
                    printf("-1\n");
                    return 0;
                }
        if(n<m)
            for(long long i=1;i<=n;i++)
                if((i-1)*(L/n)%(L/m)==0&&s[i-1]!=t[(i-1)*(L/n)/(L/m)]){
                    printf("-1\n");
                    return 0;
                }
        printf("%lld\n",L);
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int a[3][3] = {0};
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> a[i][j];
    }
  }
  
  int n;
  cin >> n;
  
  int temp;
  for(int i = 0; i < n; i++){
    cin >> temp;
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 3; k++){
        if(a[j][k] == temp){
          a[j][k] = 0;
        }
      }
    }
  }
  
  for(int j = 0; j < 3; j++){
    if(a[j][0] == 0){
      if(a[j][1] == 0){
        if(a[j][2] == 0){
          cout << "Yes";
          return 0;
      	}
      }
    }
    
    if(a[0][j] == 0){
      if(a[1][j] == 0){
        if(a[2][j] == 0){
          cout << "Yes";
          return 0;
      	}
      }
    }
  }
  
  if(a[0][0] == 0){
    if(a[1][1] == 0){
      if(a[2][2] == 0){
        cout << "Yes";
        return 0;
      }
    }
  }
  
  if(a[2][0] == 0){
    if(a[1][1] == 0){
      if(a[0][2] == 0){
        cout << "Yes";
        return 0;
      }
    }
  }
  
  cout << "No";
  
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  bool ans = true;
  for (int i = 0; i < n; i++) {
    if (a[i] % 2 == 0) {
      if (!((a[i] % 3 == 0) || (a[i] % 5 == 0))) {
        ans = false;
      }
    }
  }
  if (ans)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
}

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

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

  int a[ n ];
  for( int i = 0; i < n; i++ ) {
    cin >> a[ i ];
  }


  int mini = 0;
  int swap_cnt = 0;
  for( int i = 0; i < n; i++ ) {
    mini = i;
    for( int j = i; j < n; j++ ) {
      if( a[ j ] < a[ mini ] ) {
        mini = j;
      }
    }
    swap( a[ i ], a[ mini ] );
    if( i != mini ) {
      swap_cnt += 1;
    }
  }

  for( int i = 0; i < n; i++ ) {
    cout << a[ i ];
    if( i < n - 1 ) {
      cout << " ";
    }
    else {
      cout << endl;
    }
  }
  cout << swap_cnt << endl;

  return 0;
}



Measured memory_bytes: 3100
# https://atcoder.jp/contests/abc117/tasks/abc117_c

import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, m = input_int_list()
    X = sorted(input_int_list())
    diffs = []
    for i in range(1, m):
        diffs.append(abs(X[i - 1] - X[i]))
    diffs = sorted(diffs)
    ans = sum(diffs[:m - n])
    if n >= m:
        print(0)
        return
    else:
        print(ans)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 92244
import numpy as np
N, M = map(int, input().split())
AC = np.array([0]*N)
WA = np.array([0]*N)

for i in range(M):
    p, s = map(str, input().split())
    if AC[int(p)-1] == 0 and s =="WA":
        WA[int(p)-1] += 1
    else:
        AC[int(p)-1] = 1
        

print(sum(AC), sum(AC*WA))

Measured memory_bytes: 14788
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <set>
#define ll long long
using namespace std;

int main(){
    int X,N;
    cin>>X>>N;
    set<ll> s;
    for(int i=0;i<N;i++){
        int p;
        cin>>p;
        s.insert(p);
    }
    int cnt=0;
    while(1){
        if(!s.count(X-cnt)){
            cout<<X-cnt<<endl;
            break;
        }
        if(!s.count(X+cnt)){
            cout<<X+cnt<<endl;
            break;
        }
        cnt++;
    }
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////





int main() {

	ll A, B;
	cin >> A >> B;
	if (A == 1) { A += 13; }
	if (B == 1) { B += 13; }
	if (A > B) { cout << "Alice"; }
	if (B > A) { cout << "Bob"; }
	if (A == B) { cout << "Draw"; }



	system("PAUSE");
}


Measured memory_bytes: 504
#include <stdio.h>
#include <cmath>
#include <iostream>
 
using namespace std;
 
int main() {
    int k;
    char d;
    int a,b;
    int counter;
    int robx;
    int roby;
    int kari;
    while (cin >> k) {
        if (k == 0) {
            break;
        }
        counter = 0;
        int hyou[30][30] = {0};
        int koudou[30][2] = {0};
        for (int i = 0; i < k; i++) {
            cin >> a >> b;
            hyou[a][b] = 1;
            counter++;
        }
        cin >> k;
        for (int i = 0; i < k; i++) {
            cin >> d >> a;
            if (d == 'N') {
                koudou[i][0] = a;
            } else if (d == 'S') {
                koudou[i][0] = -a;
            } else if (d == 'E') {
                koudou[i][1] = a;
            } else {
                koudou[i][1] = -a;
            }
        }
        robx = 10;
        roby = 10;
        if (hyou[10][10] == 1) {
            hyou[10][10] = 0;
            counter--;
        }
        for (int i = 0; i < k; i++) {
            if (koudou[i][0] == 0) {
                kari = 1;
            } else {
                kari = 0;
            }
            for (int j = 0; j < abs(koudou[i][kari]); j++) {
                if (koudou[i][kari] > 0) {
                    if (kari == 0) {
                        roby++;
                    } else {
                        robx++;
                    }
                } else {
                    if (kari == 0) {
                        roby--;
                    } else {
                        robx--;
                    }
                }
                //printf("%d %d\n",robx,roby);
                if (hyou[robx][roby] == 1) {
                    hyou[robx][roby] = 0;
                    counter--;
                }
            	//cout<<robx<<" "<<roby<<endl;
            }
        }
        if (counter == 0) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n, m;
int a[114514];
signed main() {
	cin >> n >> m;
	rep(i, m)cin >> a[i];
	vector<int>v;
	sort(a, a + m);
	int sum = 0;
	rep(i, m - 1) {
		v.push_back(a[i + 1] - a[i]);
		sum += a[i + 1] - a[i];
	}
	sort(all(v), greater<>());
	rep(i, min(m - 1, n - 1)) {
		sum -= v[i];
	}
	cout << sum << endl;
}


Measured memory_bytes: 2168
n, m = map(int, input().split())
graph = [[]*n for _ in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  graph[a].append(b)
  graph[b].append(a)

import itertools
np = [i for i in range(1,n)]
p = list(itertools.permutations(np))
ans = 0
for pi in p:
  flag = True
  sta = 0
  for j in range(n-1):
    if pi[j] not in graph[sta]:
      flag = False
      break
    else:
      sta = pi[j]
  if flag: ans += 1

print(ans)

Measured memory_bytes: 40432
#include<iostream>
#include<string>

int main() {

	int sc; // shuffle count
	int h;	// shuffle point number
	int i;

	std::string card;
	
	for (;;) {

		std::cin >> card;

		if (card == "-")break;
		
		std::cin >> sc;

		for (i = 0; i < sc; i++) {
			std::cin >> h;

			card = card + card.substr(0, h);	// add
			
			card.erase(0, h);//erase

			

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


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

int main() {
  
  int k;
  string s;
  cin >> k >> s;
  
  int size = s.size();
  if (k >= size){
    cout << s << endl;
  }
  else if (k < size){
    for (int i = 0; i < k; i++){
      cout << s.at(i);
    }
    cout << "..." << endl;
    
  }
  
  
}




Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg puts("It's Just Begining.Wait For The End!!!!!\n")
#define CHECK(x) cout << (#x) << " is " << (x) <<"\n";
#define endl printf("\n")
typedef pair<ll,ll> pii;
#define pb push_back
#define ms(a,b) memset(a, b, sizeof(a))
#define in(x) scanf("%lld",&x)
#define out(x) printf("%lld",x)
#define X first
#define Y second
#define sps printf(" ")
#define dou(x) cout<<fixed<<setprecision(6)<<x
#define all(v) v.begin(),v.end()
#define dis(it,it1) distance(it,it1)+1
#define MAX 200005
#define INF 1000000000
#define MOD 1000000007
#define print(cs) printf("Case %lld: ",cs)
#define Yesno(ok) if(ok)puts("YES");else puts("NO")
#define yesno(ok) if(ok)puts("Yes");else puts("No")
ll lcm(ll a,ll b)
{
    return ((a*b)/__gcd(a,b));
}
int main()
{
    ll test=1;
    while(test--)
    {
        ll i,j,k,l,n,m,r;
        n=0;
        string s;
        cin>>s;
        for(i=0;i<s.size();i++)n+=(s[i]-'0');
        yesno(!(n%9));
    }
}


Measured memory_bytes: 3752