akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  intll a,b ,c;
  cin >> a >> b >> c ;
  string ans = "Yes";
  
  if(c-b-a < 0)
    ans = "No";
  
  intll large = (c-b-a)*(c-b-a);
  intll left = 4*a*b ;
  
  if(left >= large)
    ans = "No";
  
  cout << ans ;
    


}


Measured memory_bytes: 256
object Main extends App{
  
  override def main(args :Array[String]):Unit = {
    
    val input = io.StdIn.readLine.split(' ')
    
    val a:point = point(input(0).toDouble, input(1).toDouble)
    val b:point = point(input(2).toDouble,input(3).toDouble)
    
    val length = a.distanceFrom(b)
    
    println(length)
  }
  
  
  case class point(x: Double, y: Double){
    def distanceFrom(p: point): Double = {
      Math.sqrt((x - p.x) * (x-p.x) + (y-p.y)*(y-p.y)) 
    }
  }
  
}

Measured memory_bytes: 43712
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=str(input())
t=list(t)
a=[0]*n
ans=0
for i in range(k):
  if t[i]=="r":
    ans=ans+p
    a[i]="r"
  if t[i]=="s":
    ans=ans+r
    a[i]="s"
  if t[i]=="p":
    ans=ans+s
    a[i]="p"
for i in range(k,n):
  if t[i]!=a[i-k]:
    if t[i]=="r":
      ans=ans+p
      a[i]="r"
    if t[i]=="s":
      ans=ans+r
      a[i]="s"
    if t[i]=="p":
      ans=ans+s
      a[i]="p"
print(ans)    

Measured memory_bytes: 10532
# -*- coding: utf-8 -*-
"""
D - Water Bottle
https://atcoder.jp/contests/abc144/tasks/abc144_d

"""
import sys


from math import tan, radians, pi

def is_ok(a, b, x, d):
    if b * tan(pi/2 - radians(d)) <= a:
        return (b * b * tan(pi/2 - radians(d)) * a) / 2 >= x
    else:
        return a * a * (b - a * tan(radians(d))) + (a * a * a * tan(radians(d))) / 2 >= x


def solve(a, b, x):
    lb, ub = 0.0, 90.0
    for _ in range(100):
        mid = (lb + ub) / 2
        if is_ok(a, b, x, mid):
            lb = mid
        else:
            ub = mid
    return (lb + ub) / 2


