akhauriyash/Code-Regression huggingface dataset:
a,b = map(int,input().split())
if a != 1 and b != 1:
    if a > b :
        print("Alice")
    elif a < b:
        print("Bob")
    else:
        print("Draw")
elif a == 1 and b != 1:
    print("Alice")
elif a != 1 and b == 1:
    print("Bob")
else:
    print("Draw")


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
#define INFTY (1<<21)
#define MAX 100
void floyd(int m, int C[MAX][MAX], int T[MAX][MAX]){
 for(int k = 0;k<m;k++)
 for(int i = 0;i<m;i++)
for(int j = 0;j<m;j++){
C[i][j] = min( C[i][j], C[i][k] + C[k][j] );
T[i][j] = min( T[i][j], T[i][k] + T[k][j] );
 }
}
main(){
 int n, m, a, b, c, t, k, q, C[MAX][MAX], T[MAX][MAX];
 while( cin >> n >> m && !(n == 0 && m == 0) ){
for(int i = 0;i<m;i++)
 for(int j = 0;j<m;j++) { C[i][j] = T[i][j] = INFTY; }
for(int i = 0;i<n;i++){
 cin >> a >> b >> c >> t; C[a-1][b-1] = C[b-1][a-1] = c; T[a-1][b-1] = T[b-1][a-1] = t;
}
floyd(m, C, T);
cin >> k;
for(int i = 0;i<k;i++){
 cin >> a >> b >> q; if ( q ) cout << T[a
-1][b
-1] << endl; else cout << C[a-1][b-1] << endl; } } }


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long int arr[1000][1000];
int main()
{
	long long int mod=1000000007;
	int n,m,i,j,k;
	cin >> n >> m;
	char c;
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			cin >> c;
			if(c=='.')
			arr[i][j]=-1;
			else
			arr[i][j]=0;
		}
	}
	arr[0][0]=1;
    for(i=0;i<n;i++)
    {
    	for(j=0;j<m;j++)
    	{
    		if(i==0&&j==0)
    		arr[i][j]=1;
    		else if(arr[i][j]==0)
    		continue;
    		else if(i==0&&j>0)
    		arr[i][j]=arr[i][j-1];
    		else if(j==0&&i>0)
    		arr[i][j]=arr[i-1][j];
    		else
    		arr[i][j]=(arr[i-1][j]%mod+arr[i][j-1]%mod)%mod;
		}
	}
	cout << arr[n-1][m-1];
	return 0;
}

Measured memory_bytes: 8064
#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 n;cin>>n;
  vector<ll> a(n), b(n);
  rep(i,n)cin>>a[i]>>b[i];
  ll result=0;
  for(int i=n-1; i>=0; i--){
    ll ca = result+a[i];
    if(ca%b[i])result+=(b[i]-ca%b[i]);
  }
  cout<<result;
  return 0;
}

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

class Program {
  static void Main() {
    var n = int.Parse(Console.ReadLine());
    var a = Enumerable.Range(0, n).Select(_ => int.Parse(Console.ReadLine())).OrderByDescending(x => x).ToArray();
    a[0] /= 2;
    Console.WriteLine(a.Sum());
  }
}

Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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 <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    if (n == m) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 2000000
#define MAX 10000

int main(){
  int a[N];
  int n,i,c[MAX+1];
  
  scanf("%d",&n);

  int b[n];
  
  for(i=1;i<=n;i++) scanf("%d",&a[i]);

  for(i=0;i<=MAX;i++){
    c[i]=0;
  }

  for(i=0;i<n;i++){
    c[a[i+1]]++;
  }

  for(i=1;i<MAX;i++){
    c[i]=c[i]+c[i-1];
  }

  for(i=n;i>0;i--){
    b[c[a[i]]]=a[i];
    c[a[i]]--;
  }
  
  for(i=1;i<n;i++) printf("%d ",b[i]);
  printf("%d\n",b[i]);
  
  return 0;
}



Measured memory_bytes: 17516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

ll cntLower(vector<ll>& a, ll x) {
  ll n = SZ(a);
  ll res = 0;
  REP(i, n) {
    ll t = x / a[i];
    auto it = upper_bound(a.begin() + i + 1, a.end(), t);
    res += it - (a.begin() + i + 1);
  }
  return res;
}

ll cntHigher(vector<ll>& a, vector<ll>& b, ll x) {
  ll n = SZ(a);
  ll res = 0;
  REP(i, n) {
    ll t = (x + a[i] - 1) / a[i];
    auto it = lower_bound(b.begin(), b.end(), t);
    res += b.end() - it;
  }
  return res;
}

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n), pos, neg;
  REP(i, n) {
    cin >> a[i];
    if (a[i] > 0) {
      pos.push_back(a[i]);
    } else if (a[i] < 0) {
      neg.push_back(-a[i]);
    }
  }
  ll z = n - SZ(pos) - SZ(neg);

  sort(ALL(pos));
  sort(ALL(neg));

  ll ok, ng;
  // 積がx以下となるペアがk個以上　となるxの最小値

  // 0未満は？
  ll t = SZ(pos) * SZ(neg);
  if (t >= k) {
    ok = 1, ng = 1e18 + 1;
    while (ok + 1 < ng) {
      ll m = (ok + ng) / 2;
      ll cnt = cntHigher(pos, neg, m);
      (cnt >= k ? ok : ng) = m;
    }
    cout << -ok << endl;
    exit(0);
  }

  // 正は？
  ll u = SZ(pos) * (SZ(pos) - 1) / 2 + SZ(neg) * (SZ(neg) - 1) / 2;
  if (n * (n - 1) / 2 - (k - 1) > u) {
    // 0
    cout << 0 << endl;
    exit(0);
  }

  // 正
  ng = 1, ok = 1e18 + 1;
  k -= n * (n - 1) / 2 - u;  //０ika を消す
  while (ng + 1 < ok) {
    ll m = (ok + ng) / 2;
    ll cnt = cntLower(pos, m) + cntLower(neg, m);
    (cnt >= k ? ok : ng) = m;
  }
  cout << ok << endl;
}


