akhauriyash/Code-Regression huggingface dataset:
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "Yes" : "No")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F first
#define S second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    bool TakaWin = true;
    while(1)
    {
        C -= B;
        if(C <= 0) break;
        A -= D;
        if(A <= 0)
        {
            TakaWin = false;
            break;
        }
    }
    cout << YN(TakaWin) << endl;
}

// Main

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    PreProcessTables();

    int T = 1, t;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define YES(n) cout << (n?"YES":"NO")<<endl;
#define Yes(n) cout << (n?"Yes":"No")<<endl;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    cout << (abs(a - x) <= abs(b - x) ? 'A' : 'B') << endl;
}

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

long int a, b, c, k;
long int ans = 0;

int main(){
    cin >> a >> b >> c >> k;

    if(a>=k){
        cout << k << endl;
    }
    else if(a+b>=k){
        cout << a << endl;
    }
    else if(a+b+c>=k){
        cout << a-(k-a-b) << endl;
    }
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    bool r = (x == w / 2 && y == h / 2);
    printf("%.9f %d\n", w * h / 2, r);
}

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

int main() {
	int N;
	cin >> N;
	unordered_map<int, int> Nums;
	int max = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (a > 0) Nums[a - 1]++;
		Nums[a]++;
		Nums[a + 1]++;
		if (max < Nums[a - 1]) max = Nums[a - 1];
		if (max < Nums[a]) max = Nums[a];
		if (max < Nums[a + 1]) max = Nums[a + 1];
	}
	cout << max;
}

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

using namespace std;

int main(void){
    int n;
    string s, t;
    cin >> n;
    cin >> s;
    cin >> t;
    for (size_t i = 0; i < n; i++)
    {
        cout << s[i] << t[i];
    }
    cout << endl;
    
}


Measured memory_bytes: 256
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> n)
    {
		n %= 1000;

		n = 1000 - n;

		cout << n % 1000 << endl;
    }


}





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

using namespace std;

double getT(double v){return v/9.8;}
double getY(double t){return 4.9*t*t;}

int main()
{
	
	double v,t,y;

	while(cin>>v){
		int N=0;
		t=getT(v);

		y=getY(t);

		while(1){
			if(5*N-5>y)
				break;
			N++;
		}

		cout<<N<<endl;
	}
	return 0;
}

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

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    int i;
    for(i=1;i<=B;i++){
        if((A*i)%B==C){
            cout<<"YES"<<endl;
            return 0;
        }else if(i==B){
            cout<<"NO"<<endl;
        }
    }

    return 0;
}


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

const int maxn=2e5+10;
const int mod=998244353;
char c[maxn];
ll a[maxn],sum[maxn],tot,f[maxn],b[maxn];
int n;
ll poww(ll x,ll k) {
    ll ans=1;
    while(k) {
        if(k&1) ans=ans*x%mod;x=x*x%mod;k>>=1; 
    }return ans;
}
bool check(int x) {
    int now=1,f=0;
    for(int i=1;i<=n;++i) {
        if(((c[now]-'0')^f)>(c[i]-'0')) return 0;
        else if(((c[now]-'0')^f)<(c[i]-'0')) return 1;
        else {
            now++;
            if(now>x) now=1,f^=1;
        }
    }
    return 1;
}
int get(int x) { 
    if((n/x)%2) {
        if(check(x))
        return sum[x]+1;
        else return sum[x];
    }
    return 0;
} 
ll ans;
int main()
{
    scanf("%d",&n);
    scanf("%s",c+1);
    for(int i=1;i<=n;++i) {
        tot=tot*2%mod;
        if(c[i]=='1') tot=tot+1;
        sum[i]=tot; 
    //  cout<<sum[i]<<"*\n";
    }
    tot=tot%mod;
    for(int i=1;i<=sqrt(n);++i) {
        if(n%i==0) f[i]=get(i);
        if(i*i!=n&&(n%(n/i)==0)) f[n/i]=get(n/i);
    }
    //cout<<get(n/2)<<"\n";
    //for(int i=1;i<=n;++i) cout<<f[i]<<"*\n";
    for(int i=1;i<=n;++i) {
        for(int j=i+i;j<=n;j+=i) f[j]=(f[j]-f[i]+mod)%mod;
    }
    for(int i=1;i<=n;++i) {
        if(n%i==0 && n/i %2 == 1) {
            ans=(ans+f[i]*2*i%mod)%mod;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int n,m,a;
long long ans;
priority_queue <int> q;
int main () {
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) {
		scanf("%d",&a);
		q.push(a);
	}
	for (int i=1;i<=m;i++) {
		int a=q.top();
		q.pop();
		a/=2;
		q.push(a);
	}
	while (!q.empty()) {
		ans+=q.top();
		q.pop();
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 892
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])

if a+b+c+d==7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a+b+c-d==7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a+b-c+d==7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a+b-c-d==7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
elif a-b+c+d==7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a-b+c-d==7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a-b-c+d==7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')



Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_C
{
    class C069
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] a = Console.ReadLine().Split(' ');

            int count2 = 0, count1 = 0, count0 = 0;
            foreach (string b in a)
            {
                int i = int.Parse(b);
                if (i % 4 == 0) count2++;
                else if (i % 2 == 0) count1++;
                else count0++;
            }

            string s;
            if (count2 >= count0) s = "Yes";
            else if (count2 == count0 - 1 && count1 == 0) s = "Yes";
            else s = "No";
            Console.WriteLine(s);
        }

    }
}


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