def main(args):
    a, b, x = map(int, input().split())
    ans = solve(a, b, x)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (t.compare(s) > 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

def solve():
    N = int(input())
    S = input()

    ans = 0
    x = 0

    for moji in S:
        if moji == "I":
            x += 1
            ans = max(ans, x)
        else:
            x -= 1
    
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main(){
    int n,k;

    cin >> n;
    cin >> k;
    int ans = 0;
    for(int i=0;i<n;i++){
        int h;
        cin >> h;
        if(h>=k){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    char s[100+1];
    scanf("%s",s);
    for(int i=0;i<101;i++){
        for(int j=i+1;j<101;j++){
            if(s[i]=='C'){
                if(s[j]=='F'){
                    printf("Yes\n");
                    return 0;
                }
            }
        }
    }
    printf("No\n");
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max(a,b)-min(a,b))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)n,(int)n)
#define nHr(n,r) nCr((int)(n+r+1),(int)r)
#define sankaku(x) ((1+x)*x)/2
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
void initialize(){
  
}
void swap(ll *p,ll *q){
  ll tmp;
  tmp = *p;
  *p = *q;
  *q = tmp;
}
int main(void){
  initialize();
  ll n,k,i,j,result=0,sum=0;
  int a[LIMIT1];
  char s[LIMIT1];

  scanf("%lld %lld",&n,&k);
  result = min(n%k,k-n%k);
  printf("%lld",result);
  return 0;
}

Measured memory_bytes: 128
# 自然数aをn乗してmodを取った数
def fast_pow(a:int, n:int, mod:int) -> int:
    
    res = 1
    
    while n>0:
        if n & 1:
            res = res*a % mod
            
        a = a*a % mod
        n >>= 1
        
    return res


S = input()
N = len(S)
mod = 10**9+7

# 初期設定
a_left = 0
q_left = 0
c_right = S.count("C")
q_right = S.count("?")
ans = 0

# 0回目の更新
if S[0] == "C":
    c_right -= 1
elif S[0] == "?":
    q_right -= 1
    
# 1～N-1回目の更新
for i in range(N-1):
    if S[i] == "A":
        a_left += 1
    elif S[i] == "?":
        q_left += 1
        
    if S[i+1] == "C":
        c_right -= 1
    elif S[i+1] == "?":
        q_right -= 1
        
    if S[i+1] == "B" or S[i+1] == "?":
        ans += ((q_left*fast_pow(3,q_left-1,mod)+a_left*fast_pow(3,q_left,mod))\
                * (q_right*fast_pow(3,q_right-1,mod)+c_right*fast_pow(3,q_right,mod)) % mod)


        
print(ans%mod)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
constexpr Int MOD = 1e9 + 7;
int main()
{
    int N; cin >> N;
    vector<int> A(N), B(N), mi(N, 1), ma(N, 2e9);
    for (auto &a : A) cin >> a;
    for (auto &b : B) cin >> b;
    for (int i = 0; i < N; i++) {
        int prev = (i == 0 ? 0 : A[i-1]);
        if (prev < A[i]) mi[i] = max(mi[i], A[i]);
        ma[i] = min(ma[i], A[i]);
    }
    for (int i = N-1; i >= 0; i--) {
        int prev = (i == N-1 ? 0 : B[i+1]);
        if (prev < B[i]) mi[i] = max(mi[i], B[i]);
        ma[i] = min(ma[i], B[i]);
    }
    Int ans = 1;
    for (int i = 0; i < N; i++) {
        if (mi[i] > ma[i]) ans = 0;
        else ans = ans * (ma[i] - mi[i] + 1) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cctype>
#include <string>

int main() {
    std::string W;
    std::cin >> W;

    for (auto &c: W) c = tolower(c);

    int ans = 0;
    std::string t;
    while (std::cin >> t) {
        std::string T;
        for (auto &c: t) {
            if (isalpha(c)) T += tolower(c);
        }

        if (T == W) ans++;
    }

    std::cout << ans << std::endl;
}



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

using namespace std;

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;

#ifdef WIN32
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

const int maxn = 100005;

bool was[maxn];
int a[maxn];
int pos[maxn];
set<int> need[maxn];
set<int> waiting;
int ans[maxn], posans[maxn];
int n, m, q;

set<pair<int, int>> wass;

int main()
{
	scanf("%d%d", &n, &m);
	scanf("%d", &q);
	for (int i = 0; i < q; i++)
	{
		scanf("%d", &a[i]);
		a[i]--;
// 		scanf("%d", &a[m + i]);
// 		a[m + i]--;
	}
// 	q += m;
	for (int i = 0; i < m; i++) was[i] = false;
	for (int i = 0; i < n; i++)
	{
		need[a[q - 1]].insert(i);
		pos[i] = 0;
	}
	ans[0] = a[q - 1];
	was[a[q - 1]] = true;
	int anslen = 1;
	for (int i = q - 1; i >= 0; i--)
	{
		if (need[a[i]].size() > 0)
		{
			int wh = *need[a[i]].begin();
			need[a[i]].erase(need[a[i]].begin());
			pos[wh]++;
			if (anslen > pos[wh]) need[ans[pos[wh]]].insert(wh);
			else waiting.insert(wh);
			continue;
		}
		if (was[a[i]]) continue;
		ans[anslen] = a[i];
		anslen++;
		for (auto t : waiting)
		{
			need[a[i]].insert(t);
		}
		waiting.clear();
		was[a[i]] = true;
		{
			int wh = *need[a[i]].begin();
			need[a[i]].erase(need[a[i]].begin());
			pos[wh]++;
			if (anslen > pos[wh]) need[ans[pos[wh]]].insert(wh);
			else waiting.insert(wh);
		}
	}
// 	cout << anslen << endl;
// 	for (int i = 0; i < anslen; i++) cout << ans[i] << ' ';
// 	cout << endl;
// 	for (int i = 0; i < n; i++) cout << pos[i] << ' ';
// 	cout << endl;
	for (int i = 0; i < m; i++) posans[i] = m;
	for (int i = 0; i < anslen; i++) posans[ans[i]] = i;
	for (int i = 0; i < n; i++) if (pos[i] < anslen)
	{
// 		cout << i << ' ' << pos[i] << endl;
		int cur = 0;
		while (pos[i] < anslen && cur < m)
		{
// 			cout << cur << ' ' << posans[cur] << ' ' << pos[i] << endl;
			if (wass.count({pos[i], cur}))
			{
				pos[i] = anslen;
				break;
			}
			wass.insert({pos[i], cur});
			if (posans[cur] > pos[i])
			{
				printf("No\n");
				return 0;
			} else if (posans[cur] == pos[i])
			{
				pos[i]++;
				cur++;
			} else
			{
				cur++;
			}
		}
		if (pos[i] < anslen)
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
    return 0;
}

Measured memory_bytes: 16128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll =  long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;


constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
	template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
	template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
	template<typename T> void chadd(T& a, T b) { a = a + b; }

	void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }


	// 標準入出力
	struct inp {
		size_t sz;
		inp(size_t _sz = 1) : sz(_sz) {}
		template <typename T> operator T () const { T a; std::cin >> a; return a; }
		template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
		template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
	};

	inp inp1; // input one
}

int main() {

	int n = inp1;
	vector<int> x(n), y(n);
	rep(i, n) cin >> x[i] >> y[i];

	vector<int> ord(n);
	iota(allof(ord), 0);

	double ans = 0.0;

	int cnt = 0;
	do {
		++cnt;
		Rep(i, 1, n) {
			ans += sqrt(pow(x[ord[i]] - x[ord[i - 1]], 2) + pow(y[ord[i]] - y[ord[i - 1]], 2));
		}
	} while (next_permutation(allof(ord)));

	ans /= (double)cnt;

	cout << fixed << setprecision(7) << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int n , a[10100] = {0} ;
    for(int i = 1 ; i <= 100 ; i++)
    {
         for(int j = 1 ; j <= 100 ; j++)
         {
              for(int k = 1 ; k <= 100 ; k++)
              {
                    int x = i*i + j*j + k*k + i*j + j*k + k*i ;
                    if(x > 10099)
                    {
                         continue ;
                    }
                    a[x]++ ;
              }
         }
    }
    cin >> n ;
    for(int i = 1 ; i <= n ; i++)
    {
         cout << a[i] << endl ;
    }
}


Measured memory_bytes: 3572
w, h, n = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(n)]

ans=[0,0,w,h]
for i in range(n):
    if xya[i][2] == 1:
        if xya[i][0] >= ans[0]:
            ans[0] = xya[i][0]
    elif xya[i][2] == 2:
        if xya[i][0] <= ans[2]:
            ans[2] = xya[i][0]
    elif xya[i][2] == 3:
        if xya[i][1] >= ans[1]:
            ans[1] = xya[i][1]
    elif xya[i][2] == 4:
        if xya[i][1] <= ans[3]:
            ans[3] = xya[i][1]

print(0 if ans[2]-ans[0] <= 0 or ans[3]-ans[1] <= 0 else (ans[2]-ans[0])*(ans[3]-ans[1]))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
//const N = 2e6, inf = 1e18;

string a, b;
int main()
{
    ll n, m, k;
    set<ll>st;
    for(int i = 0; i < 3; i++)
    {
        ll x;
        cin>>x;
        st.insert(x);
    }
    if(st.size() == 2) puts("Yes");
    else puts("No");
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int a, b, c;

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>


using namespace std;

int height, width;

int dp[1401][1401];
int tiles[1401][1401];


int compute() {
  int maxW = 0;
  for (int h = 0; h < height; ++h)
  {
    dp[h][0] = (tiles[h][0] + 1) % 2;
    maxW = max(dp[h][0], maxW);
  }

  for (int w = 0; w < width; ++w)
  {
    dp[0][w] = (tiles[0][w] + 1) % 2;
    maxW = max(dp[0][w], maxW);
  }

  for (int h = 1; h < height; ++h)
  {
    for (int w = 1; w < width; ++w)
    {
      if (tiles[h][w] == 0 && (h == 0 || w == 0) ){
        dp[h][w] = 1;
        continue;
      }
      if (tiles[h][w] == 1 ){
        dp[h][w] = 0;
      }else{
        dp[h][w] = min(dp[h][w-1], min(dp[h-1][w], dp[h-1][w-1])) + 1;
        maxW = max(dp[h][w], maxW);
      }
    }
  }

  return maxW * maxW;
}



int main(){
  scanf("%d %d", &height, &width);
  for (int h = 0; h < height; ++h)
  {
    for (int w = 0; w < width; ++w)
    {
      scanf( "%d", &tiles[h][w]);
    }
  }

  cout << compute() << endl;
}

Measured memory_bytes: 16540
def resolve():
    def f(x):
        res = x % 4
        if res == 0:
            return x
        elif res == 1:
            return 1
        elif res == 2:
            return x + 1
        else:
            return 0

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

    # 累積和の考えで [0, B] - [0, A-1]
    # 数列を4つ区切りでxorすると0になる
    # 0,1,2,3, -> 00, 01, 10, 11  = 0

    ans = f(B) ^ f(A - 1)
    print(ans)


if __name__ == "__main__":
    resolve()

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

double dp[3000][3002];

int main() {
  int n;
  cin >> n;
  rep(i, n) dp[i][0] = 0;
  rep(i, n+2) dp[0][i] = 0;
  double p;
  cin >> p;
  dp[0][1] = 1 - p; dp[0][2] = p;
  for (int i=1; i<n; i++) {
    cin >> p;
    for (int j=1; j<n+2; j++)
      dp[i][j] = (1-p) * dp[i-1][j] + p * dp[i-1][j-1];
  }
  double ans = 0;
  for (int i=(n/2)+2; i<n+2; i++)
    ans += dp[n-1][i];
  cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 70528
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    var maxProfit = Long.MIN_VALUE
    var minR = scanner.nextLong()
    (2..n).forEach {
        val R = scanner.nextLong()
        maxProfit = Math.max(maxProfit, R - minR)
        minR = Math.min(minR, R)
    }
    println(maxProfit)
}


Measured memory_bytes: 73872
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<b;i++)
#define f(i,n) for(int i=0;i<n;i++)
typedef unsigned long long ull;
typedef long long ll;
#define pb(a) push_back(a);

int main(){
	int n;
	cin>>n;
	// int dp[]
	int choice[n];
	int a[n][3];
	int maxA,maxB,maxC,total,na,nb,nc;
  	int i;
	f(i,n){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
		if(i==0) {
			maxA=a[i][0];
			maxB=a[i][1];
			maxC=a[i][2];
			//total = max(maxA,max(maxB,maxC));
		}
		else{
			na = a[i][0] + max(maxC,maxB);
			nb = a[i][1] + max(maxA,maxC);
			nc = a[i][2] + max(maxB,maxA);
			//total = max(na,max(nc,nb));
			maxA=na;
			maxB=nb;
			maxC=nc;
		}
		
	}
  	if(i==0){total = max(maxA,max(maxB,maxC));}
    else total = max(na,max(nc,nb));
	cout<<total<<endl;
	return 0;
}

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

int main() {
    vector<int> vl, vr;
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int n; cin >> n;
    rep(i,n){
        int a,b; cin >> a >> b;
        vl.push_back(a);vr.push_back(b);
    }
    sort(vl.begin(), vl.end());
    sort(vr.begin(), vr.end());
    if(n%2 == 0){
        cout << vr[n/2]+vr[n/2-1]-vl[n/2]-vl[n/2-1]+1 << endl;
    }
    else {
        cout << vr[n/2]-vl[n/2]+1 << endl;
    }
}

Measured memory_bytes: 5140
using System;
class Program
 {
        static void Main(string[] args)
        {
        bool flag = false;
    　　string[] str = Console.ReadLine().Split(' ');
	    string ab = str[0] + str[1];
		int abc = int.Parse(ab);
          
		for(int i = 1; i * i <= abc; i++) {
			if (i * i == abc) flag = true;
        	}
        
        if(flag) Console.WriteLine("Yes");
        else Console.WriteLine("No");
		}
 }

Measured memory_bytes: 13140
#include<stdio.h>
int main(void)
{
	int a,b,a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,a6,b6,a7,b7;
	scanf("%d",&a1);
	scanf("%d",&b1);
	scanf("%d",&a2);
	scanf("%d",&b2);
	scanf("%d",&a3);
	scanf("%d",&b3);
	scanf("%d",&a4);
	scanf("%d",&b4);
	scanf("%d",&a5);
	scanf("%d",&b5);
	scanf("%d",&a6);
	scanf("%d",&b6);
	scanf("%d",&a7);
	scanf("%d",&b7);
	(-40 <= a <= 40);
	(-40 <= b <= 40);
	
	printf("%d\n",a1-b1);
	printf("%d\n",a2-b2);
	printf("%d\n",a3-b3);
	printf("%d\n",a4-b4);
	printf("%d\n",a5-b5);
	printf("%d\n",a6-b6);
	printf("%d\n",a7-b7);
	return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);++i)
