akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
typedef long long ll;
using namespace std;

int main(){
  set<int> s,t;
  int n,m,a;
  cin >> n;
  while(n--){
    cin >> a;
    s.insert(a);
  }
  cin >> m;
  while(m--){
    cin >> a;
    t.insert(a);
  }
  vector<int> v;
  set_union(s.begin(),s.end(),t.begin(),t.end(),back_inserter(v));
  if(v.size()==s.size())cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 23652
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    ll a, b;
    vector<pair<ll, ll > > v;
    for(int i=0;i<m;i++){
    	cin >> a >> b;
    	v.push_back({b, a});
    }
    sort(be(v));
    ll id = -1;
    ll ans = 0;
    for(auto i: v){
    	if(i.second >= id){
    		id = i.first;
    		ans++;
    	}
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  string S;
  int Q;
  cin >> S >> Q;
  bool sei = true;

  vector<char> start(1000000);
  vector<char> end(1000000);

  int sIndex = 0;
  int eIndex = 0;

  rep(i, Q) {
    int r, f;
    char c;
    cin >> r;
    if (r == 2) {
      cin >> f >> c;
    }

    if (r == 1) {
      sei = !sei;
    } else {
      if (f == 1) {
        if (sei) {
          start[sIndex] = c;
          sIndex++;
        } else {
          end[eIndex] = c;
          eIndex++;
        }
      } else {
        if (sei) {
          end[eIndex] = c;
          eIndex++;
        } else {
          start[sIndex] = c;
          sIndex++;
        }
      }
    }
  }
  if (sei) {
    rep(i, start.size()) {
      if (!start[start.size() - 1 - i]) continue;
      cout << start[start.size() - 1 - i];
    }
    cout << S;
    rep(i, end.size()) {
      if (!end[i]) break;
      cout << end[i];
    }
  } else {
    rep(i, end.size()) {
      if (!end[end.size() - 1 - i]) continue;
      cout << end[end.size() - 1 - i];
    }
    reverse(S.begin(), S.end());
    cout << S;
    rep(i, start.size()) {
      if (!start[i]) break;
      cout << start[i];
    }
  }
  cout << endl;

  return 0;
}


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

#define int long long
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define DESYNC ios::sync_with_stdio(0); cin.tie(0);
#define deb(x) cerr << ">> " << #x << " : " << x << "\n";
#define print(a) for(auto &x : a) cout << x << " "; cout << "\n";

const int inf = 1e18 + 5;

// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

void solve()
{
    int x;
    cin >> x;
    int ans = 0;
    if(x >= 400 && x < 600) ans = 8;
    else if(x >= 600 && x < 800) ans = 7;
    else if(x >= 800 && x < 1000) ans = 6;
    else if(x >= 1000 && x < 1200) ans = 5;
    else if(x >= 1200 && x < 1400)  ans = 4;
    else if(x >= 1400 && x < 1600) ans = 3;
    else if(x >= 1600 && x < 1800) ans = 2;
    else ans = 1;
    cout << ans << endl;
}

int32_t main()
{
    DESYNC
    int t = 1;
    // cin >> t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
int main ()
{
	int S, h, m, s;
	scanf("%d", &S);
	h = S / 3600;
	m = S % 3600 / 60;
	s = S % 3600 % 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
} 


Measured memory_bytes: 2092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int input_sec = sc.nextInt();
		int hour = input_sec / 3600;
		int min = ( input_sec % 3600 ) / 60;
		int sec = ( input_sec % 3600 ) % 60;

		System.out.println( hour + ":" + min + ":" + sec );
	}

}


Measured memory_bytes: 26268
#include <stdio.h>
#include <math.h>

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)

int main(void) {
    int A, B, H, M;
    int mn;
    double Ax, Ay, Bx, By;
    double D;

    scanf("%d %d %d %d", &A, &B, &H, &M);

    mn = (H * 60) + M;

    Ax = A * cos(deg_to_rad(((double)(mn / 720.0 * 360))));
    Ay = A * sin(deg_to_rad(((double)(mn / 720.0 * 360))));
    Bx = B * cos(deg_to_rad(((double)(M / 60.0 * 360))));
    By = B * sin(deg_to_rad(((double)(M / 60.0 * 360))));

    D = sqrt(pow((Ax - Bx), 2) + pow((Ay - By), 2));

    printf("%.12lf\n", D);

    return 0;
}


