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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int32 n = s.size();
  bool flg = false;
  REP(i,n){
    if(!flg){
      if(s[i] == 'C')flg = true;
    }else{
      if(s[i] == 'F'){
        Yes(true);
        return 0;
      }
    }
  }
  Yes(false);
  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
//#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define MST(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define VI vector<int>
#define VL vector<long long>
#define VII vector<PII>
#define VLL vector<PLL>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}

const LL maxn=500+10;
struct NODE{
	db o,r,d;
};
LL t,n,m,ans;
LL MOD=1e9+7,inf=0x1f1f1f1f;
db eps=1e-5;
char  f[maxn][maxn],a[maxn][maxn],b[maxn][maxn];

int main()
{
//	FOUT;//FIN;
	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,ca=0,u=0,v=0,d;
	cin>>n>>m;
	repu(i,1,n){
		cin>>f[i];
		strcpy(a[i],f[i]);
		if(i&1){
			rep(j,0,m-1)a[i][j]='#';
		}
		else {
			rep(j,1,m)f[i][j]='#';
		}
	}
	repu(i,2,n-1)a[i][0]=f[i][m-1]='#';
	repu(i,1,n)cout<<a[i]<<endl;
	cout<<endl;
	repu(i,1,n)cout<<f[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 1280
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <functional>
#include <complex>
#include <cmath>
#include <vector>
#include <climits>
#include <set>
using namespace std;

int main()
{	
	int n;
	int g[10][10];

	while (cin >> n, n) {
		
		set<int> pat;
		fill((int *)g, (int *)(g + 10), INT_MAX / 2);
		 
		for (int i = 0; i < n; i++) {
			int to, from, cost;
			cin >> to >> from >> cost;
			pat.insert(to);
			pat.insert(from);
			g[to][from] = cost;
			g[from][to] = cost;
		}
		
		int m = pat.size();
		
		for (int k = 0; k < m; k++) {
			for (int i = 0; i < m; i++) {
				for (int j = 0; j < m; j++) {
					if (i == j) continue;
					g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
				}
			}
		}
		
		int r = INT_MAX, index;
		for (int i = 0; i < m; i++) {
			int sum = 0;
			for (int j = 0; j < m; j++) {
				if (i == j) continue;
				sum += g[i][j];
			}
			if (r > sum) {
				r = sum;
				index = i;
			}
		}
		
		cout << index << " " << r << endl;
	}
		
	return 0;
}

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

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<string>c(n-k);

    rep(i,n){
        cin >> a[i];
    }


    rep(i,n-k){
        if(a[i+k]>a[i]){
            c[i] = "Yes";
        }
        else{
            c[i] = "No";
        }
    }
    rep(i,n-k){
        cout << c[i] << endl;
    }

}

Measured memory_bytes: 11172
import numpy as np
import sys


def main():
    readlines = sys.stdin.readlines()

    N, M, Q = map(int, readlines[0].split())
    city = np.zeros((N + 1, N + 1), dtype=int)
    L, R = np.array([i.split() for i in readlines[1:M + 1]], dtype=int).T
    p, q = np.array([i.split() for i in readlines[M + 1:]], dtype=int).T

    np.add.at(city, (L, R), 1)
    np.cumsum(city, axis=0, out=city)
    np.cumsum(city, axis=1, out=city)

    p -= 1
    answer = city[q, q] - city[p, q] - city[q, p] + city[p, p]
    print('\n'.join(answer.astype(str)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 99788
# -*- coding: utf-8 -*-
import sys
N,D=map(int, sys.stdin.readline().split())
X=[ map(int, sys.stdin.readline().split()) for _ in range(N) ]

L=[]  #2乗した数  
for i in range(201):
    L.append(i**2)

ans=0
for i in range(N-1):
    for j in range(i+1,N):
        t=0
        for x1,x2 in zip(X[i],X[j]):
            t+=(x1-x2)**2
        if t in L:
            ans+=1
print ans

Measured memory_bytes: 28524
#include <iostream>

using namespace std;

int main(void){
  int n;cin>>n;
  for(int i=0;i<n;++i){
    string proc,mes;
    cin>>proc>>mes;
    for(int j=proc.size()-1;j>=0;--j){
      if(proc[j]=='J'){
        mes = mes[mes.size()-1] + mes.substr(0,mes.size()-1);
      }else if(proc[j]=='C'){
        mes = mes.substr(1,mes.size()-1) + mes[0];
      }else if(proc[j]=='E'){
      	int len = mes.size();
      	string centre;
      	if(len%2) centre = mes[len/2];
      	string lft = mes.substr(0, len/2);
      	string rgt = mes.substr(len-len/2, len/2);
        mes = rgt + centre + lft;
      }else if(proc[j]=='A'){
      	string tmp;
      	for(int k=mes.length()-1;k>=0;--k)tmp+=mes[k];
        mes = tmp;
      }else if(proc[j]=='P'){
        for(int k=0;k<mes.length();++k){
          if('0'<=mes[k] && mes[k]<='9') mes[k]=(9+mes[k]-'0')%10+'0';
        }
      }else if(proc[j]=='M'){
        for(int k=0;k<mes.length();++k){
          if('0'<=mes[k] && mes[k]<='9') mes[k]=(1+mes[k]-'0')%10+'0';
        }
      }
    }
    cout<<mes<<endl;
  }
  return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], A = l[1], B = l[2];

            var ans = B - A - 1;
            Console.WriteLine(ans % 2 == 0 ? "Borys" : "Alice");
        }
    }
}


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

