akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MAX (int)1e5+1
#define SENTINEL (int)1e9+1

typedef struct {
    char mark;
    int value;
} Card;

Card L[MAX/2+2], R[MAX/2+2];

void swap(Card *a, Card *b) { Card tmp = *a; *a = *b; *b = tmp; }

void merge(Card A[], int left, int mid, int right) {
    int i, j, k;
    int n1 = mid - left;
    int n2 = right - mid;

    for (i = 0; i < n1; i++) { L[i] = A[left + i]; }
    for (i = 0; i < n2; i++) { R[i] = A[mid + i]; }

    L[n1].value = R[n2].value = SENTINEL;

    i = 0; j = 0;

    for (k = left; k < right; k++) {
        if (L[i].value <= R[j].value) {
            A[k] = L[i++];
        }
        else {
            A[k] = R[j++];
        }
    }
}

void merge_sort(Card A[], int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        merge_sort(A, left, mid);
        merge_sort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int partition(Card A[], int p, int r) {
    int i, j;
    i = p - 1;
    for (j = p; j <= r; j++) {
        if (A[j].value <= A[r].value) {
            i++;
            swap(&A[i], &A[j]);
        }
    }
    return i;
}

void quick_sort(Card A[], int p, int r) {
    if (p < r) {
        int q = partition(A, p, r);
        quick_sort(A, p, q-1);
        quick_sort(A, q+1, r);
    }
}

int main() {
    Card A[MAX], B[MAX];
    int i, n, v;
    int stable = 1;
    char s[10];

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%s %d", s, &v);
        A[i].mark = B[i].mark = s[0];
        A[i].value = B[i].value = v;
    }

    quick_sort(A, 0, n - 1);
    merge_sort(B, 0, n); 

    for (i = 0; i < n; i++) {
        if (A[i].mark != B[i].mark) {
            stable = 0;
            break;
        }
    }

    printf( (stable) ? "Stable\n" : "Not stable\n");

    for (i = 0; i < n; i++) {
        printf("%c %d\n", A[i].mark, A[i].value);
    }

    return 0;
}

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

ans = 0

if X == 1 and Y == 1:
    ans = 700000

if X == 2 and Y == 2:
    print(400000)
    exit()

if X == 3 and Y == 3:
    print(200000)
    exit()

if X == 1 or Y == 1:
    ans += 300000

if X == 2 or Y == 2:
    ans += 200000

if X == 3 or Y == 3:
    ans += 100000
print(ans)


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

int main(){
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    bool vis[400];
    memset(vis,false,sizeof(vis));
    int ans = 0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(!vis[x]){
            vis[x]=true;
            ans++;
        }
    }
    cout<<ans;
    return 0;
}


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

using namespace std;

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

    sort(pro, pro+n);

    int sum = pro[n-1] / 2;
    for(int i = 0; i < n-1; i++) {
        sum = sum + pro[i];
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
n,q = map(int,input().split())
s = input()
pref = [0,0]
for i in range(1,n):
  if s[i] == 'C' and s[i-1] == 'A': pref.append(pref[-1]+1)
  else: pref.append(pref[-1])
for i in range(q):
  l,r = map(int,input().split())
  print(pref[r]-pref[l])

Measured memory_bytes: 6096
def divisor(n)
    a = 0
    for i in 1..n
        if n % i == 0
            a += 1
        end
    end
    a
end

N = gets.to_i
b = 0
for i in 1..N 
    if divisor(i) == 8 && i % 2 == 1
        b += 1
    end
end
puts b


Measured memory_bytes: 1788
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    string str;
    cin >>  str;
    bool n=false,w=false,s=false,e=false;
    for (auto c :  str) {
        switch (c) {
            case 'N':
                n=true;
                break;
            case 'W':
                w=true;
                break;
            case 'S':
                s=true;
                break;
            case 'E':
                e=true;
                break;
        }
    }

    if (n==s && e==w){
        cout << "Yes" << ENDL;
    } else{
        cout << "No" << ENDL;
    }

    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,A[200005];
signed main(){
	cin>>N;
	int ok=N,ng=0;
	rep(i,N){
		cin>>A[i];
		if(i&&A[i-1]>=A[i])ng=1;
	}
	while(ok-ng>1){
		int mid=(ok+ng)/2;
		int ans[20];memset(ans,0,sizeof(ans));
		rep(i,min(20ll,A[0]))ans[i]=1;
		bool flag=true;
		REP(i,N){
			if(A[i]>20)for(int j=A[i-1];j<20;j++)ans[j]=1;
			else {
				if(A[i-1]<A[i])for(int j=A[i-1];j<A[i];j++)ans[j]=1;
				else {
					int now=A[i]-1;
					while(now>=0&&ans[now]==mid)now--;
					if(now==-1)flag=false;
					else {
						ans[now]++;
						for(int j=now+1;j<A[i];j++)ans[j]=1;
					}
				}
			}
		}
		if(flag)ok=mid;
		else ng=mid;
	}
	cout<<ok<<endl;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
int k=sc.nextInt();
int s=sc.nextInt();
int x=0;
int count=0;
int y=0;int z=0;
Set<Integer> al=new HashSet<>();
for(int i=0;i<=k;i++) {
	al.add(i);
}
for(int i=0;i<=k;i++) {
	for(int j=0;j<=k;j++) {
	
			if(al.contains(s-i-j)) {
				count++;
			}
		
}
}
System.out.println(count);
	}

}