Measured memory_bytes: 3956
#include<stdio.h>
#include<algorithm>
using namespace std;
int n, m, K, L, S[30010];
long long D[4010][2010], Mod = 1000000007, Res;
int main(){
    scanf("%d%d%d",&n,&m,&K);
    if(n>m)swap(n,m);
    L = (n+m-1)/(K-1);
    int i, j;
    for(i=0;i<=n;i++)D[0][i] = 1;
    for(i=1;i<=L;i++){
        for(j=0;j<=n;j++){
            D[i][j] = D[i-1][j];
            if(j>=K) D[i][j] = (D[i][j]-D[i-1][j-K]+Mod)%Mod;
        }
        for(j=1;j<=n;j++){
            D[i][j] = (D[i][j]+D[i][j-1])%Mod;
        }
    }
    int c = L;
    for(i=n;i>=1;i-=(K-1)){
        Res = (Res + D[c][i])%Mod;
        if(i)Res = (Res - D[c][i-1] + Mod)%Mod;
       // Res = (Res + Mod - S[i])%Mod;
        c--;
    }
    printf("%lld\n",Res);
}

Measured memory_bytes: 62976
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        List<Integer> lis = new ArrayList<Integer>();
        int n = scn.nextInt();
        for(int i = 0; i < n; i++) {
            lis.add(scn.nextInt());
        }
        Collections.reverse(lis);
        for(int i = 0; i < n; i++) {
            System.out.print(lis.get(i));
            if(i == ~-n) {
                System.out.println();
            } else {
                System.out.print(" ");
            }
        }
    }
}

Measured memory_bytes: 19628
#include <cstdio>
#define maxn 10010

int n;long long a[maxn];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	long long money=1000;
	int i=1;while(i<=n)
	{
		int j=i;
		while(j<=n&&a[j+1]>=a[j])j++;
		if(j>i)money=money/a[i]*a[j]+money%a[i];
		i=j+1;
	}
	printf("%lld",money);
}

Measured memory_bytes: 1740
#include <bits/stdc++.h>
using namespace std;
  int arr[1000];
bool checkSorted(int n, int arr[])
{
    int b[n];
    for (int i = 0; i < n; i++)
        b[i] = arr[i];
    sort(b, b + n);
    int ct = 0;
    for (int i = 0; i < n; i++)
        if (arr[i] != b[i])
            ct++;
    if (ct == 0 || ct == 2)
        return true;
    else
        return false;
}


int main()
{
    int n;
      cin>>n;
    for(int i=0;i<n;i++)
      cin>>arr[i];
    if (checkSorted(n, arr))
        cout << "YES"<<endl;
    else
        cout << "NO"<<endl;
    return 0;
}


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

using namespace std;


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

	long long n, m, r, i, j, k, a, b, c, ans, s;
	cin >> n >> m >> r;
	vector<long long> rr(r);
	for (i = 0; i < r; i++) cin >> rr[i];
	vector<vector<long long>> d(n + 1, vector<long long>(n + 1, 1LL << 50));
	for (i = 1; i <= n; i++) d[i][i] = 0;
	while (m--) {
		cin >> a >> b >> c;
		d[a][b] = c;
		d[b][a] = c;
	}
	for (k = 1; k <= n; k++) {
		for (i = 1; i <= n; i++)
			for (j = 1; j <= n; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	}

	sort(rr.begin(), rr.end());
	ans = 1LL << 60;
	do {
		s = 0;
		for (i = 1; i < r; i++) s += d[rr[i - 1]][rr[i]];
		ans = min(ans, s);
	} while (next_permutation(rr.begin(), rr.end()));
	cout << ans << "\n";

	return 0;
}


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

int main() {
    int H, W;
    cin>>H>>W;
    vector<string> a;
    string tmp;
    for(int i=0;i<H;++i){
        cin>>tmp;
        a.push_back(tmp);
    }
    map<char, int> amap;
    vector<char> aarr;
    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            if(amap[a[i][j]]==0){
                aarr.push_back(a[i][j]);
            }
            amap[a[i][j]]++;
        }
    }

    int two=0, one=0;
    if(H%2==1){
        two += W;
    }
    if(W%2==1){
        two += H;
    }
    if((H%2==1) & (W%2==1)){
        one++;
        two--;
    }
    int onenum=0, twonum=0;
    for(int i=0;i<aarr.size();++i){
        if(amap[aarr[i]]%4==2) twonum+=2;
        else if(amap[aarr[i]]%4==1) onenum++;
        else if(amap[aarr[i]]%4==3){
            onenum++;
            twonum+=2;
        }
    }
    if(one!=onenum | two<twonum){
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
}


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