#define rep2(i,a,b) for (int i=(a);i<(b);++i)
#define rrep(i,n) for (int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
const int mod = 1e9 + 9;
using Graph = vector<vector<int>>;
const double EPS = 1e-8;
inline int sgn(double a, double b = 0) { return a < b - EPS ? -1 : a > b + EPS ? 1 : 0; }

double p, q;
int a, n;

int dfs(int i, int t, int A, double B) {
    if (sgn(B, p / q) == 0) return 1;
    if (sgn(B, p / q) == 1) return 0;
    if (i >= n) return 0;

    int ret = 0;
    for (int x = t; A * x <= a; x++) {
        ret += dfs(i + 1, x, A * x, B + 1. / x);
    }
    return ret;
}

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

    int testcase = 0;
    while (cin >> p >> q >> a >> n, n) {
        cout << dfs(0, 1, 1, 0) << endl;
    }
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b, c, d, e, m;
  cin >> n >> a >> b >> c >> d >> e;
  m = min( { a, b, c, d, e });
  cout << (n <= m ? 0 : (n - m) / m + (n % m ? 1 : 0)) + 5;
  return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np
import copy
import itertools
sys.setrecursionlimit(1000000)
 
N,M = map(int,input().split())

ks =  [[int(i) for i in input().split()] for M in range(M)]