Measured memory_bytes: 2520
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力
		long N = sc.nextLong();
		long K = sc.nextLong();
		long x = Math.abs(N - ((N / K) * K));
		
		int i = 0;
		while (i == 0) {
			long abs = Math.abs(x-K);
			if (abs < x) {
				x = abs;
			} else {
				break;
			}
		}
		System.out.println(x);			
	}

	
	// ユークリッドの控除法(最大公約数を求める)
	private static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	// 複数の最大公約数を求める
	private static long gcdex(long param[]) {
		long g = gcd(param[0], param[1]);
		for (int i = 1; i < param.length-1; i++) {
			g = gcd(g, param[i+1]);
		}
		return g;
	}

	// 最小公倍数を求める
	private static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}

	//
	private static long all(long n, long count, int N) {
		if (count == N) {
			return count;
		}
		return all(1, count, N);
	}

}

Measured memory_bytes: 21844
MOD=1000000007
N=int(input())
A=list(map(int,input().split()))
x=sum(A)%MOD
ans=x*x%MOD
ans+=sum(MOD-A[i]*A[i]%MOD for i in range(N))
ans%=MOD
ans*=500000004
ans%=MOD
print(ans)


Measured memory_bytes: 31580
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;

int main() {

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

	cout << t + s << endl;
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Globalization;
using System.Threading;

namespace atcoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int temp = int.Parse(input[0]);

            if (temp >= 30) Console.WriteLine("Yes");
            else Console.WriteLine("No");

         }
    }
}


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

int main()
{
  bool ans = 0;
  std::string S,T;
  std::cin >> S >> T;
  for(int i = 0;i < S.length();i++){
      for(int j = 0;j < S.length();j++){
         if(S[(j + i) % S.length()] != T[j])break;
         if(j == S.length() - 1)ans = 1;
      }
  }
  if(ans){
    std::cout << "Yes" << "\n";
  }else{
    std::cout << "No" << "\n";
  }
}

Measured memory_bytes: 256
#include "iostream"
#include "cstdio"
#include "vector"
using namespace std;
typedef struct color
{
	double l,a,b;
}color;

double dist(color x,color y)
{
	double L=x.l-y.l,A=x.a-y.a,B=x.b-y.b;
	return L*L+A*A+B*B;
}