int main(){
    int n,m,d,r=0,l=0;
    char c;
    while(cin>>n>>c>>m>>c>>d){
        if(n==m)
            l++;
        if(n*n+m*m==d*d)
            r++;
    }
    cout<<r<<endl<<l<<endl;
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
    int S, W;
    cin >> S >> W;

    if(W >= S) {
        cout << "unsafe" << endl;
    }
    else {
        cout << "safe" << endl;
    }
    return 0;
}

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

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}
template<typename S>
void print(S a){
    cout<<a<<endl;
}


int main(){
    char s;
    cin>>s;
    if(isupper(s)){
        fin("A");
    }else{
        fin("a");
    }


    return 0;
}




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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  //cout << a << endl,
  //cout << b << endl;
  //cout << a % 2 << endl;
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

class UnionFind {
    public:
    int n;
    vector<int> par, rank;

    UnionFind(int n) {
        rep(n) {
            par.push_back(i);
            rank.push_back(0);
        }
    }

    int find(int x) {
        return ((par[x] == x) ? x : par[x] = find(par[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);

        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
        return;
    }

    bool is_same(int x, int y) {
        return find(x) == find(y);
    }
};

struct Edge{
    int from, to; ll cost;
    Edge(int from, int to, ll cost){
        this->from = from;
        this->to = to;
        this->cost = cost;
    }
    bool operator<(const Edge &e) const{
        return cost < e.cost;
    }
};

struct Graph{
    int V,E;
    vector<Edge> edges;

    Graph(){
        cin >> V >> E;
        int s,t; ll w;
        rep(E){
            cin >> s >> t >> w;
            edges.emplace_back(Edge(s,t,w));
        }
    }

    ll kruskal(){
        ll ret = 0LL;
        UnionFind uf = UnionFind(V);
        sort(all(edges));
        for(Edge e: edges){
            if(!uf.is_same(e.from, e.to)){
                ret += e.cost;
                uf.unite(e.from, e.to);
            }
        }
        return ret;
    }
};

int main(){
    Graph g = Graph();
    cout << g.kruskal() << endl;
}


Measured memory_bytes: 4924
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n, = map(int,input().split())

x = [0,1,3,6,10,15,21,28,36,45,55,66]

from bisect import bisect_right
ans = 0
N = 10**6
for i in range(2,N):
    r = 0
    while n%i==0:
        n//=i
        r += 1
        
    if r>0:
        ans += bisect_right(x,r)-1        
        #print(i,r,ans)

if n!=1:
    #print(n)
    ans += 1    
    
print(ans)        





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

for i in range(len(p)):
    for j in reversed(range(i+1,len(p))):
        if p[j] < p[j-1]:
            p[j-1],p[j] = p[j],p[j-1]

print(sum(p[:k]))


Measured memory_bytes: 9188
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
	int n, k;
	scanf ("%d%d", &n, &k);
	int a[n+5];
	for (int i=1;i<=n;++i){
		scanf ("%d", a+i);
	}
	sort (a+1, a+n+1);
	int sum=0;
	for (int i=n;i>=n-k+1;--i){
		sum+=a[i];
	}
	printf ("%d", sum);
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

	// number of W
	left := make([]int, n+1)
	right := make([]int, n+1)
	left[0] = 0
	right[0] = 0
	for i := 0; i < n; i++ {
		left[i+1] = left[i]
		if s[i] == 'W' {
			left[i+1]++
		}
		right[i+1] = right[i]
		if s[i] == 'E' {
			right[i+1]++
		}
	}

	ans := n
	for i := 0; i < n; i++ {
		ans = min(ans, left[i]+right[n]-right[i+1])
	}
	fmt.Println(ans)
}


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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,m;

ll sm2[maxn],sm[maxn],ans;

void Work(){
	int y;
	REP(i,1,n){
		int x;read(x);
		if(i>1){
			if(x>=y){
				sm2[y+2]++;
				sm2[x+1]--;
				sm[x+1]-=x-y-1;
				ans+=x-y;
			}
			else{
				sm2[y+2]++;
				sm2[1]++;
				sm2[x+1]--;
				sm[1]+=m-y-1;
				sm[x+1]-=m+x-y-1;
				ans+=m+x-y;
			}
		}
		y=x;
	}
//	cout<<ans<<endl;
//	REP(i,1,m)cout<<sm2[i]<<' ';cout<<endl;
//	REP(i,1,m)cout<<sm[i]<<' ';cout<<endl;
	REP(i,1,m)sm2[i]+=sm2[i-1];
//	REP(i,1,m)cout<<sm2[i]<<' ';cout<<endl;
	REP(i,1,m)sm2[i]+=sm[i];
	REP(i,1,m)sm2[i]+=sm2[i-1];
	REP(i,1,m)sm[i]=sm2[i]+sm[i];
	ll t=0;
	REP(i,1,m)t=max(t,sm2[i]);
//	REP(i,1,m)cout<<sm[i]<<' ';cout<<endl;
	cout<<ans-t<<endl;
}

void Init(){
	read(n,m);
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
#define int long long
#define pb(x) push_back(x)
#define fi first
#define se second
#define mp(x,y) make_pair(x,y);

/*struct comp
{
    bool operator()()
    {
        
    }
};*/

int32_t main() {
    int t=1;
    //cin>>t;
    while(t--)
    {
     int N,M;
     cin>>N>>M;
     vector<int>H(N+1);
     for(int i=1;i<=N;i++)cin>>H[i];
     
     vector<bool>good(N+1,true);
     for(int j=0;j<M;j++)
     {
         int A,B;
         cin>>A>>B;
         if(H[A]==H[B])
         {
             good[A]=false;
             good[B]=false;
         }
         else if(H[A]<H[B])
         {
             good[A]=false;
         }
         else
         {
             good[B]=false;
         }
         
     }
     int cnt=0;
     for(int i=1;i<=N;i++)
     {
         if(good[i])
         cnt++;
     }
     cout<<cnt<<endl;

        
    }
    return 0;
}

Measured memory_bytes: 4052
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	while ( true ) {

	    final int n = stdin.nextInt();
	    if ( n == -1 ) {
		break;
	    }

	    double x = 1.0;
	    double y = 0.0;

	    for ( int i = 0; i < n - 1; i++ ) {
		double vx = -y;
		double vy = x;

		double norm = sqrt( vx * vx + vy * vy );
		vx /= norm;
		vy /= norm;

		x += vx;
		y += vy;
	    }
	    System.out.println( x );
	    System.out.println( y ); 
	}	
    }    
}

