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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;



int main() {
	vector<pair<lli, lli> >ab;
	lli n, i, j, k;

	cin >> n;
	SIZE(ab, n);

	rep(i, n) {
		cin >> j >> k;
		ab[i] = make_pair(k, j);
	}
	sort(ALL(ab));
	
	j = ab[0].first;
	k = ab[0].second;
	if (j < k) {
		cout << "No";
		return 0;
	}
	repj(i,1, n) {
		j = ab[i].first;
		k += ab[i].second;
		if (j < k) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";

	return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n = 3;
  vector<int> a(n); rep(i,n) cin >> a[i];
  int k; cin >> k;

  sort(a.begin(),a.end());
  rep(i,k){
    a[n-1] *= 2;
  }

  int sum = 0;
  rep(i,n) sum+=a[i];

  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 3636
n = int(input())
a = list(map(int, input().split())) # 横入力

ans = 'APPROVED' 
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 != 0 and a[i] % 5 != 0:
            ans = 'DENIED'
            break

print(ans)

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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2")

using namespace std;

#define f first
#define s second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define up(x, v) upper_bound(all(x), v)
#define low(x, v) lower_bound(all(x), v)
#define bin(x, v) binary_search(all(x), v)
#define FOR(k, a, b) for(int k = (a); k < (b); ++k)
#define ROF(k, a, b) for(int k = (a); k > (b); --k)
#define fn(k, n) for(int k = 0; k < n; ++k)

#define EPS 1.0e-9

#define X real()
#define Y imag()

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

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using point = pair<double, double>;
using Vector = complex<double>;

int main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int h, a;

	cin >> h >> a;

	cout << (h + a - 1) / a << '\n';

    return 0;
}


Measured memory_bytes: 256
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;



int main() {
	int X, N;
	cin >> X >> N;

	map<int, bool> P;

	for (int i=0; i<N; i++) {
		int p;
		cin >> p;
		P[p] = true;
	}

	int ans = -1000;
	for (int i=-1000; i<1000; i++) {
		if (P[i] == true) continue;
		if (abs(X - i) < abs(X - ans)) ans = i;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3692
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct Card{
  char suit;
  int value;
};
void bubble(struct Card A[],int N){
  int i,j;
  struct Card t;
  for(i = 0 ; i < N ; i++){
    for(j = N - 1 ; j >= i + 1 ; j--){
      if(A[j].value < A[j - 1].value){
	t = A[j];
	A[j] = A[j - 1];
	A[j - 1] = t;
      }
    }
  }    
}

void selection(struct Card A[],int N){
  int i,j,minj;
  struct Card t;
  for(i = 0 ; i < N ; i++){
    minj = i;
    for(j = i ; j < N ; j++){
      if(A[j].value < A[minj].value)minj = j;
    }
    t = A[i];
    A[i] = A[minj];
    A[minj] = t;
  }
}

void print(struct Card A[],int N){
  int i;
  for(i = 0 ; i < N ; i++){
    if(i > 0)printf(" ");
    printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(struct Card C1[],struct Card C2[],int N){
  int i;
  for(i = 0 ; i < N ; i++){
    //if(strcmp(&C1[i].suit,&C2[i].suit) != 0)return 0;
if (C1[i].suit != C2[i].suit ) return 0;
  }
  return 1;
}

int main(){
  struct Card C1[100],C2[100];
  int N,i;
  char num[3];

  scanf("%d",&N);
  for(i = 0 ; i < N ; i++){
    scanf("%s",num);
    C1[i].suit = num[0];
    C1[i].value = atoi(&num[1]);
  }

  for(i = 0 ; i < N ; i++){
    C2[i] = C1[i];
  }
  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }
  return 0;
}



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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

inline li calc(vector<li>& x) {
    li n = sz(x);
    li total = 0;
    li res = 0;
    rin{
        total += x[i];
        res = (res + total) % MOD;
    }
    total = res;
    repp(i, 1, n) {
        total = (total - x[i - 1] * (n - i + 1) % MOD + MOD) % MOD;
        res = (res + total) % MOD;
    }
    return res;
}

int main() {
    vector<li> x, y;
    vector<li> dx, dy;
    li n, m;
    cin >> n >> m;
    rin{
        li tmp;
        cin >> tmp;
        x.pb(tmp);
        if (i > 0) {
            dx.pb(x[i] - x[i - 1]);
        }
    }
    rep(i, m) {
        li tmp;
        cin >> tmp;
        y.pb(tmp);
        if (i > 0) {
            dy.pb(y[i] - y[i - 1]);
        }
    }

    cout << calc(dx)*calc(dy) % MOD << endl;



    return 0;
}

Measured memory_bytes: 4204
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long int LL;
const int Max_N(100050);

int N, Head[Max_N], Total, To[Max_N << 1], Next[Max_N << 1], Weight[Max_N << 1], Size[Max_N], SonMax[Max_N], root;
LL Ans;

inline void Add_Edge(int s, int t, int w)
{
	++Total, To[Total] = t, Next[Total] = Head[s], Weight[Total] = w, Head[s] = Total;
}

void dfsSize(int u, int fa)
{
	Size[u] = 1, SonMax[u] = 0;
	for (int i = Head[u], v;i;i = Next[i])
		if ((v = To[i]) != fa)
			dfsSize(v, u), Size[u] += Size[v], SonMax[u] = max(SonMax[u], Size[v]);
	SonMax[u] = max(SonMax[u], N - Size[u]);
}

void dfsDist(int u, int fa, LL Dis)
{
	Ans += Dis * 2LL;
	for (int i = Head[u], v;i;i = Next[i])
		if ((v = To[i]) != fa)
			dfsDist(v, u, Dis + Weight[i]);
}

/*
考虑提出任意重心root，可以证明：存在一个最优解，使得哈密顿路上相邻两个点的路径均经过root
可以先构造出哈密顿回路：把在不同子树中的点两两匹配起来（可能存在孤立点），以root为起点，再考虑root走到的点和走到root的点，显然哈密顿回路 = Sum{2 * Dist(root, i)   |   1 <= i <= N}
然后考虑去掉哈密顿回路上边权最小的边就可以得到答案，显然一定是去掉和root相邻的一个点x到root的路径（是root走到的点或走到root的点）
当最大子树匹配过程中有孤立点时，x必须在可能存在孤立点的子树中（x是root走到的点或走到root的点）：(1)最大子树 或 (2)去掉该子树中1个点，2 * 最大子树 <= 剩下的点数N - 2 
*/

int main()
{
	scanf("%d", &N);
	for (int i = 1, u, v, w;i != N;++i)
		scanf("%d%d%d", &u, &v, &w), Add_Edge(u, v, w), Add_Edge(v, u, w);
	dfsSize(1, -1), root = 1;
	for (int i = 2;i <= N;++i)
		if (SonMax[i] < SonMax[root])
			root = i;
	dfsDist(root, -1, 0LL);
	dfsSize(root, -1);
	int Min(0X3F3F3F3F);
	if (N & 1)//SonMax[root] <= N / 2，N是奇数故SonMax[root] <= (N - 1) / 2，所以可以两两匹配，不存在孤立点
		for (int i = Head[root];i;i = Next[i])
			Min = min(Min, Weight[i]);
	else//找可能存在孤立点的子树 
		for (int i = Head[root], v;i;i = Next[i])
			if (Size[v = To[i]] == SonMax[root] || (N - 2 >= 2 * SonMax[root]))
				Min = min(Min, Weight[i]);
	printf("%lld", Ans - Min);
	return 0;
}

Measured memory_bytes: 7680
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] check = { "this", "that", "the" };
        while (sc.hasNext()) {
            String str = sc.nextLine();
            end: for (int i = 0; i < 26; i++) {
                for (String t : check) {
                    if (str.contains(t)) {
                        System.out.println(str);
                        break end;
                    }
                }
                String temp = "";
                for (char c : str.toCharArray()) {
                    if (c >= 'a' && c <= 'z')
                        c = (char) (c == 'z' ? 'a' : c + 1);
                    temp += c;
                }
                str = temp;
            }
        }
    }
}


Measured memory_bytes: 26480
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#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 all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int main()
{
    int a, b;
    cin >> a >> b;
    if(a%3 == 0||b%3 == 0||(a+b)%3 == 0) puts("Possible");
    else puts("Impossible");
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

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

    if (n == 3) {
        cout << "2 5 63" << endl;
        return 0;
    }
    if (n == 4) {
        cout << "2 5 20 63" << endl;
        return 0;
    }
    if (n == 6) {
        cout << "3 9 2 4 6 12" << endl;
        return 0;
    }

    int cnt = 0;
    vector<int> ans;
    if (n % 2 == 0) {
        ans = { 2, 4, 6, 8, 10, 12, 3, 9 };
        cnt = 8;

        for (int i = 14; i+10 <= 30000; i += 12) {
            if (cnt + 6 > n)
                break;
            for (int j = 0; j < 6; j++)
                ans.push_back(i + 2 * j);
            cnt += 6;
        }
        for (int i = 15; i+6 <= 30000; i += 12) {
            if (cnt == n)
                break;
            ans.push_back(i);
            ans.push_back(i + 6);
            cnt += 2;
        }
        for (int i = 0; i < n; i++)
            cout << (i == 0 ? "" : " ") << ans[i];
        cout << endl;
    }
    else {
        ans = { 2,4,6,3,9 };
        cnt = 5;
        for (int i = 8; i+10 <= 30000; i += 12) {
            if (cnt + 6 > n)
                break;
            for (int j = 0; j < 6; j++)
                ans.push_back(i + 2 * j);
            cnt += 6;
        }
        for (int i = 15; i+6 <= 30000; i += 12) {
            if (cnt == n)
                break;
            ans.push_back(i);
            ans.push_back(i + 6);
            cnt += 2;
        }
        if (n == 19999) {
            ans.push_back(29996);
            ans.push_back(29998);
        }
       
        for (int i = 0; i < n; i++)
            cout << (i == 0 ? "" : " ") << ans[i];
        cout << endl;
    }


    return 0;
}

Measured memory_bytes: 512
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

import math
r = inn()
print(2*math.pi*r)


Measured memory_bytes: 62148
n = int(input())
A = list(map(int,input().split()))

def chk(i,A):
    bl = False
    for j in range(i+1,n):
        if A[j] > A[i]:
            bl = True
            break
        elif A[j] < A[i]:
            break
    return bl

def buy(cash, kabu, ai):
    num = int(cash / ai)
    cash -= num * ai
    kabu += num
    return cash,kabu

def sell(cash, kabu, ai):
    cash += kabu * ai
    kabu = 0 
    return cash,kabu

cash = 1000
kabu = 0
for i in range(n):
    if chk(i,A):
        (cash, kabu) = buy(cash, kabu, A[i])
    else:
        (cash, kabu) = sell(cash, kabu, A[i])

print(cash)

Measured memory_bytes: 9168
import math
import sys


def parse(file):
    n, k = map(int, file.readline().split())
    return n, k


def main(n, k):
    if k % 2 == 1:
        return math.floor(n / k) ** 3
    else:
        return math.floor(n / k) ** 3 + math.floor((n + k/2) / k) ** 3


if __name__ == '__main__':
    print(main(*parse(sys.stdin)))

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

int main() {
  int N = 0, A, B;
  cin >> A >> B;
  for (int i = A; i <= B; i++) {
  int s1, s2, s3, s4;
  s1 = i / 10000;
  s2 = i % 10000 / 1000;
  s3 = i % 10000 % 1000 % 100 / 10;
  s4 = i % 10000 % 1000 % 100 % 10;
    if(s1 == s4 && s2 == s3)
    N += 1;
  }
  cout << N;
}


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

int main() {
  int A, B;
  int n = 0;
  cin >> A >> B;
  
  for(int i = A; i <= B; i++){
    if(i / 10000 == i % 10 &&
       i / 1000 % 10 == i / 10 % 10)
      n++;
  }
  cout << n << endl;
}

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

int main() {
    long long l, r; cin >> l >> r;
    if(r-l>=2018){
        cout << 0 << endl;
        return 0;
    }
    long long ans=2018;
    for(long long  i=l; i<r; i++){
        for(long long j=i+1; j<=r; j++){
            ans=min(ans, (i*j)%2019);
          if(ans==0){
          	cout << 0 << endl;
          	return 0;
          }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
const int MOD = 1e9+7;
const int MOOD = 998244353;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

int dp[200000][11];

int main(){
	int d, g;
	cin >> d >> g;
	vector<int> p(d+1), c(d+1);
	g /= 100;
	for (int i = 0; i < 200000; i++){
		for (int j = 0; j <= 10; j++){
			dp[i][j] = MOD;
		}
	}

	for (int i = 1; i <= d; i++){
		cin >> p[i] >> c[i];
		c[i] /= 100;
	}
	dp[0][0] = 0;
	for (int i = 0; i <= g; i++){
		for (int j = 1; j <= d; j++){
			if (dp[i][j-1] != MOD){
				for (int k = 0; k < p[j]; k++){
					dp[i+j*k][j] = min(dp[i][j-1] + k, dp[i+j*k][j]);
				}
				dp[i+j*p[j]+c[j]][j] = min(dp[i][j-1] + p[j], dp[i+j*p[j]+c[j]][j]);
			}
		}
	}
	int ans = MOD;
	for (int i = g; i <= g+20000; i++){
		for (int j = 1; j <= d; j++){
			ans = min(ans, dp[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12192
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int P[1010];
int cost[5000];
int src[5000];	
int dst[5000];
int A[100 + 10][100 + 10];
int M = 0;
vector< pair<int,int> > edges;

void init(int N)
{
    for(int i = 1; i <= N; ++i)
    {
        P[i] = i;
    }
}
 
int root(int a)
{
    if(P[a] == a)
    {
        return a;
    }
    return (P[a] = root(P[a]));
}
 
bool is_same_set(int a, int b)
{
    return root(a) == root(b);
}
 
void unite(int a, int b)
{
    P[root(a)] = root(b);
}

int main()
{
	int n = 0;
	cin >> n; 
	for(int r = 0; r < n; ++r)
	{
		for(int c = 0; c < n; ++c)
		{
			cin >> A[r][c];
		}
	}
	for (int r = 0; r < n; ++r)
	{
		for(int c = r + 1; c < n; ++c)
		{
			if(A[r][c] > -1)
			{
				cost[M] = A[r][c];
				src[M] = r;
				dst[M] = c;
				edges.push_back(make_pair(cost[M],M));
				M += 1;
			}
		}
	}
	sort(edges.begin(),edges.end());
	int sum = 0;
	init(n);
	for(int i = 0; i < M; ++i)
	{
		if(is_same_set(src[edges[i].second], dst[edges[i].second]) == 1) continue;
			unite(dst[edges[i].second],src[edges[i].second]);
			sum += edges[i].first;
	}
	cout << sum << endl;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
long long a[100005],s[100005];
int solve(int l,int r,long long x)
{
	if(a[l]>x) return -1;
	while(l+1<r)
	{
		int mid=(l+r)>>1;
		if(a[mid]<=x) l=mid;
		else r=mid-1;
	}
	if(a[r]<=x) return r;
	else return l;
}

int main()
{
	//freopen("1.txt","r",stdin);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	s[0]=0;
	for(int i=1;i<=n;++i) s[i]=a[i]+s[i-1];
	int ans=0;
	for(int i=1;i<=n;++i)
	{
		int l=1;
		long long v=0,p=2*a[i];
		while(l<=n)
		{
			int x=solve(l,n,p);
			if(x==-1) break;
			v+=s[x]-s[l-1];
			p=2*v;
			l=x+1;
		}
		if(l>n) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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


bool cp(long long a, long long b)
{
    int x = 0, y = 0;
    for(auto t = a; t; t /= 10)
        x += t % 10;
    for(auto t = b; t; t /= 10)
        y += t % 10;
    return a * y < b * x;
}

int main()
{
    vector<long long> v;

    for(int i = 1; i < 10; i++)
        v.push_back(i);


    for(long long int i = 10, j = 1; i < 1e15; i *= 10, j++) {
        long long m = i + 9, mm = 10, mmm = 10;

        for (long long k = 1, l = 1, b = i; k <= j; k++, l *= 10) {
            b += l * 9;

            if (b * mm < m * (k * 9 + 1)) {
                m = b;
                mm = k * 9 + 1;
                mmm = l * 10;
            }
        }


        while (m < i * 10) {

            while (v.size() && cp(m, v.back()))
                v.pop_back();

            v.push_back(m);
            m += mmm;
        }
    }




    int K;
    cin >> K;
    for (int i = 0; i < K; i++) {
        cout << v[i] << '\n';

    }


}


Measured memory_bytes: 256
l = list(input())

from itertools import product
t = list(product('+-', repeat=3))

for i in range(len(t)):
    temp = l[0]+t[i][0]+l[1]+t[i][1]+l[2]+t[i][2]+l[3]
    if eval(temp) == 7:
        print(temp + '=7')
        break

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



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


Measured memory_bytes: 3560
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n, m = map(int,input().split())
    A = list(map(int,input().split()))
    res = n - sum(A)
    res = max(res, -1)
    print(res)
resolve()

Measured memory_bytes: 66924
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    def prime(n):
        if n<=1: return False
        A = [i for i in range(2, n+1)]
        P = []
        lim = n**.5
        while True:
            prime = A[0]
            if prime > lim: break
            P.append(prime)
            i = 0
            while i < len(A):
                if A[i] % prime == 0:
                    A.pop(i)
                    continue
                i += 1
        for a in A:
            P.append(a)
        return P

    C=5+10**5
    S=[0]*C
    T=[0]*C
    for p in prime(C):
        S[p]=1
    for i in range(C):
        if i%2==0: continue
        if S[i]==1 and S[(i+1)//2]==1:
            T[i]=1
    # cumsum
    for i in range(C-1):
        T[i+1]+=T[i]
    # input
    q=int(input())
    for _ in range(q):
        l,r=map(int,input().split())
        print(T[r]-T[l-1])
resolve()

Measured memory_bytes: 8600
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです
*/

// Dep crates are...
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::{i32, i64, isize, u32, u64, usize};

use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_integer::{binomial, gcd, lcm, Integer};
use permutohedron::Heap;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

// code...
#[fastout]
fn main() {
    input! {
        n: usize,
        s: Chars
    }

    let mut r = vec![0; n+1];
    let mut g = vec![0; n+1];
    let mut b = vec![0; n+1];


    for (i, c) in s.iter().enumerate() {
        r[i+1] = r[i] + if *c == 'R' { 1 } else { 0 };
        g[i+1] = g[i] + if *c == 'G' { 1 } else { 0 };
        b[i+1] = b[i] + if *c == 'B' { 1 } else { 0 };
    }

    // println!("{:?}", r);
    // println!("{:?}", g);
    // println!("{:?}", b);

    let mut rr = vec![0; n-1];
    let mut gg = vec![0; n-1];
    let mut bb = vec![0; n-1];

    for i in 0..n {
        for j in 0..n {
            if (i + j) % 2 == 0 {
                match (s[i], s[j]) {
                    ('R', 'G') | ('G', 'R') => bb[((i+j)/2)-1] += 1,
                    ('B', 'G') | ('G', 'B') => rr[((i+j)/2)-1] += 1,
                    ('R', 'B') | ('B', 'R') => gg[((i+j)/2)-1] += 1,
                    _ => {}
                }
            }
        }
    }

    // println!("{:?}", rr);
    // println!("{:?}", gg);
    // println!("{:?}", bb);

    let mut ans = 0u64;

    for (i, mid) in s.iter().enumerate().skip(1).take(n-2) {
        ans += match mid {
            'R' => {
                (g[i] * (b[n]-b[i+1])) + (b[i] * (g[n]-g[i+1])) - rr[i-1] / 2
            }
            'G' => {
                (r[i] * (b[n]-b[i+1])) + (b[i] * (r[n]-r[i+1])) - gg[i-1] / 2
            }
            'B' => {
                (g[i] * (r[n]-r[i+1])) + (r[i] * (g[n]-g[i+1])) - bb[i-1] / 2
            }
            _ => { unreachable!() }
        };
    }


    println!("{}", ans);
}


Measured memory_bytes: 2304
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main(){
  ll N;
  cin>>N;
  ll i=1;
  FOR(j,N){
    ll t;
    cin>>t;
    if(t==i)i++;
  }
  if(i==1){
    cout<<-1<<endl;
  }else{
    cout<<N-i+1<<endl;
  }
      
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n';
#define ll long long
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back

int main() {

   // IOS;
   /*ll n;
    cin>>n;
    string s;
   while(n>0){
     int x=(n%26);
     cout<<(char)(x+97);
     n/=2;
   }
   */
   int n;
   cin>>n;
   int a[n];
   int arr[100001]={0};
   ll sum=0;
   rep(i,0,n){cin>>a[i];
    sum+=a[i];
    arr[a[i]]++;
   }
   int q;
   cin>>q;
   rep(i,0,q){
        int b,c;
        cin>>b>>c;
        arr[c]+=arr[b];

        sum+=arr[b]*(c-b);
        arr[b]=0;
        cout<<sum<<endl;

   }



    return 0;
}


Measured memory_bytes: 4408
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll black;
ll cnt;

int main(){
	ll h,w,k;
	cin >> h >> w >> k;
	char c[h][w];
	rep(i,h){
		rep(j,w){
			cin >> c[i][j];
			if(c[i][j]=='#')
				black++;
		}
	}

	ll tmp;

	rep(bith,1<<h){
		rep(bitw,1<<w){
			tmp=0;
			rep(i,h){
				rep(j,w){
					if(c[i][j]=='#'){
						if(bith&(1<<i))
							tmp++;
						else if(bitw&(1<<j))
							tmp++;
					}
				}
			}
			if(black-tmp==k)
					cnt++;
		}
	}
	cout << cnt << endl;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	int n = s.length();
	if (n % 2 == 0)
	{
		cout << "No";
		return 0;
	}

	for(int i=0; i<n/2; i++)
		if (s[i] != s[n - i - 1])
		{
			cout << "No";
			return 0;
		}

	for(int i=0; i<(n-1)/2/2; i++)
		if (s[i] != s[(n - 1) / 2 - i - 1])
		{
			cout << "No";
			return 0;
		}

	for (int i = (n + 3) / 2 - 1; i < (n + ((n + 3) / 2 - 1)) / 2; i++)
		if (s[i] != s[(n + ((n + 3) / 2 - 1)) - i - 1])
		{
			cout << "No";
			return 0;
		}

	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O999")
//示例：#define ll long long
//unsigned long long ;
const int INF=0x3f3f3f3f;
const int maxn=50000005;
using namespace std;

int main(){
	//freopen(".in", "r",stdin );
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(0);
	string s;
	cin >> s;
	cout<<s[0]<<s[1]<<s[2]<<endl;
	return 0;
}

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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    
    int ans = 0;
    int index = 0;
    while(true)
    {
        index = s.find("ABC", index);
        if (index == string::npos)
        {
            break;
        }
        ans++;
        index++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
typedef long double f80;

const int N = 2e5 + 5;
int val[N];
vector<int> g[N];

void dfs(int u,int p) {
    val[u] += val[p];
    for(int v : g[u]) {
        if(v != p) {
            dfs(v, u);
        }
    }
}

signed main()
{
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, q;
    cin >> n >> q;
    fr(i, 1, n - 1) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    fr(i, 1, q) {
        int p, x;
        cin >> p >> x;
        val[p] += x;
    }
    dfs(1, 0);
    fr(i, 1, n) {
        cout << val[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 23552
import Foundation

let values = readLine()!.components(separatedBy: " ")

let A = Int(values[0])!
let B = Int(values[1])!
let C = Int(values[2])!
let K = Int(values[3])!

var a = 0
var b = 0
var c = 0
var k = K

a = min(A, K)
k -= a
if k > 0 {
    b = min(B, k)
    k -= b
    if k > 0 {
        c = min(C, k)
    }
}

var total = a + (-1 * c)
print(total)



Measured memory_bytes: 14180
import math

n = int(input())
s = int(input())
ans = -1

def f(b, n):
    if n < b:
        return n
    else:
        return f(b, n//b) + n%b

#
if n == s: ans = n+1
for i in range(2, int(math.sqrt(n))+1):
    if f(i, n) == s:
        ans = i
        break
if ans == -1:
    for i in range(int(math.sqrt(n)), 0, -1):
        b = int((n-s) / i + 1)
        if b >= 2 and f(b,n) == s:
            ans = b
            break

print(ans)


Measured memory_bytes: 44268
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	cout << s.at(0) << n - 2 << s.at(n - 1) << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))
a,b=input().split()

a=int(a)
b=int(b.replace(".", ""))

print(a*b//100)


Measured memory_bytes: 61868
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,i,j=-1,m=0;
    
  cin >> N;
  
  int A[N],B[N],C[N];
  
  for(i=1;i<=N;i++){
      cin >> A[i];
  }
   for(i=1;i<=N;i++){
      cin >> B[i];
  }
   for(i=1;i<=N-1;i++){
      cin >> C[i];
  }
  
  for(i=1;i<=N;i++){
      m += B[A[i]];
    if(A[i]==j+1){
      m+=C[j];
    }
    j = A[i];
  }

 

  cout << m << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define HERE cout<<"    "<<"HERE"<<en

int main(){
  int a,b,c,d,e,h;
  cin>>a>>b>>c>>d>>e>>h;
  int sum=a+b+c+d+e+h;
  
  int f=min(a,b);
  f=min(f,c);
  f=min(f,d);
  
  int g=min(h,e);
  
  cout<<sum-g-f<<en
}


Measured memory_bytes: 3092
import java.util.*;
public class Main {
	static boolean prime[] = new boolean[200000];

	static int big(int n){
		int result = 0;
		for(int i=n-1;i>0;i--)if(prime[i]){
			result = i;
			break;
		}
		return result;
	}
	static int small(int n){
		int result=0;
		for(int i=n+1;;i++)if(prime[i]){
			result = i;
			break;
		}
		return result;
	}
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		for(int i=0;i<prime.length;i++)prime[i]=true;
		prime[0]=false;prime[1]=false;
		for(int s=0;s<prime.length;s++){
			if(prime[s])
				for(int i=s+s;i<prime.length;i+=s)prime[i]=false;
		}
		while(in.hasNext()){
			int n = in.nextInt();
			System.out.println(big(n)+" "+small(n));
		}
	}
}

Measured memory_bytes: 20008
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 2e5+5;
const int mod=9998753;
const int MOD=10000007;
const int INF=0x3f3f3f3f;
int TLEkiller[1000005][30];
map<pll,int>mp;
ll ans;string s[N];
int n,cnt[30],qwq;
int main()
{
	char c=getchar();
	while(c!=' '&&c!='\n')n=n*10+c-'0',c=getchar();
	mp[MP(0,0)]=++qwq;
	for(int i=0;i<n;i++)
	{
		char c=getchar();
		while(c!=' '&&c!='\n')s[i]+=c,c=getchar();
		for(int j=0;j<s[i].size();j++)
			cnt[s[i][j]-'a']++;
		ll hash1=0,hash2=0,pw1=1,pw2=1;int num=1;
		for(int j=(int)s[i].size()-1;j>=0;j--)
		{
			for(int k=0;k<26;k++)
				if(cnt[k])
					TLEkiller[num][k]++;
			hash1=(ll)(s[i][j]-'a'+1)%mod*pw1%mod+hash1;
			hash2=(ll)(s[i][j]-'a'+1)%MOD*pw2%MOD+hash2;
			hash1%=mod;hash2%=MOD;pw1=pw1*113%mod;pw2=pw2*113%MOD;
			if(!mp[MP(hash1,hash2)])mp[MP(hash1,hash2)]=++qwq,num=qwq;
			else num=mp[MP(hash1,hash2)];
			cnt[s[i][j]-'a']--;
		}
	}
	for(int i=0;i<n;i++)
	{
		string S=s[i].substr(1,(int)s[i].size()-1);
		reverse(S.begin(),S.end());
		ll hash1=0,hash2=0,pw1=1,pw2=1;
		for(int j=0;j<S.size();j++)
		{
			hash1=(ll)(S[j]-'a'+1)%mod*pw1%mod+hash1;
			hash2=(ll)(S[j]-'a'+1)%MOD*pw2%MOD+hash2;
			hash1%=mod;hash2%=MOD;pw1=pw1*113%mod;pw2=pw2*113%MOD;
		}
		ans+=TLEkiller[mp[MP(hash1,hash2)]][s[i][0]-'a'];
	}
	cout<<ans-n<<"\n";
	return 0;
}


Measured memory_bytes: 190668
#include<string>
#include <stdio.h>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#define ll long long
#define PI 3.14159265358979323846
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;



int main() {
    ll A, B, ans;
    cin >> A >> B;
    ans = A * B;
    cout << ans << endl;
      return 0;
 }


Measured memory_bytes: 3596
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
const int N = int(1e5 + 5);
void solve() {
    int n, q, x;
    ll sum = 0;
    cin >> n;
    vi freq(N, 0);
    forn(i, n) {
        cin >> x;
        sum += x;
        freq[x]++;
    }
    cin >> q;
    while(q--) {
        int b, c;
        cin >> b >> c;
        sum += (c - b) * (freq[b]);
        freq[c] += freq[b];
        freq[b] = 0;
        cout << sum << '\n';
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 3724
#include <stdio.h>
int main(void){
    int N, x=0, max=0;
    char S[101];
    scanf("%d%s", &N, S);
    for(int i=0; i<N; i++){
        if(S[i]=='I') x++;
        else if(S[i]=='D') x--;
        if(max<x) max=x;
    }
    printf("%d", max);
    return 0;
}

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

using namespace std;

bool is_tameru(string s) {
	if ("tameru" == s) return true;
	return false;
}
bool is_mamoru(string s) {
	if ("mamoru" == s) return true;
	return false;
}
bool is_kougekida(string s) {
	if ("kougekida" == s) return true;
	return false;
}
int play_func(string s1, string s2, int &p1, int &p2) {
	if (is_tameru(s1)) {
		p1 = min(5, p1+1);
	}
	if (is_tameru(s2)) {
		p2 = min(5, p2+1);
	}
	if (is_kougekida(s1) and is_kougekida(s2)) {
		if (p1 > p2) {
			return 1;
		}else if (p1 < p2) {
			return 0;
		}else {
			p1 = 0;
			p2 = 0;
			return 2;
		}
	}else if (is_kougekida(s1)) {
		if (p1 == 0) {
			return 0;
		}else if (is_mamoru(s2) and p1 == 5) {
			return 1;
		}else if (is_tameru(s2)) {
			return 1;
		}
		p1 = 0;
	}else if (is_kougekida(s2)) {
		if (p2 == 0) {
			return 1;
		}else if (is_mamoru(s1) and p2 == 5) {
			return 0;
		}else if (is_tameru(s1)) {
			return 0;
		}
		p2 = 0;
	}
	return 2;
}
int main() {
	int k; cin >> k;
	int isono_atk = 0;
	int naka_atk = 0;
	vector<string> iso(k);
	vector<string> nak(k);
	for (int i = 0; i < k; i++) {
		cin >> iso[i];
	}
	for (int i = 0; i < k; i++) {
		cin >> nak[i];
	}
	for (int i = 0; i < k; i++) {
		string p1 = iso[i];
		string p2 = nak[i];
		int res = play_func(p1,p2,isono_atk,naka_atk);
		if (res == 1) {
			cout << "Isono-kun" << endl;	
			return 0;
		}else if (res == 0) {
			cout << "Nakajima-kun" << endl;	
			return 0;
		}
		//cout << isono_atk << " " << naka_atk << endl;
	}
	cout << "Hikiwake-kun" << endl;
	return 0;
}



Measured memory_bytes: 3220
n = int(input())

A = [int(s) for s in input().split()]
print(*A)

for i in range(1, n):
    key = A[i]
    j = i - 1
    while j >= 0 and A[j] > key:
        j -= 1
    A.insert(j+1, key)
    del A[i+1]

    print(*A)


Measured memory_bytes: 5980
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main()
{
int n=rr;
double ans=0;
rep(i,0,n)
{
	int t=rr;
	ans+=(1.0/(t*1.0));
}
cout<<1.0/ans<<"\n";
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1);
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//

const int max_n = 8;
const int max_m = 30;
int n, m, p, a, b;
vector<int> t;
vector<vector<int> > vv;
vector<vector<int> > d;
double dp[1 << max_n][max_m];

//----------//

// sがチケットの集合, vが現在の都市
double solve(int s, int v, int bef){
    if(dp[s][v] != -1){
        return dp[s][v];
    }

    if(v == b){
        return dp[s][v] = 0;
    }

    if(s == (1 << n)-1){
        return INTINF;
    }

    double res = INTINF;
    for(int u : vv[v]){
        if(u != bef){
            rep(use, n){
                if(!(s >> use & 1)){
                    res = min(res, solve(s | 1 << use, u, v) + d[v][u] / double(t[use]));
                }
            }
        }
    }

    //cout << res << endl;
    return dp[s][v] = res;
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    while(1){
        cin >> n >> m >> p >> a >> b;
        if(!n && !m && !p && !a && !b){
            break;
        }
        a--; b--;
        rep(i, n){
            int tmp;
            cin >> tmp;
            t.push_back(tmp);
        }
        t.clear();
        vv.clear();
        d.clear();
        vv.resize(m);
        d.resize(m);
        rep(i, m){
            d[i].resize(m);
        }
        rep(i, p){
            int x, y, z;
            cin >> x >> y >> z;
            x--; y--;
            vv[x].push_back(y);
            vv[y].push_back(x);
            d[x][y] = z;
            d[y][x] = z;
        }
        rep(i, 1<< max_n){
            fill(dp[i], dp[i]+max_m, -1);
        }
        double ans = solve(0, a, -1);
        if(ans ==INTINF)cout << "Impossible" << endl;
        else printf("%.3f\n", ans);
    }
    
    
    return 0;
}



Measured memory_bytes: 3380
<?php

fscanf(STDIN, '%d %d', $n,$k);

$d = explode(' ', trim(fgets(STDIN)));

for ($i=$n;$i<100000;$i++) {

    $na = str_split($i);
    $cnt = 0;

    foreach($na as $value){

        if(in_array($value, $d)){
            continue 2;
        };

        $cnt += 1;

        if($cnt == count($na)){
            print($i);
            exit;
        }

    }
}



Measured memory_bytes: 4984
"use strict"
function main(arg) {
    var data = arg.trim().split("\n")
    var n = (data.shift()).split(' ')[0]
    var n_str = n
    n = Number(n)
    var _d = data[0].split(' ').map(Number).sort()
    var d = []
    var i = 0
    for (i = 0; i < 10; i++) {
        var j = 0
        for (j = 0; j < _d.length; j++) {
            if (i === _d[j]) break
        }
        
        if (j === _d.length) {
            d.push(i)
        }
    }
    if (d.length === 1) {
        var s = d[0]
        var ss = pad_x(s, n_str.length, s)
        if (Number(ss) >= n) {
            console.log(ss)
            return
        }
        console.log(Number(pad_x(s, n_str.length + 1, s)))
        return 
    }
    i = 0
    for (i = 0; ; i++) {
        var map = i.toString(d.length)
        if (map.length > n_str.length + 1) {
            break
        }
        var map = pad(map, n_str.length )
        
        map = map.split('').map(Number)
        var row = ""
        for (var j = 0; j < map.length; j++) {
            var k = map[j]
            row += d[k]
        }
        // console.log(row)
        row = Number(row)
        if (row >= n) {
            console.log(row)
            return
        }
    }
    // console.log("--")
    for (; ; i++) {
        var map = i.toString(d.length)
        // if (map.length > n_str.length + 1) {
        //     break
        // }
        var map = pad(map, n_str.length + 1)
        
        map = map.split('').map(Number)
        var row = ""
        for (var j = 0; j < map.length; j++) {
            var k = map[j]
            row += d[k]
        }
        // console.log(row)
        row = Number(row)
        if (row >= n) {
            console.log(row)
            return
        }
    }
    // console.log(row)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function pad(num, length) {
    var str = '0'
    return (new Array(length).fill(str).join('') + num).slice(-length);
}
function pad_x(num, length, str) {
    return (new Array(length).fill(str).join('') + num).slice(-length);
}

Measured memory_bytes: 10312
/*D - Banned K*/
#include <bits/stdc++.h>

using namespace std;
using Long = long long;

int main(){
	
	int tam;
	Long num;

	cin >> tam;

	vector <int> arr(tam);
	map <int, Long> ocurr;

	for (int i = 0; i < tam; ++i)
	{
		cin >> arr[i];

		if(ocurr.count(arr[i])){
			ocurr[arr[i]]++;
		}
		else{
			ocurr[arr[i]] = 1;
		}
	}

	Long total = 0;
	map <int, Long>::iterator it;	
	Long n;

	for (it = ocurr.begin(); it != ocurr.end() ; ++it)
	{
		
		n = it -> second;
		total += ((n-1) * n / 2);

	}

	for (it = ocurr.begin(); it != ocurr.end() ; ++it)
	{
		n = it -> second;
		it -> second = total - ((n - 1) * n / 2);
		n--;
		it -> second += ((n-1) * n / 2);
	}

	for (int i = 0; i < tam; ++i)
	{
		num = arr[i];
		cout << ocurr[num] << '\n';
	}


	return 0;
}

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

using namespace std;

int main() {

	int a, b;
	string op;
	
	while (cin >> a >> op >> b && op != "?") {
		if (op == "+")
			cout << a + b << endl;
		if (op == "-")
			cout << a - b << endl;
		if (op == "*")
			cout << a * b << endl;
		if (op == "/")
			cout << a / b << endl;	
	}
}



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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long N, long long K, std::vector<long long> A) {
    rep(i, N) A[i]--;
    vector<int> pos(2 * N);
    vector<bool> visit(2 * N);
    pos[0] = 0;
    visit[0] = 1;

    int first = 0;
    int mod = 0;
    loop(i, 1, 2 * N) {
        auto next = A[pos[i - 1]];
        if (visit[next]) {
            first = find(pos.begin(), pos.end(), next) - pos.begin();
            mod = i - first;
            break;
        }
        visit[next] = 1;
        pos[i] = next;
    }
    if (K < first + mod) {
        cout << pos[K] + 1 << endl;
    } else {
        cout << pos[first + ((K - first) % mod)] + 1 << endl;
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 6432
#include <bits/stdc++.h>
using namespace std;
#define QOEINDIEDIS freesteed
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

void solve(){
	int n,m,a,b;
	cin>>n>>m;
	vector<VI> grid(n+1);
	rep(i,0,m){
		cin>>a>>b;
		grid[a].pb(b);
	}
	int board=n+1,ans=0;
	for(int i=n-1;i;i--){
		if(sz(grid[i])){
			int mn = (*min_element(all(grid[i])));
			if(mn<board){
				board = i+1;
				ans++;
			}
		}
	}
	cout<<ans;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}






Measured memory_bytes: 5760
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
using namespace std;
int main() {
	int a = 3, b = 0, c = 0, d = 0, e = 0, count = 0;
	char v[2];
	bool l = false,m=false,n=false;
	for (int i = 0; i < a; i++) {
		cin >> v[i];
		if (v[i] == 'a') {
			l = true;
		}
		if (v[i] == 'b') {
			m = true;
		}
		if (v[i] == 'c') {
			n = true;
		}
	}
	if (l == true && m == true && n == true) {
		cout << "Yes" << endl;
	}
	else { cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

# ord: アスキーコードを取得
# ord('a') -> 97

# chr: アスキーコードから文字へ
# chr('12354') -> 'あ'

ss = str()

for i in s:
    t = chr(ord(i) + n)

    if ord(t) > ord('Z'):
        t = chr(ord(t) - ord('Z') + ord('A')-1)
    
    ss += t

print(ss)

Measured memory_bytes: 3060