akhauriyash/Code-Regression huggingface dataset:
package main

import (
  "fmt"
  "sort"
)

func main() {
  var s [3]int;
  for i := 0; i < 3; i++ {fmt.Scan(&s[i])}
  sort.Ints(s[:])
  ans := "NO"
  if s[0] == 5 && s[1] == 5 && s[2] == 7 {ans = "YES"}
  fmt.Println(ans)
}

Measured memory_bytes: 512
s, ae= 0, [int(input()) for _ in range(5)]
f = True if ae[0]<0 else False
while ae[0]!= ae[1]:
    if ae[0]< 0:
        s, ae[0]= s+ae[2], ae[0]+1
    elif ae[0]== 0 and f:
        s, f= s+ae[3], False
    else:
        s, ae[0]= s+ae[4], ae[0]+1
print(s)

Measured memory_bytes: 7704
import sys

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

if N>=M:
    print(0)
    sys.exit()

X.sort()

Y=[0]*(M-1)
for i in range(M-1):
    Y[i]=X[i+1]-X[i]

Y=sorted(Y)[:-(N-M)]
print(sum(Y))

Measured memory_bytes: 85408
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n,m,x,y; cin >> n >> m >> x >> y;
    int b=-100,s=100,p;
    for (int i=0; i<n; i++) {cin >> p; b = max(b,p);}
    for (int j=0; j<m; j++) {cin >> p; s = min(s,p);}
    if ( ( (x<s) && (s<=y) ) && (b<s) ) puts("No War");
    else puts("War");
}

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

int main() {
  vector<int> x(5);
  for (int i = 0; i < 5; i++) cin >> x[i];
  int ans = -1;
  for (int i = 0; i < 5; i++) {
    if (x[i] == 0) ans = i+1;
  }
  cout << ans << endl;
}

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

int main()
{

	#ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin); 
   freopen("output.txt", "w", stdout); 
   #endif
	int d,t,s;cin>>d>>t>>s;

	int x=ceil((double)d/(double)s);
	if(x>t)
		cout<<"No";
	else
		cout<<"Yes";


}

Measured memory_bytes: 3636
/*
	@author: cheerioskun
*/

#include "bits/stdc++.h"
#define f first
#define sc second
#define pb push_back
#define MOD 1000000007L
#define inf 0x3f3f3f3f
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long int ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
using namespace std;


int main(){
	fast_io
	int N;
	cin>>N;
	map<string, int> mp;
	string s;
	int maxap = 0;
	for(int i = 0;i < N; ++i){
		cin>>s;
		mp[s]++;
		if(mp[s] > maxap) maxap = mp[s];
	}
	set<string> st;
	for(auto i: mp){
		if(i.sc == maxap){
			st.insert(i.f);
		}
	}
	for(auto i: st){
		cout<<i<<endl;
	}

}



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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li x;

    cin>>x;

    li ans=1;

    li angle=x;

    while((angle%360)!=0)
    {
        angle+=x;
        ans++;
    }

    cout<<ans;
}

int main()
{    
    

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

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3624
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 100001), 100001*100)
}

func main() {
	s := scanString()

	xs := make([]byte, 0, len(s))
	for i := 0; i < len(s)-1; i++ {
		if s[i:i+2] == "BC" {
			xs = append(xs, 'D')
			i++
			continue
		}
		xs = append(xs, s[i])
	}

	cnt := 0
	ans := 0
	for i := 0; i < len(xs); i++ {
		switch xs[i] {
		case 'A':
			cnt++
		case 'B', 'C':
			cnt = 0
		case 'D':
			ans += cnt
		}
	}
	fmt.Println(ans)
}


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

using namespace std;

int main() {
	int64_t N;
	cin >> N;
	uint64_t sum = 0;
	// for (int64_t d = 1; d <= N; ++d) {
	// 	if (N/d == N%d) {
	// 		cout << d << " " << N/d << endl;
	// 	}
	// }
	for (int64_t r = 1; r*r <= N; ++r) {
		if (N%r == 0) {
			int64_t test = N/r - 1;
			if (test<=0) continue;
			if (N/test == N%test) {
				// cout << test << endl;
				sum += test;
			}
			// cout <<  << endl;
		}
		// int64_t d = N/r, dd = d-r;
		// cout << "ee " << d << " " << dd << endl;
		// if (dd < 0) continue;
		// if (N%dd == N/dd) {
		// 	cout << dd << " " << N/dd << endl;
		// 	// cout << d
		// }
	}
	cout << sum << endl;
	// cout << sum << endl;
}

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