int main(){
  int n,x;
  cin>> n >> x;
  vector<int> l(n);
  for (int i=0; i<n; i++) cin>> l.at(i);
  
  int d=0;
  int ans=1;
  for (int i=0; i<n; i++){
    d+=l.at(i);
    if (x<d) break;
    ans++; //ansを順次足す形にしただけ
  }
  cout<< ans << endl;
}

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


public class Main{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		while(scan.hasNext()){
			int n=scan.nextInt();
			int limit=scan.nextInt();
			int sum=0;
			int[] arr= new int[n];
			for(int i=0;i<n;i++){
				if(scan.nextInt()>=limit){
					sum++;
				}
			}
			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 49144
using System;
    class Program
    {
        static void Main(string[] args)
        {

            // 整数の入力
            string input = Console.ReadLine();
            int N = int.Parse(input);


            // atcoderってこんな数学な感じなんですか・・・
            // なんとなく普通の二進数にしたあと奇数番と偶数番でうなるのがいい気がしてきた
            int[] Splus = new int[34];
            int[] Shonmono = new int[34];

            //// そっかプラスだけじゃないんかぁ
            //int pn = 0;
            //if (N >= 0) {
            //    pn = 1;
            //}
            //else
            //{
            //    pn = 0;
            //    N = -N;
            //}

            //普通に二進数
            for (int i = 0; i < 34; i++)
            {
                if (i % 2 == 0)
                {
                    if (N % 2 != 0)
                    {
                        Shonmono[i] = 1;
                        N = N - 1;
                    }
                }
                else
                {
                    if (N % 2 != 0)
                    {
                        Shonmono[i] = 1;
                        N = N + 1;
                    }
                }
                N = N / 2;
            }

            ////偶数番の2倍の分だけ低くなるのかな？・・・・・・
            //for (int i = 0; i < 16; i++)
            //{
            //    if (Splus[i] == 1)
            //    {
            //        Shonmono[i + 1]++;
            //    }
            //}


            ////めっちゃ考えた末、桁をあげるには上二つを1増やせばいいと思った。
            //for (int i = 0; i < 32; i++)
            //{
            //    if (Shonmono[i] > 1)
            //    {
            //        Shonmono[i + 1] += 1;
            //        Shonmono[i + 2] += 1;
            //        Shonmono[i] -= 2;
            //    }
            //}


            int max = 0;
            for (int i = 33; i > 0; i--)
            {
                if (Shonmono[i] == 0)
                {
                    max = i;
                }
                else { break; }
            }


            String result = "";
            for (int i = max - 1; i >= 0; i--)
            {
                result += Shonmono[i];
            }

            //出力
            Console.WriteLine(result);

            //System.Threading.Thread.Sleep(30000);
        }
    }

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
using namespace std;
int main(){
    for(;;){
        int n,m;
        string s;
        cin>>n;
        if(n==0)break;
        cin>>m>>s;
        bool isaf=false;
        int ans=0,now=0;
        int i=0;
        while(i<m){
            if(isaf){
                if(i+1<m&&s[i]=='O'&&s[i+1]=='I'){
                    now++;
                    i+=2;
                }else{
                    if(now>=n)ans+=now-n+1;
                    now=0;
                    isaf=false;
                }
            }else{
                if(i+2<m&&s[i]=='I'&&s[i+1]=='O'&&s[i+2]=='I'){
                    now=1;
                    isaf=true;
                    i+=3;
                }else i++;
            }
        }
        if(now>n)ans+=now-n+1;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1964
n=int(input())
ans=0
a=[0]*n
b=[0]*n
for i in range(n):
  s=input()
  ans+=s.count('AB')
  if s[-1]=='A':a[i]=1
  if s[0]=='B':b[i]=1
m=min(sum(a),sum(b))
ans+=m
if m:
  for i,j in zip(a,b):
    if i+j and i*j==0:break
  else:ans-=1
print(ans)

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

int main(){
    int N; cin >> N;
    vector<int> p(N);
    for(int i = 0; i < N; i++) cin >> p[i];
    int flag = 0, pre;
    for(int i = 1; i < N; i++){
        if(p[i-1] > p[i]){
            if(flag == 0){
                pre = i-1;
                flag = 1;
            }else if(flag == 1){
                swap(p[i], p[pre]);
                flag = 2;
                break;
            }
        }
    }
    if(flag == 1){
        swap(p[pre],p[pre+1]);
        flag = 2;
    }
    if(flag == 2){
        for(int i = 1; i < N; i++){
            if(p[i-1] > p[i]){
                cout << "NO\n";
                return 0;
            }
        }
    }
    cout << "YES\n";
    

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007

using namespace std;

int main(void) {
	int a[10];
	FOR(i, 0, 9) {
		cin >> a[i];
	}
	sort(a, a + 10);
	cout << a[9] << endl;
	cout << a[8] << endl;
	cout << a[7] << endl;
	return 0;
}

Measured memory_bytes: 3152
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int x; cin >>x;
  if(x==1)cout <<0<<endl;
  else cout <<1<<endl;
}

Measured memory_bytes: 3628
#pragma comment(linker, "/STACK:640000000")
#include <bits/stdc++.h>

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define ll long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)

using namespace std;

typedef pair<int, int> pii;

const double eps = 1e-9;
const double pi = acos(-1.0);

const int maxn = (int)1e5 + 10;

int a[maxn];

int main() {
	#ifdef LOCAL
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
	#endif

	int n; cin >> n;

	for (int i = 1; i <= n; i++) cin >> a[i];

	ll res = 0;

	for (int i = 1; i <= n + 1; i++) {
		res += abs(a[i] - a[i - 1]); 
	}

	for (int i = 1; i <= n; i++) {
		cout << res - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]) << endl;
	}

