akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int N, M, R;
int r[8];

vector<int> connect[200];
int dis[200][200];
struct St
{
	int n;
	int len;
	St(int n, int len) : n(n), len(len) {}
	bool operator<(const St &n) const { return len > n.len; }
};
int ans[200];
void dikstra(int from)
{
	REP(i, N) ans[i] = INT64_MAX;
	ans[from] = 0;

	priority_queue<St> q;
	q.push(St(from, 0));
	while (q.size() > 0)
	{
		St st = q.top();
		q.pop();
		for (int next : connect[st.n])
		{
			int len = st.len + dis[st.n][next];
			if (ans[next] > len)
			{
				ans[next] = len;
				q.push(St(next, len));
			}
		}
	}
}

int table[200][200];

signed main()
{
	cin >> N >> M >> R;
	REP(i, R) cin >> r[i];
	REP(i, M)
	{
		int A, B, C;
		cin >> A >> B >> C;
		A--; B--; C;
		connect[A].push_back(B);
		connect[B].push_back(A);
		dis[A][B] = C;
		dis[B][A] = C;
	}

	for (int j = 0; j < N; j++)
	{
		dikstra(j);
		for (int i = 0; i < N; i++)
		{
			table[j][i] = ans[i];
		}
	}

	int min = INT64_MAX;
	vector<int> v;
	REP(i, R) v.push_back(r[i] - 1);
	SORT(v);
	do
	{
		int l = 0;
		for (int i = 0; i < R - 1; i++)
		{
			l += table[v[i]][v[i + 1]];
		}
		if (l < min)
		{
			min = l;
		}
	} while (next_permutation(v.begin(), v.end()));

	cout << min << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>

int main()
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(r<=x&&x<=W-r)
	{
		if(r<=y&&y<=H-r)
		printf("Yes\n");
		else 
		printf("No\n");
	}
	else
	printf("No\n");
	return 0;
 } 


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

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++ )

int main()
{
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string c;
	int a;
	while (cin >> c){
		for (int i = 0; i != c.size(); i++){
			if (c[i] == '@'){
				a = c[i + 1] - '0';
				for (int j = 0; j < a; j++) {
					cout.put(c[i + 2]);
				}
				i++;
				i++;
			}
			else cout.put(c[i]);
			
		}
		cout << endl;
	}
}

Measured memory_bytes: 3140
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;



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

  cout<<(N+1)/2<<endl;


