akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);

int s_asorts(const void* a, const void* b);

//++++++++++++++++POLL

static char S[200001][11];
static int  pt[200000];


int main(void) {
	int N, i;
	int cnt = 1, j = 0, rc, max = 1;

	i_cin(N);
	for(i=0;i<N;i++)
        s_cin(S[i]);
	if (N == 1)
	{s_cout(S[i]); return 0;}

	//昇順に並べる

	qsort((void*)S, N, sizeof(S[0]), s_asorts);

	// 候補者リストを作る
	pt[0] = 0;

	for (i = 0; i < N; i++) {

		rc = strcmp(S[i], S[i + 1]);
		if (!rc)       { cnt++;   continue; }  //同じならカウント
		if (cnt == 1 || cnt < max) {
			cnt = 1; continue;      //違う票でカウント１か
		}                           //票が少なければ
	
		if (cnt == max) j++;   //同じ得票数なら
		if( cnt >  max) { max = cnt; j = 0; }  //票が多ければ
		pt[j] = i;
		cnt = 1;
	}
	if (max == 1) {
		for (i = 0; i < N; i++)
			s_cout(S[i]);
		return 0;
	}

	for (i = 0; i < j+1; i++)
		s_cout(S[pt[i]]);

	return 0;
}




//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}



Measured memory_bytes: 4476
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <numeric> //lcm


#define ERROR() cout << "ERROR!!" << endl; return 0;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 29; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int &a, int b) { if (a < b) {a = b; return true;} else return false;}


vector<pair<int, int>> factorization(int n) {
	vector<pair<int, int>> factors;

	if (n <= 0) return { {0,0} };

	int exp = 0;
	while (n % 2 == 0) {
		n /= 2;
		exp++;
	}
	/*if (exp > 0)*/ factors.push_back({ 2,exp });

	for (int i = 3; i <= 100; i += 2) {
		int exp = 0;
		while (n % i == 0) {
			n /= i;
			exp++;
		}
		/*if (exp > 0)*/ factors.push_back({ i,exp });
	}

	if (n != 1) factors.push_back({ n,1 });

	return factors;
}

void pplus(vector<pair<int,int>>& a, vector<pair<int, int>>& b) {
	rep(i, a.size()) {
		a[i] = {a[i].first, a[i].second + b[i].second};
	}
}

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

	vector<vector<pair<int, int>>> fs(n+1, vector<pair<int,int>>());
	rep1(i,n) fs[i] = factorization(i);

	rep1(i,n-1) pplus(fs[i+1],fs[i]);

	//rep(i, fs[1].size()) cout << fs[n][i].first << " " << fs[n][i].second << endl;

	int ans = 0;
	rep(i, fs[1].size()) for (int j = i+1; j < fs[1].size(); j++) for (int k = j+1; k < fs[1].size(); k++) {
		int a = fs[n][i].second, b = fs[n][j].second, c = fs[n][k].second;
		if (a >= 2 && b >= 4 && c >= 4) ans++;
		if (a >= 4 && b >= 2 && c >= 4) ans++;
		if (a >= 4 && b >= 4 && c >= 2) ans++;
	}
	rep(i, fs[1].size()) for (int j = i+1; j < fs[1].size(); j++) {
		int a = fs[n][i].second, b = fs[n][j].second;
		if (a >= 14 && b >= 4) ans++;
		if (b >= 14 && a >= 4) ans++;

		if (a >= 24 && b >= 2) ans++;
		if (b >= 24 && a >= 2) ans++;
	}
	rep(i,fs[1].size()) {
		int a = fs[n][i].second;
		if (a >= 74) ans++;
	} 
	

	cout << ans << endl;
}




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