Measured memory_bytes: 54100
#include <iostream>

using namespace std;

int main(){
	int a,b,c,maxN,i,operations=0;
	cin >> a >> b >> c;

	maxN=a;
	if(b>maxN)maxN=b;
	if(c>maxN)maxN=c;

	while(true){
		if(a==b&&b==c&&c==a)break;

		for(i=0;i<2;i++){
			if     (a<maxN)a++;
			else if(b<maxN)b++;
			else if(c<maxN)c++;
			else if(a==b&&b==c&&c==a){
				a++;
				maxN++;
			}
		}
		operations++;

	}
	cout<<operations<<endl;
	return 0;
}


Measured memory_bytes: 256
function Main(input) {
  const args = input.split(" ").map((x) => parseInt(x));
  let a = args[0];
  let b = args[1];
  if (a < b) {
    console.log("a < b");
  } else if (a === b) {
    console.log("a == b");
  } else {
    console.log("a > b");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15120
# n = int(input())
a, b, c, k = map(int, input().split())
# l = list(map(int, input().split()))

if k <= a:
    print(k)
elif a < k <= a+b:
    print(a)
elif a+b < k <= a+b+c:
    # print(a - (k - a))
    print(a-(k - a - b))

Measured memory_bytes: 9176
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
template<typename T>
inline T mod(T n, T mod){ T res = n%mod; if(res < 0) res += mod; return res; }

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

const int N = 1e5+5;
int p[N], rnk[N];
bitset<N> sei;

int find(int v){
	if(p[v] == v) return v;
	return p[v] = find(p[v]);
}

void merge(int v, int u){
	int x = find(v);
	int y = find(u);
	if(x != y){
		if(rnk[x] > rnk[y]) swap(x, y);
		p[x] = y;
		if(rnk[x] == rnk[y]) rnk[y]++;
	}
}

int main(){
	fastio;
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		p[i] = i;
		rnk[i] = 0;
	}
	for(int i = 1; i <= m; i++){
		int x, y, z;
		cin >> x >> y >> z;	
		merge(x, y);
		sei[find(x)] = 1;
	}
	set<int> st, other;
	for(int i = 1; i <= n; i++){
		int k = find(i);
		if(!sei[k]){
			st.insert(k);
		}else other.insert(k);
	}
	cout << endl << len(st)+len(other) << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <stack>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
ll v[3333][3333], dp[4][3333][3333];

void solve() {
	int r, c, k; cin >> r >> c >> k;
	for (int i = 0; i < k; i++) {
		ll rr, cc, w; cin >> rr >> cc >> w;
		v[rr - 1][cc - 1] = w;
	}
	for (int i = 0; i < r; i++)
	for (int j = 0; j < c; j++)
	{
			if (v[i][j] > 0) 
			{
				for (int cur = 2; cur >= 0; cur--) 
				{
					dp[cur + 1][i][j] = max(dp[cur + 1][i][j], dp[cur][i][j] + v[i][j]);
				}
			}
			for (int cnt = 0; cnt < 4; cnt++) 
			{
				dp[0][i + 1][j] = max(dp[0][i + 1][j], dp[cnt][i][j]);
				dp[cnt][i][j + 1] = max(dp[cnt][i][j + 1], dp[cnt][i][j]);
			}
		}
	ll ans = 0;
	for (int i = 0; i < c; i++)for (int cnt = 0; cnt < 4; cnt++)ans = max(1ll * ans, dp[cnt][r - 1][i]);
	cout << ans;




}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	// int t; cin >> t;
	// while (t--)
	solve();

}


Measured memory_bytes: 393992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,s,n) for(int i=s; i<n; i++)
#define ALL(x) x.begin(), x.end()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
	int n;
	ll m;
	while(cin >> n >> m, n) {
		vector<pii> v;
		rep(i, n) {
			int d, p;
			cin >> d >> p;
			v.push_back( pii(p, d) );
		}
		sort( v.begin(), v.end() );
		int k = n-1;
		while(k>=0 && m>0) {
			int diff = min(1LL*v[k].second, m);
			v[k].second -= diff;
			m -= diff;
			k--;
		}
		ll sum = 0;
		rep(i, n) {
			sum += v[i].first * v[i].second;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1332
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>
#include <limits.h>
#include <iomanip>
#include <stack>

using namespace std;
using namespace boost::multiprecision;

int A,B;

void solve() {
	cin >> A >> B;
	if (A <= 5)cout << 0 << endl;
	else if (A <= 12)cout << B / 2 << endl;
	else cout << B << endl;
	return;
}

Measured memory_bytes: 256
a = [[int(x) for x in input().split()] for _ in range(3)]
n = int(input())
b = [[0, 0, 0] for _ in range(3)]
def isExist(num):
    global a
    for i in range(3):
        for j in range(3):
            if a[i][j] == num:
                return i, j
    return -1, -1

def judge(b):
    for i in range(3):
        for j in range(3):
            if b[i][j] != 1:
                break
        else:
            return 1
            break
        for j in range(3):
            if b[j][i] != 1:
                break
        else:
            return 1
            break
    for i in range(3):
        if b[i][i] != 1:
            break
    else:
        return 1
    for i in range(3):
        if b[i][2-i] != 1:
            break
    else:
        return 1
    return 0

for _ in range(n):
    num = int(input())
    i, j = isExist(num)
    if i == -1 and j == -1: continue
    b[i][j] = 1

flag = judge(b)
print('Yes' if flag else 'No')

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ.Volume3
{
    public class RelatedProducts
    {
        public static int Main()
        {
            var input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int f = int.Parse(input[1]);

            var product_info = new Dictionary<int, string>();
            int p_id = 0;
            var matrix = new int[n * 10, n * 10];
            for(int i = 0; i < n; i++)
            {
                input = Console.ReadLine().Split(' ');
                int items = int.Parse(input[0]);

                // ???????????±?????????
                for (int j = 1; j <= items; j++)
                {
                    if (product_info.Count(x => x.Value == input[j]) == 0)
                    {
                        product_info.Add(p_id, input[j]);
                        p_id++;
                    }
                }

                // ??????????????£????????????????????????
                for(int j= 1; j <= items; j++)
                {
                    for(int k = 1; k <= items; k++)
                    {
                        if (j == k) { continue; }
                        int p1 = product_info.First(x => x.Value == input[j]).Key;
                        int p2 = product_info.First(x => x.Value == input[k]).Key;

                        matrix[p1, p2]++;
                    }
                }
            }

            // ??????????????°??\??????????????????????????¢???
            var frequency = new List<string>();
            for(int i = 0; i < p_id; i++)
            {
                for(int j = 0; j < p_id; j++)
                {
                    if (matrix[i, j] >= f)
                    {
                        var item_name = new List<string>() { product_info[i], product_info[j] };
                        string output = "";
                        foreach(var s in item_name.OrderBy(x => x)) { output += s + " "; }
                        output = output.Trim();
                        frequency.Add(output);
                    }
                }
            }

            // ??????
            var out_query = frequency.GroupBy(x => x).Select(y => y.Key);
            Console.WriteLine(out_query.Count());
            foreach (var s in out_query.OrderBy(x => x)) { Console.WriteLine(s); }

            return 0;
        }
    }
}

Measured memory_bytes: 19496
n,m,q=map(int,input().split())
l=[]
for i in range(q):
    l.append([int(x) for x in input().split()])
for i in range(q):
    l[i][0]-=1
    l[i][1]-=1
result=0
for i0 in range(1,m+1):
    for i1 in range(i0,m+1):
        for i2 in range(i1,m+1):
            for i3 in range(i2,m+1):
                for i4 in range(i3,m+1):
                    for i5 in range(i4,m+1):
                        for i6 in range(i5,m+1):
                            for i7 in range(i6,m+1):
                                for i8 in range(i7,m+1):
                                    for i9 in range(i8,m+1):
                                        a=[i0,i1,i2,i3,i4,i5,i6,i7,i8,i9]
                                        score=0
                                        for i in l:
                                            if a[i[1]]-a[i[0]]==i[2]:
                                                score+=i[3]
                                        result=max(score,result)
print(result)


Measured memory_bytes: 72104
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n = iter.next().unwrap().parse().unwrap();
    for i in 1..10 {
        for j in 1..10 {
            if i * j == n {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    a,b=map(int, readline().rstrip().split())
    print(int(a*b))
    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16228
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,V,W;
  int T;
  cin>>A>>V>>B>>W>>T;
  int Dist=abs(A-B);
  int VDiff=V-W;
  long long Tot=VDiff*1ll*T;
  long long Diff=Dist;
  if(Tot>=Diff)
    puts("YES");
  else	puts("NO");
  return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int s = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();

        }

        int mod = 998244353;
        long[][] dp = new long[3003][3003];
        dp[0][0] = 1;
        for (int i = 0 ; i < n ; i++) {
            for (int j = 0 ; j <= s ; j++) {
              dp[i + 1][j] += (dp[i][j] * 2);
              dp[i + 1][j] %= mod;
              if (j >= a[i]) {
                  dp[i + 1][j] += dp[i][j-a[i]] % mod;
              }
            }
        }

        System.out.println(dp[n][s] % mod);
    }

}


Measured memory_bytes: 137532
S = input()

def isYYMM(s):
    return isMM(s[2:4])

def isMMYY(s):
    return isMM(s[0:2])

def isMM(s):
    m1, m2 = list(s)
    if m1 == '0':
        if m2 == '0':
            return False
        else:
            return True
    elif m1 == '1':
        return m2 in ('0', '1', '2')
    else:
        return False
            

if isYYMM(S) and isMMYY(S):
    print("AMBIGUOUS")
elif isYYMM(S):
    print("YYMM")
elif isMMYY(S):
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 38384
#include <iostream>

using namespace std;

int main(){
	string s, t;
	bool judge = true;
	cin >> s;
	cin >> t;
	for(int i = 0; i < s.size(); ++i){
		if(s[i] != t[i]){
			judge = false;
		}
	}
	if(judge == true){
		cout << "Yes";
	}
	else if(judge == false){
		cout << "No";
	}
	return 0;
} 

Measured memory_bytes: 3624
num = int(input())
lists = list(map(int,input().split()))
result = "APPROVED"
for i in range(num):
  if lists[i] % 2 == 0:
    if not ((lists[i] % 3 == 0) or (lists[i] % 5 == 0)):
      result = "DENIED"
print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
int main() {
  cout << fixed << setprecision(10);
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll e=lcm(c,d);
  ll sum = b/c-(a-1)/c+b/d-(a-1)/d-b/e+(a-1)/e;
  ll ans = b-a+1-sum;
  cout << ans << endl;
}



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

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

    vector<int> vec(N);
    int a_i, count = 0;
    for (int i = 0; i < N; ++i) {
        cin >> a_i;
        vec.at(i) = a_i;
        if (a_i == 2) {
            count++;
        }
    }

    // calculation
    if (count == 0) {
        cout << -1 << endl;
    } else {
        int idx = vec.at(0) - 1, cnt = 1;  // ボタンは１から（インデックス０から）

        // もしインデックスが２ならこのブロックに入らない（１回で２にいく）
        while(!(idx + 1 == 2)) {
            // infinite loop
            idx = vec.at(idx) - 1;
            cnt++;
            // N回以上いくことはありえない（ループにはまる）
            if (cnt == N) {
                cout << -1 << endl;
                break;
            }
        }

        if (cnt != N) {
            cout << cnt << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 640
N = gets.to_i
A = gets.split.map(&:to_i)

R = [0] + A + [0]
diff = [0]

(N + 1).times do |i|
  diff << diff[i] + (R[i + 1] - R[i]).abs
end

N.times do |i|
  p diff.last - (diff[i + 2] - diff[i]) + (R[i + 2] - R[i]).abs
end


Measured memory_bytes: 18692
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    ll n;
    cin >> n;
    vector<ll> x1(n), x2(n);
    rep(i, n){
        cin >> x1[i];
        x2[i] = x1[i];
    }
    sort(x2.rbegin(), x2.rend());
    ll median = x2[n/2-1];
    rep(i, n){
        if(x1[i] >= median){
            cout << x2[n/2] << endl;
        }
        else{
            cout << median << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define drep(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

ll gcd(ll a,ll b){
    if(a<b){
        int t=a;a=b;b=t;
    }
    int c=a%b;
    while(c!=0){
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}

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

bool isPrime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0)return false;
    }
    return true;
}

int kaizyo(int x){
    if(x==1)return x;
    else return x*kaizyo(x-1);
}


int main() {
    ll a,b;
    
    while(cin>>a>>b){
    cout<<gcd(a,b)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3076
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=55;
int n,A[MAXN],B[MAXN];
vector<int> vec[MAXN],vec1;
bool f[MAXN][MAXN][MAXN];
bool must(int mo)
{
	bool flag=true;
	for(int i=1;i<=n;i++)
	{
		bool tf=false;
		for(auto p:vec[i])if(f[mo-1][p][B[i]]){tf=true;break;}
		if(!tf)flag=false;
	}if(flag)return false;
	for(int i=1;i<=n;i++)
	{
		vec1.clear();
		for(auto p:vec[i])
		{
			if(f[mo-1][p][B[i]])vec1.emplace_back(p);
			if(f[mo-1][p%mo][B[i]])vec1.emplace_back(p%mo);
		}vec[i].clear();sort(vec1.begin(),vec1.end());vec1.erase(unique(vec1.begin(),vec1.end()),vec1.end());
		for(auto p:vec1)vec[i].emplace_back(p);
	}return true;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)A[i]=read();
	for(int i=1;i<=n;i++)B[i]=read();
	for(int i=0;i<=50;i++)f[0][i][i]=1;
	for(int i=1;i<=50;i++)for(int j=0;j<=50;j++)
	{
		memcpy(f[i][j],f[i-1][j],sizeof(f[i][j]));
		int u=j%i;
		for(int k=0;k<=50;k++)f[i][j][k]|=f[i-1][u][k];
	}
	for(int i=1;i<=n;i++)if(!f[50][A[i]][B[i]])
		return pr2(-1),0;
	for(int i=1;i<=n;i++)vec[i].emplace_back(A[i]);
	LL ans=0;
	for(int i=50;i>=1;i--)if(must(i))ans|=(1LL<<i);
	pr2(ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define all(v) v.begin(), v.end()
using namespace std;
int x[100000];
int y[100000];
int z[100000];
vector<int> v[100000];
void init(int a) {
	f(i, a) {
		x[i] = i;
		y[i] = 0;
		z[i] = 1;
	}
}
int find(int a) {
	if (x[a] == a)return a;
	return x[a]=find(x[a]);
}
void unite(int a, int b) {
	a = find(a);
	b = find(b);
	if (a == b)return;
	if (y[a] < y[b]) {
		x[a] = b;
		z[b] += z[a];
	}
	else {
		x[b] = a;
		z[a] += z[b];
		if (y[a] == y[b])y[a]++;
	}
}
bool same(int a, int b) {
	return find(a) == find(b);
}
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
signed main() {
	int n, m, k;
	cin >> n >> m >> k;
	init(n);
	f(i, m) {
		int a, b;
		cin >> a >> b;
		unite(a - 1, b - 1);
		v[a-1].push_back(b-1);
		v[b-1].push_back(a-1);
	}
	f(i, k) {
		int a, b;
		cin >> a >> b;
		v[a-1].push_back(b-1);
		v[b-1].push_back(a-1);
	}
	f(i, n) {
		int a = z[find(i)];
		sort(v[i].begin(),v[i].end());
		f(j, v[i].size()) {
			if (same(i,v[i][j]))a--;
		}
		if (i)cout << " ";
		cout << a-1;
	}
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    REP(i, n) {
        cin >> a[i] >> b[i];
    }

    vector<vector<ll>> dp(n+1, vector<ll>(h+1, INF));
    dp[0][0] = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= h; j++) {
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][min(j+a[i], h)], dp[i+1][j]+b[i]);
        }
    }   

    cout << dp[n][h] << endl;
    //cout << ans << endl;
    return 0;
}

Measured memory_bytes: 78592
#include <iostream>
using namespace std;
int main(void){
    int n,m,c,b[20],ans=0,i,j;
    cin >> n >> m >> c;
    for(i=0;i<m;i++) cin >> b[i];
    for(i=0;i<n;i++){
        int a,tmp=0;
        for(j=0;j<m;j++){
            cin >> a;
            tmp+=a*b[j];
        }
        if(tmp+c>0) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int i;
  char s[100];
  int x[100];
  for(i = 0;i < 100;i++){
  x[i] =0;
  }
  i=0;
  while( scanf(" %s", s) != EOF ){
    if ( s[0] == '+' ){
      x[i-2]=x[i-1]+x[i-2];
      i--;
    } else if ( s[0] == '-' ){
      x[i-2]=x[i-2]-x[i-1];
      i--;
    } else if ( s[0] == '*' ){
      x[i-2]=x[i-1]*x[i-2];
      i--;
    } else {
      x[i] = atoi(s);
      i++;
    }
  }

  printf("%d\n",x[i-1]);
    
    return 0;
  }

Measured memory_bytes: 548
#include <bits/stdc++.h>
 
using namespace std;
 
typedef unsigned long long int ll;
 
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << "\n";
 
    return 0;
}

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

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

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

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, k; cin>>n>>k;
	bool v[105] = {};
	for(int i = 0; i < k; i++){
		int d; cin>>d;
		for(int u = 0; u < d; u++){
			int s; cin>>s;
			v[s] = true;
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) if(!v[i]) ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 3656
N = int(input())
s, t = [], []
for i in range(N):
  s_i, t_i = input().split(" ")
  t_i = int(t_i)
  s.append(s_i)
  t.append(t_i)
X = input()

idx = 0
while idx < N:
  if s[idx] == X:
    idx += 1
    break
  idx += 1

ans = 0
for i in range(idx, N):
  ans += t[i]
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;

double D;

int main() {
    scanf("%lf", &D);
    double ret = D * sqrt(2);
    for (int x = 0; x < D; ++x) {
        int dx = D - x;
        double dy = sqrt(D * D - dx * dx);
        ret = max(ret, dx + dy + max(0.0, 1-dy));
    }
    printf("%.12lf\n", ret);
    return 0;
}

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

int main(void){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i); 
  }
  sort(vec.begin(), vec.end());
  int max = vec.at(N - 1);
  int sum = 0;
  for(int i = 0; i < N - 1; i++){
    sum += vec.at(i);
  }
  if(sum > max) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;

	if(b >= 0 && a <= 0){
		cout<<"Zero"<<endl;
	}
	else if( a > 0 && b > 0){
		cout<<"Positive"<<endl;
	}
	else{
		int c = b - a;
		if(c%2 == 0){
			cout<<"Negative"<<endl;
		}else{
			cout<<"Positive"<<endl;
		}
	}
	return 0;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int d;
    cin >> d;
    
    vector<int> c(26);
    vector<vector<int>> s(d, vector<int>(26, 0));
    vector<int> t(d);
    vector<int> l(26);
    for(int ic=0;ic<26;ic++) {
        cin >> c.at(ic);
    }
    for(int id=0;id<d;id++) {
        for(int iw=0;iw<26;iw++) {
            cin >> s.at(id).at(iw);
        }
    }
    for(int id=0;id<d;id++) {
        cin >> t.at(id); t.at(id)--;
    }

    int v = 0;
    for(int id=0;id<d;id++) {
        v += s.at(id).at(t.at(id));
        l.at(t.at(id)) = id + 1;
        for(int il=0;il<26;il++) {
            v -= c.at(il)*(id + 1 - l.at(il));
        }
        cout << v << endl;
    }
    return 0;
}


Measured memory_bytes: 3680
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str1 = sc.next();
    String str2 = sc.next();
    int i1 = Integer.parseInt(str1);
    int i2 = Integer.parseInt(str2);
    int num = i1-i2;
    if(num>=0){
      System.out.println(num);
    }else{
      System.out.println(0);
    }
  }
}

Measured memory_bytes: 23764
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
public class Main{

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        ArrayList<Double> list = new ArrayList<Double>();
		String current;
        while((current=br.readLine())!=null){
			list.add(Double.parseDouble(current));
		}
        Collections.sort(list);
		System.out.println(list.get(list.size()-1) - list.get(0));
	}
}

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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	
	ll n, a, b;
	cin >> n >> a >> b;
	ll total = n / (a + b) * a;
	total += min(n % (a + b), a);

	cout << total << "\n";



	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}

Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def calcTwoPointDistance(x1, y1, x2, y2):
    return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    sx, sy, tx, ty = il()

    move = []
    for _ in range(sy, ty):
        move.append('U')
    for _ in range(sx, tx):
        move.append('R')
    for _ in range(sy, ty):
        move.append('D')
    for _ in range(sx, tx):
        move.append('L')
    move.append('L')

    for _ in range(sy, ty + 1):
        move.append('U')
    for _ in range(sx, tx + 1):
        move.append('R')
    move.append('D')
    move.append('R')
    for _ in range(sy, ty + 1):
        move.append('D')
    for _ in range(sx, tx + 1):
        move.append('L')
    move.append('U')

    print(*move, sep='')