int main() {
	int N;
	double T, A;
	cin >> N >> T >> A;
	double H[100000];
	double x = 0;
	int y = 1;
	for (int i = 0; i < N; i++) {
		cin >> H[i];
		double temp = A - (T - (H[i] * 0.006));
		if (i == 0)x = temp * temp;
		else if (x > temp * temp) {
			x = temp * temp;
			y = i + 1;
		}
	}
	cout << y;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, p, ans = 0, l = 0;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> p;
        ans += p;
        l = max(l, p);
    }
    ans -= l / 2;
    cout << ans << endl;

    return 0;
}

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

int main()
{
    char s[11];
    char c_yy[5], c_mm[3], c_dd[3];
    int yy, mm, dd;
    
    memset(c_yy,'\0',sizeof(c_yy));
    memset(c_mm,'\0',sizeof(c_mm));
    memset(c_dd,'\0',sizeof(c_dd));
     
    scanf("%s",s);

    memcpy(c_yy,s,5);
    memcpy(c_mm,&s[5],2);
    memcpy(c_dd,&s[8],2);
    
    yy=atoi(c_yy);
    mm=atoi(c_mm);
    dd=atoi(c_dd);
        
    if(yy==2017){
         yy = 2018;
    }
    
    printf("%04d/%02d/%02d\n",yy,mm,dd);
     
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int[] h = new int[n];
		for(int i = 0 ; i < n ; i++){
			h[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		for(int i = n - 2 ; i >= 0 ; i--){
			if(h[i] > h[i + 1]) h[i]--;
		}
		boolean ebishu = true;
		for(int i = 1 ; ebishu && i < n ; i++){
			if(h[i - 1] > h[i]) ebishu = false;
		}
		if(ebishu) ou.print("Yes\n");
		else ou.print("No\n");
		ou.flush();
    }
}

Measured memory_bytes: 59148
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <atcoder/dsu>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using namespace atcoder;
using LLONG = long long;
const LLONG MOD = 998244353;

int main()
{
	int N; cin >> N;
	map<int, pair<int, int>> id2PosMap;
	REP(i, N)
	{
		int x, y; cin >> x >> y; --x; --y;
		id2PosMap[i] = { x, y };
	}
	// x座標でソート
	map<int, int> id2XMap;
	map<int, int> x2YMap;
	map<int, int> y2XMap;
	for (const auto &kvp : id2PosMap)
	{
		int id = kvp.first;
		int x = kvp.second.first;
		int y = kvp.second.second;
		id2XMap[id] = x;
		x2YMap[x] = y;
		y2XMap[y] = x;
	}
	dsu d(N);
	set<int> minYSet{ x2YMap[0] };
	for (int x = 1; x < N; ++x)
	{
		int y = x2YMap[x];
		bool merged = false;
		for (const int minY : minYSet)
		{
			if (minY < y)
			{
				d.merge(x, y2XMap[minY]);
				merged = true;
			}
			else
			{
				break;
			}
		}
		if (merged) continue;
		minYSet.insert(y);
	}
	REP(id, N)
	{
		cout << d.size(id2XMap[id]) << endl;
	}
}


Measured memory_bytes: 45420
n = int(input())
number = list(map(int,input().split()))
num = sorted(number)
num.append(0)
p = num[0]
combi = dict()
u = 0

for i in range (n+1) :
    q = num[i]
    if p != q :
        combi[p] = u
        u = 0
    u += 1
    p = q

t = 0

for j in combi.values() :
    t += j*(j-1)//2

for k in range (n) :
    x = number[k]
    print(t + (combi[x]-1)*(combi[x]-2)//2 - combi[x]*(combi[x]-1)//2)

Measured memory_bytes: 26524
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

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

int main(){
	int N,x[100000];
	cin>>N;
	REP(i,N){
		cin>>x[i];
	}
	int c=1,next=x[0];
	REP(i,100000){
		if(next==2){
			cout<<c;
			return 0;
		}
		next=x[next-1];
		c++;
	}
	cout<<-1;
}

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

int main() {
  int n; cin >> n;
  vector<long long> a(n), ans(n);

  for(int i=0; i<n; ++i) cin >> a[i];

  for(int i=0; i<n; ++i) ans[0] += (i & 1) ? -a[i] : a[i];

  for(int i=0; i<n-1; ++i) ans[i+1] = 2*a[i] - ans[i];

  for(int i=0; i<n; ++i) cout << " " << ans[i];
}


Measured memory_bytes: 2816
x,k,d=map(int,input().split())
x=abs(x)
if k%2==0:
  ans=0 #偶数
else:
  ans=1 #奇数

semin=x//d #最小に行くための個数
if semin%2==0:
  minb=0 #最小に行くための個数が偶数
else:
  minb=1 #最小に行くための個数が奇数

if semin>k:
  print(abs(x-k*d))
else:
  if ans==0:#ｋが偶数の時
    if minb==0:
      print(abs(x-d*semin))
    else:
      print(abs((x-(d*semin))-d))
  else:#ｋが奇数の時
    if minb==0:
      print(abs((x-(d*semin))-d))
    else:
      print(abs(x-d*semin))  


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

int main() {
  char tar;
  cin >> tar;
  string S;
  S = "abcdefghijklmnopqrstuvwxyz";
  for (int i = 0;i < 26;i++) {
    if (S.at(i) == tar) {
      cout << S.at(i+1) << endl;
    }
  }
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int d[N];
    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
    }
    sort(d, d + N);

    int ans = 0;
    for (int i = 1; i <= d[N-1]; i++)
    {
        int tmp = lower_bound(d, d+N, i) - d;
        if(tmp * 2 == N) ans++;
    }
    cout << ans << endl;
}

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

int cost=0;
int n,m,x;
int ans = 100100100;
int a[12][12];
vector<int> c(12);
vector<int> b(12);
void dfs(int i){
	if (i == n ){
		bool f = true;
		rep(j,m) if(b[j] < x) f = false;
		if(f) ans = min(ans,cost);
		return;
	}
	dfs(i+1);
	cost += c[i];
	rep(j,m) b[j] += a[i][j];
	dfs(i+1);
	cost -= c[i];
	rep(j,m) b[j] -= a[i][j];
}
int main(){
	cin >> n >> m >> x;
	rep(i,n){
		cin >> c[i];
		rep(j,m){
			cin >> a[i][j];
		}
	}
	dfs(0);
	if(ans != 100100100) cout << ans << endl;
	else cout << "-1" << endl;
	return 0;
}


Measured memory_bytes: 3604
#include <iostream>

using namespace std;
const int INF = 1e5 + 10;

string s;

void solve() {
  int min0 = 0, min1 = 0;
  for (int i=0;i<s.size();i++) {
    if (i & 1) {
      min0 += s[i] != '0';
      min1 += s[i] != '1';
    } else {
      min0 += s[i] != '1';
      min1 += s[i] != '0';
    }
  }
  cout << min(min0, min1) << endl;
}

int main() {
  cin >> s;
  solve();
}


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

using namespace std;

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

    int N = S.length();

    int count0 = 0, count1 = 0;
    for(int i = 0; i < N; i++){
        if (S[i] == '0') {
            count0 += 1;
        }else{
            count1 += 1;
        }
    }

    if (count0 <= count1) {
        cout << 2 * count0 << endl;
    }else{
        cout << 2 * count1 << endl;
    }

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<double> v(n);
	for (int i = 0; i < n; i++) cin >> v[i];
	sort(v.begin(), v.end());
	double answer = v[0];

	for (int i = 1; i < n; i++) {
		answer = (answer + v[i]) / 2;
	}

	cout << setprecision(6) << answer << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		List<int> li=new List<int>(sc.Ia);
		int[] ans=new int[n];
		int j=0;
		for(int i = n-1;i>=0;i--) {
			j=li.Count-1;
			for(;j>=0;j--) {
				if(li[j]==j+1){
					ans[i]=li[j];
					li.RemoveAt(j);
					break;
				}
			}
			if(j==-1){
				Console.WriteLine(-1);
				break;
			}
		}
		if(j!=-1){Console.WriteLine(String.Join("\n",ans));}
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 13268
function Main(input) {
  input = input.split(" ");
  var a = parseInt(input[0], 10);
  var b = parseInt(input[1], 10);
  var s = a+b;
  if(s>=24){
    s=s-24;
  }
    console.log('%s', s);
  }
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

goukei = 0
for i in range(N):
    hidari = min(A[i], B[i])
    nokori = max(0, B[i] - A[i])
    migi = min(A[i+1], nokori)
    A[i+1] = max(0, A[i+1] - nokori)
    goukei += hidari + migi


print(goukei)




Measured memory_bytes: 18624
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h> 

using namespace std;

int main() {
	int n;
	cin >> n;
	int a[n+1];
	for(int i = 1 ; i <= n ; i++){
		cin >> a[i];
	}
	int dp[n+1];
	for(int i = 1 ; i < n+1  ; i++){
		dp[i] = INT_MAX;
	}
	dp[1] = 0;
	dp[2] = abs(a[2] - a[1]);
	for(int i = 3 ; i < n+1 ; i++){
		dp[i] = std::min(dp[i-1] + abs(a[i-1] - a[i]) , dp[i-2] + abs(a[i-2] - a[i]) ) ;
	}
	cout << dp[n];
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
int A,B,C;
cin>>A>>B>>C;
int i=max(A,(max (B,C)));
int n=i*3-A-B-C;
if(n%2==0)
	cout<<n/2;
else
	cout<<(n+3)/2;
return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        if((s.length() % 2 == 0) ^ (s.charAt(0) == s.charAt(s.length()-1))){
            System.out.println("Second");
        }else{
            System.out.println("First");
        }


        // int[][] num = new int[26][2];
        // for(int i=0; i<s.length(); i++){
        //     num[(int)(s.charAt(i) - 'a')][0] = s.charAt(i);
        //     num[(int)(s.charAt(i) - 'a')][1]++;
        // }

        // Arrays.sort(num, (a, b) -> Integer.compare(a[1], b[1]));

        // int ans = 0;
        // if(num[24][1]+num[25][1] <= s.length()-2){
        //     if((s.length() - (num[24][1]+num[25][1])) % 2 == 0){
        //         ans = 2;
        //     }else{
        //         ans = 1;
        //     }
        // }else if(num[24][1]+num[25][1] == s.length()-1){
        //     char third = (char)(num[23][0]);
        //     int pos = 0;
        //     for(int i=0; i<s.length(); i++){
        //         if(s.charAt(i) == third) pos = i;
        //     }
        //     if(pos == 0 || pos == s.length()-1){
        //         if(s.length() % 2 == 0){
        //             ans = 2;
        //         }else{
        //             ans = 1;
        //         }
        //     }else{
        //         if(s.charAt(pos-1) == s.charAt(pos+1)){
        //             ans = 2;
        //         }else{
        //             ans = 1;
        //         }
        //     }
        // }else{
        //     ans = 2;
        // }



        // if(ans == 1){
        //     System.out.println("First");
        // }else{
        //     System.out.println("Second");
        // }
    }
}