int main(void)
{
	int n,m;
	while (cin>>n>>m) {
		double ans=0;
		vector<color> in(n);
		for (int i = 0; i < n; i++) {
			cin>>in[i].l>>in[i].a>>in[i].b;
		}

		for (int i = 0; i < (1<<n); i++) {
			vector<color> sets;
			double cnt=0;
			for (int j = 0; j < n; j++) {
				if(i>>j&1)
				{
					sets.push_back(in[j]);
				}
			}
			if(sets.size()==m)
			{
				for (int j = 0; j < sets.size(); j++) {
					for (int k = j+1; k < sets.size(); k++) {
						cnt+=dist(sets[j],sets[k]);
					}
				}
			}
			ans=max(ans,cnt);
		}
		printf("%.9lf\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
int n;
int d1[105], d2[105];
signed main () {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> d1[i] >> d2[i];
    for (int i = 1; i <= n - 2; i++) {
        if (d1[i] == d2[i] && d1[i + 1] == d2[i + 1] && d1[i + 2] == d2[i + 2]) return puts ("Yes"), 0;
    }
    return puts ("No"), 0;
}


Measured memory_bytes: 3620
N = int(input())
H = list(map(int, input().split()))

_min = min(H)
# print(_min)
counter = _min
for i in range(N):
    H[i] -= _min

buff = [0 for i in range(101)]

for j in range(1, 101):
    flag = False
    for i in range(N):
        if H[i] - j >= 0:
            buff[i] = 1
            if not flag:
                counter += 1
            flag = True
        else:
            if flag:
                flag = False



print(counter)

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

using namespace std;

int main(void)
{
	int a[3],b[3];
	int log[3],x;
	int cnta=0,cntb=0,cntc=0;
	bool out=false;

	for(int i=0;i<4;i++){
		cin>>a[i]>>b[i];

	 	x=a[i]-b[i];
		if(x<0) x*=(-1);
		log[i]=x;
	}

	for(int i=0;i<3;i++){
		 if(log[i]==1) cnta++;
		 if(log[i]==2) cntb++;
		 if(log[i]==3) cntc++;
	}

	if(cnta==1&&cntb==1&&cntc==1) out=true;
	else if(cnta==2&&cntb==1) out=true;

	if(out) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int n, a[100010];
vector<vi> e;

ll maxpair(vector<ll> v){
	if(v.size() < 2) return 0;
	ll res = 0;
	while(v.size() > 1){
		sort(all(v));
		res += min(v[v.size() - 1], v[v.size() - 2]);
		ll d = abs(v[v.size() - 1] - v[v.size() - 2]);
		v.pop_back(); v.pop_back();
		v.pb(d);
	}
	return res;
}
ll maxpair2(vector<ll> v){
	ll res = 0;
	sort(all(v),greater<ll>());
	while(v[1] > 0){
		res++;
		v[0]--; v[1]--;
		sort(all(v),greater<ll>());
		
		if(res > 1000) break;
	}
	return res;
}

ll rec(int c, int p){
	ll sum = 0;
	vector<ll> v;
	for(int i : e[c]) if(i != p) v.pb(rec(i, c));
	
	if(v.empty()) return a[c];
	
	sum = accumulate(all(v), 0ll);
	ll mxp = max(maxpair(v), maxpair2(v));
	
	//dbg(c, p, sum, mxp);
	
	
	bool ng = sum < a[c] || sum - mxp > a[c];
	if(ng){
		cout << "NO" << endl;
		exit(0);
	}
	return 2 * a[c] - sum;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> n;
	rep(i, n) cin >> a[i];
	e.resize(n);
	rep(i, n - 1){
		int j, k; cin >> j >> k; j--; k--;
		e[j].pb(k);
		e[k].pb(j);
	}
	int p = -1;
	rep(i, n) if(e[i].size() > 1) p = i;
	if(p < 0){
		cout << (a[0] != a[1] ? "NO" : "YES") << endl;
		return 0;
	}
	
	cout << (rec(p, p) ? "NO" : "YES") << endl;
	
	return 0;
}

Measured memory_bytes: 18944
nmc=list(map(int,input().split()))
b=list(map(int,input().split()))
a=[]
ans=0
for i in range(nmc[0]):
    a.append(list(map(int,input().split())))

for i in range(nmc[0]):
    x=nmc[2]
    for j in range(nmc[1]):
        x+=a[i][j]*b[j]
    if x>0:
        ans+=1
print(ans)


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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int c[n];
    int a[n][m];
    rep(i, n){
        cin >> c[i];
        rep(j, m){
            cin >> a[i][j];
        }
    }
    ll INF = 1001001001;
    ll ans = INF;
    rep(i, 1<<n){
        ll sum = 0;
        vector<int> d(m, 0);
        rep(j, n){
            if(i>>j & 1){//奇数
                rep(k, m){
                    d[k] += a[j][k];
                }
                sum += c[j];
            }
        } 
        bool check = true;
        rep(j, m){
            if(d[j] < x) check = false;
        }
        if(check) ans = min(ans, sum);
        
    }
    cout << (ans == INF? -1: ans) << endl;
}

Measured memory_bytes: 3640
#include  <iostream>
#include  <stdio.h>
using namespace std;


int main(){

    int N;
    cin >> N;

    double x;
    string u;
    double otoshi;
    otoshi = 0;
    for( int ni = 0 ; ni < N ; ni++ ){
        cin >> x;
        cin >> u;
        if(u == "JPY"){
            otoshi = otoshi + x;
        }else{
            otoshi = otoshi + x * 380000;
        }
    }
    cout << otoshi ;

}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

L,R,d = I()
ans = 0
for i in range(L,R+1):
    if i%d == 0:
        ans += 1
print(ans)

Measured memory_bytes: 72632
#include <iostream>

int main(){
    int x, a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1,
                  14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    };
    std::cin >> x;
    std::cout << a[x-1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ft first
#define sd second
#define pb push_back
using ll = long long;
const int INF = 1e9+7;
const int EPS = -1e6;
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}
const int maxn = 100000+5;

int K, N;
int h[maxn];

int main(){
    //freopen("input.txt", "r", stdin);
    fastio();

    cin >> N>>K;
    for(int i = 0; i < N; ++i)
        cin>>h[i];

    sort(h, h+N);

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

    cout<<ans<<endl;


    return 0;
}


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

int main() {
  ll X;
  cin >>X;
  int ans=0;
  ans=(X/500)*1000;
  ans+=((X%500)/5)*5;
  
  cout << ans << endl;
}


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

#define LL long long
#define MOD 2*1e+5

int poww(int n, int p){
int r = 1;
while(p){
if(p%2==1)
    r=(1LL*r*n)%MOD;
    n=(1LL*n*n)%MOD;
    p/=2;
    }
return r;
}

#define pow poww

main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
/*char s[5];
cin>>s;
if ((s[0]==s[2] && s[1]==s[3]) || (s[0]==s[1] && s[2]==s[3]) || (s[0]==s[3] && s[1]==s[2])) cout<<"Yes";
   else cout<<"No";*/
int n,a[21];
cin>>n;
for (int i=1;i<=n;i++)
    cin>>a[i];
int ans=0;
for (int i=2;i<n;i++)
    if ((a[i]>a[i-1] && a[i]<a[i+1]) || (a[i]<a[i-1] && a[i]>a[i+1])) ans++;
cout<<ans;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ff               first
#define ss               second
#define pb               push_back
#define all(x)           (x).begin(), (x).end()
#define mem0(x)          memset(x, 0, sizeof (x))
#define mem1(x)          memset(x, -1, sizeof (x))

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<vii> vvii;
typedef vector <ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n/x + bool(n%x))*t << "\n";

}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
    int n,l;
    cin>>n>>l;
    vector<pii> vec(n);
    rep(i,n){
        int a,b;
        cin>>a>>b;
        vec[i] = pii(a,b);
    }
    
    int dp[10001]={};
    
    rep(i,n){
        int v,w;
        tie(v,w) = vec[i];
        rep(j,l+1){
            if(j-w>=0)dp[j] = max(dp[j],dp[j-w]+v);
        }
    }
    
    cout<<dp[l]<<endl;
}

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