return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(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;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

    int n;
    cin>>n;
    vll b(n-1);
    ll ans=0;
    rep(i,n-1)cin>>b[i];
    for(int i=0;i<n-2;i++)ans+=min(b[i],b[i+1]);
    ans+=b[0];
    ans+=b[n-2];
    fin(ans);

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


A, B, C, D = map(int, input().split())

c = B // C - (A - 1) // C
d = B // D - (A - 1) // D
cd = B // lcm(C, D) - (A - 1) // lcm(C, D)

num = c + d - cd
ans = B - A - num + 1
print(ans)


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

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define mod (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()

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

void print(bool f)
{
    cout << (f ? "Yes" : "No") << endl;
}

void Print(bool f)
{
    cout << (f ? "YES" : "NO") << endl;
}

int main(void)
{
    ll n, h;
    cin >> n >> h;
    vll a(n), b(n);
    ll m = 0;
    rep(i, 0, n) cin >> a[i] >> b[i], m = max(m, a[i]);

    sort(ALL(b));
    reverse(ALL(b));
    ll ans = 0;
    rep(i, 0, n)
    {
        if (b[i] > m)
            h -= b[i], ans++;
        else
            break;
        if (h <= 0)
            return cout << ans << endl, 0;
    }
    ans += ceil((double)h / m);
    cout << ans << endl;
}

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

// 別解（想定解）のb→axc解法
public class Main {
    public static void main(String[] args) throws Exception {
        // 入力
        Scanner sc = new Scanner(System.in);
        int n=Integer.parseInt(sc.next());
        int[] a=new int[n];
        for(int i=0;i<n;i++)    a[i]=Integer.parseInt(sc.next());
        int[] b=new int[n];
        for(int i=0;i<n;i++)   b[i]=Integer.parseInt(sc.next());
        int[] c=new int[n];
        for(int i=0;i<n;i++)    c[i]=Integer.parseInt(sc.next());
        Arrays.sort(a); Arrays.sort(b); Arrays.sort(c);
        
        // 各b[i]に対し、何個のcが選べるかx何個aが選べるか
        // これらは独立に計算が可能なので、掛け算して足していくと答えになります。
        // 解説した解法に載せたsを用いる手法を拡張して、s,tで同時に進めます。
        // aの処理が結構めんどくさいので頑張って。
        long ret=0;
        int s=0,t=-1;
        for(int i=0;i<n;i++){
            while(s<n&&c[s]<=b[i]) s++;
            while(t<n-1&&a[t+1]<b[i])   t++;
            ret+=(long)(n-s)*(t+1);
        }
        System.out.println(ret);
    }
}


Measured memory_bytes: 63612
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

judge = sorted(list(set(a)))
c = Counter(a)
if not (judge[0] == 0 if n % 2 == 1 else 1):
    print(0)
    exit()

f = True
for v in judge:
    f &= (c[v] == 2 if v != 0 else 1)
if not f:
    print(0)
    exit()

f = True
for i in range(len(judge) - 1):
    f &= (judge[i + 1] - judge[i] == 2)
if not f:
    print(0)
    exit()

mod = 10**9+7
print(pow(2, n//2, mod))


Measured memory_bytes: 20560
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const long long MOD=1000000007;
const long long LMOD=154590409516822759;
//const long long LMOD=1000000007;
#define Fi first
#define Se second
#define P2 pair
#define Pii pair<int,int>
#define Pll pair<long long,long long>
#define Cb make_pair
#define ll long long
#define Ull unsigned long long
#define Sf scanf
#define Pf printf
#define Pb push_back
#define Psh push
#define Stc stack
#define Vct vector
#define Ret return
#define Re0 return 0
#define Sz size
#define Is insert
#define Que queue
#define Emp empty
#define Fro front
#define Rv reverse
#define Er erase
#define Bg begin
#define Srt sort
#define Pq priority_queue
#define Ins insert
#define Ite iterator
#define Cou count
#define Cot continue
#define Beg begin
ll a[300001];
ll g[64];
int main()
{
	ll n;
	Sf("%lld",&n);
	for(ll i=1;i<=n;i++)
	{
		Sf("%lld",&a[i]);
	}
	ll res=0;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=0;j<60;j++)
		{
			g[j]+=(a[i]>>j)&1ll;
		}
	}
	ll s=0;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=0;j<60;j++)
		{
			//g[j]-=(a[i]>>j)&1ll;
			if((a[i]>>j)&1ll)
			{
				s+=(n-g[j])*((1ll<<j));
				//cout<<s<<endl;
				(res+=(n-g[j])*((1ll<<j)%MOD))%=MOD;
			}
			else
			{
				s+=(g[j])*((1ll<<j));
				//cout<<s<<endl;
				(res+=(g[j])*((1ll<<j)%MOD))%=MOD;
			}
		}
	}
	//cout<<s%MOD<<endl;
	//(res*=(MOD+1ll)/2ll)%=MOD;
	(res*=(MOD+1)/2ll)%=MOD;
	cout<<res;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define fort(i,n) for (int i = 1; i <= n; ++i)
#define pi pair<int,int>
#define vi vector<int>
#define pb push_back
#define sz size()
#define er erase
#define fr first
#define sc second
#define rc(x) return cout << x, 0
using namespace std;

int a,b[10];

int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    fort (i,4)
    {
        cin >> a;
        ++b[a];
    }
    if (b[1]==1&&b[9]==1&&b[7]==1&&b[4]==1) cout << "YES";
    else cout << "NO";
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

long long N;
long long arr[3005];
long long sum = 0;
int main()
{
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
		sum += arr[i] - 1;
	}
	printf("%lld\n", sum);

	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader r =
         new BufferedReader(new InputStreamReader(System.in));       
        String line = r.readLine();   
        
        int cnt=1;
        while(line!=null){ 
            int buf = Integer.parseInt(line);
            if (buf == 0) break;
            if (cnt > 10000) break;
            if (1 <= buf && buf <= 10000){
                System.out.println("Case "+cnt+": "+buf);
                cnt++;
            }
            line = r.readLine();
        }        
    }
}

Measured memory_bytes: 31428
# -*- coding: utf-8 -*-

H,W,M = map(int, input().split())

count_H = [0 for _ in range(H)]
count_W = [0 for _ in range(W)]
bomb = set()

for _ in range(M):
  h,w = map(int, input().split())
  bomb.add((h-1,w-1))
  count_H[h-1] += 1
  count_W[w-1] += 1

def argmax(L):
  indices = []
  maximum = -1
  for i in range(len(L)):
    if L[i] > maximum:
      indices = [i]
      maximum = L[i]
    elif L[i] == maximum:
      indices.append(i)
  return indices,maximum

