akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

using namespace std;

int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
    int k, i;
    
    scanf("%d", &k);
    
    printf("%d\n", a[k - 1]);
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

int main(){
    int h, w, n = 26;
    string ans = "No";
    cin >> h >> w;
    int A[26] = {0};
    for(int i = 0; i < h*w; i++) {
        char c;
        cin >> c;
        A[c-'a']++;
    }
    int f = 0;
    if(h%2 == 1)f++;
    if(w%2 == 1)f++;
    if(f == 0){
        bool flag = true;
        for(int i = 0; i < n; i++){
            if(A[i]%4 != 0) flag = false;
        }
        if(flag) ans = "Yes";
    }
    else if(f == 1){
        int two = 0;
        bool flag = true;
        for(int i = 0; i < n; i++){
            if(A[i]%2 != 0) {
                flag = false;
                break;
            }
            if(A[i] % 4 != 0 && A[i] % 2 == 0) two++;
        }
        int x;
        if(h % 2 == 1) x = w;
        else x = h;
        if(two * 2 > x) flag = false;
        if(flag) ans = "Yes";
    }
    else{
        int one = 0, two = 0, four = 0;
        bool flag = true;
        for(int i = 0; i < n; i++) {
            if(A[i] % 2 == 1) one++;
            if(A[i] % 4 != 0 && A[i] % 2 == 0) two++;
        }
        if(one != 1 || two * 2 > h + w - 1) flag = false;
        if(flag) ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

a.sort()
a = a[::-1]

a_total = 0
b_total = 0
for i in range(N):
    if i%2==0:
        a_total += a[i]
    else:
        b_total += a[i]

print(a_total-b_total)

Measured memory_bytes: 38384
//https://atcoder.jp/contests/abc121/tasks/abc121_a


#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>


using namespace std;
int main(){
	int H,W,h,w,ans;
	cin>>H>>W>>h>>w;
	ans=(H-h)*(W-w);
	cout<<ans<<endl;
}






Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n, k;
    string s;

    cin >> n >> k >> s;

    vector<P> p;
    int res = 0;

    for (int i = 0; i < n; i++)
    {
        if (s[i] == '1')
        {
            if (res == 0)
            {
                p.push_back(P(i, 0));
            }

            res++;
        }
        else
        {
            if (res > 0)
            {
                p.back().second = res;
                res = 0;
            }
        }
    }

    if (res > 0)
    {
        p.back().second = res;
        res = 0;
    }

    if (s[0] == '0')
    {
        p.insert(p.begin(), P(0, 0));
    }

    if (s[n - 1] == '0')
    {
        p.push_back(P(n, 0));
    }

    if (k >= p.size() - 1)
    {
        cout << n << endl;
        return 0;
    }

    ll ans = 0;

    for (int i = 0; i + k < p.size(); i++)
    {
        ans = max(ans, p[i + k].first + p[i + k].second - p[i].first);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1528
N, M = map(int, input().split())
G = [[0 for i in range(N)] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a-1][b-1]+=1
    G[b-1][a-1]+=1
for i in range(N):
    s = 0
    for j in range(N):
        s+=G[i][j]
    print(s)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define nmod         -1000000007
#define N            1000000//31630=sqrt(pow(10,9))
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
//bool pf[N+1ll];
//vec prim;
//void sieve()
//{
//    repi(i,0,N)
//    pf[i]=true;
//	pf[0] = pf[1] = false;
//    for (int i = 2; i <= N; i++) {
//        if (pf[i]) 
//		{
//            prim.push_back(i);
//            for (int j = i + i; j <= N; j+=i) {
//                pf[j] = false;
//            }
//        }
//    }
//}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}
ll a[200005],dp[200005],prefix[200005];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS; 
    while(TESTS--)
    {
    	ll m,k,g,i,l,h,j,mx,my,ans,d,n,x;
    	cin>>n;
    	cin>>a[1]>>a[2];
    	prefix[1]=a[1], prefix[2]=a[2];
    	repi(i,3,n)
    	{
    		cin>>a[i];
    		prefix[i]=prefix[i-2]+a[i];
		}
		dp[0]=0; dp[1]=0;
		repi(i,2,n)
		{
			if(i%2==0)
			dp[i]=max(prefix[i-1],dp[i-2]+a[i]);
			else
			dp[i]=max(dp[i-2]+a[i],dp[i-1]);
		}
		cout<<dp[n];
	}
	return 0;
} 

Measured memory_bytes: 8392
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int sum = 0;
		int N = scan.nextInt();
		int[] l = new int[N];
		int[] r = new int[N];
		for(int i = 0; i < N; i++) {
			l[i] = scan.nextInt();
			r[i] = scan.nextInt();
			sum += Math.abs(l[i] - r[i]) + 1;
		}
		System.out.println(sum);
		scan.close();

	}

}


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

public class Main {
	