	return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  ll x = 0, ans = 0;
  for (int b = 60; b >= 0; --b) {
    int one = 0;
    for (int i = 0; i < n; ++i) {
      if (a[i] & (1ll << b)) {
        one++;
      }
    }
    int zero = n - one;
    if (zero > one && x + (1ll << b) <= k) {
      x += (1ll << b);
      ans += (1ll << b) * zero;
    } else {
      ans += (1ll << b) * one;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define ms(a,v) memset(a,v,sizeof(a))
#define mp make_pair
#define write(x) cout<<(x)<<endl
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
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; }
inline ll pow2(const int n) { return 1ll << n; }
const int INF = 1 << 28; const ll LINF = 1ll << 60;
const int MAX = 1e5 + 5; const int MOD = 1e9 + 7; const double EPS = 1e-6;
const int dy[4] = { 0,1,0,-1 }; const int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;
// 1. 問題よくよめえええええええええええええええええええええええええ
// 2. intオーバーフロー << * + あたり
// 3. 落ち着け

string S;

int main() {
    cin >> S;
    int ans = INF;
    rep(i, S.size() - 3 + 1){
        string s = S.substr(i, 3);
        int n = stoi(s);
        chmin(ans, abs(n - 753));
    }
    write(ans);
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem154c(n, a))
}

fun problem154c(n: Int, a: List<Long>): String {
    val a = a.sorted()
    var res = "YES"
    var prev = -1L
    for (i in 0 until n) {
        if (a[i] == prev) res = "NO"
        prev = a[i]
    }
    return res
}

Measured memory_bytes: 62860
/* B */

#include <iostream>
#include <string>
using namespace std;

int main(){
    string s;
    cin >> s;
	int n = s.length();
	int max = 0;
    for(int i = 0; i < n; i++){
    	int cnt = 0;

    	for(int j = i; j < n; j++){
    		
    		if(s[j] == 'A' || s[j] == 'T' || s[j] == 'C' || s[j] == 'G'){
    			cnt++;
    		}else{
    			break;
    		}
   		}

   		if(cnt > max){
   			max = cnt;
   		}
  	}

  	cout << max << endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
typedef modint998244353 mi;
const int N = 1e5 + 87;
int cnt[N];
const mi i2 = mi(1) / mi(2);
mi f[N], fi[N], p2[N];
mi C(int n, int k)
{
    return f[n] * fi[k] * fi[n - k];
}
mi ways(int n)
{
    return f[n] * p2[n / 2] * fi[n / 2];
}
int main()
{
    fi[0] = f[0] = 1;
    for (int i = 1; i < N; ++i)
        f[i] = i * f[i - 1];
    fi[N - 1] = 1 / f[N - 1];
    for (int i = N - 2; i >= 1; --i)
        fi[i] = fi[i + 1] * (i + 1);
    p2[0] = 1;
    for (int i = 1; i < N; ++i)
        p2[i] = p2[i - 1] * i2;
    int n;
    cin >> n;
    for (int i = 0; i < 2 * n; ++i) {
        int x;
        cin >> x;
        cnt[x]++;
    }
    typedef vector<mi> poly;
    struct cmp
    {  
        bool operator () (const poly & a, const poly & b) 
        {
            return a.size() > b.size();
        }
    };
    priority_queue<poly, vector<poly>, cmp> pq;
    for (int i = 1; i < N; ++i) {
        if (cnt[i] == 0)
            continue;
        poly p = {1};
        for (int j = 1; j * 2 <= cnt[i]; ++j)
            p.push_back(C(cnt[i], j * 2) * ways(j * 2));
        pq.push(p);
    }
    while (pq.size() > 1) {
        auto a = pq.top(); pq.pop();
        auto b = pq.top(); pq.pop();
        pq.push(convolution(a, b));
    }
    auto a = pq.top();
    mi ans = ways(n * 2);
    for (int i = 1, s = -1; i < a.size(); ++i, s *= -1)
        ans += s * a[i] * ways(2 * (n - i));
    cout << ans.val() << endl;
}


Measured memory_bytes: 10184
N = gets.to_i
L = gets.split(" ").map(&:to_i).sort.reverse
count = 0

(N - 2).times do |i|
    j = i + 1
    k = N - 1
    while j < k do
        if L[j] + L[k] > L[i]
            count += k - j
            j += 1
        else
            k -= 1
        end
    end
end

puts count

Measured memory_bytes: 1912
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

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


void solve(){
    int n, k;
    cin >> n >> k;
    int ans = 0;
    while(n){
        ans++;
        n /= k;
    }
    cout << ans << endl;
}

int main(){
    /*
    int t; cin >> t;
    while(t--) solve();
    */
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int N, T;
  cin >> N >> T;
  int min_cost = 100000;
  int min_cost_id = -1;
  for (int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;
    if (t <= T) {
      // cout << c << "," << t << endl;
      if (c < min_cost) {
        min_cost = c;
        min_cost_id = i + 1;
      }
    }
  }
  if (min_cost_id == -1) {
    cout << "TLE" << endl;
  } else{
    cout << min_cost << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main () {
	int argN, argX;
	cin >> argN >> argX;

	vector<int> argM(argN);
	for (int i = 0; i < argN; ++i) {
		cin >> argM.at(i);
	}

	int ret = argN;
	int minM = *min_element(argM.begin(), argM.end());
	argX -= accumulate(argM.begin(), argM.end(), 0);

	ret += (argX / minM);
	cout << ret << endl;
}


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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 200007;

int n, L;
int a[MAXN], ra[MAXN];
LL ps[MAXN], rps[MAXN];

void init ();
void input ();
void work ();

LL getans ( int a[], LL ps[], int cl, int cr );



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	scanf ( "%d%d", &L, &n );
	lpi ( i, 1, n ) scanf ( "%d", &a[i] );
}

void work ()
{
	// main work

	lpi ( i, 1, n ) ps[i] = ps[i - 1] + a[i];

	lpi ( i, 1, n ) ra[i] = L - a[n - i + 1];
	lpi ( i, 1, n ) rps[i] = rps[i - 1] + ra[i];

	a[0] = 0, a[n + 1] = L;
	LL ans = 0, cur;
	lpi ( i, 0, n ) {
		int cl = i, cr = n - i;
		cur = 0;
		if ( cl >= cr ) cur = getans ( ra, rps, cr, cl );
		else cur = getans ( a, ps, cl, cr );
		ans = qmax ( ans, cur );
	}

	cout << ans << endl;
}



LL getans ( int a[], LL ps[], int cl, int cr )
{
	int d = cr - cl;
	LL cur1 = ( ps[cr] - ps[d] + SC ( LL, cl ) * L - ( ps[n] - ps[n - cl] ) ) * 2 - ( L - a[n - cl + 1] );
	LL cur2 = ( ps[cr] - ( d ? ps[d - 1] : 0 ) + SC ( LL, cl ) * L - ( ps[n] - ps[n - cl] ) ) * 2 - a[cr];
	return qmax ( cur1, cur2 );
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	int n;
	int total = -1000000000;
	int point[1025] = {};
	int f[101][11] = {};
	int p[101][11] = {};
	int dp[101] = {};

	cin >> n;
	FOR(i, 1, n) {
		FOR(j, 0, 9) {
			cin >> f[i][j];
		}
	}
	FOR(i, 1, n) {
		FOR(j, 0, 10) {
			cin >> p[i][j];
		}
	}

	FOR(i, 1, 1023) {
		FOR(t, 0, 100) {
			dp[t] = 0;
		}
		bitset<10> bit(i);

		//cout << bit << endl;

		FOR(t, 0, 9) {
			if (bit[t]== true) {
				FOR(s, 1, n) {
					if (f[s][t] == 1) {
						dp[s]++;
					}
				}
			}
		}
		FOR(t, 1, n) {
			point[i] += p[t][dp[t]];
		}

		//cout << i << " " << point << endl;
		
	}
	sort(point+1, point + 1024);
	
	//FOR(i, 0, 1024) {
		//cout << point[i] << endl;
	//}
	cout << point[1023] << endl;
	return 0;
}

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

using namespace std;
int main(){
    string s; cin >> s;
    int i,n = s.size(),res = 0;
    for(i=0;i<n;i++){
        res += s[i] - '0';
        res *= 10;
        res %= 9;
    }
    if(res==0){
        cout << "Yes" << endl;
    }else{
        cout <<"No" << endl;
    }
}

Measured memory_bytes: 3756
import java.io.*
import java.util.*

fun solve(S: String){
    val ws = listOf("Sunny", "Cloudy", "Rainy")
    println(ws[(ws.indexOf(S)+1)%3])
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val S = sc.next()
    solve(S)
}



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

int main() {
    
    
  int N , K, C=1;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) { 

	if (C * 2 <= C+K){
      C = C*2;
    }
    else if (C * 2 > C+K){
      C += K ;
    }

  }

  cout << C << endl;

}


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

template <typename T>
T set_oparate(T &sorted_a, T &sorted_b, char op) {
#define abc(a, b, c) begin(a), end(a), begin(b), end(b), inserter(c, end(c))
    T ret;
    switch (op) {
    case 'u':   // 和集合（A ∪ B）
        set_union(abc(sorted_a, sorted_b, ret)); break;
    case 'i':   // 積集合（A ∩ B）
        set_intersection(abc(sorted_a, sorted_b, ret)); break;
    case 'd':   // 差集合（A \ B, A ∩ B^c）
        set_difference(abc(sorted_a, sorted_b, ret)); break;
    case 's':   // 対称差（A Δ B, (A\B) ∪ (B\A)）
        set_symmetric_difference(abc(sorted_a, sorted_b, ret)); break;
    }
    return ret;
#undef abc
}

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int &ai: a) cin >> ai;
    int m; cin >> m;
    vector<int> b(m);
    for (int &bi: b) cin >> bi;
    for (int x: set_oparate(a, b, 'd')) cout << x << endl;
    return 0;
}


Measured memory_bytes: 5412
N,M,X = (int(i) for i in input().split())
A = list(map(int,input().split()))

small = 0
big = 0
for j in A:
    if j < X:
        continue
    else:
        small=small+1

for j in A:
    if j > X:
        continue
    else:
        big=big+1



if big>=small:
    print(small)
else:
    print(big)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <deque>
using namespace std;

struct P
{
    string name;
    int time;
};

int main(int argc, char const *argv[])
{
    int  n,q;   cin>>n>>q;
    P temp;
    deque<P>Q(n);
    for(int i=0;i<n;i++)
    {
        cin>>temp.name>>temp.time;
        Q[i].name=temp.name;
        Q[i].time=temp.time;
    }
int time=0;

   while(Q.size()>0)
    {
        if(Q[0].time<=q)
        {
            time+=Q[0].time;
            cout<<Q[0].name<<" "<<time<<endl;
            Q.pop_front();
            //cout<<time<<endl;
        }
        else
        {
            time+=q;
            Q[0].time-=q;
            temp=Q[0];
            Q.pop_front();
            Q.push_back(temp);
            //cout<<time<<endl;
        }
    }   

    //system("pause");
    return 0;
}



Measured memory_bytes: 6060
#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>;

const int INF = 100100100;
vector<int> to[100005];

int main() {
  int N,M;
  cin >> N >> M;
  vector<ll> H(N);
  rep(i,N) cin >> H[i];
  rep(i,M){
    int a,b;
    cin >> a >> b;
    a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  int ans = 0;
  rep(i,N){
    bool can = true;
    int l = to[i].size();
    rep(j,l){
      if(H[i] <= H[to[i][j]]){
        can = false;
        break;
      }
    }
    if(can) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9020
X, Y = map(int, input().split())

if 4 * X < Y:
  print("No")
elif Y / 2 < X:
  print("No")
else:
  y = abs(Y - 2 * X)
  x = abs(4 * X - Y)
  if y%2 == 0 and x%2 == 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 9184
a = []
for i in range(3):
    l,m,n = map(int,input().split())
    a.append([l,m,n])
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))
#print(a)
#print(b)
for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                a[i][j] = 0
tmp = 0
for i in range(3):
    if a[i][0]+a[i][1]+a[i][2] == 0:
        tmp = 1
    elif a[0][i]+a[1][i]+a[2][i] == 0:
        tmp = 1
if a[0][0]+a[1][1]+a[2][2] ==0:
    tmp = 1
elif a[0][2]+a[1][1]+a[2][0] ==0:
    tmp = 1
if tmp == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9212
//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2676345#1
//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2676345#1
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<fstream>
#include<cstring>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define P pair<int,int>
#define ll __int64

int dp[5000][5000];
int n,m;
string a,b;

int main(){
while(cin>>a>>b){
if(a.size()>b.size())swap(a,b);
n=a.size();
m=b.size();

int ans=0;
rep(i,5000)rep(j,5000)dp[i][j]=0;

for(int i=1;i<=n;i++){
	for(int j=1;j<=m;j++){
	if(a[i-1]==b[j-1]){
		//	dp[i][j]=1;
		dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
	}
	ans=max(ans,dp[i][j]);


	}
}

cout<<ans<<endl;
}


	return 0;
}



Measured memory_bytes: 100832
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool ans = false;
  for(int i=1; i<s.length(); i++){
    if(s[i-1] != s[i]){
      ans = true;
      break;
    }
  }
  ans ? cout<<"Yes\n" : cout<<"No\n";
  return 0;
}

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

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