Measured memory_bytes: 17324
while True:
    n, m = map(int, raw_input().split())
    if n==0 and m==0:
        break
    b = [input() for i in xrange(n)]
    d = [input() for i in xrange(m)]
    p = 0; ans = 0;
    for i in xrange(m):
        p += d[i]
        if p>=n-1 or p+b[p]>=n-1:
            ans = i+1
            break
        p += b[p]
    print ans

Measured memory_bytes: 4308
#include<stdio.h>
#include<string.h>

int main(){

  char s[101];
  char t[101];
  scanf("%s %s",s,t);

  int len = strlen(s);

  char copy[201];
  strcpy(copy,s);
  strcpy(copy+len,s);

  for(int i = 0; i < len; ++i){
    if(strncmp(t,copy+i,len) == 0){
      printf("Yes");
      return 0;
    }
  }

  printf("No");
  return 0;

}


Measured memory_bytes: 128
#include <stdio.h>
int main()
{
  int N,K;
  int temp;
  int i;
  scanf("%d %d", &N, &K);
  temp = K;
  for(i = 0; i < N - 1; ++i)
    K *= (temp - 1);
  printf("%d\n",K);
  return 0;
}


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

int main() {
  int N;
  cin>>N;
  if(N%10==2||N%10==4||N%10==5||N%10==7||N%10==9){
    cout<<"hon"<<endl;
  }
  else if(N%10==3){
    cout<<"bon"<<endl;
  }
  else{
    cout<<"pon"<<endl;
  }
}

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

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef vector< vector<int> > vvi;
typedef vector< pii > vpii;

int bfs(vvi &adj, int s, int k, int e){

	int ret = 0;

	int dist = 0;

	queue<int> q;
	q.push(s);
	unordered_set<int> visited;

	if(e != -1) visited.insert(e);

	while(!q.empty()){

		int n = (int)q.size();

		for(int i = 0; i < n; i++){

			int curr = q.front(); q.pop();

			if(visited.count(curr)) continue;

			// cout << curr + 1 << endl;

			for(int child : adj[curr]){
				if(!visited.count(child)) q.push(child);
			}

			ret++;
			visited.insert(curr);
		}

		// cout << ret << ' ' << dist << endl;

		if(dist == k) break;

		dist++;
	}

	return ret;
}


void solve(){

	int n, k;
	cin >> n >> k;
	
	vpii edges(n);
	vvi adj(n);

	for(int i = 0; i < n - 1; i++){
		int u, v;
		cin >> u >> v;
		u--; v--;

		adj[u].push_back(v);
		adj[v].push_back(u);

		edges.push_back( mp(u , v) );
	}

	int maxC = 0;

	if(k % 2 == 0){

		//Each Vertex
		for(int i = 0; i < n; i++){
			int covered = bfs(adj, i, k / 2, -1);
			maxC = max(maxC, covered);
		}

	}else{

		//Each edge
		for(auto e : edges){

			int c1 = bfs(adj, e.ff , k / 2, e.ss);
			int c2 = bfs(adj, e.ss , k / 2, e.ff);

			maxC = max(maxC, c1 + c2);	
			
		}
	}

	cout << n - maxC << endl;

}


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;
}

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

using namespace std;

const int MAX_N = 2e4 + 10;

int n;
bool dp[200][MAX_N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        int s;
        cin >> s;
        for (int j = 0; j < MAX_N - 200; j++) {
            if (dp[i][j]) {
                dp[i + 1][j] = 1;
                dp[i + 1][j + s] = 1;
            }
        }
    }
    for (int i = MAX_N - 1; i >= 0; i--) {
        if ((i % 10) != 0 && dp[n][i]) {
            cout << i << "\n";
            return 0;
        }
    }
    cout << "0\n";
}