int main() {
   	int x, y, z, i = 0;
  	cin >> x >> y >> z;
  	while(true){
    	i++;
      	if((y*i) + z * (i+1) > x){
        	cout << i - 1 << endl;
          	return 0;
        }
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};
int main()
{
  ll n, k;
  cin >> n >> k;
  mint ans = 0;
  combination C(2*n);
  auto H = [&](int n, int r) {
    return C(n+r-1, r);
  };
  for(int i = 1; i <= min(k, n); ++i) {
    mint add = C(n, i) * H(n-i, i);
    ans += add;
  }
  ++ans;
  cout << ans.x << endl;
}


Measured memory_bytes: 6528
"use strict";

function main(input) {
  input = input.trim();
  const isUpperCase = (c) => {
    return /^[A-Z]+$/g.test(c);
  };
  if (isUpperCase(input)) {
    console.log("A");
  } else {
    console.log("a");
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


Measured memory_bytes: 29672
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int main() {
    int n;
    cin >> n;
    vector<ll> cnt(n + 1);

    repr(a, 1, n) {
        repr(b, 1, n) {
            if (a * a + b * b + a * b + a + b > n) break;
            repr(c, 1, n) {
                int z = a * a + b * b + c * c + a * b + a * c + b * c;
                if (z > n) break;
                cnt[z]++;
            }
        }
    }

    rep(i, n) {
        cout << cnt[i + 1] << endl;
    }
}

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

int main(){
  	string s;
  	cin >> s;
  	bool flag = false;
  
  	rep(i,0,26){
      flag = false;
      rep(j,0,s.size()){
        if(s[j] == (char)(i+97)){
          flag = true;
          break;
        }
      }
      
      if(!flag){
        cout << (char)(i+97) << endl;
        return 0;
      }
    }
  
  	cout << "None" << endl;
  	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<int(n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const int MAX = 200002;
const int mod = 1e9 + 7;

// fac[]・・・a! finv[]・・・(a!)^(-1) inv[]・・・a^(-1)

long long fac[MAX], finv[MAX], inv[MAX];

void pre_comb(void){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<MAX; i++){
		fac[i] = fac[i-1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod/i) % mod;
		finv[i] = finv[i-1] * inv[i] % mod;
	}
}

long long comb(int n, int k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

ll mpow(ll x, ll r){
	if(r == 1) return x%mod;
	if(r % 2 == 1){
		return mpow(x, r-1)*x%mod;
	}else{
		ll aa = mpow(x, r/2);
		return aa*aa%mod;
	}
}

ll inve(ll x){
	return mpow(x, mod-2);
}

int N;
vector<int> G[MAX];
P dp[MAX];

P dfs(int v, int p = -1){
	ll d = 1, s = 1;
	rep(i, G[v].size()){
		if(G[v][i] == p) continue;
		P p = dfs(G[v][i], v);
		d = (d * p.first) % mod;
		s = (s + p.second) % mod;
		d = (d * comb(s-1, p.second)) % mod;
	}
	return dp[v] = P(d, s);
}

void bfs(int v, int p = -1){
	rep(i, G[v].size()){
		if(G[v][i] == p) continue;
		ll d = dp[G[v][i]].first, s = dp[G[v][i]].second;
		ll dv = dp[v].first;
		d = dv * inve(d*comb(N-1, s)%mod)%mod;
		dp[G[v][i]].first = ((dp[G[v][i]].first*d)%mod)*comb(N-1, s-1)%mod;
		bfs(G[v][i], v);
	}
}

int main(){
	pre_comb();
	cin >> N;
	rep(i, N-1){
		int a, b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(0);
	bfs(0);
	rep(i, N) cout << dp[i].first << endl;
	return 0;
}


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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
	ll n;
	cin >> n;
	for (ll a = 1; a <= 3500; ++a)
		for (ll b = 1; b <= 3500; ++b) {
			ll p = 4 * a * b - n * a - n * b;
			ll q = n * a * b;
			if (p <= 0)
				continue;
			ll g = __gcd(p, q);
			p /= g;
			q /= g;
			if (p == 1) {
				cout << a << " " << b << " " << q << "\n";
				return 0;
			}
		}
	return 0;
}




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

using namespace std;
typedef long long ll;

struct A{
    int cnt, idx;
    A(){
        cnt = 0;
    }
}x[300001], y[300001];

bool cmp(A a, A b){
    return a.cnt > b.cnt;
}

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

    int h, w, m;
    cin >> h >> w >> m;
    int p, q;
    unordered_set<ll> us;
    while(m--){
        cin >> p >> q;
        ++x[p].cnt;
        ++y[q].cnt;
        us.insert(ll(p) * 4 * 100000 + ll(q));
    }
    for(int i = 1; i <= h; ++i)
        x[i].idx = i;
    for(int i = 1; i <= w; ++i)
        y[i].idx = i;
    sort(x + 1, x + h + 1, cmp);
    sort(y + 1, y + w + 1, cmp);
    int i = 1, j = 1;
    int ans = 0;
    for(i = 1; i <= h; ++i){
        if(x[i].cnt + y[1].cnt <= ans)
            break;
        for(j = 1; j <= w; ++j){
            if(x[i].cnt + y[j].cnt <= ans)
                break;
            if(!us.count(ll(x[i].idx) * 4 * 100000 + ll(y[j].idx)))
                ans = x[i].cnt + y[j].cnt;
            else if(x[i].cnt + y[j].cnt - 1 > ans)
                ans = x[i].cnt + y[j].cnt - 1;
        }
    }
    cout << ans << "\n";
    return 0;
}


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

#define EPS 1e-8

int n;
double r;
double ls[3];

int main() {
  while (1) {
    for (int i=0; i<3; i++) scanf("%lf", &ls[i]);
    if (ls[0] == 0.0) return 0;
  
    scanf("%d", &n);
    for (int i=0; i<n; i++) {
      scanf("%lf", &r);
  
      bool found = false;
      for (int i=0; i<3; i++) {
        double d = ls[i]/2;
        if (2*sqrt(r*r-d*d)-EPS > ls[(i+1)%2]) {
          found = true;
          break;
        }
      }
  
      if (found) puts("OK");
      else puts("NA");
    }
  }
}

Measured memory_bytes: 2792
#include <iostream>

using namespace std;

int main()
{
	int n, cnt;

	while(cin >> n)
	{
		cnt = 0;
		for(int a=0; a < 10; a++)
			for(int b=0; b < 10; b++)
				for(int c=0; c < 10; c++)
					for(int d=0; d < 10; d++)
						if(n == (a+b+c+d)) cnt++;
		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>

int main() {
  int total_seconds;
  std::cin >> total_seconds;

  int hours = total_seconds / 3600;
  int minutes = total_seconds / 60 - hours * 60;
  int seconds = total_seconds % 60;
  std::cout << hours << ":" << minutes << ":" << seconds << std::endl;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;



int main(){
  ll n,d,a;
  cin >> n;
  if(n%2==1){n*=2;}
  
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
# 配列入力の受け取り
arrV = np.array(input().split(),dtype=np.int64)
arrC = np.array(input().split(),dtype=np.int64)

arrA = arrV - arrC

filter = arrA > 0
ans = sum(arrA[filter])

print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 12508
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = Long.parseLong(sc.next());
		long b = Long.parseLong(sc.next());
		long x = Long.parseLong(sc.next());
		long ans = func(b, x) - func(a - 1, x);
		System.out.println(ans);
	}
	public static long func(long n, long x) {
		if (n == -1)
			return 0;
		return n / x + 1;
	}
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main(){
  int k;
  long int sum=0;
  cin>>k;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
        sum+=gcd(i,gcd(j,l));
      }
     }
   }
   cout<<sum;
  return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>



using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A& a, const B& b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A& a, const B& b) { a = max(a, (A)b); };



int main() {
	ll inf = 1e18;
	ll N, MA, MB; cin >> N >> MA >> MB;
	vector<ll> A(1+N), B(1+N), C(1+N);
	REP(i, 1, 1+N) cin >> A[i] >> B[i] >> C[i];
	vector < vector < vector <ll>>> dp(1 + N);
	REP(i, 0, 1 + N) {
		dp[i].resize(401);
		REP(j, 0, 401)dp[i][j].resize(401, inf);
	}
	dp[0][0][0] = 0;
	REP(i, 1, N + 1)REP(j, 0, 401)REP(k, 0, 401) {
		dp[i][j][k] = dp[i - 1][j][k];
		if (j - A[i] >= 0 && k - B[i] >= 0) mins(dp[i][j][k], dp[i - 1][j - A[i]][k - B[i]] + C[i]);
	}
	ll ans = inf;
	REP(j, 1, 401)REP(k, 1, 401) {
		if (j * MB == k * MA)mins(ans, dp[N][j][k]);
	}
	if (ans == inf) PRI(-1);
	else PRI(ans);
	return 0;
}


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

int main(){
  int H, W;
  cin >> H >> W;
  
  vector<vector<bool>> fieldBool(H, vector<bool>(W, 0));
  string temp;
  vector<vector<int>> actions = {
    {1,0},
    {0,1},
    {-1,0},
    {0,-1}
  };
  vector<int> action(2);
  int h, w;
  
  // input
  for(int i=0; i<H; i++){
    cin >> temp;
    for(int j=0; j<W; j++){
      if(temp[j] == '#'){
		fieldBool[i][j] = 1;
      }
    }
  }
  
  // distinguish
  bool ans = true;
  int i = 0;
  int j = 0;
  while(ans && i<H){ //i-loop
    j = 0;
    while(ans && j<W){ //j-loop
      if(fieldBool[i][j]){
        ans = false;
        for(int k=0; k<4; k++){
          action = actions[k];
          h = action[0] + i;
          w = action[1] + j;
          if(h>=0 && h<H && w>=0 && w<W){
            if(fieldBool[h][w]){
              ans = true || ans;
            } else {
              ans = false || ans;
            }
          }
        }
      }
      j++;
    }
    i++;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
int main (){
	long double d ; long double t ; long double  s ;
	cin >> d >> t >> s ;
	long  double time = 0;
	time = d/s;
	if(time<=t){
		cout << "Yes" << endl;
	} 
	else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3716
As = list(map(int, input().split()))
As = sorted(As)
ans = 0

if As[-1]-As[0]>=2:
  step = (As[-1]-As[0])//2
  As[0] += step * 2
  ans += step
  
if As[-1]-As[1]>=2:
  step = (As[-1]-As[1])//2
  As[1] += step * 2
  ans += step
    
As = sorted(As)
if As[0]==As[1] and As[-1]>As[1]:
  ans += 1
  
elif As[0]<As[1] and As[1]==As[-1]:
  ans += 2
    
print(ans)

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

int main() {
  int n;
  string s;
  int ans = 0;
  cin >> n >> s;
  rep(i, n - 2) {
    if(s.at(i) == 'A' && s.at(i + 1) == 'B' && s.at(i + 2) == 'C') {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int n = sc.nextInt();
		int ans = 0;
		if (n == 100) {
			ans = (int) Math.pow(100, d) * (n + 1);
		} else {
			ans = (int) Math.pow(100, d) * n;
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
package main

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

func go2School(n int, l []int) []int {
	stack := make([]int, n)
	for i, v := range l {
		stack[v-1] = i + 1
	}
	return stack
}

func main() {
	var n int
	fmt.Scan(&n)

	reader := bufio.NewReaderSize(os.Stdin, 1024*1024)

	human := strings.Split(readLine(reader), " ")

	var h = make([]int, 0)
	for _, v := range human {
		num, err := strconv.ParseInt(v, 10, 64)
		checkError(err)
		h = append(h, int(num))
	}
	for _, v := range go2School(n, h) {
		fmt.Printf("%d ", v)
	}
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}


Measured memory_bytes: 9344
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while(true){

            String x = sc.next();
            int ans=0;

            if(x.equals("0")){break;}
            else{
                for(int i=0;i<x.length();i++){
                    ans += (x.charAt(i)-'0');
                }
                System.out.println(ans);
                ans = 0;
            }
        }
    }
}


Measured memory_bytes: 26376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 998244353;
const ld PI = acosl(-1);

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

    int N, X, T;
    cin >> N >> X >> T;
    cout << (N + X - 1) / X * T << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    ll N, M, V, P;
    cin >> N >> M >> V >> P;
    vector<ll> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(), A.end());

    ll left = -1, right = N-1;
    while(right-left>1){
        ll mid = (right+left)/2;
        ll X = (mid+P)*M;
        bool OK;
        if(A[mid]+M<A[N-P]) OK = false;
        else{
            for(int i=mid+1; i<=N-P; i++){
                X += A[mid]+M-A[i];
            }
            OK = (M*V <= X);
        }
        if(OK) right = mid;
        else left = mid;
    }

    cout << N - right << endl;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main {
    private static int n, c;
    private static long[] w;
    private static long[] v;
    private static long[][] dp;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        c = sc.nextInt();
        w = new long[n];
        v = new long[n];
        dp = new long[c + 1][n];
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextLong();
            v[i] = sc.nextLong();
        }

        for (int i = 0; i <= c; i++) {
            for (int j = 0; j < n; j++) {
                dp[i][j] = -1;
            }
        }
        System.out.println(solveKnapsack(c, 0));
    }

    private static long solveKnapsack(int remcap, int item) {
        if (item == n) {
            return 0;
        }
        if (dp[remcap][item] != -1) {
            return dp[remcap][item];
        }
        long t1 = 0, t2 = 0;
        if (remcap - w[item] >= 0) {
            t1 = solveKnapsack((int) (remcap - w[item]), item + 1) + v[item];
        }

        t2 = solveKnapsack(remcap, item + 1);

        return dp[remcap][item] = Math.max(t1, t2);
    }
}

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

bool exists_ball[3];

int main() {
  exists_ball[0] = true;

  while (1) {
    char a, b;
    if (scanf(" %c,%c", &a, &b) != 2) break;
    swap(exists_ball[a-'A'], exists_ball[b-'A']);
  }

  for (int i=0; i<3; i++) {
    if (exists_ball[i]) printf("%c\n", 'A'+i);
  }
}

Measured memory_bytes: 2552
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    vector<int> like(m);
    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        for(int j = 0; j < k; j++){
            int a;
            cin >> a;
            a--;
            like[a]++;
        }
    }
    int ans = 0;
    for(int i = 0; i < m; i++)
        if(like[i] == n)
            ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
n=int(input())
list=[input() for i in range(n)]

print("AC x " + str(int(list.count('AC'))))
print("WA x " + str(int(list.count('WA'))))
print("TLE x " + str(int(list.count('TLE'))))
print("RE x " + str(int(list.count('RE'))))

Measured memory_bytes: 16216
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;

int main() { _
    int x, a, b;
    cin >> x;
    cin >> a;
    cin >> b;
    x -= a;
    cout << (x % b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> l(2*n);
    for (int i = 0; i < 2*n; ++i) {
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    int ret = 0;
    for (int i = 0; i < 2*n; i += 2) {
        ret += l[i];
    }
    cout << ret << "\n";
    return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



int main() {

	double ans = 0;

	int n;
	cin >> n;
	REP(i, n) {
		double a;
		cin >> a;
		ans += 1 / a;
	}

	ans = 1 / ans;

	cout << setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
  int mi,ma,i,j,n,m,s[10],c[10];
  int tes[10];
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++) scanf("%d %d",&s[i],&c[i]);
  
  if(n==1){
    ma=9;
    mi=0;
  }else{
    ma=pow(10,n)-1;
    mi=pow(10,n-1);
  }
  for(i=mi;i<=ma;i++){
    tes[0]=i/(int)pow(10,n-1);
    if(n>=2) tes[1]=(i-tes[0]*(int)pow(10,n-1))/(int)pow(10,n-2);
    if(n>=3) tes[2]=(i-tes[0]*(int)pow(10,n-1)-tes[1]*(int)pow(10,n-2));

    for(j=0;j<m;j++){
      if(tes[s[j]-1]!=c[j]) break;
    }
    if(j==m){
      printf("%d",i);
      return 0;
    }
  }
  printf("-1");
  return 0;
}

Measured memory_bytes: 2508
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[]) {
	LL n;
	cin >> n;
	LL ans = n;
	for (LL i = 0; i <= n; ++i) {
		LL c = 0;
		LL a;
		LL r = i;
		for (a = 6; a <= r; a *= 6) {
			;
		}
		a /= 6;
		while (a > 0) {
			LL d = r / a;
			r -= a * d;
			c += d;
			a /= 6;
		}
		r = n - i;
		for (a = 9; a <= r; a *= 9) {
			;
		}
		a /= 9;
		while (a > 0) {
			LL d = r / a;
			r -= a * d;
			c += d;
			a /= 9;
		}
		ans = min(ans, c);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int N=3e3+5,mo=1e9+7,iv2=mo+1>>1;
int n,q,a[N],x,y,f[N][N],i,j,ans,mi=1;
int main(){
	scanf("%d%d",&n,&q);
	for(i=1;i<=n;++i)scanf("%d",a+i);
	for(i=1;i<=n;++i)for(j=1;j<=n;++j)f[i][j]=a[i]>a[j];
	for(;q--;){
		static int g1[N],g2[N],g3[N],g4[N];
		scanf("%d%d",&x,&y);
		for(i=1;i<=n;++i)g1[i]=f[i][x],g2[i]=f[x][i],g3[i]=f[i][y],g4[i]=f[y][i];
		j=1ll*iv2*(f[x][y]+f[y][x])%mo;
		for(i=1;i<=n;++i){
			f[i][x]=1ll*iv2*(f[i][x]+g3[i])%mo;
			f[x][i]=1ll*iv2*(f[x][i]+g4[i])%mo;
			f[i][y]=1ll*iv2*(f[i][y]+g1[i])%mo;
			f[y][i]=1ll*iv2*(f[y][i]+g2[i])%mo;
		}
		f[y][x]=f[x][y]=j;mi=mi*2%mo;f[x][x]=f[y][y]=0;
	}
	for(i=1;i<n;++i)for(j=i+1;j<=n;++j)ans=(ans+f[i][j])%mo;
	ans=1ll*ans*mi%mo;
	printf("%d\n",ans);
	return 0;
}

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

int main()
{
    long long n, a, b;
    cin >> n >> a >> b;
  
    long long blue_num;
    if (0 != a + b)
    {
      blue_num = n / (a + b) * a;

      long long amari = n % (a + b);
      if (amari >= a)
      {
        cout << blue_num + a << endl;
      }
      else
      {
        cout << blue_num + amari << endl;
      }
    }
    else
    {
        cout << 0 << endl;
    }

    return 0;
}

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

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long x = sc.nextLong();
		long[] a = new long[N];
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextLong();
		}

		long answer = 0;
		if (a[0] + a[1] > x) {
			if (a[0] >= x) {
				answer += a[1];
				answer += (a[0] - x);
				a[1] = 0;
				a[0] = x;
			} else {
				answer += a[1] - (x - a[0]);
				a[1] = (x - a[0]);
			}
		}


		long current = a[1];
		for (int i = 1; i < a.length - 1; i++) {
			if (current + a[i + 1] > x) {
				answer += a[i + 1] - (x - current);
				a[i + 1] = (x - current);
			}
			current = a[i + 1];
		}
		System.out.println(answer);
	}
}


Measured memory_bytes: 64544
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
int main(){
	int x;
	cin>>x;
	cout<<x*x*x<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		StringBuilder sb = new StringBuilder();
		sb.append(arr[0]);
		for (int i = 1; i < n; i++) {
		    if (arr[i] != arr[i - 1]) {
    	        sb.append(" ");
	    	    sb.append(arr[i]);
		    }
		}
		System.out.println(sb);
	}
}



Measured memory_bytes: 71972
#include<bits/stdc++.h>
#define MAX 100005
using namespace std;
 
int main(){
  int n,  x, a[MAX], i;
  scanf("%d%d", &n, &x);
  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
    a[i] = abs(a[i] - x);
  }
  while(n-1){
    sort(a, a+n);
    if(a[n-2] == 0) break;
    for(i = 0; a[i] == 0; i++);
    for(int j = i+1; j < n; j++) a[j] %= a[i];
  }
  printf("%d\n", a[n-1]);
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>



int point[ 100 ] ;



int desc( const void* a ,const void* b )
{
	return *( int* )b - *( int* )a ;
}



int main()
{
	int cnt = 0 ;
	int ans ;


	int i ,j ,k ;

	int n ;
	scanf( "%d" ,&n ) ;


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


	qsort( point ,100 ,sizeof( int ) ,desc ) ;


	ans = n ;


	for( i = 0 ; i < n ; ++i )
	{
		if( cnt >= ans )
		{
			break ;
		}


		else if( point[ i ] >= ans )
		{
			++cnt ;
		}


		else
		{
			--i ;

			--ans ;
		}
	}


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



	return 0 ;
}

Measured memory_bytes: 600
//????´\??????????????????ITP1-6-A //



#include <stdio.h>
#define N 100

int main(void)
{
	int test[N] ;
	int n,i,a,b,c;
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d", &test[i]);
	}
	for(i=0;i<n-1;i++){
		printf("%d ", test[n-i-1]);
	}
		printf("%d\n", test[0]);
return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a,b,c,count ;
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        count = 0;
        for(int i=a; i<=b; i++){
            if(c%i == 0){
                count++;
            }
        }
        System.out.println(count);
    }
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	cin >> n >> m ;
	ll G = m / n ;
	for(int i = G ; i >= 1 ; i --){
		if( m / i >= n && m % i == 0){
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256