Measured memory_bytes: 25428
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()	
	{
		string s = Console.ReadLine();
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < s.Length; i+=2)
			sb.Append(s[i]);
		Console.WriteLine(sb);
	}
}





Measured memory_bytes: 11144
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int mil = 1, n, y, m, d;
  int manth[2] = {19,20}, year[3] = {200, 195, 195};
  REP(i, 1, 1000) mil += year[i%3];
  scanf("%d", &n);
  while(n--){
    scanf("%d%d%d", &y, &m, &d);
    int res = d;
    REP(i, 1, y) res += year[i%3];
    if(y%3) REP(i, 1, m) res += manth[i%2];  
    else res += (m-1) * 20;
    printf("%d\n", mil - res);
  } 
  return 0;
}

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

int main() {

  long long a,b,c,k;
  cin >> a >> b >> c >> k;
  if(a >= k){
    cout << k << endl;
    return 0;
  }
  if(a + b >= k){
    cout << a << endl;
    return 0;
  }
  if(a+b < k){
    cout << a + abs(a+b-k)*-1 << endl;
    return 0;
  }
  
}


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

void dfs(const vector<vector<pair<int, int>>>& tree,
         vector<int>& ans, int u, int distance) {
  ans[u] = distance;
  for (auto& v : tree[u]) {
    if (ans[v.first] != -1) continue;
    dfs(tree, ans, v.first, distance ^ v.second);
  }
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n;
  cin >> n;
  vector<vector<pair<int, int>>> tree(n);
  rep(i, n-1) {
    int u, v;
    ll w;
    cin >> u >> v >> w;
    --u; --v;
    tree[u].emplace_back(v, w%2);
    tree[v].emplace_back(u, w%2);
  }
  vector<int> ans(n, -1);
  dfs(tree, ans, 0, 0);
  rep(i, n) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 8192
from collections import defaultdict
dic = defaultdict(int)
march = ["M","A","R","C","H"]
n = int(input())
for i in range(n):
    s = input()
    if s[0] in march:
        dic[s[0]] += 1
ans = 0
for i in range(5):
    for j in range(5):
        for k in range(5):
            if i != j and j != k and k != i:
                ans += dic[march[i]]*dic[march[j]]*dic[march[k]]
print(ans//6)

Measured memory_bytes: 43624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
bool f[101];
int main() {
	int N, M, X;
	cin >> N >> M >> X;
	for (int i = 0; i < M; i++) {
		int A;
		cin >> A;
		f[A] = 1;
	}
	int l = 0;
	for (int i = X - 1; i > 0; i--) {
		if (f[i]) l++;
	}
	int r = 0;
	for (int i = X + 1; i < N; i++) {
		if (f[i]) r++;
	}
	cout << min(l, r) << endl;
}

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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 1e2 + 5;
ll a[N];
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (fopen("VLJUM.INP", "r")){
                freopen("VLJUM.INP", "r", stdin);
                freopen("VLJUM.OUT", "w", stdout);
        }
        ll n, m;
        cin >> n >> m;
        ll sum = 0;
        for (int i = 1; i <= n; i++) {
                cin >> a[i];
                sum += a[i];
        }
        ll cnt = 0;
        ll x = sum / (4 * m);
        if (sum % (4 * m) != 0) {
                x++;
        }
        for (int i = 1; i <= n; i++){
                if (x <= a[i]){
                        cnt++;
                }
        }
        if (cnt >= m) cout << "Yes";
        else cout << "No";
}
/*
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const Int INF = (1<<20);

int main(){
    int N;cin >> N;
    string s; cin >> s;
    int cu = 0;
    for(int i=0;i<s.size()-2;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') cu++;
    }
    cout << cu << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin>>a[i];
  vector<int> dp(n);
  dp[0]=0,dp[1]=abs(a[0]-a[1]);
  for(int i=2;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i-2]-a[i]));
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 3980
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<initializer_list>
#include<map>
#include<set>
#include<utility>
#include<tuple>
using namespace std;
#define ull unsigned long long
#define llong long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()

string akiba(string s) {
	vector<string> can = {
		"KIHBR",
		"KIHBRA",
		"KIHBAR",
		"KIHBARA",
		"KIHABR",
		"KIHABRA",
		"KIHABARA",
		"AKIHBR",
		"AKIHBRA",
		"AKIHBAR",
		"AKIHABR",
		"AKIHABRA",
		"AKIHABAR",
		"AKIHABARA" };
	auto it = find(all(can), s);
	if (it != can.end())return "YES";
	else return "NO";
}
int main() {
	string s;
	cin >> s;
	cout << akiba(s) << endl;

	return 0;
}





Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.LinkedHashSet;

public class Main {
    public static void main(String[] args) throws Exception{
        int number;
        double comp;
        boolean isPrime;
        LinkedHashSet<Integer> prime;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        while(line!=null) {
            number = Integer.parseInt(line);
            prime = new LinkedHashSet<>();
            if(number >= 2){
                prime.add(2);
            }
            for (int i = 3; i < number + 1; i += 2) {
                isPrime = true;
                for (int p : prime) {
                    comp = (double) i / (double) p;
                    if (p == 1) {
                        continue;
                    }
                    if (i % p == 0) { //iが見つかった素数で割り切れる
                        isPrime = false;
                        break;
                    } else if (p > comp) {
                        break;
                    }
                }
                if (isPrime) {
                    prime.add(i);
                }
            }
            System.out.println(prime.size());
            line = br.readLine();
        }
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define pf push_front
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

//各位の和
int sod(ll n){
    int sum=0;
    while(n) {
        sum+=(n%10);
        n/=10;
    }
    return sum;
}


signed main() {
    ll n;
    cin >> n;
    for (int i = 0; i < 100; ++i) {
        for (int j = 0; j < 100; ++j) {
            if((i*4 + j*7 ) == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 384
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	unsigned size_; 
	std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	//unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	unsigned root(unsigned x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};


__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}

int main()
{
	
	int N,M;
	
	cin >> N >> M;
	int x;
	int m[10] = {0,2,5,5,4,5,6,3,7,6};

	int d[20];
	memset(d, 0, sizeof(d));
	
	int dp[10010];
	memset(dp, 0, sizeof(dp));

	//int f[N+1], prev[N+1];
	//int f[120000], prev[120000];
	int f[10010], prev[10010];
	memset(f, 0, sizeof(f));
	memset(prev, 0, sizeof(prev));

	rep(i, M)
	{
		cin >> x;
		d[x] = 1;
	}
	
	for (int i = 1; i <= 9; i++)
	{
		if (d[i])
		{
			for (int j = 0; j <= N; j++)
			{
				if ( (j == 0) || dp[j] )
				{
					if (dp[j] + 1 >= dp[j+m[i]])
					{
						dp[j+m[i]] = dp[j]+1;
						f[j+m[i]] = i;
						prev[j+m[i]] = j;
					}
				}
			}
		}
	}

	for(int i = N; i; i = prev[i])
	{
		cout << f[i];
	}

	cout << endl;
	
	return 0;
}


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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//Union Find
struct UnionFind {
  vector<int> par; // 親ノード
  vector<int> rank; // ランク

  UnionFind(int n = 1) {
    init(n);
  }
  void init(int n = 1) {
    par.resize(n); rank.resize(n);
    for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
  }
  int root(int x) {
    if (par[x] == x) {
    return x;
  }
    else {
      int r = root(par[x]);
      return par[x] = r;
    }
  }
  bool issame(int x, int y) {
    return root(x) == root(y);
  }

  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) ++rank[x];
    par[y] = x;
    return true;
  }
};

int main() {
  int N,M,x,y,z;
  cin >> N >> M;
  vector<vector<int>> g(N);
  vector<int> ans(N,-1);
  UnionFind uf(N);

  rep(i,M) {
    cin >> x >> y >> z;
    x--;y--;
    if (z%2==2) {
      ans[x] = ans[y] = 2;
    }
    uf.merge(x,y);
  }
  set<int> known;
  map<int,int> m;
  rep(i,N) {
    if (ans[i]==2) known.insert(uf.root(i));
    m[uf.root(i)]++;
  }
  int cnt=0;
  
  for (auto i=m.begin();i!=m.end();i++) {
    if (known.find(i->first)!=known.end()) continue;
    else {
      auto tmp = i->second;
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

using namespace std;
#define pb push_back
#define db(x) cerr << #x << " = " << x << endl;
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define vi vector<int>
#define vll vector<ll>
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<pii>
#define ll long long
#define ull unsigned long long
typedef long double ld;

#define MAXN 112
#define MAXV 1123

int n, w;
int V[MAXN];
ll W[MAXN];
int target;
int t;
int vis[MAXN][MAXV * MAXN];
ll dp[MAXN][MAXV * MAXN];

ll solve(int idx, int tot)
{
    if (idx == n)
        return tot >= target ? 0:INF;

    if (vis[idx][tot] == t)
        return dp[idx][tot];
    vis[idx][tot] = t;

    ll res = min(solve(idx + 1, tot), solve(idx + 1, tot + V[idx]) + W[idx]);
    return dp[idx][tot] = res;
}

int main()
{
    scanf("%d%d", &n, &w);

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

    int up = 100000;
    int lo = 0;
    int best = -1;

    while (lo <= up)
    {
        int mid = lo + (up - lo)/2;
        target = mid;
        ++t;
        if (solve(0, 0) <= w)    
        {
            best = mid;
            lo = mid + 1;
        }
        else
        {
            up = mid - 1;
        }
    }
    
    printf("%d\n", best);
}

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

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	vector<long long int> s(N + 1, 0);
	for (int i = 0; i < N; ++i) s[i + 1] = s[i] + A[i];
	for (int i = 0; i < N - K; i++) {
		long long int X = s[K+i] - s[i];
		long long int Y = s[K+i+1] - s[i+1];
		if (X < Y) {
			cout << "Yes" << "\n";
		}
		else {
			cout << "No" << "\n";
		}
	}
}

Measured memory_bytes: 5632
import sys
import numpy as np
n = int(input())
a = [int(input()) for _ in range(n)]
mx = str(max(a))
mx_id = a.index(int(mx))
a.remove(int(mx))
mx_sub = str(max(a))
ans = '\n'.join(mx if i != mx_id else mx_sub for i in range(n))

print(ans)

Measured memory_bytes: 37904
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
#include<string.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int n;
	cin >> n;
	if (n % 1000 == 0) cout << 0 << endl;
	else cout << 1000 - n % 1000 << endl;
}

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

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

  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];

  int sum = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      int h_p = a[i] * a[j];
      sum += h_p;
    }
  }

  cout << sum << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
 int a,b,c,count=0;
 
 scanf("%d%d%d",&a,&b,&c);
 
 while(a<=b){
     if(c%a==0){
         count++;
     }
     a++;
 }
printf("%d\n",count);
return 0;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n,k;
  cin >> n >> k;
  int64_t a[n] = {};
  for(int64_t i=0;i<n;i++){
    cin >> a[i];
    a[i] -= 1;
  }

  int64_t visited[n] = {};
  int64_t current = 0;
  int64_t loopCount = 0;
  for(int64_t i=0;i<n;i++){
    visited[i] = -1;
  }
  for(int64_t i=0;i<n+1;i++){
    if(i==k){
      cout << current+1 << endl;
      return 0;
    }
    if(visited[current]!=-1){
      loopCount = i-visited[current];
      break;
    }
    visited[current] = i;
    current = a[current];
  }
  int64_t newK = (k-visited[current])%loopCount;
  for(int64_t i=0;i<newK;i++){
    current = a[current];
  }
  cout << current+1 << endl;
  return 0;
}

Measured memory_bytes: 6768
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,c,k;
int t[100100];

int main(){
	cin>>n>>c>>k;
	REP(i,n)
		cin>>t[i];
	sort(t,t+n);
	int ans=0;
	int bus=0;
	int busar=0;
	int i=0;
	if(c==1){
		cout<<n<<endl;
		return 0;
	}
	while(i<n){
		busar=t[i];
		for(int j=1;j<c;j++){
			if(i>=n)break;
			i++;
			if(t[i]-busar>k){
				break;
			}
			if(j==c-1)i++;
		}
		bus++;
	}
	cout<<bus<<endl;
	return 0;
}

Measured memory_bytes: 640
S = input()
T = input()

N = len(S)

S = [S[i:i+1] for i in range(len(S))]
T = [T[i:i+1] for i in range(len(T))]

ans = 0

for k in range(N):
    if S[k] != T[k]:
        ans += 1

print(ans) 

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

//using namespace std;

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

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

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}
}

int main() {

	ll n, k;
	std::cin >> n >> k;
	std::vector <ll> a(n), b(n);
	rep(i, n) std::cin >> a[i] >> b[i];

	std::vector<ll> num(1e5 + 1, 0);
	rep(i, n) num[a[i]] += b[i];

	ll sum = 0;
	Rep(i, 1, 1e5 + 1) {
		sum += num[i];
		if (sum >= k) {
			std::cout << i << std::endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(){
	string s;
  cin >>s;
  long long int ans=0;
  for(int bit=0;bit<(1<<s.size()-1);bit++){
    ll t=(ll)s[0]-'0';
    for(int i=0;i<s.size()-1;i++){
      if(bit>>i&1){
        ans+=t;
        cerr<<t<<endl;
        t=(ll)s[i+1]-'0';
      }
      else{
        t=t*10+(ll)s[i+1]-'0';
      }
    }
    ans+=t;
    cerr<<t<<endl;
  }
  cout <<ans <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;

int main(){
	int a;
	cin>>a;
	double b[a];
	for(int i=0;i<a;i++){
		cin>>b[i];
	}
	double c;
	for(int i=0;i<a;i++){
		c+=1/b[i];
	}
	cout<<1/c<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        Console.ReadLine();
        Console.WriteLine(Console.ReadLine().Split().Select(int.Parse).Where(x => x % 2 == 0).All(x => x % 3 == 0 || x % 5 == 0) ? "APPROVED" : "DENIED");
    }
}

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

int N, A[1000];

void print() {
  for (int i = 0; i < N; i++) {
    if (i != 0) cout << " ";
    cout << A[i];
  }
  cout << endl;
}

void isort() {
  for (int i = 1; i < N; i++) {
    int v = A[i];
    int j;
    print();
    for (j = i - 1; j >= 0 && A[j] > v; j--) {
      A[j+1] = A[j];
    }
    A[j+1] = v;
  }
  print();
}

int main(void) {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  
  isort();
  
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")


// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
// initialize: UnionFind UF(N)

class UnionFind {                                              // OOP style
private:
	vector<int> p, rank, setSize;
	// p = path toward the root of disjoint set; p[i] = i means it is root
	// rank = upper bound of the actual height of the tree; not reliable as accurate measure
	// setSize = size of each disjoint set

	int numSets;
public:
	UnionFind(int N) {
		setSize.assign(N, 1);
		numSets = N;
		rank.assign(N, 0);
		p.assign(N, 0);
		for (int i = 0; i < N; i++) p[i] = i;	// each belongs to its own set
	}

	int findSet(int i) {
		return (p[i] == i) ? i : (p[i] = findSet(p[i]));		// path compression: cut short of the path if possible
	}

	bool isSameSet(int i, int j) {
		return findSet(i) == findSet(j);
	}

	void unionSet(int i, int j) {
		if (!isSameSet(i, j)) {
			numSets--;
			int x = findSet(i), y = findSet(j);
			// rank is used to keep the tree short
			if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
			else {
				p[x] = y; setSize[y] += setSize[x];
				if (rank[x] == rank[y]) rank[y]++;
			}
		}
	}

	int numDisjointSets() {		// # of disjoint sets
		return numSets;
	}

	int sizeOfSet(int i) {		// size of set
		return setSize[findSet(i)];
	}
};


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

	int n, q, i, j, k, a, b, t, ans;
	cin >> n >> q;
	
	UnionFind uf(n + 1);

	while (q--) {
		cin >> t >> a >> b;
		if (t == 0) uf.unionSet(a, b);
		else {
			if (uf.isSameSet(a, b)) cout << "1\n";
			else cout << "0\n";
		}
	}

	return 0;
}



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

int main(){
  int H, N;
  cin >> H >> N;
  int A;
  for(int i=0; i<N; i++){
    cin >> A;
    H-=A;
  }
  if(H<=0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int64_t A, B, K;
   cin >> A >> B >> K;
   if(A>=K){
       cout << A-K << " " << B << endl;
   }
   else{
       if(B>=K-A){
           cout << 0 << " " << B-(K-A) << endl;
       }
       if(A+B<K){
           cout << 0 << " " << 0 << endl; 
       }
   }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

#define maxs(x,y) (x=std::max(x,y))
#define mins(x,y) (x=std::min(x,y))
using P = std::pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n-1));
  rep(i,n) {
    rep(j,n-1) {
      cin >> a[i][j];
      a[i][j]--;
    }
    std::reverse(a[i].begin(), a[i].end());
  }
  vector<P> q;
  auto check = [&](int i) {
    if (a[i].size() == 0) return;
    int j = a[i].back();
    if (a[j].size() == 0) return;
    if (a[j].back() == i) {
      P p(i,j);
      if (p.second < p.first) swap(p.first, p.second);
      q.push_back(p);
    }
  };
  rep(i,n) {
    check(i);
  }
  int day = 0;
  while (q.size() > 0) {
    day++;
    sort(q.begin(), q.end());
    q.erase(unique(q.begin(), q.end()), q.end());
    vector<P> prevQ;
    swap(prevQ, q);
    for (P p : prevQ) {
      int i = p.first, j = p.second;
      a[i].pop_back();
      a[j].pop_back();
    }
    for (P p : prevQ) {
      int i = p.first, j = p.second;
      check(i);
      check(j);
    }
  }
  rep(i,n) {
    if (a[i].size() != 0) {
      puts("-1");
      return 0;
    }
  }
  cout << day << endl;
  return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;

  vector<long> nums;

  for (int i = 1; i <= n; i++) {
    if (i >= k) {
      nums.push_back(n);
    } else {
      long t = (long)ceil(log2((double)k / i));
      nums.push_back(n * pow(2, t));
    }
  }

  long m = nums[0];
  long c = 0;
  for (auto &num : nums) {
    c += m / num;
  }
  cout << setprecision(10) << (long double)c/m << endl;
}


Measured memory_bytes: 1400
# 1,0-bfs?
from collections import deque

h, w = map(int, input().split())
sx, sy = map(int, input().split())
gx, gy = map(int, input().split())
sx -= 1
sy -= 1
gx -= 1
gy -= 1

S = [list(input()) for _ in range(h)]
walk = [[False] * (w) for _ in range(h)]
jump = [[False] * (w) for _ in range(h)]
# S[h][w]

que = deque([])
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

que.append((sx, sy, 0))
walk[sx][sy] = True
jump[sx][sy] = True

ans = -1
while que:
    nowx, nowy, times = que.popleft()
    if nowx == gx and nowy == gy:
        ans = times
        break
    for i in range(4):
        nx = nowx + dx[i]
        ny = nowy + dy[i]
        if nx < 0 or nx >= h or ny < 0 or ny >= w:
            continue
        if walk[nx][ny]:
            continue
        if S[nx][ny] == ".":
            walk[nx][ny] = True
            que.appendleft((nx, ny, times))
    for ddx in range(5):
        for ddy in range(5):
            nx = nowx + ddx - 2
            ny = nowy + ddy - 2
            if nx < 0 or nx >= h or ny < 0 or ny >= w:
                continue
            if jump[nx][ny]:
                continue
            if S[nx][ny] == ".":
                jump[nx][ny] = True
                que.append((nx, ny, times + 1))
print(ans)


Measured memory_bytes: 151568
MAX = 10 ** 5 * 2
mod = 10 ** 9 + 7
frac = [1]
def pow(a, n):
    if n == 0 : return  1
    elif n == 1 : return a
    tmp = pow(a, n//2)
    tmp = (tmp * tmp) % mod
    if n % 2 == 1 :
        tmp = (tmp * a) % mod
    return tmp
def inv(x):
    return pow(x, mod - 2 )
def comb(n, k):
    a=1
    b=1
    for i in range(n-k+1,n+1):
        a=(a*i)%mod
    for i in range(1,k+1):
        b=(b*i)%mod
    if k >= n or k < 0 : return 1
    return (a* inv(b))%mod
n,a,b = map(int,input().split())
print((pow(2,n)-1-comb(n,a)-comb(n,b))%mod)

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

signed main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; i++) cin >> v[i];
    sort(v.begin(),v.end());
    
    
    vector<int> ans;
    for(int i=v.size()-1; i>0;i--){
        if(v[i] == v[i-1]){
            ans.push_back(v[i]);
            i--;
        }
    }
    if(ans.size() <= 1){
        cout << 0 << endl;
        return 0;
    }
    sort(ans.begin(), ans.end());
    cout << ans[ans.size()-1] * ans[ans.size()-2] << endl;

    return 0;
}

Measured memory_bytes: 1660