  int N; cin >> N;
  vector<ll> cs(N+1);
  for (int i = 1; i <= N; i++) {
    cin >> cs[i];
    cs[i] += cs[i-1];
  }

  auto f = [&](int x, int y, int z) {
    return abs((cs[y] - cs[x]) - (cs[z] - cs[y]));
  };

  int bc = 1, cd = 2, de = 3;
  while (de < N) {
    if (f(cd, de, N) < f(cd, de+1, N)) break;
    de++;
  }

  auto g = [&]() {
    initializer_list<ll> l = {cs[bc]-cs[0], cs[cd]-cs[bc],
                              cs[de]-cs[cd], cs[N]-cs[de]};
    return max(l) - min(l);
  };

  ll ans = g();
  for (cd = 3; cd < N; cd++) {
    while (bc < cd) {
      if (f(0, bc, cd) < f(0, bc+1, cd)) break;
      bc++;
    }
    while (de < N) {
      if (f(cd, de, N) < f(cd, de+1, N)) break;
      de++;
    }
    ans = min(ans, g());
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>

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

using namespace std;
typedef long long int ll;
const int INF = 100000000;

int main()
{
    ll a, b;
    cin >> a >> b;

    bool a_is_large = (a > b);
    ll num = 0;
    if (a_is_large) num = a;
    else num = b;

    ll ans = 0;
    while (true) {
        if (a_is_large) {
            if (num % b == 0) {
                ans = num;
                break;
            }
            num += a;
        }
        else {
            if (num % a == 0) {
                ans = num;
                break;
            }
            num += b;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  ll x;
  scanf("%lld", &x);

  int n = (int)(ceil(sqrt(2 * x + 0.25) - 0.5) + 1e-9);
  printf("%d\n", n);
  return 0;
}


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

vector<pair<long long, long long>> prime_factorize(long long n) {
  vector<pair<long long, long long>> res;
  for (long long p = 2; p*p <= n; p++) {
    if (n % p != 0) continue;
    int num = 0;
    while (n % p == 0) { num++; n /= p; }
    res.push_back(make_pair(p, num));
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}

int main() {
  long long N; cin >> N;
  if (N == 1) { cout << 0 << endl; return 0; }
  vector<pair<long long, long long>> pf = prime_factorize(N);
  int cnt = 0;
  for (pair<long long, long long> p : pf) {
    int tmp = 1;
    for (int i = 2; i < 100; i++) {
      if (p.second >= tmp) {
        cnt++;
        tmp += i;
      }
      else break;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;

char sa[200],sb[200],sc[200];
int main(){

  scanf("%s",sa);
  scanf("%s",sb);
  scanf("%s",sc);
  int alen=strlen(sa);
  int blen=strlen(sb);
  int clen=strlen(sc);
  int acur=0,bcur=0,ccur=0;

  char cha='a';
  while(1){
    if(alen==acur && cha=='a') {printf("A\n"); break;}
    if(blen==bcur && cha=='b') {printf("B\n"); break;}
    if(clen==ccur && cha=='c') {printf("C\n"); break;}

    if(cha=='a'){
      cha=sa[acur];
      acur+=1;
    }
    else if(cha=='b'){
      cha=sb[bcur];
      bcur+=1;
    }
    else if(cha=='c'){
      cha=sc[ccur];
      ccur+=1;
    }

  }


  return 0;

}


Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int s, w;
	cin >> s >> w;
	if (w >= s) cout << "unsafe" << endl;
	else cout << "safe" << endl;
	
	//cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

ll func(int num, int cnt){
    ll ans = 1;
    rep(i, cnt) ans *= num;
    return ans;
}

int main(){
    int N, P;
    cin >> N >> P;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    int odd_cnt = 0;
    rep(i, N) if(A[i] % 2 == 1) odd_cnt++;
    if(odd_cnt == 0){
        if(P == 1) cout << 0 << endl;
        if(P == 0) cout << func(2, N) << endl;
    }else{
        cout << func(2, N-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def solve():
    from collections import defaultdict
    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.par = [-1] * n

        def find(self, x):
            if self.par[x] < 0:
                return x
            else:
                while self.par[x] >= 0:
                  x = self.par[x]
                return x

        def unite(self, x, y):
            x = self.find(x)
            y = self.find(y)

            if x == y:
                return

            if self.par[x] > self.par[y]:
                x, y = y, x

            self.par[x] += self.par[y]
            self.par[y] = x

        def size(self, x):
            return -self.par[self.find(x)]

        def same(self, x, y):
            return self.find(x) == self.find(y)

    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    c = list(map(int, input().split()))
    mp = defaultdict(int)
    uf = UnionFind(n)

    for i in range(n):
        uf.unite(i, p[i] - 1)

    for i in range(n):
        mp[uf.find(i)] += c[i]

    ans = -10 ** 14
    for i in range(n):
        roop = uf.size(i)
        times = (k - 1) // roop if mp[uf.find(i)] > 0 else 0
        over = max(min(roop, k - roop * times), 1)
        tmp = 0
        s = -10 ** 10
        idx = i
        for j in range(over):
            tmp += c[idx]
            s = max(s, tmp)
            idx = p[idx] - 1
        s += times * mp[uf.find(i)]
        ans = max(ans, s)
    print(ans)


solve()


Measured memory_bytes: 75852
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long d = sc.NextLong();
        long[] c = sc.LongArray();
        long[,] s = new long[d, 26];
        for (int i = 0; i < d; i++)
        {
            for (int j = 0; j < 26; j++)
            {
                s[i, j] = sc.NextLong();
            }
        }

        long[] sums = new long[26];
        for (int i = 0; i < 26; i++)
        {
            long sum = 0;
            for (int j = 0; j < d; j++)
            {
                sum += s[j, i];
            }
            sums[i] = sum;
        }

        long maxDay = 0;
        long max = 0;
        for (int i = 0; i < 26; i++)
        {
            if (sums[i] > max)
            {
                max = sums[i];
                maxDay = i;
            }
        }

        for (int i = 0; i < d; i++)
        {
            Console.WriteLine(maxDay + 1);
        }

    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 28836
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

set<string> st;

void dfs(string s, map<string, vector<string> > mp, vector<string> group, map<string, bool> &used){
	if (used[s]) return;
	REP(j,mp[s].size()){
		string mem = mp[s][j];
		if (mp[mem].size() == 0) st.insert(mem);
		else dfs(mem, mp, group, used);
	}
	used[s] = 1;
}

int main(){
	int n;
	while (cin >> n && n){
		map<string, vector<string> > mp;
		vector<string> group;
		REP(i,n){
			string s, t, u;
			cin >> s;
			int x = 0;
			while (s[x] != ':'){
				t += s[x];
				x++;
			}
			group.push_back(t);
			x++;
			while (x < s.length()){
				if (s[x] == ',' || s[x] == '.'){
					mp[t].push_back(u);
					u.clear();
				}else{
					u += s[x];
				}
				x++;
			}
		}
		st.clear();
		map<string, bool> used;
		dfs(group[0], mp, group, used);
		cout << st.size() << endl;
	}


    return 0;
}

Measured memory_bytes: 5020
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<int, int>;
using data = pair<int, P>;

struct edge {
    int from;
    int to;
    int cost;
};

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

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

    bool issame(int x, int y) { return root(x) == root(y); }

    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y)
            return false;
        if(par[x] > par[y])
            swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) { return -par[root(x)]; }
};

int kruskal(vector<edge> &graph, int V) {
    sort(ALL(graph),
         [](const edge &a, const edge &b) { return a.cost < b.cost; });
    UnionFind uf(V);

    int res = 0;
    for(int v = 0; v < (int)graph.size(); v++) {
        edge e = graph[v];
        if(!uf.issame(e.from, e.to)) {
            uf.merge(e.from, e.to);
            res += e.cost;
        }
    }
    return res;
}

int calc(const P &a, const P &b) {
    return min(abs(a.first - b.first), abs(a.second - b.second));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<data> px(n), py(n);
    for(int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        px[i] = py[i] = data(i, P(x, y));
    }
    sort(ALL(px), [](const auto &a, const auto &b) {
        return a.second.first < b.second.first;
    });
    sort(ALL(py), [](const auto &a, const auto &b) {
        return a.second.second < b.second.second;
    });

    vector<edge> g;
    for(int i = 1; i < n; i++) {
        g.emplace_back(edge{px[i - 1].first, px[i].first,
                            calc(px[i - 1].second, px[i].second)});
        g.emplace_back(edge{py[i - 1].first, py[i].first,
                            calc(py[i - 1].second, py[i].second)});
    }
    cout << kruskal(g, n) << endl;
}

Measured memory_bytes: 7284
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n,m = map(int,input().split())
	x = list(map(int,input().split()))
	if(n>=m):
		print('0')
		exit()
	x.sort()
	ans = x[-1] - x[0] 
	y = []
	for i in range(m-1):
		y.append(x[i+1]-x[i])
	y.sort(reverse=True)
	for i in range(n-1):
		ans -= y[i]
	print(ans)

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Measured memory_bytes: 81572
#include <bits/stdc++.h>
using namespace std;
int main(){
  string A;
  int H,W;
  cin >> H >> W ;
  for (int i = 0;i<W + 2;i++)
    cout << '#';
  cout << endl;
  for (int i = 0; i< H;i++){
    cin >> A;
    cout << '#' << A << '#' << endl;
  }
  for (int i = 0;i<W + 2;i++)
    cout << '#';
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 200001
#define N 15
using namespace std;
int m,n,w[M],t[M],c[N],b[N];
int dp[(1<<N)],W[M],T[M];

int cal(int x,int l[],int C){
  C+=l[x];
  int L=x,R=m+1;
  while(L<R){
    int mid=(L+R)/2;
    if(C<l[mid])R=mid;
    else L=mid+1;
  }
  return L-1;
}

int main(){
  cin>>m>>n;
  for(int i=1;i<=m;i++){
    cin>>w[i]>>t[i];
    W[i]=W[i-1]+w[i];
    T[i]=T[i-1]+t[i];
  }
  for(int i=0;i<n;i++)cin>>c[i]>>b[i];
  for(int i=0;i<(1<<n);i++){
    for(int j=0;j<n;j++){
      if(i&(1<<j))continue;
      int r=min(cal(dp[i],W,c[j]),cal(dp[i],T,b[j]));
      dp[(i|(1<<j))]=max(dp[(i|(1<<j))],r);
    }
  }
  cout<<dp[(1<<n)-1]<<endl;
  return 0;
}

Measured memory_bytes: 4412