if __name__ == '__main__':
    main()


Measured memory_bytes: 10732
import java.util.*;
import java.util.function.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] P = new int[N];
    int[] Q = new int[N];
    for (int i = 0; i < N; i++) P[i] = sc.nextInt();
    for (int i = 0; i < N; i++) Q[i] = sc.nextInt();
    sc.close();

   		BiPredicate<int[], Integer> exist = (a, n) -> {
			for (int i = 0; i < a.length; i++) if (a[i] == n) return true;
			return false;
		};


		BiFunction<int[], Integer, Boolean> next_perm = (a, r) -> {
			if (a[0] == 0) {
				for (int i = 0; i < a.length; i++) a[i] = i + 1;
				return true;
			}

			int n = a.length;
			for (int i = n - 1; -1 < i; i--) {
				int b = 0;
				for (int j = a[i] + 1; j < r + 1; j++)
					if (!exist.test(a, j)) {
						b = j;
						break;
					}
				a[i] = b;
				if (a[i] != 0) break;
			}
			if (a[0] == 0) return false;
			for (int i = 0; i < n; i++) {
				if (a[i] != 0) continue;
				for (int j = 1; j < n + 1; j++)
					if (!exist.test(a, j)) {
						a[i] = j;
						break;
					}
			}
			return true;
		};

    long c = 0;
    long p = -1;
    long q = -1;
    int[] a = new int[N];
    while ((p == -1 || q == -1) && next_perm.apply(a, N)) {
      c++;
      if (p == -1 && Arrays.equals(a, P)) p = c;
      if (q == -1 && Arrays.equals(a, Q)) q = c;
    }
    long ans = Math.abs(q - p);
    System.out.println(Math.abs(q - p));
  }
}

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