	public static void main(String arg[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[]  a = new String[N];
		String[] resultArray;
		int minj = 0;
		int[][] A = new int[N][2];
		int[][] B = new int[N][2];
		int tmp = 0;
		int num = 0;
		
		for(int i=0; i<N; i++){
			a[i] = sc.next();
			resultArray = a[i].split("");
			num = Integer.parseInt(resultArray[1]);
			A[i][0] = i;
			A[i][1] = num;
			B[i][0] = A[i][0];
			B[i][1] = A[i][1];
		}
		
		/*Bubble*/
		for (int i=0; i<N; i++){
			for (int j=N-1; j>0; j--){
				if(B[j][1] < B[j-1][1]) {
					tmp = B[j][0];
					num = B[j][1];
					B[j][0] = B[j-1][0];
					B[j][1] = B[j-1][1];
					B[j-1][0] = tmp;
					B[j-1][1] = num;
				}
			}
		}
		for(int i=0; i<N; i++){
			if(i<N-1){
				System.out.print(a[B[i][0]] + " ");
			}else{
				System.out.println(a[B[i][0]]);
			}
		}
		System.out.println("Stable");
		
		/*Selection*/
		for(int i=0; i<N; i++){
			minj = i;
			for(int j=i; j<N; j++){
				if(A[j][1] < A[minj][1]){
					minj = j;
				}
			}
			if(A[i][1]!=A[minj][1]){
				tmp = A[i][0];
				num = A[i][1];
				A[i][0] = A[minj][0];
				A[i][1] = A[minj][1];
				A[minj][0] = tmp;
				A[minj][1] = num;
			}
		}
		for(int i=0; i<N; i++){
			if(i<N-1) {
				System.out.print(a[A[i][0]] + " ");
			}else{
				System.out.println(a[A[i][0]]);
			}
		}
		for(int i=0; i<N; i++){
			if(A[i][0]!=B[i][0]) {
				System.out.println("Not stable");
				break;
			}else if(A[i][0]==B[i][0] && i !=N-1){
				continue;
			}else{
				System.out.println("Stable");
			}
		}
	}
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int a, b;
    char op;
    cin >> a >> op >> b;
    if(op=='+')
        cout << a + b << endl;
    else
        cout << a - b << endl;
    // end

    return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(20)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll N;
pll X[10];
vector<vector<ll>> V;

void dfs(vector<ll> v)
{
    if (v.size() == N)
    {
        V.push_back(v);
        return;
    }

    REP(i, N)
    {
        bool e = false;
        REP(j, v.size())
        {
            if (v[j] == i)
            {
                e = true;
                break;
            }
        }
        if (e)
            continue;
        v.push_back(i);
        dfs(v);
        v.pop_back();
    }
}

int main()
{
    cin >> N;
    REP(i, N)
    {
        cin >> X[i].first >> X[i].second;
    }

    V.resize(0);
    vector<ll> v;
    dfs(v);

    double s = 0;
    REP(i, V.size())
    {
        auto t = V[i];
        REP(j, N - 1)
        {
            double x = X[t[j]].first - X[t[j + 1]].first;
            double y = X[t[j]].second - X[t[j + 1]].second;
            s += sqrt(x * x + y * y);
        }
    }

    s = (s / (double)(V.size()));
    cout << OF64 << s << endl;
    return 0;
}

Measured memory_bytes: 4408
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, M): (usize, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };
    let a: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    fn gcd(a: i64, b: i64) -> i64 {
        if b == 0 {
            a
        } else {
            gcd(b, a % b)
        }
    }
    fn lcm(a: i64, b: i64) -> i64 {
        a / gcd(a, b) * b
    }

    let h = a[1..].iter().fold(a[0], |h, &x| {
        if ((h - x) / 2) % gcd(h, x) == 0 && lcm(h, x) <= 2 * M {
            lcm(h, x)
        } else {
            0
        }
    });
    let ans = if 0 < h && h <= 2 * M {
        1 + (M - h / 2) / h
    } else {
        0
    };

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


Measured memory_bytes: 8444
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

inline double sqrt2(double a) {
	double b = a;
	for (int i = 0; i < 15; i++) {
		b = (b * b + a) / (2 * b);
	}
	return b;
}

inline double dist(pair<double, double> a, pair<double, double> b) {
	return sqrt2((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second));
}

pair<double, double> calc_c(pair<double, double> a, pair<double, double>b, pair<double, double>c, double& r) {
	pair<double, double> e, f, g;
	e.first = (a.first + b.first) / 2;
	e.second = (a.second + b.second) / 2;
	f.first = (b.first + c.first) / 2;
	f.second = (b.second + c.second) / 2;
	double tan_a, tan_b;
	tan_a = tan(atan((b.second - a.second) / (b.first - a.first)) + PI / 2);
	tan_b = tan(atan((c.second - b.second) / (c.first - b.first)) + PI / 2);
	g.first = (e.second - f.second - e.first * tan_a + f.first * tan_b) / (tan_b - tan_a);
	g.second = e.second - (e.first - g.first) * tan_a;
	r = dist(a, g);
	return g;
}

pair<double, double> calc_c(pair<double, double> a, pair<double, double>b, double& r) {
	pair<double, double> g;
	g.first = (a.first + b.first) / 2;
	g.second = (a.second + b.second) / 2;
	r = dist(a, g);
	return g;
}

bool is_inner(pair<double, double> c, pair<double, double>p, double r) {
	return dist(c, p) <= (r + 1e-5);
}

int main() {
	io_init;
	int N;
	cin >> N;
	vector<pair<double, double>> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i].first >> a[i].second;
	}
	double ans = INF;
	if (N != 2) {
		for (int i = 0; i < N - 2; i++) {
			for (int j = i + 1; j < N - 1; j++) {
				for (int k = j + 1; k < N; k++) {
					//cout << i << " " << j << " " << k << endl;
					double r;
					auto c = calc_c(a[i], a[j], a[k], r);
					bool f = false;
					for (int s = 0; s < N; s++) {
						if (!is_inner(c, a[s], r))f = true;
					}
					if (!f)ans = min(ans, r);
				}
			}
		}
	}
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			if (i == j) continue;
			double r;
			auto c = calc_c(a[i], a[j], r);
			bool f = false;
			for (int k = 0; k < N; k++) {
				if (!is_inner(c, a[k], r))f = true;
			}
			if (!f)ans = min(ans, r);
		}
	}
	cout << ans << endl;
}

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

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        int W = Integer.parseInt(scanner.next());
        int[][] n = new int[N][2];
        for (int i = 0; i < N; i++) {
            n[i][0] = Integer.parseInt(scanner.next());
            n[i][1] = Integer.parseInt(scanner.next());
        }
        long[][] dp = new long[N + 1][100001];
        for (int i = 0; i <= N; i++) {
            Arrays.fill(dp[i], Long.MAX_VALUE / 2);
        }
        dp[0][0] = 0;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 100001; j++) {
                if (j + n[i][1] <= 100000) {
                    dp[i + 1][j + n[i][1]] = Math.min(dp[i + 1][j + n[i][1]], dp[i][j] + n[i][0]);
                }
                dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j]);
            }
        }

        long ans = 0;
        for (int j = 100000; j >= 0; j--) {
            if (dp[N][j] <= W) {
                ans = j;
                break;
            }
        }

        System.out.println(ans);
    }

}