Measured memory_bytes: 1152
n = int(input())
a = [int(i) for i in input().split()]
two = 0
four = 0
for i in range(n):
    if a[i] % 4 == 0:
        four += 1
    elif a[i] % 2 == 0:
        two += 1
if n == 2:
    ans = 'Yes' if 1 <= four or two == n else 'No'
elif n == 3:
    ans = 'Yes' if 1 <= four or two == n else 'No'
else:
    ans = 'Yes' if (2 <= four and (n-four*2 <= two or (n-4)//2 <= four-2)) or (four == 1 and n-2 <= two) or two == n else 'No'
print(ans)

Measured memory_bytes: 14252
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
const int N = 1e6 + 5;
typedef long long ll;
#define int ll
using namespace std; 

int n, a[N], ans1, ans2; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int mabs(int x) { return x < 0 ? -x : x; }

signed main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin);
#endif
	n = read <int> ();
	for(int i = 1; i <= n; i++) a[i] = read <int> (); 
	for(int sum = 0, i = 1; i <= n; i++)
	{
		if(i & 1)
		{
			if(sum + a[i] > 0) { sum += a[i]; continue; }
			ans1 += mabs(sum + a[i]) + 1, sum = 1; 
		}
		else
		{
			if(sum + a[i] < 0) { sum += a[i]; continue; }
			ans1 += mabs(sum + a[i]) + 1, sum = -1; 
		}
	}
	for(int sum = 0, i = 1; i <= n; i++)
	{
		if(!(i & 1))
		{
			if(sum + a[i] > 0) { sum += a[i]; continue; }
			ans2 += mabs(sum + a[i]) + 1, sum = 1; 
		}
		else
		{
			if(sum + a[i] < 0) { sum += a[i]; continue; }
			ans2 += mabs(sum + a[i]) + 1, sum = -1; 
		}
	}
	printf("%lld\n", min(ans1, ans2)); 
	return 0; 
}


Measured memory_bytes: 3956
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    BigInteger k = new BigInteger(sc.next());
    ArrayList<BigInteger> a = new ArrayList<>();
    ArrayList<BigInteger> b = new ArrayList<>();

    int indexA = -1;
    int indexB = -1;
    BigInteger sum = BigInteger.ZERO;
    boolean boo = true;
    for (int i = 0; i < n; i++) {
      BigInteger aTmp = new BigInteger(sc.next());
      BigInteger tmp = sum.add(aTmp);
      if (boo && tmp.compareTo(k) <= 0) {
        indexA = i;
        sum = tmp;
      } else {
        boo = false;
      }
      a.add(aTmp);
    }
    boo = sum.compareTo(k) <= 0;
    for (int i = 0; i < m; i++) {
      BigInteger bTmp = new BigInteger(sc.next());
      BigInteger tmp = sum.add(bTmp);
      if (boo && tmp.compareTo(k) <= 0) {
        indexB = i;
        sum = tmp;
      } else {
        boo = false;
      }
      b.add(bTmp);
    }

    int max = (indexA + 1) + (indexB + 1);
    for (int i = indexA; i >= 0; i--) {
      if (indexB == m - 1) {
        break;
      }
      sum = sum.subtract(a.get(i));
      BigInteger tmp = sum;
      while (true) {
        if (indexB == m - 1) {
          break;
        }
        tmp = tmp.add(b.get(indexB + 1));
        if (tmp.compareTo(k) <= 0) {
          indexB++;
          sum = tmp;
        } else {
          break;
        }
      }
      int t = i + (indexB + 1);
      if (t > max) {
        max = t;
      }
    }
    System.out.println(max);
  }


}


Measured memory_bytes: 80404
function is_possible_trip(prev, next){
  prev_array = prev.split(' ').map(x => parseInt(x));
  next_array = next.split(' ').map(x => parseInt(x));;
  time_distance = next_array[0] - prev_array[0];
  x_distance = next_array[1] - prev_array[1];
  if(x_distance < 0){x_distance = -1*x_distance;}
  y_distance = next_array[2] - prev_array[2];
  if(y_distance < 0){y_distance = -1*y_distance;}
  distance = x_distance + y_distance;
  
  if(distance > time_distance){return false;}
  
  if((time_distance - distance)%2!=0){return false;}
  
  return true;
}

function main(input) {
  input_array = input.split('\n');
  count = input_array[0];
  
  input_array[0]='0 0 0';
  
  for(i=0; i < count;i++){
    if(!is_possible_trip(input_array[i],input_array[i+1])){
      console.log('No');
      return;
    }
  }
  console.log('Yes');
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  auto dfs = [&](auto&& self, char nxt) -> void {
    if ((int)s.size() == n) {
      cout << s << '\n';
      return;
    }
    for (char c = 'a'; c <= 'z'; ++c) {
      if (s.find(c) != string::npos) {
        s += c;
        self(self, nxt);
        s.pop_back();
      }
    }
    s += nxt;
    self(self, nxt + 1);
    s.pop_back();
  };
  dfs(dfs, 'a');
}


Measured memory_bytes: 1536
#include <iostream>

using namespace std;