using D = double;
struct Point {
  int id;
  D x, y;
  Point(const D d = 0.0) : x(d), y(d) {}
  Point(const D x, const D y) : x(x), y(y) {}
};
enum POSITION {ONLINE_FRONT = -2, CLOCKWISE, ON_SEGMENT, COUNTER_CLOCKWISE, ONLINE_BACK};

const D EPS = 1e-9;
const D PI = acos(-1);

bool relative_equal(const D d1, const D d2) {return d1 == 0 ? std::abs(d2) < EPS : std::abs((d1 - d2) / d1) < EPS;}
bool operator==(const Point& lhs, const Point& rhs) {return relative_equal(lhs.x, rhs.x) && relative_equal(lhs.y, rhs.y);}
bool operator<(const Point& lhs, const Point& rhs) {return relative_equal(lhs.x, rhs.x) ? lhs.y < rhs.y : lhs.x < rhs.x;}
bool operator>(const Point& lhs, const Point& rhs) {return relative_equal(lhs.x, rhs.x) ? lhs.y > rhs.y : lhs.x > rhs.x;}
bool operator!=(const Point& lhs, const Point& rhs) {return !(lhs == rhs);}
bool operator<=(const Point& lhs, const Point& rhs) {return !(lhs > rhs);}
bool operator>=(const Point& lhs, const Point& rhs) {return !(lhs < rhs);}
const Point operator+(const Point& lhs, const Point& rhs) {return Point(lhs.x + rhs.x, lhs.y + rhs.y);}
const Point operator-(const Point& lhs, const Point& rhs) {return Point(lhs.x - rhs.x, lhs.y - rhs.y);}
const Point operator*(const Point& lhs, const Point& rhs) {return Point(lhs.x * rhs.x, lhs.y * rhs.y);}
const Point operator/(const Point& lhs, const Point& rhs) {return Point(lhs.x / rhs.x, lhs.y / rhs.y);}
D abs(const Point& p) {return hypot(p.x, p.y);}
D norm(const Point& p) {return p.x * p.x + p.y * p.y;}
D dot(const Point& a, const Point& b) {return a.x * b.x + a.y * b.y;}
D cross(const Point& a, const Point& b) {return a.x * b.y - a.y * b.x;}
POSITION ccw(const Point& a, const Point& b, const Point& p) {
  Point v1 = b - a;
  Point v2 = p - a;
  if(cross(v1, v2) >= EPS) return COUNTER_CLOCKWISE;
  if(cross(v1, v2) <= -EPS) return CLOCKWISE;
  if(dot(v1, v2) <= -EPS) return ONLINE_BACK;
  if(norm(v1) < norm(v2)) return ONLINE_FRONT;
  return ON_SEGMENT;
}