Measured memory_bytes: 127056
#include<iostream>
using namespace std;
int main(){
  int e,x,y,z,i,j,k,b,m;
  cin >> e;
  while(e!=0){
    x=0;y=0;z=0;
    m=e;
    for(z=0;z*z*z<=e;z++){
      x=0;y=0;
      b=e-z*z*z;
      while(y*y<=b) y++;
      y--;
      b-=y*y;
      while(x<=b) x++;
      x--;
      m = (x+y+z) < m ?(x+y+z) : m;
    }
    cout << m << endl;
    cin >> e;
  }
  return 0;
}

Measured memory_bytes: 1160
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let L: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    const INF: i64 = 1_000_000_000;
    let S = {
        let mut S = L.clone();
        S.push(INF);
        S.sort();
        S
    };
    let ans = (0..(N - 2)).map(|i| {
        let (s, _) = ((i + 1)..(N - 1)).fold((0, i + 2), |(res, k), j| {
            let r = (k..(N + 1)).find(|&l| S[l] >= S[i] + S[j]).unwrap();
            (res + r - j - 1, r)
        });
        s
    }).sum::<usize>();

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

Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

struct edge {
  ll from, to, cost;

  edge( ll from, ll to, ll cost )
  : from(from), to(to), cost(cost)
  {}
};

ll N, M, P;
std::vector<edge> es;
std::vector<ll> d;
std::vector<ll> G[3000], rG[3000];
bool conn1[3000], connN[3000];

void dfs( ll v ) {
  conn1[v] = true;

  for( auto u : G[v] ) if( !conn1[u] )
    dfs( u );
}

void rdfs( ll v ) {
  connN[v] = true;

  for( auto u : rG[v] ) if( !connN[u] )
   rdfs( u );
}

int main()
{
  std::cin >> N >> M >> P;

  rep( i, M ) {
    ll A, B, C;
    std::cin >> A >> B >> C;
    --A; --B;

    es.emplace_back( A, B, P-C );
    G[A].emplace_back( B );
    rG[B].emplace_back( A );
  }

  dfs( 0 );
  rdfs( N-1 );

  d.assign( N+10, INF );
  d[0] = 0;

  bool upd = true;
  ll cnt = 0;

  while( upd ) {
    upd = false;

    auto ok = [&]( ll v ) {
      return conn1[v] && connN[v];
    };

    for( auto e : es ) {
      if( !ok(e.from) )
        continue;
      if( !ok(e.to) )
        continue;

      if( d[e.from] != INF && chmin( d[e.to], d[e.from]+e.cost ) )
        upd = true;
    }

    ++cnt;

    if( cnt > N ) {
      std::cout << -1 << std::endl;

      return 0;
    }
  }

  std::cout << std::max( 0ll, -d[N-1] ) << std::endl;

  return 0;
}

Measured memory_bytes: 4068
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int N, K, S;
	cin >> N >> K >> S;
	vector<int> ans(N);
	for (int i = 0; i < K; i++)
		ans[i] = S;
	for (int i = K; i < N; i++)
	{
		if (S == 1e9)
			ans[i] = 1;
		else
			ans[i] = S+1;
	}
	for (int i = 0; i < N; i++)
	{
		cout << ans[i];
		if (i != N-1)
			cout << " ";
	}
	cout << endl;
}



Measured memory_bytes: 1664
from fractions import gcd
A, B, C, D = map(int, input().split())

def f(x):
  l=x//C
  m=x//D
  k=C*D//gcd(C,D)
  n=x//k
  
  return(x-l-m+n)