int main()
{
  int l, r;
  cin >> l >> r;
  vector<bool> ok(2019,false);
  int i, j;
  for(i = l; i <= r; i++)
  {
    if(ok.at(i%2019) == false)ok.at(i%2019) = true;
    else break;
  }
  if(ok.at(0))cout << 0 << endl;
  else
  {
    int minn = 2019;
    for(i = 0; i < 2019-1; i++)
    {
      for(j = i+1; j < 2019; j++)
      {
        if(ok.at(i) && ok.at(j))
        {
          if((i*j)%2019 < minn)minn = (i*j)%2019;
        }
      }
    }
    cout << minn << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 500005
#define K 19
#define M 200005
#define seed 23333

using namespace std;
const int inf=(int)1e9;
int i,j,m,n,p,k,f[N][27],B[N][K+1],Q,l,r;
char s[N];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	memset(f,60,sizeof(f));
	for (i=n;i;--i)
	{
			f[i][s[i]-'a']=i+1;
				for (j=s[i]-'a'+1;j<=s[i]-'a'+26;++j)
			{
					int now=j%27,la=(j+26)%27;
					if (j>=27) la=26;
					if (f[i][la]>inf) continue;
					if (j>=27)
					f[i][now]=f[f[i][la]][now];
					else 
					f[i][now]=f[f[i][la]][la];
			}
	}
	memset(B,60,sizeof(B));
	for (i=n;i;--i)
	{
			B[i][0]=f[i][26];
			for (j=1;j<=K;++j)
			{
					if (B[i][j-1]>inf) B[i][j]=inf+5;
					else B[i][j]=B[B[i][j-1]][j-1];
			}
	}
	scanf("%d",&Q);
	for (;Q--;)
	{
			scanf("%d%d",&l,&r);
			for (i=K;i>=0;--i)
				if (B[l][i]<=r+1) l=B[l][i];
			if (l==r+1) puts("Yes");
			else puts("No"); 
	}
}


Measured memory_bytes: 92928
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef pair< ll , ll > P;
typedef pair< ll , P > PP;

#define MAX 200005
int N;
ll x[MAX],y[MAX];
vector<PP> t;

int main(){
  set< PP > st;
  
  cin>>N;
  t.resize(N+N);
  for(int i=0;i<N;i++){
    cin>>x[i]>>y[i];
    t[i]=PP(x[i],P(i,0));
    t[i+N]=PP(y[i],P(i,1));
    st.insert(t[i]);
    st.insert(t[i+N]);
  }
  
  
  sort(t.begin(),t.end());

  ll ans=(1LL<<60);
  
  unordered_map<ll,int> mp;
  int L=0, count=0;
  int size=t.size();
  for(int i=0;i<size;i++){
    
    while(L<size && count<N){
      mp[ t[L].second.first ]++;
      if(mp[ t[L].second.first ]==1){
        count++;
        st.erase(t[L]);
      }else{

      }

      L++;
    }

    if(count==N){
      //      cout<<i<<' '<<L<<' '<<st.size()<<endl;
      set< PP > :: iterator it;
      it=st.end();
      it--;
      ll maxm=it->first;
      ll mini=st.begin()->first;
      ll width= t[L-1].first - t[i].first;
      ans=min( ans, width*(maxm-mini) );

      //      cout<<'a'<<endl;
    }


    mp[ t[i].second.first ]--;
    if(     mp[ t[i].second.first ]==0)count--;
    
    st.insert(t[i]);
  }

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 48024
/*
 * written by Yaqi Zhang (zhang623@wisc.edu)
 * University of Wisconsin-Madison
 * 2020
 */
#include <bits/stdc++.h>

#define INF 0x3f3f3f3f
typedef long long ll;

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    cout << (S == "ABC" ? "ARC" : "ABC") << endl;
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  vector<int> V(N),W(N);
  
  for (int i = 0; i < N; i++) {
    cin >> V[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> W[i];
    
    if (V[i] >= W[i]) {
      sum += V[i] - W[i];
    }
    else {
      continue;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
defmodule Main do
  def main do
    n = IO.gets("") |> String.trim() |> String.to_integer()

    n
    |> process([])
    |> List.to_string()
    |> IO.puts()
  end

  def process(0, acc), do: acc
  def process(n, acc) do
    code = rem(n-1, 26) + ?a
    next = div(n-1, 26)
    process(next, [code|acc])
  end

end


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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

ll mod0cnt[35], mod1cnt[35], mod2cnt[35];
ll d[35][35], g[510][510];

int main(){
    int n, c; cin>>n>>c;
    for(int i=0; i<c; i++){
        for(int j=0; j<c; j++){
            cin>>d[i][j];
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cin>>g[i][j];
            if((i+1+j+1)%3==0) mod0cnt[g[i][j]]++;
            else if((i+1+j+1)%3==1) mod1cnt[g[i][j]]++;
            else mod2cnt[g[i][j]]++;
        }
    }

    ll ans=INF;
    for(int i=1; i<=c; i++){
        for(int j=1; j<=c; j++){
            for(int k=1; k<=c; k++){
                if(i==j || k==j || k==i) continue;
                ll sum=0;

                for(int l=1; l<=c; l++){
                    sum+=mod0cnt[l]*d[l-1][i-1];
                    sum+=mod1cnt[l]*d[l-1][j-1];
                    sum+=mod2cnt[l]*d[l-1][k-1];
                }

                ans=min(ans, sum);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2304
h,w=map(int,input().split())
result=[]
b=[0]
for i in range(1,h+1):
    a=[0]+list(map(int,input().split()))
    r=[]
    for j in range(1,w+1):
        if len(r)==2:
            result.append([i,j-1,i,j])
        
        if a[j]%2==1:
            r+=[i,j]
            if len(r)==4:
                r=[]
    if len(r)==2:
        b.append(1)
    else:
        b.append(0)
r=[]
for i in range(1,h+1):
        if len(r)==2:
            result.append([i-1,w,i,w])
        
        if b[i]%2==1:
            r+=[i,j]
            if len(r)==4:
                r=[]
l=len(result)
print(l)
for i in range(l):
    print(result[i][0],result[i][1],result[i][2],result[i][3])

Measured memory_bytes: 25776
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

int N, X;
int64 arr[101010];

int main() {
    cin >> N >> X;
    for (int j = 0; j < N; ++j) { cin >> arr[j]; }
    int64  ret = 0;
    for (int j = 1; j < N; ++j) {
        if (arr[j-1] + arr[j] >= X) {
            int64 inc = arr[j-1] + arr[j] - X;
            arr[j] -= min(arr[j], inc);
            ret += inc;
        }
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 1024
//abc112_d.cpp
//Wed May  8 22:25:47 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int ans = 1;
	for (int i=n;i<=m/2;i++){
		if (m%i==0){
			ans = m/i;
			break;
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

int n;
int A[100000];

int partition(int A[], int p, int r) {
	int x = A[r];
	int i = p - 1;

	for (int j = p; j < r; j++) {
		if (A[j] <= x) {
			i++;
			swap(A[i], A[j]);
		}
	}

	swap(A[i + 1], A[r]);
	return i++;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) cin >> A[i];
	int p = partition(A, 0, n - 1);
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		if (i == p + 1) cout << "[" << A[i] << "]";
		else cout << A[i];
	}
	cout << endl;
}


Measured memory_bytes: 3456
N=gets.to_i
if N == 1
    puts 1
    exit
end
xys=[]
diffs={}
N.times do
    x,y=gets.chomp.split(" ").map(&:to_i)
    xys.each do |w,t|
        if x>w || x==w && y>t
            diffs["#{x-w}_#{y-t}"] ||= 0
            diffs["#{x-w}_#{y-t}"] += 1
        else
            diffs["#{w-x}_#{t-y}"] ||= 0
            diffs["#{w-x}_#{t-y}"] += 1
        end
    end
    xys.push([x,y])
end
n=diffs.values.sort[-1]
puts N-n


Measured memory_bytes: 14356
N,M = map(int,input().split())
min_l = -1
min_r = N+1
for _ in range(M):
  l,r = map(int,input().split())
  if min_l < l:
    min_l = l
  if min_r > r:
    min_r = r
    
print(max(min_r-min_l+1,0))
  

            


Measured memory_bytes: 3060
#降順ソートの方がうまくいきそう
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())),reverse=True)
cs=[]
sum=0
for i in range(n):
	sum+=a[i]
	cs.append(sum)

#和が引数以上の場合をカウントする
def overX(x):
	count=0
	#両手が違う人を握るときのみ考える
	if a[0]*2<x:
		return 0
	else:
		for i in range(n):
			if a[i]+a[0]<x:
				count+=0
			else:
				lb, ub = 0, n
				#パターンAのにぶたん。左がOなので[lb,ub)で持つ。
				while ub-lb>1:
					mid=(lb+ub)//2
					if a[i]+a[mid]>=x:
						lb=mid
					else:
						ub=mid
				count+=lb+1
		return count
#print(overX(130))

#overX>=mなる最大のxを探す->xは小さい方が実現しやすいのでパターンA->[lb,ub)でもつ
lb=1 #実現しやすい方
ub=2*10**5+1
while ub-lb>1:
	mid=(ub+lb)//2
	if overX(mid)>=m:
		lb=mid
	else:
		ub=mid
#ub=overX(x)>=mなる最小のx。これ以上大きくするとmに満たなくなる。
maxx=lb

hp=0
#maxx+1以上の要素をすべてたす
#和がmaxx+1以上になる組み合わせの数だけhpを加え、countをインクリメントする
if a[0]*2>=maxx+1:
	for i in range(n):
		if a[i]+a[0]<maxx+1:
			break
		else:
			lb, ub = 0, n
			#パターンAのにぶたん。左がOなので[lb,ub)で持つ。
			while ub-lb>1:
				mid=(lb+ub)//2
				if a[i]+a[mid]>=maxx+1:
					lb=mid
				else:
					ub=mid
			#a[0]からa[lb]は、a[i]と足した時にx以上になり条件を満たす。
			hp+=a[i]*(lb+1)+cs[lb]
hp+=(m-overX(maxx+1))*maxx
print(hp)

Measured memory_bytes: 58756
import sys
def input(): return sys.stdin.readline().rstrip()
from operator import itemgetter
def main():
    n=int(input())
    ST=[]
    for i in range(n):
        x,l=map(int,input().split())
        ST.append((x-l,x+l))
    ST.sort(key=itemgetter(1))
    ans=0
    for i,st in enumerate(ST):
        if i==0:
            ans+=1
            max_t=st[1]
        if max_t<=st[0]:
            ans+=1
            max_t=st[1]
    print(ans)




if __name__=='__main__':
    main()

Measured memory_bytes: 53084
#include<stdio.h>
int main(void){
  double x,y,a,b,c,d,e,f;
  while((scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f))!=EOF){
    x=(f-c*e/b)/(d-a*e/b);
    y=(f-c*d/a)/(e-b*d/a);
    if(x==-0.0000)
      x=0.000;
    if(y==-0.00)
      y=0.000;
    printf("%.3f %.3f\n",x,y);
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	ll ans= 1, m= pow(10, 9)+7;
	int N;
	cin >> N;
	REP(i, 1, N+1){
		ans *= i;
		ans%=m;
	}
	cout << ans;

}


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

int main(){
	#define int long long
	int T , A , B , C , D;
	for(cin >> T ; T ; --T){
		cin >> A >> B >> C >> D;
		if(A < B || B > D){puts("No"); continue;}
		A %= B; D = __gcd(D , B);
		int tms = (B - 1 - A) / D; A += tms * D;
		puts(C >= A ? "Yes" : "No"); continue;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
const int mod = 1000000007;
int main(){ //srand((unsigned)time(NULL));
  ll n;
  cin >> n;
  vector<ll> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  bool ans[2001] = {false};
  for (int bit = 1; bit < (1 << n); bit++) {
    ll sum = 0;
    for (int l = 0; l < n; l++) {
      if(bit & (1 << l))sum += A[l];
    }
    ans[sum] = true;
  }
  ll q;
  cin >> q;
  vector<ll> m(q);
  for (int i = 0; i < q; i++) {
    cin >> m[i];
    cout << (ans[m[i]] ? "yes" : "no") << endl;
  }
}



Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <map>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>

using namespace std;
#define set_precision cout << fixed << setprecision(10)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define vpi vector<pair<int,int>>
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define dsortA(arr) sort(arr.begin(), arr.end(), greater<ll>())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define nth(v,n) nth_element(v.begin,v.begin+n-1,v.end())
#define dnth(v,n) nth_element(v.begin,v.begin+n-1,v.end(), greater<ll>())
#define init(a)  memset((a),0,sizeof(a))
#define pi pair<int,int>
#define pb push_back
#define pl pair<ll,ll>
#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
long double EPS = 1e-9;

/*struct comp {
  bool operator() (const int& lhs, const int& rhs) const
  {return lhs<rhs;}
};*/

ll cel(ll a,ll b){return((a-1)/b+1);} 
ll gcd(ll a, ll b){
    if (a < b)swap(a, b);
    return (b == 0)? a: gcd(b, a % b);
}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll po(ll x,ll y){
    ll ans=1;
    while(y){
        if(y&1){ans=(ans*x)%mod;}
        y>>=1;x=(x*x)%mod;
    }
    return ans;
}

int main()
{
    FIO;
    ll n,t,x,y;
    string s;cin>>s;
    x=0;
    for(char c:s){x+=(c-'0');}
    if(x%9==0)cout<<"Yes";else cout<<"No";
    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
int calc(int m) {
    if (m == 0) return 1;
    return m * calc(m - 1);
}
int main() {
    int n;
    cin >> n;
    vector<int> X, Y;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        X.push_back(x);
        Y.push_back(y);
    }
    double sum_dist = 0;
    vector<int> perm;
    for (int i = 0; i < n; i++) perm.push_back(i);
    do {
       for (int i = 0; i < n - 1; i++) {
           int dx = X[perm[i+1]] - X[perm[i]];
           int dy = Y[perm[i+1]] - Y[perm[i]];
           sum_dist += sqrt(dx * dx + dy * dy);
       }  
    } while (next_permutation(perm.begin(), perm.end()));
    double ave = sum_dist / calc(n);
    printf("%.10f\n", ave);
    return 0;
}

Measured memory_bytes: 3796
#include <stdio.h>
 
int main(void){
    int m,f,r;
     
    scanf("%d %d %d",&m,&f,&r);
     
    while(!(m==-1 && f==-1 && r==-1)){
    	if(m==-1 || f==-1) printf("F\n");
        else if(m+f>=80 ) printf("A\n");
        else if(m+f>=65) printf("B\n");
        else if(m+f>=50) printf("C\n");
        else if(m+f>=30 && r>=50) printf("C\n");
        else if(m+f>=30 && r<50) printf("D\n");
        else if(m+f<30) printf("F\n");
         
        scanf("%d %d %d",&m,&f,&r);
    }
    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int par[10000];
int find(int x)
{
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

void unite(int x, int y)
{
	x = find(x); y = find(y);
	if (x == y) return;
	if (par[x] < par[y]) swap(x, y);
	if (par[x] == par[y]) par[x]--;
	par[y] = x;
}

bool same(int x, int y)
{
	return find(x) == find(y);
}
int main()
{
	int n, q;
	cin >> n >> q;
	MS(par, -1);
	REP(i, q)
	{
		int a, b, c;
		cin >> a >> b >> c;
		if (a==0)
		{
			unite(b, c);
		}
		else
		{
			if (same(b, c)) puts("1");
			else puts("0");
		}
	}
	return 0;
}

Measured memory_bytes: 1212
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt(), k = in.nextInt();
			int[] l = in.nextIntArray(n);

			Arrays.sort(l);

			int ans = 0;
			for (int i = 0; i < k; i++) {
				ans += l[i];
			}

			out.println(-ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = -nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

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

	int n;
	cin >> n;

	vector<pll> v(n);
	rep(i, n) cin >> v[i].first >> v[i].second;
	sort(v.begin(), v.end());

	ll INF = LLONG_MAX / 2;
	vector<ll> lf(n+1, 0), lb(n+1, 0), rf(n+1, INF), rb(n+1, INF);
	rep(i, n){
		lf[i+1] = max(lf[i], v[i].first);
		rf[i+1] = min(rf[i], v[i].second);
	}

	for(int i = n - 1; i >= 0; i--){
		lb[i] = max(lb[i+1], v[i].first);
		rb[i] = min(rb[i+1], v[i].second);
	}
	
	ll ans = 0;
	rep(i, n - 1){
		ans = max(
			ans
			, max(0ll, rf[i+1] - lf[i+1] + 1) 
			+ max(0ll, rb[i+1] - lb[i+1] + 1)
		);
	}

	rep(i, n){
		ans = max(
			ans
			, v[i].second - v[i].first + 1 
			+ max(0ll, min(rf[i], rb[i]) - max(lf[i], lb[i]) + 1)
		);
	}

	cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  int MAX = 0;
  int k = 0;
  vector<int> vec(N);
  int kaburi = 0;
  for (int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  for (int p = 0; p < N; p++){
    MAX = 0;
    for (int i = 0; i < N; i++){
      if (MAX <= vec.at(i)){
        MAX = vec.at(i);
        k = i;
      }
    }
    vec.at(k) = -1;
    for (int i = 0; i < N; i++){
      if (MAX == vec.at(i)){
        MAX = vec.at(i);
        vec.at(i) = -1;
        kaburi++;
      }
    }    
  }
  cout << N - kaburi << endl;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <string.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))

int main(){
	ll n,m;
	scanf("%lld%lld",&n,&m);
	printf("%lld",(n*100+m*1800)<<m);
}

Measured memory_bytes: 128
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: i64 = sc.input();
    let s: String = sc.input();
    let chs: Vec<u32> = s.chars().map(|x| x.to_digit(10).unwrap()).collect();

    let mut ans = 0;
    for i in 0..1000 {
        let first = if i < 100 { 0 } else { i / 100 };
        let second = if i < 10 { 0 } else { i % 100 / 10 };
        let third = i % 10;

        let x = match chs.iter().position(|x| x == &first) {
            Some(s) => s,
            None => continue,
        };
        let y = match chs[x + 1..].iter().position(|x| x == &second) {
            Some(s) => s,
            None => continue,
        };
        match chs[x + 1..][y + 1..].iter().position(|x| x == &third) {
            Some(s) => ans += 1,
            None => continue,
        }

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


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;




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

	int N, K; cin >> N >> K;
	if (K == 1) {
		print(0); return 0;
	}
	print(N - K);
}


Measured memory_bytes: 256
import sys
from collections import deque

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():
    N = in_n()

    for i in range(1, N + 1):
        if i * (i + 1) == N * 2:
            X = i
            break
    else:
        print('No')
        exit()

    ans = [[] for _ in range(X + 1)]
    ans[0] = [t for t in range(1, X + 1)]
    non_used = deque(range(X + 1, N + 1))
    used = [deque(range(1, X + 1))]

    for i in range(1, X + 1):
        for u in used:
            ans[i].append(u.popleft())

        size = len(ans[i])
        t = []
        for j in range(X - size):
            t.append(non_used.popleft())

        if t:
            ans[i] += t
            used.append(deque(t))

    print('Yes')
    print(X + 1)
    for a in ans:
        print(' '.join(map(str, [X] + a)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14608
# ABC 74, B - collecting balls easy version
n = int(input())
k = int(input())

X = [int(el) for el in input().split(' ')]

total = 0
for x in X:
    if x < abs(k-x):
        total += 2*x
    else:
        total += 2*abs(k-x)
print(total)


Measured memory_bytes: 2940
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;

#define _CRT_SECURE_NO_WARNINGS

int N = 0;
bool on=false;
bool lon, ron;
int main() {
	while (scanf("%d",&N),N!=0) {
		on = false; lon = false; ron = false;
		int count = 0;
		for (int i = 0; i < N; i++) {
			char s[3];
			scanf("%s", s);
			if (s[0] == 'l') {
				lon = !lon;
			}
			else {
				ron = !ron;
			}
			if (on) {
				if (!lon && !ron) {
					on = false;
					count++;
				}
			}
			else {
				if (lon&&ron) {
					on = true;
					count++;
				}
			}
		}
		printf("%d\n", count);
	}
	return 0;
}




Measured memory_bytes: 2732
a,b,c,d = map(int,list(input()))

#場合分け
if a+b+c+d==7:print('{}+{}+{}+{}=7'.format(a,b,c,d));exit()
if a-b+c+d==7:print('{}-{}+{}+{}=7'.format(a,b,c,d));exit()
if a+b-c+d==7:print('{}+{}-{}+{}=7'.format(a,b,c,d));exit()
if a+b+c-d==7:print('{}+{}+{}-{}=7'.format(a,b,c,d));exit()
if a-b-c+d==7:print('{}-{}-{}+{}=7'.format(a,b,c,d));exit()
if a+b-c-d==7:print('{}+{}-{}-{}=7'.format(a,b,c,d));exit()
if a-b+c-d==7:print('{}-{}+{}-{}=7'.format(a,b,c,d));exit()
if a-b-c-d==7:print('{}-{}-{}-{}=7'.format(a,b,c,d));exit()

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<57;
const double pi=acos(-1);
const double eps=1e-6;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

class Graph{
	private:
	int V;
	vvi List;
	vb used;
	void dfs(int v,vi& a){
		used[v]=1;
		a.push_back(v);
		for(int i=0;i<List[v].size();i++){
			int u=List[v][i];
			if(!used[u]){
				dfs(u,a);
				break;
			}
		}
	}
	public:
	Graph(int v){
		V=v;
		List=vvi(v);
		used=vb(v,0);
	}
	void add_edge(int s,int t){
		List[s].push_back(t);
		List[t].push_back(s);
	}
	void solve(){
		vi a,b;
		dfs(0,a);
		dfs(0,b);
		int A=a.size(),B=b.size();
		vi res;
		for(int i=A-1;i>=0;i--) res.push_back(a[i]);
		for(int i=1;i<B;i++) res.push_back(b[i]);
		int S=res.size();
		cout<<S<<endl;
		for(int i=0;i<S;i++){
			if(i) cout<<' ';
			cout<<res[i]+1;
		}
		cout<<endl;
	}
};

int n,m;

int main(){
	cin>>n>>m;
	Graph g(n);
	for(int i=0;i<m;i++){
		int s,t;
		cin>>s>>t;
		g.add_edge(s-1,t-1);
	}
	g.solve();
}

Measured memory_bytes: 9144
#include <cstdio>

const int p=1000000007;

int i,n,l,r,s,t,w;

inline int calc(int x)
{
	if (x<10) return 1;
	if (x<100) return 2;
	if (x<1000) return 3;
	if (x<10000) return 4;
	if (x<100000) return 5;
	if (x<1000000) return 6;
	if (x<10000000) return 7;
	if (x<100000000) return 8;
	return 9;
}

inline int power(int x,int y)
{
	int s=1;
	for (int i=30;i>=0;i--)
	{
		s=1LL*s*s%p;
		if ((1<<i)&y)
			s=1LL*s*x%p;
	}
	return s;
}

int main()
{
	scanf("%d",&n);
	for (i=9;i<=n;i++)
	{
		if (! (n%i))
			s=(s+9LL*power(10,i-1)-(n/i)%p+p)%p;
		if (n>=1LL*(n%i)*(i+1))
			s=(s+((n-(n%i)*(i+1))/i+i)/(i+1))%p;
	}
	t=0;
	for (l=1,r=1;calc(l)<=8;l++)
	{
		for (;t<n;r++)
			t=t+calc(r);
		if (t==n)
			s++;
		t=t-calc(l);
	}
	printf("%d",s%p);
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  int64_t K;
  cin >> K;
  int64_t ans=0;
  bool flag=false;
  char c=S.at(0);
  bool judge=true;
  int64_t x=0;
  for(int i=1;i<S.size();i++){
    if(flag){
      flag=false;
      continue;
    }
    if(S.at(i)==S.at(i-1)){
      ans++;
      flag=true;
    }
  }
  if(S.size()%2!=0){
    for(int i=1;i<S.size();i++){
      if(c!=S.at(i)){
        judge=false;
        break;
      }
    }
    if(judge){
      for(int64_t i=1;i<=K;i++){
        if(i%2==0){
          x+=ans+1;
        }else{
          x+=ans;
        }
      }
      cout << x << endl;
      return 0;
    }
  }
  int64_t n=ans;
  c=S.at(0);
  judge=false;
  string T="";
  if(S.size()>=2){
    if(S.at(0)==S.at(S.size()-1)){
      for(int i=0;i<S.size();i++){
        if(c==S.at(i)){
          T+=S.at(i);
        }else{
          if((c==S.at(0))&&(T.size()%2!=0)){
            judge=true;
          }
          T=S.at(i);
          c=S.at(i);
        }
      }
      if((judge)&&(T.size()%2!=0)){
        judge=true;
      }else{
        judge=false;
      }
      if(judge){
        n+=(ans+1)*(K-1);
        cout << n << endl;
        return 0;
      }
    }
    }
  ans*=K;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  cout << a+b+c-max({a,b,c}) << endl;

  return 0;
}

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

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    b = [LI() for _ in range(N)]

    for i in range(1,N):
        if b[i][0] < b[i-1][0] or b[i][1] < b[i-1][1]:
            r = max((b[i-1][0]-1)//b[i][0],(b[i-1][1]-1)//b[i][1]) + 1
            b[i][0] *= r
            b[i][1] *= r
    print(sum(b[-1]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 40684
def solve(tokens):
    stack = []

    for token in tokens:
        if token == "+":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t1 + t2)
        elif token == "-":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t2 - t1)
        elif token == "*":
            t1 = stack.pop()
            t2 = stack.pop()
            stack.append(t1 * t2)
        else:
            stack.append(int(token))

    return stack.pop()


def main():
    print solve(raw_input().split())


if __name__ == "__main__":
    main()

Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }

    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m, k;
    cin >> n >> m >> k;
    vi f(n);
    UnionFind uf(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        f[a]--; f[b]--;
        uf.unite(a, b);
    }
    rep(i, k) {
        int c, d;
        cin >> c >> d;
        c--; d--;
        if (uf.same(c, d)) {
            f[c]--; f[d]--;
        }
    }
    rep(i, n) f[i] += uf.size(i) - 1;
    rep(i, n) {
        if (i != 0) cout << " ";
        cout << f[i];
    }
    cout << endl;
}

Measured memory_bytes: 1664
/* 44 - 01*/

#include <iostream>
#include <vector>
#include <queue>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++) 

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

class NODE{
public:
	int x1;
	int y1;
	int x2;
	int y2;
	int depth;
};

bool done[52][52][52][52];

int main(){
	int X,Y,tx,ty,kx,ky;
	char data[2][52][52];
	while(cin >> X >> Y , X){
		rep(k,2)rep(i,52)rep(j,52)data[k][i][j] = '#';
		vector<string> vec[2];
		vec[0].resize(Y);vec[1].resize(Y);
		rep(i,Y)cin >> vec[0][i] >> vec[1][i] ;
		
		rep(i,Y)rep(j,X){
			char c = vec[0][i][j];
			if(c == 'L')tx = 1+j , ty = i+1;
			data[0][1+i][1+j] = c;
		}
		
		rep(i,Y){
			rep(j,X){
				char c = vec[1][i][j];
				if(c == 'R')kx = 1+j , ky = i+1;
				data[1][1+i][1+j] = c;
			}
		}
		queue<NODE> Q;
		NODE t = {tx,ty,kx,ky,0};
		
		rep(i,52)rep(j,52)rep(k,52)rep(l,52)done[i][j][k][l] = false;
		
		Q.push(t);
		while(Q.size()){
			NODE q = Q.front();Q.pop();
			//if(q.depth >= 100)continue;
			if( done[q.x1][q.y1][q.x2][q.y2] )continue;
			done[q.x1][q.y1][q.x2][q.y2] = true;
			
			if(data[0][q.y1][q.x1] == '%' || data[1][q.y2][q.x2] == '%'){
				if(data[0][q.y1][q.x1] == '%' && data[1][q.y2][q.x2] == '%'){
					cout << "Yes" << endl;
					goto end;	
				}
				continue;
			}
			rep(i,4){
				NODE next;
				next.x1 = q.x1 + dx[i];
				next.y1 = q.y1 + dy[i];
				next.x2 = q.x2 + dx2[i];
				next.y2 = q.y2 + dy2[i];
				next.depth = q.depth + 1;
				if(data[0][next.y1][next.x1] == '#'){
					next.x1 = q.x1;
					next.y1 = q.y1;
				}
				if(data[1][next.y2][next.x2] == '#'){
					next.x2 = q.x2;
					next.y2 = q.y2;
				}
				Q.push(next);
			}
		}
		cout << "No" << endl;
		end:;	
	}

}

Measured memory_bytes: 12000
#include<stdio.h>
#include<string.h>
#define N 100


int main(){
  int i,top=0,stack[N],len;
  char n,r[7];

  for(i=0;i<N;i++)stack[i]=0;
  for(i=0;i<200;i++){
    if(EOF==scanf("%s",r))break;
    if(r[0]=='+'){
      stack[top-2]+=stack[top-1];
      top--;
      stack[top]=0;
    }
    else if(r[0]=='-'){
      stack[top-2]-=stack[top-1];
      top--;
      stack[top]=0;
    }
    else if(r[0]=='*'){
      stack[top-2]*=stack[top-1];
      top--;
      stack[top]=0;
    }
    else if(r[0]>='0' && r[0]<='9'){
      len=strlen(r);
      for(i=0;i<len;i++){
	stack[top]*=10;
	stack[top]+=r[i]-'0';
      }
      top++;
    }
  }
  printf("%d",stack[top-1]);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462
typedef long long ll;
typedef double db;
int main(){
    string s,t;
    cin>>s>>t;
    int num=0;
    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i]) num++;
    }
    cout<<num<<endl;
} 

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

#define N 1000
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define all(cont) cont.begin(), cont.end()
#define sortcmp(n, cmpfunc) sort(all(n), cmpfunc)
#define fastio ios::sync_with_stdio(false); cin.tie(0)

ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
ll powm(ll a, ll b);
ll divm(ll a, ll b);
ll multm(ll a, ll b);
ll subm(ll a, ll b);
ll addm(ll a, ll b);

int main(){
	fastio;
	// #ifndef ONLINE_JUDGE
 //    	freopen("input.in", "r", stdin);
 //    	freopen("output.out", "w", stdout);
	// #endif
	int a, b, t;
	cin >> a >> b >> t;
	cout << t/a * b << endl;


	return 0;
}

// template function
ll gcd(ll a, ll b) { 
	if (b == 0) return a; 
	return gcd(b, a % b);  
} 

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

ll powm(ll a, ll b){
	ll x=1, y=a; 
    while (b > 0) {
        if (b%2) x = (x*y) % mod;
        y = (y*y) % mod;
        b /= 2;
    }
    return x % mod;
}

ll multm(ll a, ll b){
	return ((a%mod) * (b%mod)) % mod;
}

ll divm(ll a, ll b){
	return (a * powm(b, mod - 2)); 
}

ll subm(ll a, ll b){
	a -= b;
  	if (a < 0) a += mod;
	return a;
}

ll addm(ll a, ll b){
	a += b;
  	if (a >= mod) a -= mod;
  	return a;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,j;
	int lasa[28];
	int value[31];

	for(i=1;i<=30;i++)
	{
		value[i]=i;
	}

	for(i=0;i<=28;i++)
	{
		scanf("%d\n",&lasa[i]);
	}

	for(i=0;i<29;i++)
	{
		for(j=1;j<31;j++)
		{
			if(lasa[i]==value[j])
			{
				value[j]=-1;
			}
		}
	}
	for(i=1;i<=30;i++)
	{
		if(value[i]>-1)
		{
			printf("%d\n",value[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;


 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);
  
 

ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 


 
const int MAX = 680000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

ll modpow(ll a,ll n,ll mod){
  ll ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  //vll segtree(524287);
  //ll N=262144;
  ll x,y;
    cin>>x>>y;

  if((x+y)%3!=0){
    cout<<0<<endl;
    return;
  }

  ll n=(x+y)/3;//何回移動するか
  ll a=2*n;
  ll b=n;
  ll count=a-x;
  
  if(count<0||count>2*n){
    cout<<0<<endl;
    return;
  }
  
  comuse;
  cout<<combi(n,count)<<endl;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  if(t.substr(0,s.size())==s) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main(void)
{
	int month, day, sum = 0, s_y = 3;
	int m_and_D[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	char select_y[7][10] = 
	{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

	while(scanf("%d %d",&month, &day) && month > 0)
	{
		s_y = 3;
		sum = 0;
		for(int f1 = 1; f1 < month; f1++)
		{
			sum += m_and_D[f1];
		}

		sum += day - 1;
		s_y = (sum + s_y) % 7;

		printf("%s\n",select_y[s_y]);
	}
	return 0;
}

Measured memory_bytes: 1012