int main() {
  int N; cin >> N;
  vector<int> W(N);
  int Sone = 0;
  int Stwo = 0;
  for (int i = 0; i < N; i++)
  {
    cin >> W.at(i);
    Stwo += W.at(i);
  }
  
  int ans = Stwo;
  for (int i = 0; i < N; i++)
  {
    Sone += W.at(i);
    Stwo -= W.at(i);
    int sa = max(Sone, Stwo) - min(Sone, Stwo);
    ans = min(ans, sa);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,x;
vector <int> g[100010];

int dfs(int pos)
{
	vector <int> v;
	v.clear();
	rep(i,g[pos].size()) v.pb(dfs(g[pos][i]));
	if(v.size()==0) return 0;
	sort(v.begin(),v.end());
	int ret=0;
	for(int i=v.size()-1,j=1;i>=0;i--,j++) ret=max(ret,v[i]+j);
	return ret;
}

int main()
{
	cin>>n;
	for(int i=2;i<=n;i++)
	{
		scanf("%d",&x);
		g[x].pb(i);
	}
	cout<<dfs(1)<<endl;
	return 0;
}

Measured memory_bytes: 15104
#include<iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int A,B;
  int n = 0;
  cin  >> A >> B;    
  int sum = 1;
  
  while(sum < B){
    sum--;
    sum += A;
    n++;
  }
  cout << n << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <cmath>

typedef long long ll;

#include <iostream>
using std::cin;
using std::cout;
using std::ios_base;
using std::endl;

#include <string>
using std::string;
#include <vector>
using std::vector;
#include <map>
using std::map;
#include <set>
using std::set;
#include <bitset>
using std::bitset;
#include <deque>
using std::deque;
#include <queue>
using std::queue;
#include <stack>
using std::stack;
using std::pair;

ll n;
string s;
ll a, b, c, d;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> a >> b >> c >> d;
    cin >> s;
    if (c <= d)
    {
        a--, b--, c--, d--;
        int t = 1;
        for (int i = b; i < d; i++)
        {
            if (s[i] == '#' && s[i + 1] == '#')
                t = 0;
        }
        for (int i = a; i < c; i++)
        {
            if (s[i] == '#' && s[i + 1] == '#')
                t = 0;
        }
        if (t)
            cout << "Yes";
        else
            cout << "No";
    }
    else
    {
        a--, b--, c--, d--;
        int t = 0;
        for (int i = b; i <= d; i++)
        {
            if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.')
                t = 1;
        }
        if (t == 0)
        {
            cout << "No";
            return 0;
        }
        for (int i = a; i < c; i++)
        {
            if (s[i] == '#' && s[i + 1] == '#')
                t = 0;
        }
        if (t)
            cout << "Yes";
        else
            cout << "No";
    }
}


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

bool checkc(char w, char t) {//i番目に対して同じならtrue
  if(w == t) return true;
  else if(96 < w && w < 123 && w - 32 == t) return true;//w小文字
  else if(64 < w && w < 91 && w + 32 == t) return true;//w大文字
  else return false;
}

int main() {
  string w, w2;
  cin >> w;
  int64_t cnt = 0;
  while(true) {
    string t;
    cin >> t;
    if(t == "END_OF_TEXT") break;
    if(w.size() == t.size()) {
      bool check = true;
      for(int i = 0; i < w.size(); i++) {
        if(!checkc(w[i], t[i])) {
          check = false;
          break;
        }
      }
      if(check) cnt++;
    }
  }
  cout << cnt << "\n";
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
int dp[100010]={0};
unordered_map<int,vector<int>>nodes;
int cal(int i){
if(dp[i]!=0)return dp[i];
int &x=dp[i];
for(auto j:nodes[i])x=max(1+ cal(j),x);
return dp[i]=x;
}
int main(){
int n,m;
cin>>n>>m;
for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    nodes[x].pb(y);
}
int is=0;
for(int i=1;i<=n;i++){
    is=max(is,cal(i));
}
cout<<is<<'\n';
return 0;
}


Measured memory_bytes: 11428
#include<iostream>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
	int n,x;
	cin >>x>>n;
	int p[n+2];
	int *q=p;
	*q=-2;
	p[n+1]=102;
	int in;
	rep(i,n){
		cin >>in;
		for(q=p+i;*q>in;*(q+1)=*q,q--);
		*(q+1)=in;	
	}
	q=p;
	int place=-1;
	rep(i,n){
		q++;
		if(*q==x)place=i+1;
	}
	if(place==-1){
		cout<<x;
		return 0;
	}
	int back=place-1,front=place+1;
	int backx=x-1,frontx=x+1;
	while(1){
		if(p[back]!=backx){
			cout << backx;
			return 0;
		}
		if(p[front]!=frontx){
			cout << frontx;
			return 0;
		}
		back--;
		backx--;
		front++;
		frontx++;
	}
}

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

using namespace std;






int main(){
	int size; cin >> size; 
	int jump; cin >> jump;
	int array[size];
	int value[size];
	for(int i=0; i<size; i++){
		int next; cin >> next;
		value[i]=next;
	}

	for(int i=0; i<size; i++){
		array[i]=INT_MAX;
	}
	array[0]=0;
	for(int i=0; i<size; i++){
		for(int j=1; j<=jump && j+i < size; j++){
		 array[i+j]=min( array[i+j], array[i]+ abs(value[i]-value[i+j]));

		}

	}


	cout << array[size-1];

}

Measured memory_bytes: 4384
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<utility>
#include<numeric>
#include<functional>
#include<algorithm>
#include<queue>


#define FOR(i, a, b) for(int i=a; i<b; i++)
#define COUT(a) cout << a << endl;

using namespace std;
using Int = long long;
using P = pair<Int, Int>;

Int H, W;

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


    COUT(n/3);
}

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

using namespace std;

vector<int> calc(int t, string &num, int key){
	vector<int> sum;
	string::reverse_iterator it = num.rbegin();
	int temp = *it - '0';
	int mlt = 10;
	it++;
	for(int i = 1; i <= 1 << (num.size() -2); i <<= 1){
		if((key & i) == i){
			sum.push_back(temp);
			temp = *it - '0';
			mlt = 10;
		}
		else{
			temp += (*it - '0')*mlt;
			mlt *= 10;
		}
		it++;
	}
	sum.push_back(temp);
	/*
	for(int i = 0; i < sum.size(); i++){
		cout << sum[i] << " ";
	}
	cout << endl;
	*/
	return sum;
}

int main(){
	while(true){
		int t;
		string num;
		cin >> t >> num;
		if(t == 0 )break;
		vector<int> ans(1);
		ans[0] = atoi(num.c_str());
		int anssum = t >= ans[0] ? ans[0] : 0;
		bool flag = false;
		for(int i = 1; i < (1 << (num.size()-1)); i++){
			vector<int> temp = calc(t,num,i);
			int sum = accumulate(temp.begin(),temp.end(),0);
			if(sum > t)continue;
			if(sum > anssum){
				anssum = sum;
				swap(ans,temp);
				flag = false;
			}
			else if(sum == anssum){
				flag = true;
			}
		}
		if(anssum == 0){
			cout << "error" << endl;
		}
		else if(flag){
			cout << "rejected" << endl;
		}
		else {
			cout << anssum << " ";
			for(int i = ans.size()-1; i >= 0; i--){
				cout << ans[i];
				if(i != 0){
					cout << " ";
				}
			}
			cout << endl;
		}
	}
		
	return 0;
}

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

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  bool ans = true;
  if (s[0] != 'A') {
    ans = false;
  }
  if (s[1] < 'a' || s[1] > 'z') {
    ans = false;
  }
  if (s[s.length() - 1] < 'a' || s[s.length() - 1] > 'z') {
    ans = false;
  }
  int c_cnt = 0;
  for (int i = 2; i < s.length() - 1; i++) {
    if (s[i] == 'C') {
      c_cnt++;
    } else if (s[i] < 'a' || s[i] > 'z') {
      ans = false;
    }
  }
  if (c_cnt != 1) {
    ans = false;
  }
  if (ans) {
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }
  return 0;
}


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