print(f(B)-f(A-1))


Measured memory_bytes: 5304
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>

using namespace std;

bool is_month(string s) {
  int i = stoi(s);
  return 1 <= i && i <= 12;
}

int main() {
  string S;
  cin >> S;
  string fh, lh;
  fh = S.substr(0, 2);
  lh = S.substr(2, S.length());
  if (is_month(fh) && is_month(lh)) {
    cout << "AMBIGUOUS" << endl;
  } else if (is_month(fh)) {
    cout << "MMYY" << endl;
  } else if (is_month(lh)) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k;
bool used[10] = {0};
bool chk(int n){
    while(n){
        if(used[n%10]) return 0;
        n/=10;
    }
    return 1;
}
int main(){
    scanf("%d%d",&n,&k);
    for(int i = 1;i<=k;i++){
        int x;
        scanf("%d",&x);
        used[x] = 1;
    }
    for(int i = n;i;i++)
        if(chk(i)){
            printf("%d\n",i);
            break;
        }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define EPS 1e-7
 
class Point {
  public:
    double x, y;
    Point (double x = 0.0, double y = 0.0) : x(x),y(y) {}
    Point operator + (Point p) {
        return Point(x + p.x, y + p.y);
    }
    
    Point operator - (Point p) {
        return Point(x - p.x, y - p.y);
    }
    
    Point operator * (double a) {
        return Point(x * a, y * a);
    }
    
    Point operator / (double a) {
        return Point(x / a, y / a);
    }
    double abs() {
        return sqrt(norm());
    }
    double norm() {
        return x * x + y * y;
    }
};

double dot(Point a, Point b)
{
    return a.x * b.x + a.y * b.y;
}

double cross(Point a, Point b)
{
    return a.x * b.y - a.y * b.x;
}
 
class Segment {
  public:
    Point t, s;
    Segment(Point t, Point s) : t(t), s(s) {}
    Point projection(Point &p) {
	Point b = s - t;
	double d = dot(p-t,b) / b.norm();
	return t + b*d;
    }
};
 
class Circle {
  public:
    double x, y, r;
    Circle(double x = 0.0, double y = 0.0, double r = 0.0) :
        x(x), y(y), r(r) {}
};
 
int N;
Point t, s;
Circle ci[300];
 
bool check(Point p0, Point p1, Point p2)
{
    Point a = p1 - p0;
    Point b = p2 - p0;
    if (cross(a,b) > EPS) return 0;
    if (cross(a,b) < -EPS) return 0;
    if (dot(a,b) < -EPS) return 0;
    if (a.norm() < b.norm()) return 0;
    return 1;
}
 
bool getStateCS(Circle c, Segment seg)
{
    Point cp = Point(c.x, c.y);
    Point p = seg.projection(cp);
    Point pp = p - cp;
 
 
    Point a = seg.t - cp;
    Point b = seg.s - cp;
     
    if((a.abs() > c.r && b.abs() < c.r) ||
       (a.abs() < c.r && b.abs() > c.r) ) return 1;
    if(a.abs() > c.r && b.abs() > c.r){
	if(pp.abs()-EPS < c.r && check(seg.t, seg.s,p)){
	    return 1;
	}
    }
    return 0;
}
 
bool judge()
{
    Segment seg = Segment(t, s);
 
    for (int i = 0; i < N; i++) {
	if (getStateCS(ci[i], seg)) return 1;
    }
    return 0;
}
 
int main()
{
    int M;
    while (cin >> N, N) {
	for (int i = 0; i < N; i++) {
	    cin >> ci[i].x >> ci[i].y >> ci[i].r;
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
	    cin >> t.x >> t.y >> s.x >> s.y; 
	    if (judge()) {
		cout << "Safe" << endl;
	    } else {
		cout << "Danger" << endl;
	    }
	}
    }
    return 0;
}

Measured memory_bytes: 3144
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>

using std::cout;
using std::endl;
using std::cin;
using std::string;

int main(){
  string a;
  bool flg=false;
  cin >> a;
  for(int i=0;i<3;i++){
    if(a.substr(i,1)=="7")
      flg=true;
  }
  if(flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
using namespace std;
int N=0,K=0;
long ans=1000000000;

int main(){
  	cin >>N >>K;
  	long h[N+1]={};
  	for(int i=0;i<N;i++) {
      cin >>h[i];
    }
    

  	sort(h,h+N);
  	
  	for(int i=0;i<N-K+1;i++){
    	ans=min(ans,h[K-1+i]-h[i]);
    }
  
	
  
  	cout <<ans <<endl;
}

Measured memory_bytes: 1024
import re

s = input()
k = int(input())
ans = [min(s)]
i = 1
while True:
    if len(ans) == k:
        print(ans[-1])
        break
    else:
        base = ans[-1]
        sub = sorted(re.findall(base + '.', s))
        if len(sub) == 0:
            while True:
                if chr(ord(min(s))+i) in s:
                    ans.append(chr(ord(min(s))+i))
                    break
                else:
                    i += 1

        else:
            ans.append(sub[0])


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

using namespace std;
 
#define ld long double
#define ll long long

int main(){
    //freopen("input.txt","r",stdin);
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
    
    int n;cin>>n;
    vector<double> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    double ans = v[0];
    for(int i=1;i<n;i++){
        ans = (v[i] + ans) / 2;
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
   char str[3];
   int i,num=0;
    scanf("%s",str);
   for(i=0;i<=3;i++){
      if(str[i]=='+')
         num+=1;
      if(str[i]=='-')
         num-=1;
   }

printf("%d",num);

return 0;
}

Measured memory_bytes: 128
s = input()
max = ''
for i in range(len(s)):
    for j in range(len(s)):
        flag = True
        judge = s[i:j+1]
        for k in judge:
            if k != "A" and k != "C" and k != "G" and k != "T":
                flag = False
                break
        if flag and len(judge) > len(max):
            max = judge
print(len(max))

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

using namespace std;

int main() {
  string S;
  cin >> S;
  for (int b = 0; b < (1 << 3); ++b) {
    int total = S[0] - '0';
    string f = string(1, S[0]);
    for (int i = 0; i < 3; ++i) {
      int n = S[i + 1] - '0';
      if (b & (1 << i)) total += n, f += '+';
      else total -= n, f += '-';
      f += S[i + 1];
    }
    f = f + '=' + to_string(total);

    if (total == 7) {
      cout << f << endl;
      break;
    }
  }
}

Measured memory_bytes: 3664
N = int(input())
L = list(map(int,input().split()))
L.sort()

def checkTri(a,b,c):
  if a == b or b == c or a == c:
    return False
  if abs(a-c) < b < a+c:
    return True
  else:
    return False

cnt = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      if checkTri(L[i],L[j],L[k]):
        cnt += 1
      
print(cnt)

Measured memory_bytes: 9144
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Control.Monad
import Control.Monad.State
import Control.DeepSeq
import Data.Array
import Data.Bits
import Data.Char
import Data.Functor.Identity
import Data.List
import Data.Maybe
import Data.Ord
import Data.Tree
import Data.Tuple
import qualified System.IO
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.Sequence as Q
import qualified Data.ByteString.Char8 as B

main = do
  n <- getInt
  as <- getInts
  let
    amin = minimum as
    amax = maximum as
    bs = [(amax + 1)`div`2 .. amax] ++ [(amax + 2)`div`2 .. amax]
    aset = multiset as
    bset = multiset bs
    cset = diff aset bset
  -- print aset
  -- print bset
  -- print cset
  let
    ans = and
      [ valid cset
      , M.null cset || minimum (M.keys cset) > (amax + 1)`div`2
      ]
  putStrLn $ if ans then "Possible" else "Impossible"

multiset = M.fromListWith (+) . flip zip (repeat 1)

valid = all (>=1) . M.elems

diff a b = normalize $ M.unionWith (+) a (M.map negate b)

normalize = M.filter (/= 0)

 
type Z = Int
type Q = Rational
type R = Double
type S = String

fint :: (Integral a, Num b) => a -> b
fint = fromIntegral

getInt = fst . fromJust . B.readInt <$> B.getLine
getIntPair = (\[a,b]->(a,b)) <$> getInts
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine
getStr = B.unpack <$> B.getLine

yesNo :: Bool -> String
yesNo True = "Yes"
yesNo False = "No"

printList :: (Show a) => [a] -> IO ()
printList = putStrLn . unwords . map show

readLnList :: (Read a) => IO [a]
readLnList = map read . words <$> getLine


-----  Union-find
type UnionFindT v m a = StateT (M.Map v (UnionFindVal v)) m a
newtype UnionFindVal v = UnionFindVal v

runUnionFindT :: (Monad m) => UnionFindT v m a -> m a
runUnionFindT = flip evalStateT $ M.empty

runUnionFind = runIdentity . runUnionFindT

ufFresh :: (Monad m, Ord v) => v -> UnionFindT v m ()
ufFresh v = modify $ M.insert v (UnionFindVal v)

ufClass :: (Monad m, Ord v) => v -> UnionFindT v m v
ufClass v = do
  (UnionFindVal pv) <- gets (M.! v)
  if v == pv
    then return v
    else do
      c <- ufClass pv
      modify $ M.insert v (UnionFindVal c)
      return c

ufUnify v w = do
  cv <- ufClass v
  cw <- ufClass w
  modify $ M.insert cw (UnionFindVal cv)
  return $ cv /= cw


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

const int N = int(2e5) + 7;
typedef pair<int, int> pii;

int n, a[N], b[N], res, Q[N];

int prv(int i) {return i - 1 >= 1? i - 1: n;}
int nxt(int i) {return i + 1 <= n? i + 1: 1;}
priority_queue<pii> pq;
bool Check(int i) {return b[i] > a[i] && b[i] - a[i] >= b[prv(i)] + b[nxt(i)];}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    for(int i = 1; i <= n; ++i) {
        cin >> b[i];
        if(Check(i)) pq.push(mp(b[i], i)), Q[i] = 1;
    }
    ll ans = 0;
    while(pq.size()) {
       pii top = pq.top(); pq.pop(); Q[top.se] = 0;
       int x = b[prv(top.se)], y = b[top.se], z = b[nxt(top.se)];
       if(y - a[top.se] >= x + z) {
         b[top.se] -= (y - a[top.se]) / (x + z) * (x + z);
         ans += (y - b[top.se]) / (x + z);
       } else break;
       if(Check(top.se)) pq.push(mp(b[top.se], top.se)), Q[top.se] = 1;
       x = prv(top.se);
       for(int i = 1; i <= 2; ++i, x = prv(x))
          if(Check(x) && !Q[x]) pq.push(mp(b[x], x)), Q[x] = 1;
       x = nxt(top.se);
       for(int i = 1; i <= 2; ++i, x = nxt(x))
          if(Check(x) && !Q[x]) pq.push(mp(b[x], x)), Q[x] = 1;
    }
    for(int i = 1; i <= n; ++i) {
        if(a[i] != b[i]) return cout << -1, 0;
    }
    cout << ans;
}


Measured memory_bytes: 3572
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

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

using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 0;
    rep(i, 60) {
        ll zero_num = 0;
        ll one_num = 0;
        rep(j, n) {
            if (a[j] >> i & 1) one_num++;
            else zero_num++;
        }
        ll mul = zero_num * one_num;
        rep(k, i) mul = (mul * 2) % mod;
        ans = (ans + mul) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5572
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    S = input()
    ans = 0
    for i in range(n-1):
        l = S[:i+1]
        r = S[i+1:]
        cnt = 0
        for s in set(l):
            if r.find(s) >= 0:
                cnt += 1
        ans = max(ans, cnt)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9088
while True:
    x, y, z = map(int, raw_input().split())
    if x==0 and y==0 and z==0: break
    dp = [[0.0 for col in range(5101)] for row in range(61)]
    m = {}
    for i in range(y+10):
        m[i] = (0,0)
    v = []
    v = map(int, raw_input().split())
    for i in range(z):
        n, e, a = map(int, raw_input().split())
        m[n] = (e, a)
    dp[0][0] = 1.0
    for i in range(y):
        for j in range(y*100):
            if dp[i][j] == 0.0: continue
            for k in range(x):
                nx = i + v[k]
                if m[nx][0] == 1:
                    dp[min(y,nx+m[nx][1])][j]+=dp[i][j]/x
                elif m[nx][0]==2:
                    dp[nx][j+m[nx][1]]+=dp[i][j]/x
                elif m[nx][0]==3:
                    dp[nx][max(0,j-m[nx][1])]+=dp[i][j]/x
                else:
                    dp[min(y,nx)][j] += dp[i][j]/x                       
    ans = 0.0
    for i in range(5001):   
        ans += dp[y][i]*i
    print int(ans) 

Measured memory_bytes: 10112
open System

let n = Console.ReadLine() |> Int64.Parse
let ss =
    seq {
        for i in 1 .. int(n) do
            yield Console.ReadLine()
    }

let ans =
    let march = ['M'; 'A'; 'R'; 'C'; 'H']
    let mutable m =
        new Map<char, Int64> (
            march
            |> List.toSeq
            |> Seq.map (fun c -> (c, 0L))
        )

    for s in ss do
        let c = s.[0]
        match List.tryFind (fun x -> x = c) march with
            | Some _ -> m <- m |> Map.add c (m.[c] + 1L)
            | _ -> ()

    let rec dfs (cs: char list) rest =
        match rest with
        | [] ->
            if cs.Length = 3 then
                cs
                |> List.map (fun c -> m.[c])
                |> List.fold (*) 1L
            else
                0L
        | c :: rest ->
            (dfs cs rest) + (dfs (c :: cs) rest)

    dfs [] march

ans |> Console.WriteLine



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

int main() {
  double W, H, x, y;
  cin >> W >> H >> x >> y;

  cout << fixed << setprecision(9);
  cout << (W * H) / 2 << ' ';
  if (W == 2 * x && H == 2 * y) cout << 1 << endl;
  else
    cout << 0 << endl;
}

Measured memory_bytes: 256
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sun Jan 27 15:07:05 2019
//
package main

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

type unionFind struct {
	roots []int
}

func new(n int) unionFind {
	uf := unionFind{}
	uf.roots = make([]int, n+1)

	for i := range uf.roots {
		uf.roots[i] = i
	}

	return uf
}

func (uf unionFind) root(n int) int {
	parent := uf.roots[n]

	if parent == n {
		return n
	}
	root := uf.root(parent)
	uf.roots[n] = root
	return root
}

func (uf unionFind) union(n, m int) {
	rootN := uf.root(n)
	rootM := uf.root(m)
	if rootN < rootM {
		uf.roots[rootN] = rootM
	} else {
		uf.roots[rootM] = rootN
	}
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	M := nextInt()

	arr := make([]int, N)
	for i := range arr {
		arr[i] = nextInt()
	}

	uf := new(N)
	for i := 0; i < M; i++ {
		n := nextInt()
		m := nextInt()
		uf.union(n, m)
	}

	m1 := map[int][]int{}
	m2 := map[int]map[int]bool{}
	for i := range arr {
		m1[uf.root(arr[i])] = append(m1[uf.root(arr[i])], i+1)
		if m2[uf.root(arr[i])] == nil {
			m2[uf.root(arr[i])] = map[int]bool{}
		}
		m2[uf.root(arr[i])][arr[i]] = true
	}

	ans := 0
	for k, v := range m1 {
		for i := range v {
			if _, ok := m2[k][v[i]]; ok {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 30848
#include <bits/stdc++.h>
const int mod = 998244353;
int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> dp(m + 1);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    ++dp[0];
    int a;
    std::cin >> a;
    for (int j = m; j >= a; --j)
      dp[j] = (dp[j] + dp[j - a]) % mod;
    ans = (ans + dp[m]) % mod;
  }
  std::cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
#include <iomanip>
using namespace std;
typedef long long ll;

int Tmax, V, E, u, v, d, Nnew, new_id, dst, order[11111], check[444], par[444], sum = 0;
vector<vector<pair<int, int>>> li(444);
queue<pair<int, int>> route;
queue<int> store;
queue<int> car;

void dfs(int now, int distance) {
	route.push(make_pair(now, distance));
	sum += distance * 2;
	for (auto &e : li[now]) {
		if (par[e.first] == now) {
			dfs(e.first, e.second);
			route.push(make_pair(now, e.second));
		}
	}
}

int main() {
	cin >> V >> E;
	for (int i = 0; i < E; i++) {
		cin >> u >> v >> d;
		li[u].push_back(make_pair(v, d));
		li[v].push_back(make_pair(u, d));
	}
	cin >> Tmax;
	for (int i = 0; i < Tmax; i++) {
		cin >> Nnew;
		if (Nnew)
			cin >> new_id >> order[i];
		else
			order[i] = -1;
	}
	for (int i = 1; i <= V; i++)
		check[i] = 0;
	priority_queue<pair<pair<int, int>, int>, vector<pair<pair<int, int>, int>>, greater<pair<pair<int, int>, int >>> que;
	que.push(make_pair(make_pair(0, 1), -1));
	while (!que.empty()) {
		int now = que.top().first.second, npar = que.top().second;
		que.pop();
		if (!check[now]) {
			check[now]++;
			par[now] = npar;
			for (auto &e : li[now]) {
				int next = e.first, dnext = e.second;
				if (!check[next])
					que.push(make_pair(make_pair(dnext, next), now));
			}
		}
	}
	dfs(1, 0);
	route.pop();
	int count = 0, ndst=1, check_store = 1;
	for (int i=0; i < Tmax; i++) {
		if (order[i] > 0)
			store.push(order[i]);
		if (ndst == 1 && !count)
			check_store = 1;
		if (check_store) {
			while (!store.empty()) {
				car.push(store.front());
				store.pop();
			}
		}
		if (check_store&&car.size() < 1)
			cout << "-1" << endl;
		else {
			check_store = 0;
			if (!count) {
				queue<int> keep;
				while (!car.empty()) {
					if (car.front() != ndst)
						keep.push(car.front());
					car.pop();
				}
				while (!keep.empty()) {
					car.push(keep.front());
					keep.pop();	
				}
				int nowp = ndst;
				ndst = route.front().first;
				count = route.front().second;
				route.pop();
				route.push(make_pair(ndst, count));
				if (car.empty()) {
					while (ndst != par[nowp]) {
						ndst = route.front().first;
						count = route.front().second;
						route.pop();
						route.push(make_pair(ndst, count));
					}
				}
			}
			cout << ndst << endl;
			count--;
		}
	}
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		if((0 <= x-r) && (x+r <= w) && (0 <= y-r) && (y+r <= h)){
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}



Measured memory_bytes: 26348
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()


int main(){
    ll A, B;
    cin >> A >> B;
    ll an = A+B;
    an = max(an, A-B);
    an = max(an, 1ll*A*B);
    printf("%lld\n", an);
}


Measured memory_bytes: 256
def cmb(n, r, mod):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod
mod = 10**9 + 7

fact = [1, 1]
factinv = [1, 1]
inv = [0,1]

n, k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
if k == 1:
    print(0)
    exit()

for i in range(2,n+1):
    fact.append((fact[-1] * i) % mod)
    inv.append((inv[mod % i] * (mod - (mod // i))) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)

saidai = 0
saisyo = 0

for i in range(n-k+1):
    saisyo += (a[i]*cmb(n-i-1,k-1,mod))%mod
    saisyo %= mod
for i in range(k-1,n):
    saidai += (a[i]*cmb(i,k-1,mod))%mod
    saidai %= mod
print((saidai-saisyo)%mod)

Measured memory_bytes: 25748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,res;
    cin>>n;
    string s;
    if(n==0){
        cout<<"0"<<endl;
        return 0;
    }
    while(n){
        if(n%2){
            s = "1"+s;
            n--;
        }else{
            s = "0"+s;
        }
        n /=-2;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace ABC046_B
{
    class Program
    {
        static void Main(string[] args)
        {
            long ans=1;
            var t = scan;
            long N = t[0];
            long K = t[1];
            ans = K;
            for (int i = 1; i < N; i++)
            {
                ans *= (K - 1);
            }
            Console.WriteLine(ans);
        }

        static int[] scan { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } }
    }
}


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

int main()
{
	string s, t;
	cin >> s >> t;
	map<char, char> S, T;
	for (int i = 0; i < s.size(); ++i)
	{
		if (S.count(s[i]) == 0)
		{
			S[s[i]] = t[i];
		}
		if (T.count(t[i]) == 0)
		{
			T[t[i]] = s[i];
		}
		if(S[s[i]] != t[i] || T[t[i]] != s[i])
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 776
dic = {}

while 1:
    line = input()
    if line == "END_OF_FIRST_PART":
        break
    index,num = line.split()
    dic[index] = int(num)

def solve(st):
    #print(st)
    if st == "0":
        return False
    ans = 0    
    kigou = ""
    mass = 0
    num = ""
    i = 0
    while i < len(st):
        #print(st[i])
       # print(ans)
        if st[i] in ['0','1','2','3','4','5','6','7','8','9']:
            if len(kigou)>0:
                mass = dic[kigou]
            if mass == "UNKNOWN":
                return mass
            kigou = ""
            if  i+1<len(st) and st[i+1]  in ['0','1','2','3','4','5','6','7','8','9']:
                ans += mass * int(st[i:i+2])
                i+=1
     #           print(mass,int(st[i:i+2]))
            else:
                ans += mass * int(st[i])
      #          print(mass,int(st[i]))
        elif st[i] == '(':
            if len(kigou)>0:
                if not(kigou in dic.keys()):
                    return "UNKNOWN"
                ans += dic[kigou]
                kigou = ""
            j = i+1
            c = 1
            while c>0:
                if st[j] =='(':
                    c +=1
                if st[j] == ')':
                    c -=1
                j += 1
            mass = solve(st[i+1:j-1])
            i = j-1
            kigou=""

        elif str.isupper(st[i]):
            if len(kigou) > 0:
                if not(kigou in dic.keys()):
                    return "UNKNOWN"
                ans += dic[kigou]
            kigou = st[i]
        else:
            kigou += st[i]
        i+=1
        #print(ans)
    if len(kigou)>0:
        if not(kigou in dic.keys()):
            return "UNKNOWN"
        ans += dic[kigou]
    return ans

while True:
    ans = solve(input())
    if ans:
        print(ans)
    else:
        break



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 29;
constexpr lint   INFL = 1LL << 61;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

using Weight = int;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(void) {}
  Edge(int src, int dst) : src(src), dst(dst) {}
  Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void edges_to_graph(Graph &graph, const Edges &edges, const int vertices, const bool directed = true) {
  graph.resize(vertices);
  for (const auto &e : edges) graph[e.src].emplace_back(e);
  if (!directed) for (const auto &e : edges) graph[e.dst].emplace_back(Edge(e.dst, e.src, e.weight));
}

void dfs(const Graph &g, const int v, const int p, const vector<int> &cnt, const int sum, vector<int> &ret) {
  ret[v] = sum + cnt[v];
  for (const auto &e : g[v]) {
    if (e.dst == p) continue;
    dfs(g, e.dst, v, cnt, ret[v], ret);
  }
}

Graph graph;
int main(void) {
  int n, q;
  cin >> n >> q;
  Edges edges(n - 1);
  rep (i, n - 1) {
    int a, b;
    cin >> a >> b;
    edges[i] = {--a, --b};
  }
  vector<int> cnt(n);
  rep (i, q) {
    int p, x;
    cin >> p >> x;
    cnt[--p] += x;
  }
  edges_to_graph(graph, edges, n, false);
  vector<int> ret(n);
  dfs(graph, 0, -1, cnt, 0, ret);
  rep (i, n) cout << ret[i] << "\n";
  return 0;
}

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

int X, Y, Z;

int main() {
    cin >> X >> Y >> Z;

    // 1人目
    int ans = 1;
    X -= Y + 2 * Z;

    int add = X / (Y + Z);

    cout << ans + add << endl;
}

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

flag = 1
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 != 0 and a[i] % 5 != 0:
            flag = 0

if flag == 0:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 3060
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

int N;
uint[100] FS;
int[11][100] PS;

int bit_count(uint i) {
    i = i - ((i >>> 1) & 0x55555555);
    i = (i & 0x33333333) + ((i >>> 2) & 0x33333333);
    i = (i + (i >>> 4)) & 0x0f0f0f0f;
    i = i + (i >>> 8);
    i = i + (i >>> 16);
    return i & 0x3f;
}

void main()
{
    N = readln.chomp.to!int;

    foreach (i; 0..N) {
        auto f = readln.split.to!(int[]);
        foreach (j, b; f) if (b) FS[i] |= (1<<j);
    }
    foreach (i; 0..N) PS[i][] = readln.split.to!(int[])[];

    int solve(int i, uint key) {
        if (i == 10) {
            if (!key) return int.min;
            int sum_c;
            foreach (j; 0..N) sum_c += PS[j][bit_count(FS[j] & key)];
            return sum_c;
        } else {
            return max(solve(i+1, key), solve(i+1, key | (1<<i)));
        }
    }

    writeln(solve(0, 0));
}

Measured memory_bytes: 380
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 

vi a(100005);
 
int32_t main()
{
    fast;
    int n, val, tot = 0; cin >> n;
    For(i, 0, n) {
        cin >> val;
        tot += val;
        a[val]++;
    }
    int q; cin >> q;
    while(q--) {
        int b, c;
        cin >> b >> c;
        tot -= (a[b] * b);
        tot += (a[b] * c);
        a[c] += a[b];
        a[b] = 0;
        cout << tot << "\n";

    }
    
    return 0;
}

Measured memory_bytes: 3900