indices_H,max_H = argmax(count_H)
indices_W,max_W = argmax(count_W)

answer = max_H + max_W - 1
flg = -1
for h in indices_H:
  for w in indices_W:
    if (h,w) not in bomb:
      answer = max_H + max_W
      flg = 0
      break
  if flg == 0:
    break

print(answer)

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

using namespace std;

vector<vector<int>> adj((int)1e5 + 1);
vector<int> memo((int)1e5 + 1, -1);

void max_self(int& a, int b) {
    a = max(a, b);
}

int dp(int v) {
    if (memo[v] != -1)
        return memo[v];

    int len = 0;
    for (int u: adj[v])
        max_self(len, 1 + dp(u));

    memo[v] = len;
    return len;
}

int main() {
    int N, M, x, y;

    scanf("%d %d", &N, &M);

    while (M--) {
        scanf("%d %d", &x, &y);
        adj[x].push_back(y);
    }

    int ans = 0;
    for (int v = 1; v <= N; v++)
        max_self(ans, dp(v));

    printf("%d\n", ans);

    return 0;
}

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

typedef struct pp{
    char name[100];
    int time;
} P;

P Q[LEN];
int head, tail, n, q, cnt=0;

void initialize(){
    head = 0;
    tail = 0;
}

bool isFull(){
    return head == (tail+1) % LEN;
}

bool isEmpty(){
    return head == tail;
}