vector<Point> convex_hull(auto P) {
  sort(begin(P), end(P), [](auto l, auto r) {return tuple<D,D,int>(l.x, l.y, l.id) < tuple<D,D,int>(r.x, r.y, r.id);});
  P.insert(end(P), rbegin(P)+1, rend(P));
  vector<Point> res;
  for(const auto& p: P) {
    while(res.size() >= 2 && ccw(res[res.size() - 2], res.back(), p) == CLOCKWISE) res.pop_back();
    res.push_back(p);
  }
  res.pop_back();
  return res;
}

int main() {
  int N;
  cin >> N;
  vector<Point> P(N);
  for(auto& i: P) cin >> i.x >> i.y;
  for(auto i=0; i<N; ++i) P[i].id = i;

  auto ch = convex_hull(P);
  vector<D> d(N);
  for(auto i=0; i<ch.size(); ++i) {
    auto u=ch[i];
    auto v=ch[(i+1)%ch.size()];
    auto w=ch[(i+2)%ch.size()];
    auto a1 = atan2(u.y - v.y, u.x - v.x);
    auto a2 = atan2(w.y - v.y, w.x - v.x);
    auto a = abs(a1-a2);
    if(a < PI) a = 2*PI - a;
    a -= PI;
    d[v.id] += a;
  }
  D sum = 0;
  for(auto i: d) sum += i;
  for(auto i: d) cout << setprecision(8) << fixed << i / sum << endl;
}


