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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

// Problem Specific Parameter:

const int limit = 100010;
using edge = struct {int to, cost;};
vector<edge> graph[limit];

int group[1 << 16];

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

	group[0] = 0;
	rep(mask, 1 << 16) {
		rep(i, 1, 16) {
			if (mask & (1 << i)) continue;
			const int nmask = mask | (1 << i);
			int ans = 0;
			rep(j, 1, 16) if (nmask & (1 << j)) ans ^= j;
			chmax(group[nmask], group[mask] + (ans == 0));
		}
	}

	rep(i, n - 1) {
		int x, y, a;
		cin >> x >> y >> a;
		graph[x].push_back({y, a});
		graph[y].push_back({x, a});
	}

	vector<int> num(16, 0);
	rep(v, n) {
		int x = 0;
		for (auto &e : graph[v]) x ^= e.cost;
		num[x]++;
	}

	int ans = n  - num[0], mask = 0;
	rep(i, 1, 16) {
		if (num[i] % 2 == 1) mask |= (1 << i);
		ans -= num[i] / 2;
	}
	ans -= group[mask];

	cout << ans << endl;

	return 0;
}

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

using namespace std;
const int N = 2005;
int n, x, y, a[N], dp[N][N][2];
int sol(int i, int last, int bit)
{
	if(i == n-1) return abs(a[n-1]-a[last]);
	int &ret = dp[i][last][bit];
	if(ret != -1) return ret;
	if(bit)
	{
		ret = min(sol(i+1, last, bit), sol(i+1, i, bit^1));
	}
	else ret = max(sol(i+1, last, bit), sol(i+1, i, bit^1));
	return ret;
}
int main()
{
	cin >> n >> x >> y;
	for(int i=0; i<n; i++) cin >> a[i];
	memset(dp, -1, sizeof dp);
	a[n] = y;
	cout << sol(0, n, 0) << endl;
}

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

int main(){
  int i,j,c,a[5];
  for(i=0;i<5;i++){
    cin>>a[i];
  }
  for(i=0;i<4;i++){
    for(j=i+1;j<5;j++){
      
      if(a[i]<a[j]){
	c=a[i];
	a[i]=a[j];
	a[j]=c;
      }
    }
  }
  for(i=0;i<5;i++){
    cout<<a[i];
    if(i!=4)cout<<' ';
  }
  cout<<endl;
  
  return 0;
}

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

bool isOn(int bit,int i){
    return bit & 1<<(i-1);
}

int main(){
    int n, m; cin >> n >> m;
    vector<vector<int>> lights;
    vector<int> conditions;

    rep(i, m){
        int k; cin >> k;
        vector<int> light;
        rep(j, k){
            int s; cin >> s;
            light.push_back(s);
        }
        lights.push_back(light);
    }
    rep(i, m){
        int p; cin >> p;
        conditions.push_back(p);
    }

    int res = 0;
    for(int bit=0; bit < (1<<n); ++bit){
        int lightOn = 0;
        rep(i, lights.size()){
            int cnt_swc = 0;
            for(auto swc : lights[i]){
                if(isOn(bit, swc)) ++cnt_swc;
            }
            if(cnt_swc%2 == conditions[i]) ++lightOn;
        }
        if(lightOn == m) ++res;
    }
    cout << res << endl;
}


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = int(2e5), alphsz = 26, inf = 0x3f3f3f3f;
int n, lst[alphsz + 5], g[nsz + 5][alphsz + 5], bad[nsz + 5], len[nsz + 5], pre[nsz + 5];
string s, ans;