void enquene(P x){
    if (isFull()) {
        cout << "overflow" << endl;
    }
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequene(){
    if (isEmpty()) {
        cout << "underflow" << endl;
    }
    P x = Q[head]; 
    head = (head + 1) % LEN;
    return x;
}

int main(){
    cin >> n >> q;
    for (int i=0;i<n;i++) {
        cin >> Q[i].name >> Q[i].time;
        head = 0;
        tail = n; 
    }
    int i = 0;
    while (head != tail){
        if (Q[i].time <= q){
            cnt += dequene().time;
            cout << Q[i].name << ' ' << cnt << endl;
        }
        else{
            cnt += q;
            P x = dequene();
            x.time -= q;
            enquene(x);
        }
        i++;
    }
    return 0;
}


Measured memory_bytes: 22220
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    int a[n];
    vector<pii> v[n];
    rep(i,0,n){
        cin>>a[i];
        rep(j,0,a[i]){
            int x,y;cin>>x>>y;x--;
            v[i].push_back({x,y});
        }
        
    }
    int ans=0;
    rep(i,0,1<<n){
        bool used[n];
        fill(used,used+n,false);
        int uu=i;
        int su=0;
        rep(j,0,n){
            if(uu%2){used[j]=true;su++;}
            uu/=2;
        }
        int u=i;
        int r=0;
        rep(j,0,n){
            if(u%2){
                rep(k,0,v[j].size()){
                    int ne=v[j][k].first,tt=v[j][k].second;
                    if(used[ne]&&tt==0){
                        r=1;
                        break;
                    }
                    if(!used[ne]&&tt==1){
                        r=1;
                        break;
                    }
                }
                if(r==1)break;
            }
            u/=2;
        }
        if(r==0){
            ans=max(ans,su);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
def solve(s, t):
    n = len(s)
    for i in range(n):
        u = s[i:] + s[:i]
        if u == t:
            return "Yes"
    return "No"

assert solve("kyoto","tokyo") == "Yes"
assert solve("abc", "arc") == "No"
assert solve("aaaaaaaaaaaaaaab", "aaaaaaaaaaaaaaab") == "Yes"
s = raw_input()
t = raw_input()
print solve(s, t)

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int N; cin >> N;
  vector<int> a(N); cin >> a;
  int cont = 0;
  int ans = 0;
  rep(i, N) {
    if (i && a[i] == a[i - 1]) {
      cont++;
      if (cont % 2) {
        ans++;
      }
    } else {
      cont = 0;
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL A, B, C, X, Y;
	in >> A >> B >> C >> X >> Y;

	LL ans = 1145148101919364364;
	for (LL i = 0; i <= 212345; i += 2)
	{
		LL wantA = X - i / 2, wantB = Y - i / 2, res = C * i;
		if (wantA > 0) res += A * wantA;
		if (wantB > 0) res += B * wantB;
		ans = std::min(ans, res);
	}

	out << ans << std::endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Harshad
 */

#include <bits/stdc++.h>

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 1e5+5;
int dp[N], a[N];

class AFrog1 {
public:
    int n;
    int rec(int i) {
        if(i == n - 1) return 0;
        if(dp[i] != -1) return dp[i];
        int res = abs(a[i] - a[i+1]) + rec(i+1);
        if(i+2 < n) res = min(res, abs(a[i] - a[i+2]) + rec(i+2));
        return dp[i] = res;
    }
	void solve(std::istream& in, std::ostream& out) {
        in >> n;
        for(int i = 0; i < n; ++i) in >> a[i];
        memset(dp, -1, sizeof dp);
        out << rec(0);
	}
};


int32_t main() {
	AFrog1 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 5760
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int i,r=0,b=0,n;cin>>n;
	string s;cin>>s;
	for(char it:s){
		if(it=='R'){r++;}else{b++;}
	}cout<<(r>b?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>
#include<tuple>

using namespace std;

#define reep(i, s, n) for(int i=s;i<(int)n;i++)
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define REP(i, n) for(int i=0;i<(int)n;i++)
#define all(v) v.begin(), v.end()
#define tyd typedef
#define vc vector
#define pb push_Back
#define eb emplace_back
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
const int IINF = 1<<28;

#define fs first
#define sc second
#define X real()
#define Y imag()
typedef long double R;
const R EPS = 1e-9;
const R INF = 1e9;
inline int sig(const R &x){return abs(x) < EPS ? 0 : x > 0 ? 1 : -1;}
typedef complex<R> P;
inline  R inp(const P &a, const P &b){ return (conj(a)*b).X;}
inline R outp(const P &a, const P &b){ return (conj(a)*b).Y;}
inline int ccw(const P &s, const P &t, const P &p){
	int res = sig(outp(t-s, p-s));
	if(res) return res;
	if(sig(inp(t-s, p-s)) < 0) return -2;
	if(sig(inp(s-t, p-t)) < 0) return 2;
	return 0;
}
int intersect(const P &s0, const P &s1, const P &t0, const P &t1){
	int p = ccw(t0, t1, s0) * ccw(t0, t1, s1);
	int q = ccw(s0, s1, t0) * ccw(s0, s1, t1);
	return !(p>0 || q>0);
}

int n, m;

typedef pair<R, int> pRi;

R solve(vector<P> p, P p1, P p2){
	int n = p.size();
	priority_queue<pRi, vector<pRi>, greater<pRi>> pq;
	pq.emplace(abs(p1 - p2), 0);
	vector<R> dp(n, INF);
	dp[0] = abs(p1 - p2);
	while(!pq.empty()){
		R d; int u; tie(d, u) = pq.top(); pq.pop();
		if(dp[u] + EPS < d) continue;
		R c;
		REP(v, n){
			if(u!=v && dp[v] > (c = (d + abs(p[u] - p[v])))){
				if(intersect(p[u], p[v], p1, p2)) continue;
				dp[v] = c;
				pq.emplace(c, v);
			}
		}
	}
	return dp[1];
}










int main(){
	vector<P> p1, p2;
	cin >> n >> m;
	REP(i, n){
		R x, y;
		cin >> x >> y;
		p1.eb(x, y);
	}
	REP(i, m){
		R x, y;
		cin >> x >> y;
		p2.eb(x, y);
	}
	R res = min(solve(p1, p2[0], p2[1]), solve(p2, p1[0], p1[1]));
	if(res >= INF-1) puts("-1");
	else{
		printf("%.11f\n", (double)res);
	}
	return 0;
}

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

int main() {
    int n;
    string s;cin >> n >> s;
    bool is_same = true;
    if(n == 1 || n%2) is_same = false;
    else{
        for(int i=0;i<s.size()/2;i++){
        if(s[i] != s[i+s.size()/2])is_same = false;
        }
    }
    cout << (is_same?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// まずは全探索，次にDP
// 偶奇，逆から，ソート，出現回数，出現位置，DP
// 余事象，包除
// データ構造
// 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
int main() {
cin.tie(0);
ios::sync_with_stdio(false);

int A, B; cin >> A >> B;

if (A < 10 && B < 10) cout << A*B << "\n";
else cout <<"-1\n";

}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
#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() {
	int k, s;
	cin >> k >> s;
	ll ans = 0;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
			if (0 <= s - (i + j) && s - (i + j) <= k) ans++;
		}
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 3540
N = int(input())
K = int(input())

memo_d = dict()


def key_check(n, k):
    if k == 0:
        return 1
    elif n < 10 ** (k - 1):
        return 0
    elif n < 10:
        return n
    x = memo_d.get((n, k))
    if x is None:
        x = aez(n, k)
    return x


def aez(n, k):
    nq = n // 10
    nr = n % 10
    return nr * key_check(nq, k - 1) + (9 - nr) * key_check(nq - 1, k - 1) + key_check(nq, k)


if N < 10 ** (K - 1):
    ans = 0
elif N < 10:
    ans = N
else:
    ans = aez(N, K)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

signed main()
{
	int n,m;
	n=read();
	m=read();
	int gs=0;
	while(1)
	{
		if(n<1) break;
		n/=m;
		gs++;
	}
	printf("%lld\n",gs);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;


int main()
{
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;

	vector<int> list;
	list.push_back(a);
	list.push_back(b);
	list.push_back(c);
	list.push_back(d);
	list.push_back(e);

	int min = 10;
	int idx = 0;
	
	for (int i = 0; i < 5; ++i)
	{
		int mod = list[i] % 10;
		if (min > mod && mod != 0)
		{
			min = mod;
			idx = i;
		}
	}
    
	int sum = 0;
	for (int i = 0; i < 5; ++i)
	{
		if (i == idx)
			continue;
		int div = list[i] / 10 + 1;
		int mod = list[i] % 10;
		if (mod == 0)
		{
			sum += list[i];
		}
		else
		{
			sum += div * 10;
		}
	}

	sum += list[idx];

	cout << sum << endl;


	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,d,e,k,flag=0;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    scanf("%d",&e);
    scanf("%d",&k);
    if(e-a>k)flag=1;
if(e-b>k)flag=1;
if(e-c>k)flag=1;
if(e-d>k)flag=1;
if(d-c>k)flag=1;
if(d-b>k)flag=1;
if(d-a>k)flag=1;
if(c-b>k)flag=1;
if(c-a>k)flag=1;
if(flag==1)
     printf(":(");
    else
       printf("Yay!");
}


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

using namespace std;
vector < int > v[200100];
int Nodes[200100],Ans[200100];

void DFS(int x , int p){

    Ans[x] = Nodes[x];
    for(auto j : v[x]){
        if(j != p){
            Nodes[j]+=Nodes[x];
            DFS(j , x);
        }
    }
}

int main()
{
    int n,q;
    cin >> n >> q;
    for(int i = 0;i<n - 1;i++){
        int x,y;  cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    while(q--){
        int p,x;  cin >> p >> x;
        Nodes[p]+=x;
    }
    DFS(1 , -1);
    for(int i = 1;i<=n;i++)  printf("%d ",Ans[i]);
    return 0;
}


Measured memory_bytes: 24320
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a,b,d=1;
	cin>>a>>b;
	string c;
	cin>>c;
	fo(i,a+b+1){
		if(i==a){
			if(c[i]!='-')
				d=0;
		}
		else{
			if(c[i]=='-')
				d=0;
		}
	}
	if(d)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<cstring>

using namespace std;

const int INF = (1<<25);
const int MAX = 10001;
int N,M;
double ans;

struct Pile{
  int x,y;
  Pile(){}
  Pile(int x,int y):x(x),y(y){}
};

struct State{
  int pos;
  double t;
  State(){}
  State(int pos, double t):pos(pos),t(t){}
  bool operator < (const State& s) const { return t < s.t;}
};

vector<int> Edge[MAX];
vector<Pile> P;
double T[MAX];
bool used[MAX];

void init(){
  fill(T,T+MAX,-1);
  memset(used,false,sizeof(used));

  for(int i = 0; i < MAX; i++) Edge[i].clear();
  P.clear();
  ans = 0;
}

double getDis(int p, int q){
  return sqrt((P[p].x-P[q].x)*(P[p].x-P[q].x)+(P[p].y-P[q].y)*(P[p].y-P[q].y));
}

void input(){
  for(int i = 0; i < N; i++){
    Pile in;
    // cin >> in.x >> in.y;
    scanf("%d %d",&in.x, &in.y);
    P.push_back(in);
  }

  for(int i = 0; i < M; i++){
    int p,q;
    //  cin >> p >> q;
    scanf("%d %d",&p,&q);
    p--;
    q--;
    Edge[p].push_back(q);
    Edge[q].push_back(p);
    ans += getDis(p,q);
  }
}


void prim(int start){
  priority_queue<State> Q;
  Q.push(State(start,0));
  T[start] = 0;

  while(!Q.empty()){
    State now = Q.top();
    Q.pop();
     
    if(used[now.pos]) continue;
    used[now.pos] = true;

    ans -= now.t;


    for(int i = 0; i < (int)Edge[now.pos].size(); i++){
      int nex = Edge[now.pos][i];
      double cos = getDis(now.pos,nex);
      if(T[nex] < cos){
	T[nex] = cos;
	Q.push(State(nex,cos));
      }
    }
  }
}

void solve(){

  for(int i = 0; i < N; i++){
    if(!used[i]) prim(i);
  }

  printf("%.3f\n",ans);
}

int main(){
  
  while(cin >> N >> M && N+M){
    init();
    input();
    solve();
  }
  return 0;
}

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

#define endl "\n"
#define si(a) scanf("%d ",&a);
#define si2(a,b) scanf("%d %d ",&a,&b);
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sll(a) scanf("%lld ",&a);
#define sll2(a,b) scanf("%lld%lld",&a,&b)
#define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sf(a) scanf("%f ",&a);
#define sd(a) scanf("%lf ",&a);
#define sc(a) scanf("%c ",&a);
#define ss(a) scanf("%s ",a);
#define sf2(a,b) scanf("%f %f ",&a,&b);
#define sd2(a,b) scanf("%lf %lf ",&a,&b);
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define forq(i,q,n) for(int i=q;i<n;i++)
#define form(i,n) for(int i=n;i>=0;i--)
#define forp(i,q,n) for(int i=q;i>=n;i--)
#define fi first
#define se second
#define INF 1000000010
#define MOD 1000000007
#define MAXN
#define LL long long int


using namespace std;

int n;

void init(){
	si(n);
	if(n < 1200){
		printf("ABC\n");
	}
	else if(n >= 1200){
		printf("ARC\n");
	}
}

int main(){
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	init();
	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 int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int D = 80*160+10;
const int D2 = D*2;
typedef bitset<D2> bs;

int a[100][100];
bs dp[90][90];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	rep(i,h)rep(j,w) cin >> a[i][j];
	rep(i,h)rep(j,w){
		int x;
		cin >> x;
		a[i][j] = abs(x - a[i][j]);
	}
	dp[0][0][D-a[0][0]] = 1;
	dp[0][0][D+a[0][0]] = 1;
	rep(i,h)rep(j,w){
		if(i){
			dp[i][j] |= dp[i-1][j]<<a[i][j];
			dp[i][j] |= dp[i-1][j]>>a[i][j];
		}
		if(j){
			dp[i][j] |= dp[i][j-1]<<a[i][j];
			dp[i][j] |= dp[i][j-1]>>a[i][j];
		}
	}
	int ans = D2;
	rep(i,D2){
		if(dp[h-1][w-1][i]){
			chmin(ans, abs(i-D));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 24704
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
typedef pair<int, int> P;
int N,A;
vector<P> Col;
int ans;
int main()
{
	while (true){
		Col.clear();
		ans = 0;
		scanf("%d", &N);
		if (N == 0)break;
		scanf("%d", &A);
		Col.push_back(P(A, 1));
		for (int i = 1; i < N; i++){
			scanf("%d", &A);
			if ((i & 1) == 0){
				if (Col[Col.size() - 1].first == A){
					Col[Col.size() - 1].second++;
				}
				else{
					Col.push_back(P(A, 1));
				}
			}
			else{
				if (Col[Col.size() - 1].first == A){
					Col[Col.size() - 1].second++;
				}
				else{
					P p = Col[Col.size() - 1];
					Col.erase(Col.end() - 1, Col.end());
					if (Col.size() == 0){
						Col.push_back(P(A, p.second + 1));
					}
					else{
						Col[Col.size() - 1].second += (p.second + 1);
					}
				}
			}
		}
		for (int i = 0; i < Col.size(); i++){
			if (Col[i].first == 0)ans += Col[i].second;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

int main() {
  int n;
  cin>>n;
  bool ok = true;
  int cnt = 0;
  string prev = "Un";
  REP(i,n) {
    string s;
    cin>>s;
    if (s == "A") {
      //if (prev == "Un" && cnt != 0) ok = false;
      ++cnt;
    } else {
      --cnt;
      if (cnt < 0) ok = false;
    }
    prev = s;
  }
  if (cnt != 0) ok = false;
  if (ok) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 3196
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[]w = new int[n];

    int all = 0;
    int mae = 0;
    int cou = 0;
    for(int i=0; i<n; i++) {
    	w[i] = sc.nextInt();
    		all += w[i];
      	}
    for(int i=0; i<=n; i++) {
    	if(mae < all/2) {
    		mae += w[i];
    	   	cou++;
    	   	   	}
    	}
    int usiro = all - mae;
    int A = mae - usiro;
    A =	Math.abs(A);
    int B = (mae - w[cou-1]) - (usiro + w[cou-1]);
    B = Math.abs(B);
    
    System.out.print(Math.min(A, B));
    }
}


Measured memory_bytes: 35936
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;

vector<int>g[100010];
bool visited[100010];
vector<int>ans;
map<pair<int,int>,int>p;

void bfs(int sx){
	for (int i = 0;i < 100010;i++)visited[i]=false;
	queue<P> q;
	int color=1;
	for (int i = 0;i < (int)g[sx].size();i++){
		int next=g[sx][i];
		p[P(sx,next)]=color;
		p[P(next,sx)]=color;
		q.push(P(next,color));
		color++;
	}
	visited[sx]=true;
	while (!q.empty()) {
		P x = q.front();
		q.pop();
		int now=x.first;
		int nc=x.second;
		visited[now]=true;
		color=1;
		for (int i = 0;i < (int)g[now].size();i++) {
			int next=g[now][i];
			if(!visited[next]){
				if(color<nc){
					p[P(now,next)]=color;
					p[P(next,now)]=color;
					q.push(P(next,color));
					color++;
				}
				else{
					if(color==nc){
						color++;
						p[P(now,next)]=color;
						p[P(next,now)]=color;
						q.push(P(next,color));
					}
					else{		
						color++;			
						p[P(now,next)]=color;
						p[P(next,now)]=color;
						q.push(P(next,color));
					}
				}
			}
		}
	}	
}
 
int main(void){
    int n;
	cin>>n;
	vector<int>a(n),b(n);
	for(int i=0;i<n-1;i++){
		cin>>a[i]>>b[i];
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}
	bfs(1);
	set<int>s;
	for(int i=0;i<n-1;i++){
		s.insert(p[P(a[i],b[i])]);
	}
	cout<<s.size()<<endl;
	for(int i=0;i<n-1;i++){
		cout<<p[P(a[i],b[i])]<<endl;
	}
    return 0;
}

Measured memory_bytes: 19456
k = int(input())

import queue

que = queue.Queue()

for i in range(1, 10):
    que.put(i)

for i in range(1, k + 1):
    ans = que.get()
    keta1 = ans % 10
    if keta1 == 0:
        append_list = [ans * 10, ans * 10 + 1]
    elif keta1 == 9:
        append_list = [ans * 10 + 8, ans * 10 + 9]
    else:
        append_list = [ans * 10 + keta1 - 1, ans * 10 + keta1, ans * 10 + keta1 + 1]
    for item in append_list:
        que.put(item)
print(ans)

Measured memory_bytes: 18680
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[1])
#print(ab)
tot=0
for i in range(n):
    tot+=ab[i][0]
    if tot>ab[i][1]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 46876
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    K=ii()
    L=list(range(10))

    if K <= 9:
        print(K)
        exit()
    
    # print(L)
    head_i = 1
    while len(L) < K+10:
        assert head_i < len(L)
        head = L[head_i]
        head_tail = head % 10
        for x in [head_tail-1,head_tail,head_tail+1]:
            if x < 0 or x >= 10: continue
            
            # print(head_i,head,head_tail)
            # assert not head * 10 + x in L
            L.append(head * 10 + x)
        
        head_i += 1

    # print(L)
    print(L[K])

    


if __name__ == "__main__":
    main()

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    int n;
    string s;
    cin >> n >> s;
    
    bool y(false);
    
    for (int i = 1; i <= n; ++i)
    {
        string test(s.substr(0, i));
        
        if ((test + test).compare(s) == 0)
        {
            y = true;
            break;
        }
    }
    
    if (y)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 256
//Bismillahir Rahmanir Raheem
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<stdlib.h>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
#define pb push_back
#define all(x) (x).begin(), (x).end()
typedef long long LL;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
#define FF first
#define SS second
#define mxN (int) 2e5 + 2
#define MP make_pair
bool isPal(string s)
{
    string r(s);
    reverse(all(r));
    return s == r;
}

int main()
{
    LL n;
    cin >> n;
    double x = (double) n / 3.0;
    cout << setprecision(12) << fixed << x * x * x << endl;

}





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

int main() {
   long long int a, b, c;
    cin>>a>>b>>c;
    if(a == b && a == c){
        if(a % 2 == 0){
            cout << -1 << endl;
        } else {
            cout<<0<<endl;
        }
    } else {
       long long int a1, b1, c1;
       long long int ans = 0;
        while(a % 2== 0 && b % 2 == 0 && c % 2 == 0){
            a1 = b/2 + c/2;
            b1 = a/2 + c/2;
            c1 = a/2 + b/2;
            a = a1;
            b = b1;
            c = c1;
            ans ++ ;
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

N = INT()
S = input()

ans = 1
cnt = Counter(S).values()
for v in cnt:
	ans = (ans*(v+1))%mod
print((ans-1)%mod)


Measured memory_bytes: 5464
# Problem A - Biscuits

# input
N, P = map(int, input().split())
a_list = list(map(int, input().split()))

# initialization
even_count = 0
odd_count = 0

# count
for a in a_list:
    if a%2==0:
        even_count += 1
    else:
        odd_count = 2 ** (N - 1)
if even_count==len(a_list):
    if P==0:
        print(2 ** N)
    else:
        print(0)
else:
    print(2**(N-1))


Measured memory_bytes: 38256
import java.util.Scanner;

class Main{
      public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	String str;
    	String left;
    	String right;
    	String end = "-";
    	int shuffle;
    	int m;
    	
    	for(;;){
    		str = scan.next();
    		if(str.equals(end)) {
    			break;
    		}
    		m = scan.nextInt();
    		for(int i = 0; i < m; i++){
    			shuffle = scan.nextInt();
    			left = str.substring(0, shuffle);
    			right = str.substring(shuffle);
    			str = right + left;
    		}
    		System.out.println(str);
    	}
     }
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

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

const double PI = 3.14159265358979;

struct Edge{ ll cost, to; };
void solve()
{
  ll n, a, b, c;
  cin >> n;
  vector< vector<Edge> > G(n, vector<Edge>());
  for(int i = 0; i < n - 1; ++i)
  {
    cin >> a >> b >> c;
    a--; b--;
    G[a].emplace_back(Edge{c, b});
    G[b].emplace_back(Edge{c, a});
  }

  ll q, k, x, y;
  cin >> q >> k;
  k--;

  const ll INF = 1LL << 60;
  vector<ll> d(n, INF);
  d[k] = 0;
  priority_queue<P, vector<P>, greater<P>> que;
  que.push(P(0, k)); // P(cost, start)
  while (!que.empty())
  {
    P p = que.top();
    que.pop();
    ll node = p.second;
    if (d[node] < p.first) continue;
    for (const auto& edge : G[node])
    {
        if (d[edge.to] > d[node] + edge.cost)
        {
            d[edge.to] = d[node] + edge.cost;
            que.push(P(d[edge.to], edge.to));
        }
    }
  }

  for(int i = 0; i < q; ++i)
  {
    cin >> x >> y;
    x--; y--;
    cout << d[x] + d[y] << endl;
  }

}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 14032
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    string S; cin >> S;
    map<char, bool> ch;

    rep(i, len(S)) {
        if (ch.count(S[i])) ch[S[i]] = true;
        else ch[S[i]] = true;
    }
    if (ch['N'] == ch['S'] && ch['W'] == ch['E']) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3580
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	int i, j;
	int ans = 0;
	int C_count = 0;
	int A_count = 0;
	string S;
	cin >> S;

	if (S[0] == 'A') {
		++ans;
		++A_count;
	}

	for (i = 2; i < S.size()-1; ++i) {
	//	cout << S[i] << endl;
		if (S[i] == 'C') {
			++C_count;
		}
	}
	if (C_count == 1) {
		++ans;
	}

	for (i = 1; i < S.size(); ++i) {
		if ((65 <= S[i] && S[i] <= 90) || S[i] == 'C') {
			++ans;
			if (S[i] == 'C') {
				++C_count;
			}
		}
	}


	//cout <<"デバッグ"<< ans << endl;

	if (A_count == 1 && C_count == 2 && ans == 3) {
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}

}



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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,h,nm,ans=1;

signed main() {
    cin >> n >> nm;
    rep(i,n-1) {
        cin >> h;
        if (nm <= h) ans++,nm = h;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std; 
int n; 
string s; 

int main()
{
	cin >> n >> s; 
	if (n % 2 != 0)
	{
		cout << "No"; 
		return 0; 
	}
	for (int i = 0; i < n / 2; ++i)
	{
		if (s[i] != s[i + n / 2])
		{
			cout << "No"; 
			return 0; 
		}
	}
	cout << "Yes"; 
	return 0; 
}

Measured memory_bytes: 256