int main(){
  
  int x1,y1,x2,y2,x3,y3,x4,y4;
  cin >> x1 >> y1 >> x2 >> y2;
  x3 = x2+y1-y2;
  y3 = y2+x2-x1;
  x4 = x1+y1-y2;
  y4 = y1+x2-x1;
  printf("%d %d %d %d\n",x3,y3,x4,y4);
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

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

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  if (v < w) {
    cout << "NO" << endl;
  }
  else {
    if (abs(a - b) <= (v - w) * t)cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int constexpr maxn = 100009;
int n;
int act[maxn][3];
int dp[maxn][3];
bool done[maxn][3];

void read_input()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> act[i][0] >> act[i][1] >> act[i][2];
}

int go(int idx, int choosed_before) {
    if(done[idx][choosed_before]) return dp[idx][choosed_before];

    dp[idx][choosed_before] = -1;
    for(int i = 0; i < 3; i++) {
        if(choosed_before == i) continue;
        dp[idx][choosed_before] = max(go(idx - 1, i) + act[idx][i], dp[idx][choosed_before]);
    }
    done[idx][choosed_before] = true;
    return dp[idx][choosed_before];
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    read_input();
    done[1][0] = true; dp[1][0] = max(act[1][1], act[1][2]);
    done[1][1] = true; dp[1][1] = max(act[1][0], act[1][2]);
    done[1][2] = true; dp[1][2] = max(act[1][0], act[1][1]);

    cout << max(go(n, 0), go(n, 1)) << endl;
}


Measured memory_bytes: 10752
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>

using namespace std;

int main(void){

    int N;
    string name;
    map<string, int> keihin;
    int num_item(0);
    cin >> N;

    
   
    
    for(int i=0;i<N;++i){
        cin >> name;
        if(keihin.find(name)==keihin.end()){
            keihin[name] = 1;
            ++num_item;
        }else{
            ++keihin.at(name);
        }
    }

    cout << num_item << endl;
        
    return 0;
}


Measured memory_bytes: 19228
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int a, b;
	int ans = 0;
	int x = 1;
	int y = 0;

	cin >> a >> b;

	ans = b - a;

	for (int i = 2; i < 1050; i++) {
		y = x;
		x += i;
		
		if (ans == x - y) {
			cout << y - a << endl;
			return 0;
		}
	}

	
}

Measured memory_bytes: 256
x,y=map(int,input().split())
if 0<=x<y:
    print(y-x)
if 0<=y<x:
    print(x-y+2 - (y==0))
if y<x<=0:
    print(x-y+2 - (x==0))
if x<y<=0:
    print(y-x  )

if x<0<y:
    print(round(abs(y+x))+1)
if y<0<x:
    print(round(abs(y+x))+1)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
    int N, i;
    int ans = 0;
    cin >> N;
    long long int A[N];
    for (i = 0; i < N; i++){
        cin >> A[i];
    }
    while(1) {
        for (i = 0; i < N; i++){
            if(A[i] % 2 == 1){
                cout << ans << endl;
                return 0;
            }
            else A[i] /= 2;
        }
        ans++;
    }
}

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

int main(){
    ll n,k;
    cin >> n >> k;
    ll han = 1;
    ll cnt = 0;
    while(n >= han){
        han *= k;
        cnt++;
    }
    if(cnt == 0) cout << '1';
    else cout << cnt;
    return 0;
}

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

const int N = 500010;
const int mod = 998244353;

typedef long long LL;

inline int Pow(int x, int y) {
    int res = 1;
    for (; y; y >>= 1, x = (LL)x * x % mod) if (y & 1) res = (LL)res * x % mod;
    return res;
}

int frac[N], inv[N];

inline int C(int n, int r) {
    if (r > n) return 0;
    return (LL)frac[n] * inv[r] % mod * inv[n - r] % mod;
}

int main() {
    int n, k, res = 0; cin >> n >> k; 
    frac[0] = inv[0] = 1;
    for (int i = 1; i <= k; i++) frac[i] = (LL)frac[i - 1] * i % mod, inv[i] = Pow(frac[i], mod - 2);
    for (int R = n; R <= k; R++) 
        res = (res + C(k, R) - C(k, R * 2 - n + 1)) % mod;
    printf("%d\n", (res + mod) % mod);
    return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cmath>
#include <time.h>
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) ((c).rbegin(),(c).rend())
//#define sort(v,n) sort(v,v+n)
#define ll long long
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;


int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		set<string> set1;
		for (int j = 1; j < s.length(); j++) {
			string a, b;
			a = s.substr(0, j);
			b = s.substr(j, s.length() - j);
			set1.insert(a + b); //cout << a + b << endl;
			set1.insert(b + a); //cout << b + a << endl;
			string t, h;
			for (int k = a.length()-1; k>=0; k--) {
				t += a[k];
			}
			for (int k = b.length()-1; k >= 0; k--) {
				h += b[k];
			}
			set1.insert(a + h);// cout << a + h << endl;
			set1.insert(b + t); //cout << b+t << endl;
			set1.insert(t + h); //cout << t+h << endl;
			set1.insert(h + t); //cout << h+t << endl;
			set1.insert(h + a); //cout << h+a << endl;
			set1.insert(t + b); //cout << t+b << endl;
		}
		cout << set1.size() << endl;
	}
	return 0;
}

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