int main(){
	int a,b,k;
	cin >> a;
	cin >> b;
	if(a > b && (a-b)%2 == 0){
		k = a - (a-b)/2;
		cout << k;
	}
	else if(a < b && (b-a)%2 == 0){
		k = b - (b-a)/2;
		cout << k;
	}
	else if((a-b)%2 != 0 || (b-a)%2 != 0){
		cout << "IMPOSSIBLE";
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
plist = list(map(int, input().split()))

ans = 0

for i in range(1, n-1):
    if plist[i-1] < plist[i] < plist[i+1]:
        ans += 1
    elif plist[i-1] > plist[i] > plist[i+1]:
        ans += 1

print(ans)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, a[1<<18], b[1<<18], c[1<<18];
int main() {
	read(n);
	for (int i = 0; i < (1<<n); i++) read(a[i]);
	for (int i = 0; i < (1<<n); i++)
		for (int j = i; j < (1<<n); j = (j+1)|i)
			c[j] = max(c[j], a[i]+b[j]), b[j] = max(b[j], a[i]);
	for (int i = 0; i < (1<<n); i++) c[i] = max(c[i], c[i-1]);
	for (int i = 1; i < (1<<n); i++) printf("%d\n", c[i]);
	return 0;
}


Measured memory_bytes: 6144
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    0.25 0.5 1 2
    Q H S D
    N
    """
    Q, H, S, D = read_ints()
    N = read_int()
    min_cost_per_liter = min(4*Q, 2*H, S)
    return min(N*min_cost_per_liter, (N//2)*D+(N%2)*min_cost_per_liter)


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 61812
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int W, H, N;
	static int[][] horz, vert;
	static int[] DR = { 1, 0, -1, 0 };
	static int[] DC = { 0, 1, 0, -1 };

	public static void main(String[] args) {
		W = sc.nextInt();
		H = sc.nextInt();
		N = sc.nextInt();
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		horz = new int[H + 1][W];
		vert = new int[H][W + 1];
		for (int i = 0; i < N; ++i) {
			move();
		}
		System.out.println(search((x1 << 16) + y1, (x2 << 16) + y2));
	}

	static int search(int p1, int p2) {
		PriorityQueue<Long> q = new PriorityQueue<Long>();
		q.add((long) p1);
		boolean[][] visited = new boolean[H + 1][W + 1];
		while (true) {
			long cur = q.poll();
			int pos = (int) cur;
			long val = cur >> 32;
			if (pos == p2) return (int) val;
			int x = pos >> 16;
			int y = pos & 0xFFFF;
			if (visited[y][x]) continue;
			visited[y][x] = true;
			for (int i = 0; i < 4; ++i) {
				int nx = x + DC[i];
				int ny = y + DR[i];
				if (nx < 0 || W < nx || ny < 0 || H < ny || visited[ny][nx]) continue;
				int nv;
				if (y != ny) {
					nv = vert[Math.min(y, ny)][x];
				} else {
					nv = horz[y][Math.min(x, nx)];
				}
				q.add(((val + nv) << 32) + (nx << 16) + ny);
			}
		}
	}

	static void move() {
		int x = sc.nextInt();
		int y = sc.nextInt();
		int t = sc.nextInt();
		char[] move = sc.next().toCharArray();
		int[] dir = new int[move.length];
		for (int i = 0; i < move.length; ++i) {
			dir[i] = "DRUL".indexOf(move[i]);
		}
		for (int i = 0; i < t; ++i) {
			for (int j = 0; j < dir.length; ++j) {
				int ny = y + DR[dir[j]];
				int nx = x + DC[dir[j]];
				if (ny < 0) ny = 0;
				if (ny >= H) ny = H - 1;
				if (nx < 0) nx = 0;
				if (nx >= W) nx = W - 1;
				if (y != ny) {
					horz[Math.min(y, ny) + 1][x]++;
				} else if (x != nx) {
					vert[y][Math.min(x, nx) + 1]++;
				}
				y = ny;
				x = nx;
			}
		}
	}

}

Measured memory_bytes: 50312
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ans;
    if(n<2){
        ans = 1;
    }else if( n<4){
        ans = 2;
    }else if(n<8){
        ans = 4;
    }else if(n<16){
        ans = 8;
    }else if(n<32){
        ans = 16;
    }else if(n<64){
        ans = 32;
    }else{
        ans = 64;
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#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 int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(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 DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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

    int n;
    cin>>n;
    map<string,int> dict;
    REP(i,n){
        string cmd, str;
        cin>>cmd>>str;

        if(cmd=="insert"){
            dict[str] = 1;
        }else if(cmd=="find"){
            if(dict[str] == 1) cout << "yes" << endl;
            else  cout << "no" << endl;
        }
    }
    
    return 0;
}


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

#define fec(i, x, y) (int i = head[x], y = g[i].to; i; i = g[i].ne, y = g[i].to)
#define dbg(...) fprintf(stderr, __VA_ARGS__)
#define File(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)
#define fi first
#define se second
#define pb push_back

template<typename A, typename B> inline char SMAX(A &a, const B &b) {return a < b ? a = b , 1 : 0;}
template<typename A, typename B> inline char SMIN(A &a, const B &b) {return b < a ? a = b , 1 : 0;}

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

template<typename I>
inline void read(I &x) {
	int f = 0, c;
	while (!isdigit(c = getchar())) c == '-' ? f = 1 : 0;
	x = c & 15;
	while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15);
	f ? x = -x : 0;
}

int n, a, b;

int main() {
	read(n), read(a), read(b);
	if (a + b <= n) printf("%d 0\n", std::min(a, b));
	else printf("%d %d\n", std::min(a, b), a + b - n);
}

Measured memory_bytes: 256
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    n, k = map(int, input().split())
    p = []
    p = list(map(int, input().split()))
    p.sort()
    ans = 0
    for i in range(k):
        ans += p[i]
    print(ans)


main()

Measured memory_bytes: 9068
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	lint N;
	cin >> N;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	lint Q;
	cin >> Q;
	lint b, e, t;
	rep(tt, Q) {
		cin >> b >> e >> t;
		for (lint k = 0; k < e - b; k++) {
			swap(A[b + k], A[t + k]);
		}
	}
	rep(i, N) {
		cout << A[i];
		if (i != N - 1) {
			cout << ' ';
		}
		else {
			cout << endl;
		}
	}
}




Measured memory_bytes: 3112
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

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


const int L=2e5+10;
char ts[L];
char ds[L];
char s[L];
int main() {
	int N,Q;
	cin >> N >> Q >> (s+1);
	for(int i=0;i<Q;i++){
		cin >> ts[i] >> ds[i];
	}
	int low=0;
	int hi=N+1;
	while(low+1<hi){
		int m=(low+hi)/2;
		int p=m;
		for(int i=0;i<Q;i++){
			if(ts[i]==s[p]){
				if(ds[i]=='L'){
					p--;
				}
				else{
					p++;
				}
			}
		}
		if(p==0){
			low=m;
		}
		else{
			hi=m;
		}
	}
	//cerr << low << endl;
	int ret=low;
	low=0;
	hi=N+1;
	while(low+1<hi){
		int m=(low+hi)/2;
		int p=m;
		for(int i=0;i<Q;i++){
			if(ts[i]==s[p]){
				if(ds[i]=='L'){
					p--;
				}
				else{
					p++;
				}
			}
		}
		if(p==N+1){
			hi=m;
		}
		else{
			low=m;
		}
	}
	//cerr << N+1-hi << endl;
	ret+=N+1-hi;
	cout << N-ret << endl;


	return 0;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int,int> l , pair<int,int> m)
{
	if(l.second!=m.second)
		return l.second<m.second;
	return l.first>m.first;
}

int main() 
{
	int n;
	cin >> n ;
	vector<pair<int,int>> v(n);
	for(int i=0;i<n;i++)
		cin>>v[i].first >>v[i].second;
	sort(v.begin(),v.end(),comp);
	int time = 0;
	for(int i=0;i<n;i++)
	{
		time+=v[i].first;
		if(time>v[i].second)
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n,i,r;
char s[200200];
int main() {
  scanf("%s",s);
  n=strlen(s);
  for (i=0; i<n; i++) if (s[i]=='?') s[i]='D';
  printf("%s\n",s);
  return 0;
}


Measured memory_bytes: 3836
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();

		scan.close();

		//D=25 なら Christmas, D=24 なら Christmas Eve, D=23 なら Christmas Eve Eve, D=22 なら Christmas Eve Eve Eve
		if(N==25) {
			System.out.println("Christmas");
		}
		if(N==24) {
			System.out.println("Christmas Eve");
		}
		if(N==23) {
			System.out.println("Christmas Eve Eve");
		}
		if(N==22) {
			System.out.println("Christmas Eve Eve Eve");
		}
	}

}

Measured memory_bytes: 22612
package main
 
import (
	"fmt"
)

func main() {
	var (
		a int
		o int
	)
	fmt.Scanf("%d", &a)
	if a % 2 == 0  {
		o = (a - 2) / 2
	} else {
		o = (a - 1) / 2
	}
	fmt.Print(o)
}

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

char win(char c)
{
    char tp;
    switch(c) {
        case 'r':
            tp = 'p';
            break;
        case 's':
            tp = 'r';
            break;
        case 'p':
            tp = 's';
            break;
    }
    return tp;
}

void
solver(int n, int k, int r, int s, int p, char *t)
{
    int total=0;
    int i;
    char u[100001], tp;

    for (i=0; i<n; i++) {
        tp = win(t[i]);
        
        if (i+1>k && tp==u[i-k]) {
            if (i>n-k || t[i+k]==tp)
                tp = t[i];
            else {
                tp = t[i+k];
            }
        }
        else {
            switch(tp) {
                case 'r':
                    total += r;
                    break;
                case 's':
                    total += s;
                    break;
                case 'p':
                    total += p;
                    break;
            }
        }
        u[i] = tp;
    }

    printf("%d\n", total);
}

int main(int argc, char *argv[])
{
    int N, K;
    int R, S, P;
    char T[100001];

    scanf("%d%d", &N, &K);
    scanf("%d%d%d", &R, &S, &P);
    scanf("%s", T);

    solver(N, K, R, S, P, T);

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int N;
  cin >> N;
  vector<int> A(N), B(N);
  int first = 0, second = 0;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    if(first <= A[i]) {
      second = first;
      first = A[i];
    }
    else if(second <= A[i]) {
      second = A[i];
    }
  }

  for(int i = 0; i < N; i++) {
    if(A[i] == first) {
      cout << second << endl;
    }
    else {
      cout << first << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 4768
#include<iostream>
using namespace std;
int a[100005],b[100005],c[100005];
int gcd(int a,int b){
	if(a<b) swap(a,b);
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}
int main()
{
	int n,i;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i];
	
	b[1]=a[1];
	for(i=2;i<=n;i++)
		b[i]=gcd(b[i-1],a[i]);
	
	c[n]=a[n];
	for(i=n-1;i>=1;i--)
		c[i]=gcd(c[i+1],a[i]);
	
	int maxv=0;
	for(i=1;i<=n;i++)
		maxv=max(maxv,gcd(b[i-1],c[i+1]));
	cout<<maxv;
	return 0;
}

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

int  hei;
char fld[5002];

void typeW(int s, int l)
{
	int line = 0;
	for(int x=s; x<s+l; x++)
	{
		line |= (1<<x);
	}

	for(int y=hei; y>=0; y--)
	{
		if(fld[y]&line)
		{
			fld [y+1] |= line;
			hei = (y+1>hei?y+1:hei);
			break;
		}
	}
}

void typeH(int s, int l)
{
	int line = (1<<s);
	for(int y=hei; y>=0; y--)
	{
		if(fld[y]&line)
		{
			for(int y2=0; y2<l; y2++)
			{
				fld [y+y2+1] |= line;
				hei = (y+y2+1>hei?y+y2+1:hei);
			}
			break;
		}
	}
}

void eraseline()
{
	for(int y=1; y<=hei; )
	{
		if(fld[y] == 31)
		{
			hei--;
			for(int y2=y; y2<=hei+1; y2++)
			{
				fld[y2] = fld[y2+1];
			}
		}
		else
		{
			y++;
		}
	}
}

int main()
{
	int n,d,p,q,c;
	while(cin >> n, n)
	{
		hei = 0;
		fld[0] = 31;
		for(int y=1; y<5002; y++)
		{
			fld[y] = 0;
		}

		while(n--)
		{
			cin >> d >> p >> q;		
			if(d==1) typeW(q-1,p);
			if(d==2) typeH(q-1,p);
			eraseline();
		}
	
		c=0;
		for(int y=1; y<=hei; y++)
		for(int x=0; x<5;    x++)
		{
			if(fld[y]&(1<<x)) c++;
		}

		cout << c << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> P;

signed main(){
	int N; cin >> N;
	int ans = 0;
	for(int i  =0; i < N; i++){
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt(),b=scan.nextInt(),c=scan.nextInt(),d=scan.nextInt();
		System.out.println(Math.min(a, b)+(Math.min(c, d)));

	}

}


Measured memory_bytes: 35724
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	w := make([]string, n)
	for i:=0; i < n; i++ {
		fmt.Scan(&w[i])
		for j :=0; j < i; j++ {
			if w[i] == w[j] {
				fmt.Println("No")
				return
			}
		}
	}
	var atama,ushiro rune
	kotoba := []rune(w[0]) 
	ushiro = kotoba[len(kotoba) - 1] 
	for i:=1; i < n; i++{
		kotoba = []rune(w[i])

		atama = kotoba[0]
		if atama != ushiro {
			fmt.Println("No")
			return
		}
		ushiro = kotoba[len(kotoba) - 1]
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
N=gets.to_i
a=gets.chomp.split.map(&:to_i)
ans=1


flag = nil
i=0
while(i<N-1)
    if a[i] == a[i+1]
        i+=1
        next
    end

    if flag == nil
        flag = a[i+1] > a[i]
        next
    end

    if flag == a[i+1] > a[i]
        i += 1
    else
        ans += 1
        flag = nil
        i += 1
    end
end
puts ans

Measured memory_bytes: 9476
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<n;i++)

int main(){
  int N;
  cin >> N;
  cout << (1+(N-1)/1000) * 1000 - N << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

int main(void){
    int K, X;
    cin >>K >> X;
    int l, r;
    l = max(X-K+1, -1000000);
    r = min(X+K-1, 1000000);
    for(int i = l; i<r; i++) cout << i <<" ";
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
n = int(stdin.readline().rstrip())
li = [int(stdin.readline().rstrip()) for _ in range(n)]
count = 0
point = 0
for i in li:
    if i == 0:
        point += count//2
        count = 0
    else:
        count += i
point += count//2
print(point)

Measured memory_bytes: 7072
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <deque>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <climits>

using namespace std;

int main(){
    int n, a, b; cin >> n >> a >> b;
    vector<int> hs(n);
    for(int i=0; i<n; ++i){
        cin >> hs[i];
    }
    long long mx=*max_element(hs.begin(), hs.end());
    long long left=0, right=(mx+a-1)*n/a;
    while(right-left>1){
        long long cand=(left+right)/2;
        long long num_extra=0;
        for(int i=0; i<n; ++i){
            long long t=hs[i]-cand*b;
            if(t<=0) continue;
            num_extra+=(t+a-b-1)/(a-b);
        }
        if(num_extra<=cand) right=cand;
        else left=cand;
    }
    cout << right << endl;
    return 0;
}


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

int main(){
	
	ll w,h,x,y; cin>>w>>h>>x>>y;
	cout << (double)w*h/2 << endl;
	if(x*2==w&&y*2==h) cout << 1 << endl;
	else cout << 0 << endl;
	
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define vec vector
#define vll vec<ll>
#define dou(s) atof(s.c_str())
#define lon(s) atoll(s.c_str())
#define str(n) to_string(n)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define line "\n"
#define mav(a) (*max_element(ALL(a)))
#define miv(a) (*min_element(ALL(a)))
#define vfind(a,n) (find(ALL(a),n)-a.begin())
#define prque priority_queue
#define MOD 1000000007ll
using namespace std;
void solve();
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

//nCk(mod p)
/*ll fac[510000], finv[510000], inv[510000];
void cmodf(ll p = MOD) {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	rep(i, 2, 510000) {
		fac[i] = fac[i - 1] * i%p;
		inv[i] = p - inv[p%i] * (p / i) % p;
		finv[i] = finv[i - 1] * inv[i] % p;
	}
}
ll cmod(ll n, ll k, ll p = MOD) {
	return fac[n] * (finv[k] * finv[n - k] % p) % p;
}*/

//最大公約数
ll gcd(ll n, ll m) {
	ll k = n % m;
	while (k != 0) { n = m; m = k; k = n % m; }
	return m;
}
ll gcd(vector<ll> a) {
	rep(i, 1, a.size()) {
		ll k = a[i - 1] % a[i];
		while (k != 0) {
			a[i - 1] = a[i];
			a[i] = k;
			k = a[i - 1] % a[i];
		}
	}
	return a.back();
}

//最小公倍数
ll lcm(ll n, ll m) {
	ll t = n * m, k = n % m;
	while (k != 0) { n = m; m = k; k = n % m; }
	return t / m;
}
ll lcm(vector<ll> a) {
	ll n;
	rep(i, 1, a.size()) {
		n = a[i - 1] * a[i];
		ll k = a[i - 1] % a[i];
		while (k != 0) {
			a[i - 1] = a[i];
			a[i] = k;
			k = a[i - 1] % a[i];
		}
		n /= a[i];
		a[i] = n;
	}
	return n;
}

//keyの小さい方から探していった時に初めてvalueがjoken以上になる時のkey（keyが増えたらvalueも増えるか同じになるとき）
ll value(ll key) {
	/*変更*/
	return 0;
}
ll mini(ll lkey, ll rkey/*ここも調べる*/, ll joken) {
	ll mkey;
	while (lkey != rkey) {
		mkey = (lkey + rkey) / 2;
		if (value(mkey) >= joken)rkey = mkey;
		else lkey = mkey + 1;
	}
	return rkey;
}

//ペア配列の整理
struct cpl {
	ll f, s;
	bool operator<(const cpl &c) const {
		return f != c.f ? f < c.f : s < c.s;
	};
};

//変数定義

//再帰関数

//アルゴリズム
void solve() {
	ll n; cin >> n;
	vec<vll> a(n, vll(n, 0));
	rep(i, 0, n) {
		ll k, m; cin >> k >> m;
		rep(j, 0, m) {
			ll l; cin >> l;
			a[k - 1][l - 1] = 1;
		}
	}
	vll st(n, 0), en(n, 0);
	ll t = 0;
	while (miv(st) == 0) {
		ll k; t++;
		rep(i, 0, n)if (st[i] == 0) { k = i; break; }
		deque<ll> b(1, k);
		st[k] = t;
		rep(i, 0, n)a[i][k] = 0;
		while (b.size() != 0) {
			t++;
			bool x = true;
			rep(i, 0, n) {
				if (a[b[b.size() - 1]][i] == 1) {
					rep(j, 0, n)a[j][i] = 0;
					b.push_back(i);
					st[i] = t;
					x = false;
					break;
				}
			}
			if (x) {
				en[b[b.size() - 1]] = t;
				b.pop_back();
			}
		}
	}
	rep(i, 0, n) {
		cout << i + 1 << " " << st[i] << " " << en[i] << line;
	}
}


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

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

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

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

  cout << lcm(a,b) << endl;

  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, m;
    string s[110], t[110];

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

    cin >> m;
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }

    int max = 0;
    for (int i = 0; i < n; i++) {
        int plus = 0, minus = 0;
        for (int j = 0; j < n; j++) {
            if (s[i] == s[j]) plus++;
        }
        for (int j = 0; j < m; j++) {
            if (s[i] == t[j]) minus++;
        }
        if (plus - minus > max) {
            max = plus - minus;
        }
    }

    cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
ios::sync_with_stdio(false);cin.tie(0);
    int N;
    cin>>N;
    int cnt = 0,m=0;
    for (size_t i = 0; i < N; i++)
    {
        int d1,d2;
        cin>>d1>>d2;
        if(d1==d2)
        {
            cnt++;
        }
        else
        {
            cnt=0;
        }
        chmax(m,cnt);
        
    }
    if(m>=3)
    {
        cout<<"Yes";
    }else
    {
        cout<<"No";
    }
    
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int main(){
  int n,c;cin>>n>>c;
  int d[c+1][c+1];
  int s[n][n];
  for(int i=1;i<=c;i++)for(int j=1;j<=c;j++)cin>>d[i][j];
  int v[3][c+1];
  for(int i=0;i<c+1;i++){
    v[0][i]=0;v[1][i]=0;v[2][i]=0;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>s[i][j];
      int q=(i+j)%3;
      v[q][s[i][j]]++;
     
    }
  }
  int ma=1<<30;
 for(int i=1;i<=c;i++){
   for(int j=1;j<=c;j++){
     if(i!=j){
       for(int k=1;k<=c;k++){
         int sum=0;
         if(k!=i&&k!=j){
           for(int l=1;l<=c;l++)sum+=v[0][l]*d[l][i];
           for(int l=1;l<=c;l++)sum+=v[1][l]*d[l][j];
           for(int l=1;l<=c;l++)sum+=v[2][l]*d[l][k];
           ma=min(ma,sum);
         }
       }
     }
   }
 }
  cout<<ma<<endl;
}


Measured memory_bytes: 1280
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("sumsqr.in");ofstream out("sumsqr.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

ll a,k;

int check(vec<pii> &o){
    set<int> s;
    for(pii p : o){
        s.insert(p.S-p.F);
        s.insert(a-(p.S-p.F));
    }
    return s.size()==o.size()*2;
}

int main() {
    fast;
    cin>>a>>k;
    vec<pii> o;
    if(a%2==1){
        for(int q=0; q<k; q++) o.pb({q+1, a-q});
    }
    else{
        for(int q=0; q<k; q++){
            o.pb({q+1, a-q-(q>=a/4)});
        }
    }
    for(pii p : o) cout<<p.F<<" "<<p.S<<"\n";
    //cout<<"RES: "<<check(o);
}

Measured memory_bytes: 4328
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

ll n;
float ans;
vector<float> a;

void input(void){
   cin>>n;
   rep(i,n){
       cin>>ans;
       a.push_back(ans);
   }
}
void solve(void){
    ans=0;
    rep(i,n){
        ans+=(1/a[i]);
    }
    cout<<1/ans<<endl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
typedef long long int ll;
const int MOD = 1000000007;
const int MAX = 1100000;

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

void comInit() {
	fac[0] = fac[1] = inv[1] = finv[0] = finv[1] = 1;
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long nCr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}
int main( void ){
	int x, y;
	std::cin >> x >> y;
	if (( x + y ) % 3 != 0){
		printf( "0\n" );
		return 0;
	}
	int n = ( 2 * y - x ) / 3;
	int m = ( 2 * x - y ) / 3;
	comInit();
	printf( "%d\n", nCr(n+m, n));
}


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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> V(N + 1), W(N + 1);
    for (int64_t i = 1; i <= N; i++) {
        cin >> V[i] >> W[i];
    }

    int64_t Q;
    cin >> Q;
    vector<int64_t> v(Q), L(Q);
    for (int64_t i = 0; i < Q; i++) {
        cin >> v[i] >> L[i];
    }

    //半分全列挙
    int64_t lb = min(N, (int64_t)(1ull << 9));
    int64_t MAX_WEIGHT = 1e5;

    //dp[i][j] := i番目のノードにおいて残り容量がjであるときの最大価値
    vector<vector<int64_t>> dp(lb + 1, vector<int64_t>(MAX_WEIGHT + 1, 0));

    //1のところを初期化
    for (int64_t j = W[1]; j <= MAX_WEIGHT; j++) {
        dp[1][j] = V[1];
    }

    for (int64_t i = 1; i <= lb; i++) {
        for (int64_t j = 0; j <= MAX_WEIGHT; j++) {
            //選ばない場合
            dp[i][j] = max(dp[i][j], dp[i / 2][j]);

            //選ぶ場合
            if (j - W[i] >= 0) {
                dp[i][j] = max(dp[i][j], dp[i / 2][j - W[i]] + V[i]);
            }
        }
    }

    //クエリを解く
    for (int64_t i = 0; i < Q; i++) {
        //スタート位置が基準より前だったらそのまま答えて終わり
        if (v[i] <= lb) {
            cout << dp[v[i]][L[i]] << endl;
            continue;
        }

        //そうでなかったらlbに入るまでを全探索
        vector<int64_t> curr_v, curr_w;
        int64_t node = v[i];
        for (; node > lb; node /= 2) {
            curr_v.push_back(V[node]);
            curr_w.push_back(W[node]);
        }

        int64_t ans = 0;
        int64_t max_bit = (1ull << curr_v.size());
        for (int64_t j = 0; j < max_bit; j++) {
            int64_t curr_ans = 0, curr_weight = 0;
            for (int64_t k = 0; k < curr_v.size(); k++) {
                if (j & (1ull << k)) {
                    curr_ans += curr_v[k];
                    curr_weight += curr_w[k];
                }
            }

            if (curr_weight > L[i]) {
                continue;
            }

            ans = max(ans, curr_ans + dp[node][L[i] - curr_weight]);
        }

        cout << ans << endl;
    }
}

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

int main() {
  int N;
  cin >> N;
  
  int odd_count = 0;
  int a;
  for (int i = 0; i < N; i++) {
    cin >> a;
    if(a % 2) odd_count++;
  }
  
  if (odd_count % 2) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
 
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#define MN 300000
#define N 131072
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,m,Ans[MN+5],T[N*2+5];
vector<int> v[MN+5];
vector<pair<int,int> >q[MN+5];
inline void Renew(int x,int v){for(T[x+=N]+=v;x>>=1;)T[x]=T[x<<1]+T[x<<1|1];}
inline int Query(int l,int r)
{
    int res=0;
    for(l+=N-1,r+=N+1;l^r^1;l>>=1,r>>=1)
    {
        if(~l&1) res+=T[l+1];
        if( r&1) res+=T[r-1];
    }
    return res;
}
int main()
{
    n=read();m=read();
    for(int i=1;i<=n;++i)
    {
        int l=read(),r=read();
        v[r].push_back(l);
    }
    for(int i=1;i<=m;++i)
    {
        for(int j=0;j<m;j+=i)
        {
            int nx=min(m+1,j+i);
            if(j+1<=nx-1) q[nx-1].push_back(make_pair(j+1,i));
        }
    }
    for(int i=1;i<=m;++i)
    {
        for(int j=0;j<v[i].size();++j) Renew(v[i][j],1);
        for(int j=0;j<q[i].size();++j) Ans[q[i][j].second]+=Query(q[i][j].first,m);
    }
    for(int i=1;i<=m;++i) printf("%d\n",n-Ans[i]);
    return 0;
}


Measured memory_bytes: 33272
n = (int)(input())
alp = [10000 for i in range(0 , 90)]
for i in range(0 , n):
	s = input()
	now = [0 for i in range(29)]
	for i in s:
		now[ord(i)-ord('a')]+=1
	for i in range(0  ,27):
		alp[i]=min(alp[i], now[i])
res = ""
for i in range(0 , 26):
	if alp[i]>=1:
		res = res+"".join(([(chr(i+ord('a')))]*alp[i]))
print(res)

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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int i = a;i < b;++i) cout << ary[i] << (b-1 == i ? "]\n" : ", "); } while(0)
#define p_map(map,it) do {cout << "{";for (auto it = map.begin();;++it) {if (it == map.end()) {cout << "}\n";break;}else cout << "" << it->first << "=>" << it->second << ", ";}}while(0)

int n;
ll sums[410];
vector<vector<ll>> dp(410,vector<ll>(410,-1));

ll rec(int l,int r) {
    if (dp[l][r] > -1) return dp[l][r];
    ll res = INT64_MAX;
    for (int i = l;i < r;++i) {
        ll temp = rec(l,i)+rec(i+1,r);
        res = min(res,temp);
    }
    return dp[l][r] = res+sums[r+1]-sums[l];
}

int main() {
    cin >> n;
    for (int i = 0;i < n;++i) {
        cin >> sums[i+1];
        sums[i+1] += sums[i];
        dp[i][i] = 0;
    }
    cout << rec(0,n-1) << endl;
    return 0;
}

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

#define pb push_back
#define F first
#define S second

#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define int long long
#define ll long long


	
void solve(){
	int x, n;
	cin >> x >> n;
	int a[n];
	map<int, int> mp;
	for(int i = 0 ; i < n ; i++){
		cin >> a[i];
		mp[a[i]]++;	
	}
	int i = 0;
	while(true){
		if(!mp[x - i]){
			cout << x - i;
			break;
		}
		if(!mp[x + i]){
			cout << x + i;
			break;
		}
		i++;
	}
}

signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
int main (void)
{
    int a[5],b[5],i,j,hit,blow;
    while(scanf("%d",&a[0])!=EOF){
        hit=0,blow=0;
        for(i=1;i<4;i++){
            scanf("%d",&a[i]);
        }
        for(i=0;i<4;i++){
            scanf("%d",&b[i]);
            for(j=0;j<5;j++){
                if(b[i]==a[j]){
                    if(i==j) hit++;
                    else blow++;
                }
            }
        }
        printf("%d %d\n",hit,blow);
    }
    return 0;
}

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b+c||b==c+a||c==a+b){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <iomanip>
#include <time.h>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    string X;
    cin >> X;
    int cnt=0;

    vector<vector <ll> > R(N,vector<ll>(2,0)); // cnt-1, cnt+1

    vector<char> X_reverse(N);
    for(int i=0; i<N; i++){
        if(X[i]=='1') cnt++;
        X_reverse[N-1-i]=X[i];
    }
    
    ll num1=1,num2=1;
    if(cnt!=0 && cnt!=1) R[0][0]=num1%(cnt-1);
    R[0][1]=num2%(cnt+1);
    for(int i=1; i<N; i++){
        if(cnt!=0 && cnt!=1){
            num1=num1*2%(cnt-1);
            R[i][0]=num1;
        }
        num2=num2*2%(cnt+1);
        R[i][1]=num2;
    }

    ll div1=0,div2=0;
    for(int i=0; i<N; i++){
        if(X_reverse[i]=='1'){
            if(cnt!=0 && cnt!=1) div1=(div1+R[i][0])%(cnt-1);
            div2=(div2+R[i][1])%(cnt+1);
        }
    }

    for(int i=0; i<N; i++){
        ll now;
        int ans=1;
        if(X[i]=='1' && cnt==1){
            ans=0;
            now=0;
        }else if(X[i]=='1'){
            now=(div1+cnt-1-R[N-1-i][0])%(cnt-1);
        }else{
            now=(div2+cnt+1+R[N-1-i][1])%(cnt+1);
        }
        while(now!=0){
            ll tmp=now;
            int c=0;
            while(tmp!=0){
                if(tmp%2==1) c++;
                tmp/=2;
            }
            now%=c;
            ans++;
        }
        cout << ans << endl;
    }

    
    

    return 0;
}

Measured memory_bytes: 14544
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0;
string s;
std::cin >> s;
rep(i,s.size()){
  if(s[i]=='C'){
    x++;
  }else if(s[i]=='F'&&x>0){
    std::cout << "Yes" << '\n';
    return 0;
  }
}
std::cout << "No" << '\n';
}


Measured memory_bytes: 256
a, b = gets.split.map(&:to_i)
if b == 0
  puts a
  exit
end

c = gets.split.map(&:to_i)
d = 100

if c.include?(a)
  a_d = a - 1
  a_a = a + 1
else
  puts a
  exit
end

while d == 100 do
  if c.include?(a_d)
  	a_d = a_d - 1
  else
    puts a_d
    exit
  end
  
  if c.include?(a_a)
    a_a = a_a + 1
  else
    puts a_a
    exit
  end
end

Measured memory_bytes: 14360