void inline bfs(int s, int* dis) {
	static int q[nsz + 5];
	int ql = 0, qr = 0;
	q[qr++] = s;
	cont (i, n) {
		dis[i] = inf;
	}
	for (; ql != qr;) {
		int u = q[ql++];
		if (bad[u] != -1) {
			ans += bad[u] + 'a';
			for (; u; u = pre[u]) {
				ans += ::s[u - 1];
			}
			reverse(all(ans));
			cout << ans << ln;
			break;
		}
		loop (c, 26) {
			int v = g[u][c];
			if (v == inf || dis[v] != inf)  continue;
			dis[v] = dis[u] + 1;
			q[qr++] = v;
			pre[v] = u;
		}
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin >> s;
	n = int(s.size());
	memset(lst, inf, sizeof(lst));
	memset(bad, -1, sizeof(bad));
	for (int i = n; i >= 0; --i) {
		loop (c, 26) {
			g[i][c] = lst[c];
			if (g[i][c] == inf && bad[i] == -1)  bad[i] = c;
		}
		if (i) {
			int c = s[i - 1] - 'a';
			lst[c] = i;
		}
	}
	bfs(0, len);
}

Measured memory_bytes: 27924
import java.util.Scanner;
class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a , b, c, d;
    a = sc.nextInt();
    b = sc.nextInt();
    c = sc.nextInt();
    d = sc.nextInt();
    while(a >= 0 || c >= 0){
      c = c - b;
      if(c <= 0){
        break;
      }
      a = a - d;
    }
    if(a > 0 && c <= 0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35904
n = int(input())
p = list(map(int, input().split()))

cnt = 0
for i in range(1, n - 1):
    if p[i - 1] < p[i] < p[i + 1]:
        cnt += 1
    elif p[i + 1] < p[i] < p[i - 1]:
        cnt += 1
print(cnt)


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

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x+r <= w && x-r >= 0 && y+r <= h && y-r >=0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

/*
  シカのAtCoDeerくんは二つの正整数a, bを見つけました。
  aとbの積が偶数か奇数か判定してください。
 */

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

    int product = a * b;
    
    if (product % 2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<math.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define mod 10007
using  namespace std;
int maxn (int a,int b,int c){return max(max(a,b),max(b,c));}
int main()
{
    long long n;
    scanf("%lld",&n);
    long long t=1,s=1;
    for(int i=0;i<n;i++)
    {
        long long x,y;
        scanf("%lld%lld",&x,&y);
        if(t*1.0/s<x*1.0/y)
        {
            for(int j=0;j<y;j++)
            {
                if(s%y==0) break;
                s++;
            }
            t=s/y;
            t*=x;
        }
        else if(t*1.0/s>x*1.0/y)
        {
             for(int j=0;j<x;j++)
            {
                if(t%x==0) break;
                t++;
            }
            s=t/x;
            s*=y;
        }
    }
    printf("%lld\n",t+s);
    return 0;
}



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


int main(){

  int N, x;
  cin >> N >> x;
  
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  
  int find = 0;
  
  for(int i = 0; i < N; i++){
     x -= a.at(i);
     find = i + 1;
    
    if(x == 0){
      break;
    }
    
    if(x < 0){
      find = i;
      break;
    }
  }
  if(x > 0){
  reverse(a.begin(), a.end());
  
  for(int i = 0; i < N; i++){
    
    if(x < 0){
      break;
    }
    
    x -= a.at(i);    
    find--;
  }
  }
  
  cout << find << endl;
}
  
 
    
    
  
  
  
  
  
  
  
  

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

 long MOD = 1000000000+7;
    long const MAX = 100010;
 long fact[MAX];
 long findBigMod(long base , long power, long res){
     if(power==0) return res;
     if(power&1) {
         res*=base;
         res%=MOD;
     }
     return findBigMod((base*base)%MOD, power/2, res);
 }
 void makeFact(){
     fact[0]=fact[1]=1LL;
     for(long i =2;i<MAX;i++) {
         fact [i] = (fact[i-1]*i)%MOD;
     }
 }
 long findNcR(long n, long r){
     if(n<r) return 0LL;
     long ans = fact[n];
     ans = (ans * findBigMod(fact[r],MOD-2,1) )% MOD;
     ans = (ans * findBigMod(fact[n-r],MOD-2,1) )% MOD;
     return  ans;
 }

int main(){
    ios_base::sync_with_stdio(false);

    long n,k;
    makeFact();
    cin>>n>>k;
    vector<long> data(n);
    for(long& x : data) cin>>x;
    sort(data.begin(),data.end());
    long ans= 0LL;

    for(long i=0;i<n;i++){
        ans -= findNcR(n-i-1,k-1)*data[i];
        ans +=MOD;
        ans %= MOD;
        ans += findNcR(i,k-1)*data[i];
        ans%=MOD;
    }
    cout<<ans%MOD<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
    int n,maxx, res=0;
    cin>>n;
    int a[n+5];
    bool d;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    maxx=a[1];
    for(int i=1; i<=n; i++)
    {
        //d=1;
        if(a[i]<=maxx)
        {
            maxx=a[i];
            //d=0;
                res++;
            //cout<<i<<" "<<maxx<<endl;
        }
//        for(int j=1; j<=i; j++)
//        {
//            if(a[j]<a[i])
//            {
//                  d=0;
//                  break;
//            }
//        }
//        if(d==1)
//        {
//            res++;
//        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int N,i;
int A,B,C[100000];
long long int a,b;
int main()
{
	N=read();
	for(i=0;i<N;i++)
	{
		A=read();
		B=read();
		C[i]=A+B;
		b+=B;
	}
	sort(C,C+N,greater<int>());
	for(i=0;i<N;i+=2)
	{
		a+=C[i];
	}
	cout << a-b;
	return 0;
}



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

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": # "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

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

int main()
{
	int n;
	cin>>n;
	cin.get();
	for(int i=0;i<n;i++){
		string s;
		getline(cin,s);
		for(size_t j=s.find("Hoshino",0);j!=string::npos;j=s.find("Hoshino",j))
			s[j+6]='a';
		cout<<s<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

int main(){
	int n, m;
	std::cin >> n >> m;
	for(int i = 0; i < m; ++i){
		int j;
		std::cin >> j;
		n -= j;
	}
	std::cout << (n < 0 ? -1 : n) << std::endl;
}


Measured memory_bytes: 3584
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

int main(void){
    int N;
    cin >> N;
    lint A[N];
    rep(i,N) cin >> A[i];
    lint dp[N]={};
    dp[0]=1000;
    rep(i,N-1){
        lint stk=dp[i]/A[i];
        lint money=dp[i]%A[i];
        dp[i+1]=max(dp[i],stk*A[i+1]+money);
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int H,W; cin>>H>>W;
  vector<vector<int>> A(H,vector<int>(W));
  rep(i,H){
    rep(j,W){
      cin>>A.at(i).at(j);
    }
  }
  rep(i,H) if(i%2==1) reverse(A.at(i).begin(),A.at(i).end());
  
  vector<int> S;
  vector<bool> F(H*W,false);
  rep(i,H){
    rep(j,W){
      S.push_back(A.at(i).at(j)%2);
    }
  }
  int count=0,temp=0;
  rep(i,H*W-1){
    if(temp==0&&S.at(i)==1)temp++;
    else if(temp==1&&S.at(i)==1)temp--;
    
    if(temp==1){
      F.at(i)=true;
      count++;
    }
  }
  cout<<count<<endl;
  
  rep(i,H*W){
    if(F.at(i)){
      int x=i%W,y=i/W,xd,yd;
      if(y%2==0){
        if(x==W-1) xd=x,yd=y+1;
        else xd=x+1,yd=y;
      }
      else{
        x=W-x-1;
        if(x==0) xd=x,yd=y+1;
        else xd=x-1,yd=y;
      }
      cout<<y+1<<' '<<x+1<<' '<<yd+1<<' '<<xd+1<<endl;
    }
  }
}


Measured memory_bytes: 5308
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){

    int a,b,c,x;
    cin >> a >> b >> c >> x;

    int cnt = 0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(x == 500*i + 100*j +50*k) cnt++;
            }
        }
    }
    cout << cnt << endl;
   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char s[200000];scanf("%s",s);
	long ans=0;
	int i,n=0,f=0;while(s[n++]!=0);
	for(f=n-1;s[f]=='B';f--);
	for(i=f;i>=0;i--){
		if(s[i]=='B'){
			ans+=f-i-1;
			f--;
		}
	}
	printf("%ld\n",ans);
	return 0;
}

Measured memory_bytes: 384
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n=parseInt(readline())
    flg=false
    for i in 1:9
        if n%i==0 && div(n,i)<=9
            flg=true
            break
        end
    end
    println(ifelse(flg,"Yes","No"))
end
main()

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



Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {

    static long max = 1000000000;

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

        long x1 = 0;
        long y1 = 0;

        long x2 = max;
        long y2 = 1;

        long x3 = (max - (s % max)) % max;
        long y3 = (s + x3) / max;

        System.out.format("%d %d %d %d %d %d\n", x1, y1, x2, y2, x3, y3);
    }
}


Measured memory_bytes: 23252
#include <stdio.h>

int main(void)
{
	int point[50][3];
	int m, f, r;
	int n = 0, i;
	int sum;

	while (1) {
		scanf("%d %d %d", &m, &f, &r);
		if (m == -1 && f == -1 && r == -1) {
			break;
		}
		else {
			point[n][0] = m;
			point[n][1] = f;
			point[n][2] = r;
			n++;
		}
	}

	for (i = 0; i < n; i++) {
		sum = point[i][0] + point[i][1];
		if (point[i][0] == -1 || point[i][1] == -1) {
			printf("F\n");
		}
		else if (80 <= sum) {
			printf("A\n");
		}
		else if (65 <= sum && sum < 80) {
			printf("B\n");
		}
		else if (50 <= sum && sum < 65) {
			printf("C\n");
		}
		else if (30 <= sum && sum < 50) {
			if (50 <= point[i][2]) {
				printf("C\n");
			}
			else {
				printf("D\n");
			}
		}
		else if (sum < 30) {
			printf("F\n");
		}
	}
	
	
	return 0;
}


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

//using ll=long long;

const int MAX = 2200000;
long double p;
//const long long MOD = 1000000007;
//long long INF = 90000000001000;

int main() {

int n,q;
cin >> n;
vector<long long> s(n);

for (int i = 0; i < n; ++i)
{
    cin >> s[i];
}
cin >> q;
vector<long long> t(q);
for (int i = 0; i < q; ++i)
{
    cin >> t[i];
}
sort(s.begin(),s.end());
int sz = s.size();
int cnt=0;
for(int i=0; i<t.size();++i){
    int num = t[i];
    //cout << num;
    int l=-1,r=sz,m;
    while(l+1<r){
        //cout << l << r << endl;
        m = (l+r)/2;
        if(num<s[m]) r=m;
        if(s[m]<num)l=m;
        if(s[m]==num){l=m;break;}
    }
    if(s[l]==num)cnt++;
}

cout << cnt <<endl;
return 0;
}





Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for( int i = a; i < b ; i++ ) 
#define af(i,a,b) for( int i = a; i >= b ; i--)
#define rep(i,a,b,k) for(int i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( int i = a; i >= b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)

typedef long double ld;
typedef long long int ll;
typedef vector<int> vi ;
typedef pair<int,int> ii ;
typedef vector<ii> vii ;

const int MAX= 1001;
int h[100010];
int dp[100010];
int main(){
	fastio;	
	int n,k;
	cin>>n>>k;
	f(i,0,n) cin>>h[i];
	f(i,1,n){
		dp[i]=1000000000;
		f(j,max(0,i-k),i) dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define pb push_back
#define INF 1e11
#define mod 11092019
#define eps 1e-15
#define abs(x) ((x)>=0?(x):-(x))
#define y1 solai
#define fi first
#define se second
typedef long long ll;
typedef long double ldb;
typedef pair<ll,ll> pll;
const ll N=200100;
ll n,a[N],s;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin>>n;
	for(ll i=1;i<=n;i++)
		cin>>a[i],s^=a[i];
	for(ll i=1;i<=n;i++)
		cout<<(a[i]^s)<<" ";
}


Measured memory_bytes: 5148
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

signed main(){
	fast;
	int n;
	cin>>n;
	double a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	double x=0;
	for(int i=0;i<n;i++){
		a[i]=double(1/a[i]);
	}
	for(int i=0;i<n;i++){
		x+=a[i];
	}
	cout<<fixed<<setprecision(5)<<1/x;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;



int main(){
  char g;
  cin >>g;
  if((int)g>=65 && (int)g<=90){cout << 'A' << endl;}else{cout << 'a' << endl;}
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<utility>
using namespace std;
int main()
{
    string s, t, sdash, tdash;
    pair<char, int> p;
    cin >> s >> t;
    while(s != "\0"){
        p.first = s[0];
        p.second = 0;
        for(unsigned int i = 1; i < s.size(); i++){
            if(s[i] < p.first){
                p.first = s[i];
                p.second = i;
            }
        }
        sdash += p.first;
        s.erase(s.begin() + p.second);
    }
    while(t != "\0"){
        p.first = s[0];
        p.second = 0;
        for(unsigned int i = 1; i < t.size(); i++){
            if(t[i] > p.first){
                p.first = t[i];
                p.second = i;
            }
        }
        tdash += p.first;
        t.erase(t.begin() + p.second);
    }
    cout << (sdash < tdash ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

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

    ll current_time = 0;
    pair<ll, ll> current = make_pair(0,0);

    rep(i, n) {
        ll t,x,y;
        cin >> t >> x >> y;

        ll diff = abs(current.first - x) + abs(current.second - y);
        ll time_diff = t - current_time;
        if(diff > time_diff || (time_diff-diff)%2 == 1) {
            print("No");
            return 0;
        } else {
            current = make_pair(x,y);
            current_time = t;    
        }
    }

    print("Yes");
    return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict
H,W= list(map(int,input().split()))

C = [list(map(int,input().split())) for _ in range(10)]

A =  [list(map(int,input().split())) for _ in range(H)]


cost = dict()

#d= defaultdict(int)
d = Counter()

for a in A:
    for i in a:
        if i==-1 or i==1:
            continue
        else:
            d[i]+=1




def search(glaph, start, goal):
    def get_path(start, goal, prev):
        path = []
        now = goal
        path.append(now)
        while True:
            path.append(prev[now])
            if prev[now] == start: break
            now = prev[now]
        path.reverse()
        return path

    MAX_VAL = 0x10000000
    g_size = len(glaph)
    visited = [False] * g_size
    cost = [MAX_VAL] * g_size
    prev = [None] * g_size
    cost[start] = 0
    prev[start] = start
    now = start
    while True:
        min = MAX_VAL
        next = -1
        visited[now] = True
        for i in range(g_size):
            if visited[i]: continue
            if glaph[now][i]:
                tmp_cost = glaph[now][i] + cost[now]
                if cost[i] > tmp_cost:
                    cost[i] = tmp_cost
                    prev[i] = now
            if min > cost[i]:
                min = cost[i]
                next = i
        if next == -1: break
        now = next
    return [get_path(start, goal, prev), cost[goal]]
ans = 0
for key in d:
    ans += d[key]*search(C,key,1)[1]
print(ans)

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

int main(){
	int i,j,k,n,m;

	scanf("%d",&k);

	for(i=1; i<10; i++){
		for(j=1; j<10; j++){
			if(i*j==k){
				printf("Yes\n");
				return 0; 
			}
		}
	}

	printf("No\n");
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        for(int i = 1; i <= 5; i++) {
            int N = scanner.nextInt();
            if(N == 0) {
                System.out.println(i);
                return;
            }

        }


    }
}

Measured memory_bytes: 35692
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        int a,b;
 
        while(true){
            a = sc.nextInt();
            b = sc.nextInt();
 
            if(a == 0 && b == 0)break;
 
            System.out.println(Math.min(a, b)+" "+Math.max(a, b));
        }
 
    }
}


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

int main() {
    int N;
    int M;
    int X;
    int Y;
	cin >> N;
	cin >> M;
	cin >> X;
	cin >> Y;
	int x[N];
	int y[M];
	for (int i = 0; i < N; i++) {
	    cin >> x[i];
	}
	for (int i = 0; i < M; i++) {
	    cin >> y[i];
	}
	int xmax = -101;
	for (int i = 0; i < N; i++) {
	    if (x[i] > xmax) {
	        xmax = x[i];
	    }
	}
	int ymin = 101;
	for (int i = 0; i < M; i++) {
	    if (y[i] < ymin) {
	        ymin = y[i];
	    }
	}

	bool war = false;
	if (xmax >= ymin) {
	    war = true;
	}
	if (xmax >= Y) {
	    war = true;
	}
	if (ymin <= X) {
	    war = true;
	}
	if (X >= Y) {
	    war = true;
	}

	if (war) {
	    cout << "War" << endl;
	} else {
	    cout << "No War" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 1e5;
int N;
ll X[Nmax], Y[Nmax];

class UnionFind{
	vector<int> par, rnk;
	public:
	UnionFind(int n){
		par=vector<int>(n);
		rnk=vector<int>(n,0);
		for(int i=0; i<n; i++) par[i]=i;
	}
	int root(int i){
		if(par[i]==i) return i;
		return par[i]=root(par[i]);
	}
	void unite(int i, int j){
		int ri = root(i);
		int rj = root(j);
		if(ri==rj) return;

		if(rnk[ri]==rnk[rj]){
			par[ri] = rj;
			rnk[rj]++;
		}
		else if(rnk[ri] < rnk[rj]){
			par[ri] = rj;
		}
		else{
			par[rj] = ri;
		}
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
};


int main(){
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> X[i] >> Y[i];
	}

	vector<pair<ll, int> > xs(N);
	vector<pair<ll, int> > ys(N);
	for(int i=0; i<N; i++){
		xs[i] = make_pair(X[i], i);
		ys[i] = make_pair(Y[i], i);
	}
	sort(xs.begin(), xs.end());
	sort(ys.begin(), ys.end());

	vector<pair<ll, pair<int, int> > > edge;
	for(int i=0; i<N-1; i++){
		edge.push_back(make_pair(xs[i+1].first-xs[i].first, make_pair(xs[i+1].second, xs[i].second)));
		edge.push_back(make_pair(ys[i+1].first-ys[i].first, make_pair(ys[i+1].second, ys[i].second)));
	}

	sort(edge.begin(), edge.end());

	UnionFind uf(N);
	ll ans = 0;
	for(int i=0; i<edge.size(); i++){
		int a = edge[i].second.first;
		int b = edge[i].second.second;
		if(!uf.same(a, b)){
			ans+=edge[i].first;
			uf.unite(a, b);
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
  int n,p,k=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> p;
    if(p !=i+1) k++;
  }
  if(k<=2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	int i, n, cnt[100000], most = -1;
	for (i = 0; i < 100000; i++) cnt[i] = 0;
	cin >> n;
	while (n--){
		int a;
		cin >> a;
		cnt[a]++;
	}
	for (i = 1; i < 99999; i++){
		most = max(most, cnt[i - 1] + cnt[i] + cnt[i + 1]);
	}
	cout << most << endl;
	return 0;
}

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

using namespace std;

typedef vector<vector<int> > Matrix; //隣接行列

const int INF = 1000000000;

Matrix dist;

//trueなら負の閉路を検出
bool warshall_floyd(int n) { //nは頂点数
    for (int k = 0; k < n; k++) { //経由点
        for (int i = 0; i < n; i++) { //始点
            for (int j = 0; j < n; j++) { //終点
                if (dist[i][k] != INF && dist[k][j] != INF) {
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
    }
    
    //負の閉路を検出
    for (int i = 0; i < n; i++) {
        if (dist[i][i] < 0) return true;
    }
    return false;
}

int dp[1 << 8][8];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M, R;
	cin >> N >> M >> R;
	vector<int> r(R);
	for (int i = 0; i < R; i++) {
		cin >> r[i];
		r[i]--;
	}

	dist.resize(N, vector<int>(N, INF));
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		dist[a][b] = c;
		dist[b][a] = c;
	}

	warshall_floyd(N);
	for (int i = 0; i < (1 << R); i++) {
		for (int j = 0; j < R; j++) {
			dp[i][j] = INF;
		}
	}

	for (int i = 0; i < R; i++) dp[1 << i][i] = 0;
	for (int i = 1; i < (1 << R) - 1; i++) {
		for (int j = 0; j < R; j++) {
			for (int k = 0; k < R; k++) {
				if (i & (1 << k)) continue;
				dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k], dp[i][j] + dist[r[j]][r[k]]);
			}
		}
	}

	int ans = INF;
	for (int i = 0; i < R; i++) {
		ans = min(ans, dp[(1 << R) - 1][i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
'use strict'

function main(input) {

  const t = input.split('\n')[1];
  const s = input.split('\n')[0];

  let str = s;
  let ans  = false;

  for (let i = 0; i < s.length; i++) {
    if (str === t) {
      ans = true;
      break;
    } else {
      str = str.slice(1) + str.slice(0, 1);
    }
  }

  console.log(ans ? 'Yes' : 'No');
}

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


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const string YES = "Yes";
const string NO = "No";

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }

    for(ll i = k; i < n; ++i){
        if(a.at(i - k) < a.at(i)){
            cout << YES << endl;
        }else{
            cout << NO << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long ll;
ll inf=1e18;
int main(){
	int N;
	cin>>N;
	long long a=1,b=1;
	rep(i,N){
		int x,y;
		cin>>x>>y;
		ll q=max((a+x-1)/x,(b+y-1)/y);
		a=q*x,b=q*y;
		assert(a<=inf);
		assert(b<=inf);
	}
	assert(a+b<=inf);
	cout<<a+b<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using static System.Math;

namespace _20190511
{
    class Program
    {
        public static void Main(string[] args)
        {
            using (var sc = new SetConsole())
            {
                var rgb = GetArray<int>();
                int r = rgb[0];
                int g = rgb[1];
                int b = rgb[2];
                int n = rgb[3];

                int count = 0;
                for (int i = 0; i <= 3000; i += r)
                {
                    for (int j = 0; j <= 3000; j+=g)
                    {
                        int expectedBSize = n - i - j;
                        if (expectedBSize >= 0 && expectedBSize % b == 0)
                        {
                            count++;
                        }
                    }
                }

                CWrite(count);
            }
        }

        static void CWrite<T>(T str) => Console.WriteLine(str);
        static string GetString() => Console.ReadLine();
        static T[] GetArray<T>()
        {
            var t = typeof(T);
            var str = Console.ReadLine();
            if (t == typeof(string))
            {
                return (T[])(object)str.Split();
            }
            if (t == typeof(int))
            {
                return (T[])(object)str.ToNumArray<T>();
            }
            if (t == typeof(long))
            {
                return (T[])(object)str.ToNumArray<T>();
            }
            if (t == typeof(double))
            {
                return (T[])(object)str.ToNumArray<T>();
            }
            throw new NotSupportedException($"{t} is not supported.");
        }
    }



    class SetConsole : IDisposable
    {
        readonly StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
        public SetConsole()
        {
            sw.AutoFlush = false;
            Console.SetOut(sw);
        }
        public void Dispose()
        {
            Console.Out.Flush();
            sw.AutoFlush = true;
            Console.SetOut(sw);
        }
    }

    static class ExtentionsLibrary
    {
        public static T[] ToNumArray<T>(this string str)
        {
            var t = typeof(T);
            if (t == typeof(int))
            {
                return (T[])(object)str.Split().Select(int.Parse).ToArray();
            }
            if (t == typeof(long))
            {
                return (T[])(object)str.Split().Select(long.Parse).ToArray();
            }
            if (t == typeof(double))
            {
                return (T[])(object)str.Split().Select(double.Parse).ToArray();
            }
            throw new NotSupportedException();
        }
        public static int ToInt(this string str) => int.Parse(str);
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <cstdio>
using namespace std;
int field[10][10] = {0};

void dfs1(int x, int y) {
  field[y][x] += 1;
  for(int dx = -1 ; dx <= 1 ; dx++) {
    int nx = x + dx;
    if(0 <= nx && nx < 10 && nx != x) field[y][nx] += 1;
  }
  for(int dy = -1 ; dy <= 1 ; dy++) {
    int ny = y + dy;
    if(0 <= ny && ny < 10 && ny != y) field[ny][x] += 1;
  }
}

void dfs2(int x, int y) {
  field[y][x] += 1;
  if(y+1 < 10) field[y+1][x] += 1;
  if(y-1 >= 0) field[y-1][x] += 1;
  if(x+1 < 10) field[y][x+1] += 1;
  if(x-1 >= 0) field[y][x-1] += 1;
  for(int dx = -1 ; dx <= 1 ; dx++) {
    for(int dy = -1 ; dy <= 1 ; dy++) {
      int nx = x + dx, ny = y + dy;
      if(0 <= nx && nx < 10 && 0 <= ny && ny < 10 && nx != x && ny != y) field[ny][nx] += 1;
    }
  }
}

void dfs3(int x, int y) {
  field[y][x] += 1;
  if(y+2 < 10) field[y+2][x] += 1;
  if(y-2 >= 0) field[y-2][x] += 1;
  if(x+2 < 10) field[y][x+2] += 1;
  if(x-2 >= 0) field[y][x-2] += 1;
  if(y+1 < 10) field[y+1][x] += 1;
  if(y-1 >= 0) field[y-1][x] += 1;
  if(x+1 < 10) field[y][x+1] += 1;
  if(x-1 >= 0) field[y][x-1] += 1;
  for(int dx = -1 ; dx <= 1 ; dx++) {
    for(int dy = -1 ; dy <= 1 ; dy++) {
      int nx = x + dx, ny = y + dy;
      if(0 <= nx && nx < 10 && 0 <= ny && ny < 10 && nx != x && ny != y) field[ny][nx] += 1;
    }
  }
}

int main(void) {
  int x, y, size;
  char c1, c2;
  int max=0;
  int white=0;
  while(cin >> x >> c1  >> y >> c2 >> size) {
    if(size == 1) dfs1(x, y);
    if(size == 2) dfs2(x, y);
    if(size == 3) dfs3(x, y);
  }
  /*for(int i = 0 ; i < 10 ; i++) {
    for(int j = 0 ; j < 10 ; j++) {
      cout << field[i][j] << ' ';
    }
    cout << endl;
    }*/
  for(int i = 0 ; i < 10 ; i++) {
    for(int j = 0 ; j < 10 ; j++) {
      if(field[i][j] > max) max = field[i][j];
      if(field[i][j] == 0) white++;
    }
  }
  cout << white << endl;
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<cmath>
#include<typeinfo>

using namespace std;
#define rep(i,m,n) for(int i=m;i<n;++i)
#define repll(i,m,n) for(ll i=m;i<n;++i)
#define llinf 10000000000000000
#define inf 1000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()


int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int k;
	cin >> k;
	if (e - a > k) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n, k = map(int,input().split())
r, s, p = map(int,input().split())
t = list(input())
score = 0
for i in range(k):
    if t[i] == "r":
        score += p
    elif t[i] == "s":
        score += r
    else:
        score += s

for i in range(k, len(t)):
    if t[i] != t[i-k]:
        if t[i] == "r":
            score += p
        elif t[i] == "s":
            score += r
        else:
            score += s
    else:
        t[i] = ""

print(score)


Measured memory_bytes: 4084
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	int h, w;
	cin >> h >> w;
	char a[10][10];

	int sum = 0;
	rep(i, h) {
		rep(j, w) {
			cin >> a[i][j];
			if (a[i][j] == '#') sum++;
		}
	}
	cout << (sum == h + w - 1 ? "P" : "Imp") << "ossible" << endl;
	return 0;
}

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

int main(){
    int n, k, a[4][13] = {};
    cin >> n;
    char x;
    for(int i = 0 ; i < n ; i++){
        cin >> x >> k;
        if(x == 'S') a[0][k - 1] = 1;
        else if(x == 'H') a[1][k - 1] = 1;
        else if(x == 'C') a[2][k - 1] = 1;
        else if(x == 'D') a[3][k - 1] = 1;
    }
    for(int i = 0 ; i < 4 ; i++){
        for(int j = 0 ; j < 13 ; j++){
            if(a[i][j] == 0){
                if(i == 0) x = 'S';
                else if(i == 1) x = 'H';
                else if(i == 2) x = 'C';
                else if(i == 3) x = 'D';
                cout << x << " " << j + 1 << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  int minimum = 1000000000, sum = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> m.at(i);
    sum += m.at(i);
    
    if (m.at(i) < minimum) {
      minimum = m.at(i);
    }
  }
  
  cout << (X - sum) / minimum + N << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define set setprecision　//小数点以下何位まで知りたいか
#define mod 1000000007
#define pi 3.14159265
#include<numeric>
using namespace std;
int gcd(int a, int b)//最大公約数
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
int lcm(int a, int b)//最小公倍数
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll k = b % 30000, h = b / 30000, s = 1;
	rip(i, 30000)s = (s * a) % mod; ll j = 1;
	if (h != 0)rip(i, h)j = j * s % mod;
	if (k != 0)rip(i, k)j = j * a % mod;
	return(j);
}
int  main() {
	int n;
	cin >> n;
	vector<int>a(3 * n);
	rip(i, 3 * n)cin >> a[i];
	sort(a.begin(), a.end());
	ll sum = 0;
	rip(i, n)sum += a[3 * n - (2 * (1+i))];
	cout << sum << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>

using namespace std;

int pow(int b, int p) {
	int ret = 1;
	for(int i = 0; i < p; i++) {
		ret *= b;
	}
	return ret;
}

int main() {
	int X;
	cin >> X;
	int ans = 1;
	for(int b = 2; b <= 32; b++) {
		for(int p = 2; ; p++) {
			int tmp = pow(b, p);
			if(tmp <= X) {
				ans = max(tmp, ans);
			} else {
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int[] count = new int[N];
        boolean[][] bridge = new boolean[N][N];
        
        for(int i = 0; i < M; i++) {
            int a = scan.nextInt() - 1;
            int b = scan.nextInt() - 1;
            count[a]++;
            count[b]++;
            bridge[a][b] = true;
            bridge[b][a] = true;
        }
        
        boolean continueFlag = true;
        int bridgeNumber = 0;
        
        while(continueFlag) {
            continueFlag = false;
            for(int i = 0; i < N; i++) {
                if(count[i] == 1) {
                    continueFlag = true;
                    for(int j = 0; j < N; j++) {
                        if(bridge[i][j]) {
                            bridge[i][j] = false;
                            bridge[j][i] = false;
                            bridgeNumber++;
                            count[i]--;
                            count[j]--;
                        }
                    }
                }
            }
        }
        
        System.out.println(bridgeNumber);
    }
}


Measured memory_bytes: 23380
#pragma optimize("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
// #include<iomanip>
using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pii;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define sz(a) ll(a.size())
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front 
#define MAXN 100010
#define N 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define nl '\n'
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);

template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
static_assert(D >= 1, "Vector dimension must be greater than zero!");
template<typename... Args>
	Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
	}
};
template<typename T>
struct Vec<1, T> : public vector<T> {
	Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
	}
};

ll modpower(ll x, ll y,ll p)
{
    ll res = 1;     // Initialize result
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; // y = y/2
        x = (x*x) % p;  // Change x to x^2
    }
    return res;
}
ll power(ll x, ll y)
{
    ll res = 1;     // Initialize result
    x = x ;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);
        y = y>>1; // y = y/2
        x = (x*x);  // Change x to x^2
    }
    return res;
}
// int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);}

ll modinv(ll a,ll p){return modpower(a,p-2,p);}

const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};

long long safe_sqrt(long long n) {
    long long res = sqrt((long double) n);
    if (res*res == n) return res;
    const long double eps = 1e-8;
    if ((long double)(res+1)*(res+1) < n + eps) return res+1;
    if ((long double)res*res + eps > n) return res-1;
    return res;
}   
// (a+b-1)/b for ceil
void solve(){
    ll n;
    cin>>n;
    ll x = 1000;
    while(x<n){
        x+=1000;
    }
    cout<<x-n<<nl;
    return ;
}
int main()
{
    IO;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // #endif
    int T = 1;
    // cin >> T;
    f(c, 0, T){
        solve();
    }
    return 0;
}//multiset m make_pair make_tuple  tuple<int,int,int> continue resize insert count size else true isValid second first false erase double priority_queue 
//cout<<setprecision(12); push_back pop_back pop_front push_front  lower_bound upper_bound  reverse

Measured memory_bytes: 3688
N = int(input())
v = list(map(int, input().split()))

v_s = sorted(v)

out = 0
for i in range(N):
  if i == 0:
    out += v_s[i]*((1/2)**(N-1))
  else:
    out += v_s[i]*((1/2)**(N-i))
  
print(out)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	vi b;
	for(int i=0;i<n;i++){
		vi a_;
		bool B=0;
		for(int j=n-i-1;j>=0;j--) if(a[j]==j+1){
			b.push_back(j+1);
			for(int k=0;k<n-i;k++) if(j!=k) a_.push_back(a[k]);
			a=a_;
			B=1;
			break;
		}
		if(!B){
			cout<<-1<<endl;
			return 0;
		}
	}
	for(int i=n-1;i>=0;i--) cout<<b[i]<<endl;
}

Measured memory_bytes: 256
N = int(input())
grundy = 0
for i in range(N):
    a, k = map(int, input().split())
    while a % k:
        p, q = divmod(a, k)
        a -= (p + 1)*((p+q)//(p+1))
    grundy ^= a // k
print('Takahashi' if grundy else 'Aoki')


Measured memory_bytes: 3060
def main():

    N, M = map(int, input().split())
    data = [None] * N
    for n in range(N):
        data[n] = [int(x) for x in input().split()]

    data.sort(key=lambda x: x[0])

    m = 0
    y = 0
    for n in range(N):
        if m + data[n][1] > M:
            y += (M - m) * data[n][0]
            break
        else:
            y += data[n][1] * data[n][0]
            m += data[n][1]

    print(y)


main()


Measured memory_bytes: 22756
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

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

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll bnum = b - b/c - b/d + b/(lcm(c,d));
    ll anum = a-1 - (a-1)/c - (a-1)/d + (a-1)/(lcm(c,d));
    cout<<bnum - anum<<endl;
    return 0;
}

Measured memory_bytes: 256