int main()
{
	int n,w,pos[31];


	cin>>w;
	for(int i=0;i<=w;i++) pos[i]=i;
	cin>>n;
	for(int i=0;i<n;i++){
		int left,right;
		string num,str_left,str_right;
		stringstream ss_left,ss_right;
		
		cin>>num;
		int j=0;
		while(num[j] != ','){
			j++;
		}
		str_left=num.substr(0,j);
		ss_left<<str_left;
		ss_left>>left;
		str_right=num.substr(j+1);
		ss_right<<str_right;
		ss_right>>right;
		
	//	cout<<"("<<left<<","<<right<<")"<<endl;

		int temp;
		temp=pos[left];
		pos[left]=pos[right];
		pos[right]=temp;
	}
	for(int i=1;i<=w;i++) cout<<pos[i]<<endl;
}

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

using namespace std;
#define ll long long
const int Max=1e6+7;
ll a[Max]; int n,k;

int main(){
    ios::sync_with_stdio(0);
    scanf("%d%d",&n,&k);
    for(int i=1; i<=n; i++) scanf("%lld",&a[i]);
    ll ans=0;
    //cout<<"OK"<<endl;
    if(a[1]>=0) ans=a[k];
    else if(a[n]<=0) ans=-a[n-k+1];
    else{
        int index=0;
        for(int i=1; i<=n; i++){
            if(a[i]>=0) {
                index=i; break;
            }
        }

        ans=0x3f3f3f3f;
        for(int i=index; i<index+k && i<=n; i++){
            ll tot=abs(a[i]);

            if(i-index+1<k){
               tot+=abs(a[i]);
               if(i-k+1>=1){
                    tot+=abs(a[i-k+1]);
                    //cout<<tot<<endl;
                    ans=min(tot,ans);
               }
            }else{
                //cout<<tot<<endl;
                ans=min(tot,ans);
            }
        }
        index--;
        for(int i=index; i>=1 && i>=index-k+1; i--){
            ll tot=abs(a[i]);
            if(index-i+1<k){
                tot+=abs(a[i]);
                if(k+i-1<=n){
                    tot+=abs(a[k+i-1]);
                    ans=min(ans,tot);
                }
            }
            else{
                ans=min(ans,tot);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  string S;
  string dic = "abcdefghijklmnopqrstuvwxyz";
  cin >> S;
  sort(S.begin(),S.end());
  for(int i=0;i<dic.size();i++){
    for(int j=0;j<S.size();j++){
     if(S[j]==dic[i]) break;
     if(j==S.size()-1) {
       cout << dic[i] << endl;
       return 0;
     }
   }
  }
  cout << "None" << endl;
}


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

int main()
{
    long long K, A, B;
    cin >> K >> A >> B;
    
    if(A+2>=B)
    {
        cout << K+1;
    }
    else
    {
        if(K <= A)
        {
            cout << K+1;
        }
        else
        {
            long long m = K+1-A;
            
            if(m%2 == 0)
            {
                cout << A + (B-A)*(m/2);
            }
            else
            {
                cout << A + 1 + (B-A)*(m-1)/2;
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const double PI=3.14159265358979323846;
#define int long long int
int max2(int a,int b){
    int sum=0;
    for(int i=0;i<b;i++){
        sum+=a;
        a--;
    }
    return sum;
}
signed main(){
    int n,k;cin>>n>>k;
    int min=0;
    int mx=0;
    int ans=0;
    for(int i=k;i<n+2;i++){
        if(i==k){
            for(int j=0;j<i;j++){
                min+=j;
            }
            mx=max2(n,i);
        }
        else{
            min+=(i-1);
            mx+=n-(i-1);
        }
        ans+=mx-min+1;
        ans=ans%1000000007;
    }
    //for(int i=k;i<n+2;i++){
        //if(i==k){
            //for(int j=0;j<k;j++){
                //min+=j;
            //}
        //}
        //mx=max2(n,i);
        //if(i==k)ans+=mx-min+1;
        //else ans+=mx-min;

        //min=mx;
    //}
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans = 0;
    for(ll i=1;i<=N;i++){
        ll n = N/i;
        ans += i*n*(n+1)/2;
    }
    cout << ans << "\n";
}

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

int main()
{
    vector<int> a(9);
    int sum = 0;
    for (int i = 0; i < 9; i++){
        cin >> a[i];
        sum += a[i];
    }
    cout << (sum /  3 == a[0] + a[4] + a[8] && sum % 3 == 0 ? "Yes" : "No") << endl;
        

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n; cin >> n;

	double inv = 0.0;
	FOR_LT(i, 0, n) {
		int c; cin >> c;
		inv += 1.0 / (double) c;
	}
	cout << std::setprecision(20) << (1.0 / inv) << endl;

	return 0;
}

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

int main(){
 	int n,t;
	cin >> n >> t;
	int count=t;
	int tmp,now;
	cin >> now;//end:now+t
	for(int i = 1; i< n; i++) {
		cin >> tmp;
		if(now + t - tmp>= 0) {
			count += tmp - now;
		} else {
			count += t;
		}
		now = tmp;
	}
  	cout << count << endl;
	
}


Measured memory_bytes: 256
if __name__ == '__main__':
    A, B, C, D = list(map(int, input().split()))
    if B <= C:
        print(0)
    elif B <= D:
        if A <= C:
            print(B - C)
        else:
            print(B - A)
    else:
        if A <= C:
            print(D - C)
        elif A <= D:
            print(D - A)
        else:
            print(0)


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main(){
  
  int a[50];
  int n, l, r, j;
  int cnt_in;
  int ans[10000] = {0};

  for(;;){
    cin >> n >> l >> r;
    if(n == 0 && l == 0 && r == 0){
      break;
    }
    for(int i = 0; i < n; i++){
      cin >> a[i];
    }
    
    for(int i = l; i <= r; i++){
      for(j = 0; j < n; j++){
	if(i % a[j] == 0){
	  if((j+1) % 2 == 1){
	    ans[cnt_in]++;
	  }
	  break;
	}
      }
      if(j == n){
	if(n % 2 == 0){
	  ans[cnt_in]++;
	}
      }
    }

    cnt_in++;

  }

  for(int i = 0; i < cnt_in; i++){
    cout << ans[i] << endl;
  }

  return 0;
}



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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  string s; cin >> s;
  int n = s.size();

  ll ans = 0;
  for(int bit = 0; bit < 1<<(n-1); ++bit) {
    vector<ll> num;
    string t = "";
    rep(i, n) {
      t += s[i];
      if(bit & 1<<i) {
        num.push_back(stoll(t));
        t = "";
      }
    }
    num.push_back(stoll(t));

    ans += accumulate(ALL(num), 0ll);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3584
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define mod 1000000007
#define INF 1000000000000000000
/****************************/
int main()
{
	int n;
	cin>>n;
	ll ans=0;
	rep3(i,1,n+1)
	{
		bool can=true;
		if(i>3)
		{
			if(i%3==0)
			{
				can=false;
			}
		}
		else
		{
			if(3%i==0)
			{
				can=false;
			}
		}
		if(i>5)
		{
			if(i%5==0)
			{
				can=false;
			}
		}
		else
		{
			if(5%i==0)
			{
				can=false;
			}
		}
		if(can)
		{
			ans+=i;
		}
	}
	ans++;
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3624
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map(String::toDouble)
    var sum = 0.0
    for (a in aList) {
        sum += 1.0 / a
    }
    println(1.0 / sum)
}


Measured memory_bytes: 37996
#include <bits/stdc++.h>
#define f(a, n) for (int a=0; a<n; a++)
#define F(a, n) for (int a=1; a<=n; a++)
#define ll long long
using namespace std;
long long A[100005];
long long n, mini[100005], maxi[100005];
long long high (long long md, long long mini, long long maxi){
	
}
int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(0);
	cin>>n;
	f(i, n) cin>>A[n-i];
	A[0] = 2, A[n+1] = 1;
	mini[0] = maxi [0] = 2;
	bool fail = 0;
	F(i, n){
		mini[i] = ((mini[i-1] - 1) / A[i+1]) *A[i+1] + A[i+1];  //minimum multiple of A[i+1] >= mini[i-1]
		if ((mini[i] / A[i]) * A[i] > maxi [i-1]) fail = 1;
		maxi [i] = ((maxi[i-1] + A[i] - 1) / A[i+1] ) *A[i+1]; // maximum multiple of A[i+1] <= maxi[i-1] + A[i] - 1
		if ((maxi[i] / A[i]) * A[i] < mini[i-1]) fail = 1;
	}
	if (A[1] != 2) fail = 1;
	if (fail) cout<< -1 <<endl;
	else{
		cout<< mini[n] << " " << maxi[n] <<endl;
	}
}

Measured memory_bytes: 2560
/*
	0219:A Popular Ice-cream Shop
*/
#include	<iostream>

using namespace std;

int main(void) {
	while(1) {
		int n;
		cin >> n;
		
		if( n == 0 ) { break; }
		
		int count[10] = { 0 };
		
		for(int i = 0; i < n; i++) {
			int a;
			cin >> a;
			
			count[a]++;
		}
		for(int i = 0; i < 10; i++) {
			if(count[i] == 0) {
				cout << '-' << endl;
			} else {
				for(int j = 0; j < count[i]; j++) {
					cout << '*';
				}
				cout << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int N=605;
ull base=233,inv=7204522363551799129;
ull f[N],invf[N];
int n;
char a[N][N];
ull hsr[N][N],hsc[N][N];
int main()
{
    f[0]=invf[0]=1;
    for(int i=1;i<N;i++) f[i]=f[i-1]*base,invf[i]=invf[i-1]*inv;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%s",a[i]+1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        a[i+n][j+n]=a[i+n][j]=a[i][j+n]=a[i][j];
    for(int i=1;i<=n+n;i++)
        for(int j=1;j<=n+n;j++)
    {
        for(int k=0;k<n;k++)
        {
            if(i+k<=n+n) hsr[i][j]+=(a[i+k][j]-'a'+1)*f[k+1];
            if(j+k<=n+n) hsc[i][j]+=(a[i][j+k]-'a'+1)*f[k+1];
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
    {
        bool flag=true;
        for(int k=0;k<n;k++)
        {
            if(hsr[i][j+k]!=hsc[i+k][j])
            {
                flag=false;break;
            }
        }
        ans+=flag;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll h, n;
  cin >> h >> n;

  ll sum1 = 0;
  for (ll i = 1; i <= n; i++) {
    ll x;
    cin >> x;
    sum1 += x;
  }

  if (sum1 >= h)
    cout << "Yes" << en;
  else
    cout << "No" << en;
  return 0;
}

Measured memory_bytes: 256