Measured memory_bytes: 384
N,K=[int(x) for x in input().split()]
A=[int(x) for x in input().split()]

def go(i, step):
  prevI=i
  m=[0]*N
  cnt=0
  for s in range(step):
    if m[i]:
      period=m[prevI] - m[i] + 1
      return go(i, (step-s) % period)
    cnt+=1
    m[i]=cnt
    prevI=i
    i=A[i]-1
  return i

print(go(0,K)+1)


Measured memory_bytes: 32332
#include <iostream>
using namespace std;
int main(void){
    int N, D, X; cin >> N >> D >> X;
    int A[110];
    for(int i=0; i<N; ++i) cin >> A[i];
    for(int i=0; i<N; ++i) X += (D+A[i]-1)/A[i];
    cout << X << endl;
    return 0;
}


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

int router[200][200];
int b[200][200];

int main(void){
  int N;
  cin >> N;
  for(int n=0; n < N; n++){
    int r, k;
    cin >> r >> k;
    for(int i=0; i < k; i++){
      int tmp; cin >> tmp;
      b[r][tmp] = 1;
    }
  }


  int pac_n;
  cin >> pac_n;
  for(int p=0; p < pac_n; p++){
    int start, des, ttl; cin >> start >> des >> ttl;
    
    queue<pair<int, int> > que;   //<id, now_ttl>
    que.push(make_pair(start, ttl));
    bool flg = false;
    for(int x = 0; x <= N; x++){
      for(int y = 0; y <= N; y++){
        router[x][y] = b[x][y];
      }
    }
    while(!que.empty()){
      pair<int, int> q = que.front(); que.pop();
      if(q.first == des){
        cout << ttl - q.second + 1<< endl;
        flg = true;
        break;
      }
      if(q.second > 1){
        for(int i=0; i <= N; i++){
          if(router[q.first][i] == 1){
            router[q.first][i] = 0;
            que.push(make_pair(i, q.second - 1));
          }
        }
      }
    }
    if(!flg)
      cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 1360
import itertools
ss = [int(input()) for i in range(5)]
mm = list(itertools.permutations(ss))
ans = 0
anss = 10**9
for sc in mm:
    ans = 0
    for i in range(len(sc)):
        if i == 4:
            ans += sc[i]
        else:
            ans += -(-sc[i]//10)*10
    anss = min(anss , ans)
print(anss)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fst first
#define snd second
#define mset(a,v) memset((a),(v),sizeof(a))
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
using namespace std;
typedef long long ll;
const int N=200500;
vector<int> g[N];
ll n,m;
int dp[N],ans[N],fa[N];
int mul(ll a, ll b){
	a*=b;
	return a%m;
}
vector<int> sp[N][2];
int f(int x, int p){
	int &r=dp[x];
	if(r!=-1)return r;
	r=1;
	for(int y:g[x])if(y!=p)r=mul(r,1+f(y,x));
	sp[x][0].resize(SZ(g[x]),1);
	sp[x][1].resize(SZ(g[x]),1);
	fore(i,0,SZ(g[x])){
		int y=g[x][i];
		fa[y]=i;
		if(i==SZ(g[x])-1)continue;
		sp[x][0][i+1]=mul(sp[x][0][i],(y==p?1:dp[y]+1));
	}
	for(int i=SZ(g[x])-1;i>0;i--){
		int y=g[x][i];
		sp[x][1][i-1]=mul(sp[x][1][i],(y==p?1:dp[y]+1));
	}
	return r;
}
void doit(int x, int p, int vpp=1){
	int r=vpp;
	r=mul(r,mul(sp[p][0][fa[x]],sp[p][1][fa[x]]));
	r++;
	ans[x]=mul(dp[x],r);
	if(r>=m)r-=m;
	for(int y:g[x])if(y!=p)doit(y,x,r);
}
int main(){FIN;
	cin>>n>>m;
	fore(i,1,n){
		int x,y;cin>>x>>y;
		x--;y--;
		g[x].pb(y);
		g[y].pb(x);
	}
	memset(dp,-1,sizeof dp);
	ans[0]=f(0,-1);
	for(int y:g[0])doit(y,0);
	fore(i,0,n)cout<<ans[i]<<"\n";
}

Measured memory_bytes: 33664
from numba import njit


@njit("UniTuple(i8, 3)(i8)")
def solve(N):
    for b in range(1, 3500 + 1):
        for c in range(1, 3500 + 1):
            num = N * b * c
            den = 4 * b * c - N * b - N * c
            if den > 0 and num % den == 0:
                a = num // den
                return a, b, c
    return 0, 0, 0


N = int(input())
print(*solve(N))



Measured memory_bytes: 109612
#include <bits/stdc++.h>
using namespace std;
typedef int64_t i64;

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

  

  if(n[0] == '1'){
      cout << "9";
  }else{
      cout << "1";
  }
  if(n[1] == '1'){
      cout << "9";
  }else{
      cout << "1";
  }
  if(n[2] == '1'){
      cout << "9";
  }else{
      cout << "1";
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>

using namespace std;

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

    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    
    int count = 0;
    for (int i = 0; i < n; ++i) {
        set<char> s;
        s.insert(a[i]);
        s.insert(b[i]);
        s.insert(c[i]);
        count += s.size() - 1;
    }
    cout << count;

    return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    string s, t;
    cin >> s >> t;

    REP(i, s.size()){
        if(s == t){
            cout << "Yes" << endl;
            return 0;
        }
        string ss = s.substr(0, s.size()-1);
        s = s[s.size()-1] + ss;
    }
    cout << "No" << endl;
}


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

int main()
{
	int h,w,i,j;
	
	while(1){
	cin>>h>>w;
	
	if(h==0&&w==0)
		break;
	
	for(i=0;i<h;i++){
		if(i==0||i==h-1){
			for(j=0;j<w;j++){
				cout<<"#";
				if(j==w)
				cout<<endl;
					}
				}
		if(i!=0&&i!=h-1){
			for(j=0;j<w;j++){
				if(j==0||j==w-1)
					cout<<"#";
				else cout<<".";
				}
			}
		if(j==w) cout<<endl;
			}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
N = int(input())
import copy
import math
def nP2(N):
    return (math.factorial(N)/((math.factorial(2))*math.factorial(N-2)))
L = list(map(int,input().split()))
Count = [0 for _ in range(N+1)]
for el in L:
    Count[el]+=1
res = 1
for i in Count:
    if i>=2:
        res += nP2(i)
for balls in L:
    print(int(res-Count[balls]))

Measured memory_bytes: 27036
#include <stdio.h>

int main() {
  int N,result=0;
  scanf("%d",&N);
  int A[N];
  for(int i=0;i<N;i++) {
    scanf("%d",&A[i]);
  }
  for(int i=0;i<N;i++) {
    if(A[i]%2==0) {
      if(A[i]%3!=0 && A[i]%5!=0) {
	printf("DENIED");
	result++;
	break;
      }
    }
  }
   if(result==0) {
     printf("APPROVED");
   }
   return 0;
}
  

Measured memory_bytes: 1676
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include <bits/stdc++.h>

using namespace std;
using Graph = vector<vector<int>>;
typedef unsigned long long ll;
ll mod = (10e+8)+ 7;

#define For(N,i) for(int i = 0; i < N; i++)
	
int main(){
	unordered_map<char,int> mp1;
	unordered_map<char,int> mp2;
	int N;
	cin>>N;
	string S;
	cin>>S;
	For(N/2,i){
		mp1[S[i]]++;
		
	}
	for(int i = N/2; i < N; i++){
		mp2[S[i]]++;
	}
	int cnt = 0;
	for(int i = 0; i < 26; i++){
		if(mp1['a'+i] == mp2['a'+i]){
			cnt++;
		}else{
			break;
		}
		
	}
	if(cnt == 26){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

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

typedef long long ll;
typedef pair<int,int> pri;
const int INF = 1e9 + 7;
const ll LINF = 1LL<<61;

ll h;
ll ans;

int main(){
  cin >> h;
  ll t = h;
  while(t){
    t /= 2;
    ans = ans*2 + 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256