p_amari = list(map(int,input().split()))

kouho = []

for i in range(2**N):
    kouho.append(format(i, '0'+str(N)+'b'))

temp = 0

end = 0

ans = len(kouho)


for i in range(len(kouho)):
    #print(i)
    end = 0
    for j in range(M):
        if end == 1:
            break
        temp = 0
        for k in range(ks[j][0]):
            temp = temp + int(kouho[i][ks[j][k+1]-1])
            if k == ks[j][0] - 1:
                #print(temp)
                #exit()
                if temp % 2 == p_amari[j]:
                    continue
                else:
                    end = 1
                    ans = ans - 1
                    break
        
    
print(ans)

Measured memory_bytes: 14452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

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

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  map<string, int> mp;
  REP(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3668
#include<iostream>
#include<math.h>
#include<string>
using namespace std;

#define rep(i,n) for(i=0;i<n;i++)
int main(){
    long long H,W;
    cin>>H>>W;
    if(H==1 || W==1){
        cout<<'1';
        return 0;
    }else{
        ;
    }
    if((H*W)%2==0){
        cout<<(H*W)/2;
        return 0;
    }else{
        cout<<((H*W)+1)/2;
    }
    return 0;
}


Measured memory_bytes: 3604
T = input()
P = input()

mod = 2 << 61-1
base = 1293

def gethash(S):
    H = 0
    b = 1
    for s in S[::-1]:
        H = (H + ord(s) * b) % mod
        b = b * base % mod
    return H

lp = len(P)
Hp = gethash(P)
Hs = gethash(T[:lp])
m = pow(base, lp, mod)

for i in range(len(T)-lp):
    if Hs == Hp:
        print(i)
    Hs = (Hs * base - ord(T[i]) * m + ord(T[i+lp])) % mod
if Hs == Hp:
    print(len(T)-lp)



Measured memory_bytes: 7516
import sys
input = lambda : sys.stdin.readline().rstrip()

r, g, b = map(int, input().split(" "))
k = int(input())

for i in range(k):
    if g <= r:
        g *= 2
    elif b <= g:
        b *= 2
if b > g > r:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 64340
#include<bits/stdc++.h>
using namespace std;
const int maxN = 1e3 + 13;
int n, ans, x;
bool mark[maxN];
vector<int> vec;
int main () {
    cin >> n;
    for (int i = 0; i < n; i++) {
	int a;
	cin >> a;
	x ^= a;
	a = __builtin_ctz(a);
	mark[a] = 1;
    }

    while (x) {
	vec.push_back(x % 2);
	x /= 2;
    }
    int indx = vec.size() - 1;
    int lst = 0;
    while (vec.size()) {
	int u = vec.back();
	vec.pop_back();
	if (u != lst) {
	    if (!mark[indx])
		return cout << -1 << endl, 0;
	    else
		ans++;
	}
	indx--;
	lst = u;
    }
    cout << ans << endl;
}

    


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	if(llabs(a-b)<=t*(v-w))
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <cstdlib>
#define ll long long
using namespace std;

int main(){

  ll n, snuke = 0, kuma = 0, min_c;
  ll a[200010];

  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(i != n-1) snuke += a[i];
  }
  min_c = abs(snuke - a[n-1]);
  for(int i = n-1; i >= 1; i--){
    kuma = kuma + a[i];
    min_c = min(min_c, abs(snuke - kuma));
    snuke = snuke - a[i-1];
  }
  cout << min_c << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x( N ), y( M );
    for( auto &a : x )
    {
        cin >> a;
    }
    for( auto &b : y )
    {
        cin >> b;
    }
    vector<int> v;
    REP( i, 100 )
    {
        if( i > *max_element( ALL( x ) ) && i <= *min_element( ALL( y ) ) )
        {
            v.emplace_back( i );
        }
    }
    REP( i, (int)v.size() )
    {
        if( X < v[ i ] && v[ i ] <= Y )
        {
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

a = [[int(i) for i in input().split()] for _ in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]

for bingo_num in b:
    for line in range(3):
        if bingo_num in a[line]:
            a[line][a[line].index(bingo_num)] =0

flag = False
for i in range(3):
    if a[i]==[0,0,0]:
        flag=True
    if a[0][i]==a[1][i]==a[2][i]==0:
        flag=True
if a[0][0]==a[1][1]==a[2][2]==0:
    flag = True
if a[2][0]==a[1][1]==a[0][2]==0:
    flag = True

print("Yes" if flag else "No")


Measured memory_bytes: 27116
N = int(input())
A = list(map(int, input().split()))
neg = 0
for i in range(N):
  if A[i] < 0:
    neg += 1
    A[i] = -A[i]
tot = 0
for i in range(N):
  tot += A[i]
if neg % 2 == 0:
  print(tot)
else:
  print(tot - 2 * min(A))


Measured memory_bytes: 14332
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  string s;
  cin >> s;
  bool c = false, ans = false;
  for (auto e : s) {
    if (e == 'C')
      c = true;
    if (c && e == 'F')
      ans = true;
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int main()
{
    int N;
    cin >> N;
    long long ret = 0;
    for (int i = 1; i <= N; i++)
    {
        if (i % 3 and i % 5)
        {
            ret += i;
        }
    }
    cout << ret << endl;
}


Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main()
{
	int n;
	cin >> n;
	ll ans = 1, mod = 1e9 + 7;
	rep2(i, 1, n + 1)
	{
		ans *= i;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>

using namespace std;

int N, P;
int dp[100001];

void add(int p, int v){
	for(int i=p;i<=N;i+=i&-i) dp[i] = (dp[i]+v)%P;
}

int sum(int p){
	int res = 0;
	for(int i=p;i;i-=i&-i) res = (res+dp[i])%P;
	return res;
}

string itos(int t){
	ostringstream oss;
	oss << t;
	return oss.str();
}

int main(){
	int A, B;
	while(cin >> A >> B >> P && A){
		N = B-A+1;
		memset(dp, 0, sizeof(dp));
		vector< pair<string, int> > vp;
		for(int i=A;i<=B;i++) vp.push_back(make_pair(itos(i), i));
		sort(vp.begin(), vp.end());
		for(int i=0;i<vp.size();i++){
			int idx = vp[i].second-A+1;
			add(idx, sum(idx-1)+1);
		}
		cout << sum(N) << endl;
	}
}

Measured memory_bytes: 7828
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

        }

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define all(a)  (a).begin(), (a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i = 0; i < n; i++)
#define repR(i,n) for(int i = n-1; i >= 0; i--)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define PB push_back
#define MP make_pair
#define INF (1e12)


int main(){
    int n, m;
    cin >> n >> m;
    vector<int> cnt(m);
    rep(i,m) cnt[i] = 0;
    int k,a;
    rep(i,n){
        cin >> k;
        rep(j,k){
            cin >> a;
            cnt[a-1]++;
        }
    }
    int ans = 0;
    rep(i,m){
        if(cnt[i] == n) ans++;
    }
    cout << ans << endl;
}


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

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int ans=0;
    int money=0;
    
    while(money<c){
        ans++;
        money+=a;
        if(ans%7==0 && ans!=0) money+=b;
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b) {
        cout << "YES" << endl;
        return 0;
    } else {
        cout << "NO" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using ld = long double;
int mod = 1000000007;
int main(){
    ll n,m;
    ll i,j;
    cin >> n >> m;
    vector<ll> h(n);
    for(i=0;i<n;i++) cin >> h.at(i);
    vector<int> ii(n);
    for(i=0;i<n;i++) ii.at(i)=1;
    for(i=0;i<m;i++)
    {
        ll a,b,mini;
        cin >> a >> b;
        mini=min(h.at(a-1),h.at(b-1));
        //cout << "mini is" << mini << endl;
        if(mini==h.at(a-1))ii.at(a-1)--;
        if(mini==h.at(b-1)) ii.at(b-1)--;
    }
    ll ans=0;
    for(i=0;i<n;i++){
        if(ii.at(i)==1)ans++;
        //cout << ii.at(i);
    }
    //cout << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4580
a,b=map(int,input().split())
aa=-(-a*25//2)
aaa=-(-(a+1)*25//2)-1
bb=b*10
bbb=(b+1)*10-1
if aaa<bb or bbb<aa:
  print(-1)
elif aa<bb:
  print(bb)
else:
  print(aa)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
vector<int>x[1<<17],d[1<<17];int a[1<<18],b[1<<18],ret[1<<17],ans[1<<18],n,m,q,dist[1<<17];
vector<pair<int,int> >y[1<<17];map<pair<int,int>,int>M;
int main(){
	cin>>n>>m>>q;
	for(int i=1;i<=m;i++){
		cin>>a[i]>>b[i];
		x[a[i]].push_back(b[i]);x[b[i]].push_back(a[i]);
	}
	for(int i=1;i<=q;i++){
		int c;cin>>c;
		M[make_pair(a[c],b[c])]=i;
		M[make_pair(b[c],a[c])]=i;
	}
	queue<int>Q;Q.push(1);
	for(int i=1;i<=n;i++)dist[i]=(1<<25);dist[1]=0;
	while(!Q.empty()){
		int a1=Q.front();Q.pop();
		for(int j=0;j<(int)x[a1].size();j++){
			int i=x[a1][j];
			if(dist[i]>dist[a1]+1){dist[i]=dist[a1]+1;Q.push(i);}
		}
	}
	for(int i=1;i<=n;i++){
		d[dist[i]].push_back(i);
		for(int k=0;k<(int)x[i].size();k++){
			int j=x[i][k];
			if(dist[i]>dist[j]){
				y[i].push_back(make_pair(j,M[make_pair(i,j)]));
				//cout<<i<<' '<<j<<' '<<M[make_pair(i,j)]<<endl;
			}
		}
	}
	ret[1]=1<<30;
	for(int h=1;h<=n;h++){
		for(int l=0;l<(int)d[h].size();l++){
			int i=d[h][l];
			for(int k=0;k<(int)y[i].size();k++){
				pair<int,int>j=y[i][k];
				int cs=j.second;if(cs==0)cs=(1<<30);
				ret[i]=max(ret[i],min(ret[j.first],cs));
			}
		}
	}
	//for(int i=1;i<=n;i++)cout<<ret[i]<<' '<<dist[i]<<endl;
	for(int i=1;i<=n;i++){if(ret[i]<=q)ans[ret[i]]++;}
	for(int i=1;i<=q;i++){ans[i]+=ans[i-1];cout<<ans[i]<<endl;}
	return 0;
}

Measured memory_bytes: 48444
#include <iostream>

using namespace std;

int main() {
    int N, T;
    cin >> N >> T;
    int cst = 1001;
    for (int i = 0; i < N; i++){
        int c, t;
        cin >> c >> t;
        if (t <= T){
            cst = min(cst, c);
        }
    }
    if (cst == 1001) {
        cout << "TLE" << endl;
    } else {
        cout << cst << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
main(){
  int n;
  std::cin>>n;
  std::set<char> st;
  for(int i=0;i<n;++i){
    char s;
    std::cin>>s;
    st.insert(s);
  }
  if(st.size()==3)puts("Three");
  else puts("Four");
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;

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

int64_t N, K;
vector<int64_t> a;

// !!! y should always be positive and not equal to 0
int64_t intceil(int64_t x, int64_t y) {
	if (x >= 0) {
		return (x + y - 1)/y;
	} else {
		return x/y;
	}
}

// !!! y should always be positive and not equal to 0
int64_t intfloor(int64_t x, int64_t y) {
	if (x < 0) {
		return (x - y + 1)/y;
	} else {
		return x/y;
	}
}

bool check(int64_t m) {
	int64_t count = 0;
	for (int i = 0; i < N; ++i)
		if (a[i] > 0) {
			int64_t tmp = intfloor(m, a[i]);
			auto found = upper_bound(a.begin(), a.begin() + i, tmp);
			count += found - a.begin();
		}
		else if (a[i] < 0) {
			int64_t tmp = intceil(-m, -a[i]);
			auto found = lower_bound(a.begin(), a.begin() + i, tmp);
			count += a.begin() + i  - found;
		} else {
			if (m >= 0)
				count += i;
		}
	if (count >= K)
		return true;
	else {
		return false;
	}
}

int main () {
    cin >> N >> K;
	rep(i,N) {
		int64_t v;
		cin >> v;
		a.push_back(v);
	}
	sort(a.begin(), a.end());
	const int64_t INF = 1e18;
	int64_t no = -INF-1;
	int64_t ok = INF;
	while (ok - no > 1) {
		int64_t m = (ok + no)/2;
		if (check(m))
			ok = m;
		else 
			no = m;
	}
	cout << ok << endl;
    return 0;
}

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

using namespace std;

/*
//1
int main() {
	int ans = 0;
	for (int i = 0; i < 10; i++) {
		int a;
		cin >> a;
		ans += a;
	}
	cout << ans << endl;

	return 0;
}
*/

/*
//2
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == 1 && b == 1) || c == 1) {
		cout << "Open" << endl;
	}
	else {
		cout << "Close" << endl;
	}

return 0;
}
*/

/*
//3
int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) break;

		int H[110];
		for (int i = 0; i < n + 1; i++) {
			cin >> H[i];
		}

	}

return 0;
}
*/


//4
int main() {
	while (true) {
		int N;
		cin >> N;
		if (N == 0) break;
		int num[4] = {};
		num[0] = N / 1000;
		num[1] = N % 1000 / 100;
		num[2] = N % 100 / 10;
		num[3] = N % 10;

		if (num[0] == num[1] && num[0] == num[2] && num[0] == num[3]) {
			cout << "NA" << endl;
			continue;
		}
		if (N == 6174) {
			cout << 0 << endl;
		continue;
		}

		
		int count = 0;
		while (true) {
			sort(num, num + 4);
			int S = 1000 * num[0] + 100 * num[1] + 10 * num[2] + num[3];
			int L = 1000 * num[3] + 100 * num[2] + 10 * num[1] + num[0];
			N = L - S;
			count++;
			if (N == 6174) {
				break;
			}
			num[0] = N / 1000;
			num[1] = N % 1000 / 100;
			num[2] = N % 100 / 10;
			num[3] = N % 10;
		}

		cout << count << endl;
		
	}
return 0;
}


/*
//5
int main() {


return 0;
}
*/

/*
//6
int main() {


return 0;
}
*/

/*
//7
int main() {


return 0;
}
*/

/*
//8
int main() {


return 0;
}
*/

/*
//9
int main() {


return 0;
}
*/

/*
//10
int main() {


return 0;
}
*/




Measured memory_bytes: 3164
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue
from heapq import heappop, heappush
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

d,n = inpl()
if n == 100:
    n += 1
print(n*100**d)

    

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

int main(){
    int N,fg;
    cin >> N;
    int A[N];
    for(int i = 1;i < N+1;i++){
        cin >> A[i];
    }
    for(int i = 1;i < N+1;i++){
        int g = 0;
        for(int k = 1;k < N+1;k++){
            if(i <= A[k]){
                g++;
            }
        }
        if(i <= g){
            fg = i;
        }
    }
    cout << fg << endl;
    return 0;
}


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

int gcd(int x, int y);
int main(){
    int x, y;
    cin >> x >> y;
    x = gcd(x, y);
    cout << x << endl;
}

int gcd(int x, int y){
    int r;
    if(x < y) swap(x, y);
    while(y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    long long n,k;
    cin>>n>>k;
    vector<long long> a(n),b(n);
    vector<pair<long long,long long>> cnt(n);
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        cnt[i]=make_pair(a[i],b[i]);
    }
    sort(cnt.begin(),cnt.end());
    long long p=0;
    for(int i=0;i<n;i++){
        p+=cnt[i].second;
        if(p>=k){
            cout<<cnt[i].first<<endl;
            return 0;
        }
    }
    
}

Measured memory_bytes: 3328
abm = [int(i) for i in input().split(" ")]
a = [int(i) for i in input().split(" ")]
b = [int(i) for i in input().split(" ")]

xyc = []
for i in range(abm[2]):
  xyc.append([int(i) for i in input().split(" ")])

minDiscount = float("inf")
for i in xyc:
  minDiscount = min(a[i[0]-1] + b[i[1]-1] - i[2], minDiscount)

minNotDiscount = min(a) + min(b)

print(min(minDiscount, minNotDiscount))

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

int prime[55555];
int t[55555];

void init()
{
    memset(prime,0,sizeof(prime));
    prime[0]=prime[1]=1;
    for(int i=2;i<55555;i++)
    {
        for(int j=i+i;j<55555;j+=i)
        {
            prime[j]=1;
        }
    }
//    for(int i=0;i<117;i++)
//    {
//        if(!prime[i])
//            printf("%d\n",i);
//    }
}

int main()
{
    memset(t,0,sizeof(t));
    init();
    int n;
    scanf("%d",&n);
    int ans=0;
    for(int i=0;i<55555;i++)
    {
        if(!prime[i]&&(i-1)%5==0)
        {
            t[ans++]=i;
        }
    }
    printf("%d",t[0]);
    for(int i=1;i<n;i++)
    {
        printf(" %d",t[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;

vector<vector<int>> e;

int solve(vector<int> arrived, int c) {
  arrived[c] = 1;

  int sum = accumulate(arrived.begin(), arrived.end(), 0);
  if (sum == arrived.size()) return 1;

  int res = 0;
  for (int i=0; i < arrived.size(); i++) {
    if (arrived[i] == 1) continue;
    // cout << i << endl;
    if (e[c][i] != 0) res += solve(arrived, i);
  }

  return res;
}

int main() {
  int N, M;
  cin >> N >> M;
  e = vector<vector<int>>(N,vector<int>(N, 0));

  
  for (int i=0; i<M; i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    e[a][b] = 1;
    e[b][a] = 1;
  }

  vector<int> v(N, 0);
  v[0] = 1;
  cout << solve(v, 0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    int M = 1 << N;
    vector<int> A(M);
    rep(i, M) cin >> A[i];
    sort(A.begin(), A.end());
    vector<int> slimes;
    slimes.push_back(A.back());
    A.back() = -1;
    rep(i, N) {
        sort(slimes.begin(), slimes.end());
        vector<int> prev = slimes;
        int cur = M-1;
        while (!prev.empty() && cur >= 0) {
            if (A[cur] == -1) {
                cur--; continue;
            }
            if (A[cur] < prev.back()) {
                slimes.push_back(A[cur]);
                A[cur] = -1;
                prev.pop_back();
            }
            cur--;
        }
        if (!prev.empty()) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
    // ll, 0, -, 1i, for s&g, debug
}

Measured memory_bytes: 5864
import math
while 1:
  a, op, b = input().split()
  a = int(a)
  b = int(b)
  
  if op == "?":
    break
  elif op == "+" :
    print(a+b)
  elif op == "-":
    print(a-b)
  elif op == "*":
    print(a*b)
  elif op == "/":
    print(a//b)


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

using namespace std;

typedef long long int lli;

class UnionFind {
private:
    vector<int> data;

public:
    UnionFind(int size) : data(size, -1) { }
    
    int root(int x) {
        return (data[x] < 0) ? x : data[x] = root(data[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }

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

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

int main() {
    int n, m, x, y, z;

    cin >> n >> m;
    
    UnionFind uf(n+1);
    for (int i=0; i<m; i++) {
        cin >> x >> y >> z;
        uf.unite(x, y);
    }

    int ans = 0;
    for (int i=1; i<=n; i++) {
        if (uf.root(i) == i) ans++;
    }

    cout << ans << endl;

    return 0;
}


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

namespace _0011
{
    class Program
    {
        static void Main(string[] args)
        {
            int w = int.Parse(Console.ReadLine());
            int n = int.Parse(Console.ReadLine());

            int[] amidakuji = new int[w];
            amidakuji = Enumerable.Range(1,w).ToArray();

            for (int i = 0; i < n; i++)
            {
                string[] temp = Console.ReadLine().Split(',');
                int x = int.Parse(temp[0]) - 1;
                int y = int.Parse(temp[1]) - 1;

                int a = amidakuji[x];
                amidakuji[x] = amidakuji[y];
                amidakuji[y] = a;
            }
            foreach (int item in amidakuji)
            {
                Console.WriteLine(item);
            }
        }
    }
}



Measured memory_bytes: 18304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
int n,a[15],x[15][15],y[15][15],ans=0;
void check(int bits)
{
	int num=0;
	REP(i,n)
		if(bits>>i&1)
		{
			++num;
			REP(j,a[i])
				if((bits>>x[i][j]&1)!=y[i][j])return;
		}
	ans=max(ans,num);
}
int main()
{
	cin>>n;
	REP(i,n)
	{
		cin>>a[i];
		REP(j,a[i])cin>>x[i][j]>>y[i][j],--x[i][j];
	}
	rep(bits,1,1<<n)check(bits);
	cout<<ans<<endl;
	return 0;
}


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

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

const int MAXN = 120 * 1000;

int a[MAXN];
long long d[MAXN][2];

int main () {
//  ios_base::sync_with_stdio(0);
//	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);

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

	d[0][0] = 0;
	d[0][1] = -1;
	for (int i = 0; i < n; ++i) {
		d[i + 1][0] = d[i][0] + (a[i] / 2);
		if (d[i][1] >= 0 && a[i] > 0) {
			d[i + 1][0] = max(d[i + 1][0], d[i][1] + ((a[i] - 1) / 2) + 1);
		}
		d[i + 1][1] = -1;
		if (a[i] > 0) {
			d[i + 1][1] = d[i][0] + ((a[i] - 1) / 2); 
		}
		if (d[i][1] >= 0 && a[i] > 1) {
			d[i + 1][1] = max(d[i + 1][1], d[i][1] + ((a[i] - 2) / 2) + 1);
		}
	}

	cout << max(d[n][0], d[n][1]) << endl;

	return 0;
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
using ll = long long;

int main() {
    FAST;

    int n;
    cin >> n;
    int m = ceil(double(n)/1000.);
    m *= 1000;
    cout << (m-n) << "\n";

    return 0;
}


Measured memory_bytes: 3636
use std::io::BufRead;

fn main() {
  let stdin = std::io::stdin();
  let mut lines = stdin.lock().lines();

  loop {
    let n = lines.next().unwrap().unwrap()
      .parse::<f64>().unwrap();

    if n == 0. { break; }

    let v = lines.next().unwrap().unwrap()
      .split_whitespace()
      .map(|x| x.parse::<f64>().unwrap())
      .collect::<Vec<_>>();

    let average = v.iter().sum::<f64>() / n;
    let deviation = v.iter()
      .map(|x| (x - average).powi(2))
      .sum::<f64>() / n;

    println!("{}", deviation.sqrt());
  }
}


Measured memory_bytes: 5088