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

int main() {
  
  int N;
  int D;
  
  cin >> N >> D;
  
  int K = D * 2  + 1;
  
  if(N % K == 0){
    cout << N / K << endl;
  }
  else{
    cout << N / K + 1 << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
double event[1000000];
double x[200];
double y[200];
double z[200];
double r[200];
double dist(double x1,double y1,double z1,double x2,double y2,double z2){
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));
}
double Abs(double a){return max(a,-a);}
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1);
int sig(double r){return (r<-EPS)?-1:(r>+EPS)?+1:0;}
struct Pt{
	double x,y;
	Pt(){}
	Pt(double x,double y):x(x),y(y){}
	Pt operator+(const Pt &a)const{return Pt(x+a.x,y+a.y);}
	Pt operator-(const Pt &a)const{return Pt(x-a.x,y-a.y);}
	Pt operator*(const Pt &a)const{return Pt(x*a.x-y*a.y,x*a.y+y*a.x);}
	Pt operator-()const{return Pt(-x,-y);}
	Pt operator*(const double &k)const{return Pt(x*k,y*k);}
	Pt operator/(const double &k)const{return Pt(x/k,y/k);}
	double Abs()const{return sqrt(x*x+y*y);}
	double Abs2()const{return x*x+y*y;}
	double arg()const{return atan2(y,x);}
	double dot(const Pt &a)const{return x*a.x+y*a.y;}
	double det(const Pt &a)const{return x*a.y-y*a.x;}
};
double tri(const Pt&a,const Pt&b,const Pt&c){return (b-a).det(c-a);}
pair<Pt,Pt> pCC(Pt a,double r,Pt b,double s){
	double d=(b-a).Abs();
	double x=(d*d+r*r-s*s)/(d*2);
	Pt e=(b-a)/d,w=e*Pt(0,1)*sqrt(max(r*r-x*x,0.0));
	return make_pair(a+e*x-w,a+e*x+w);
}
int ans[100000];
int UF[128];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);
	if(a==b)return;
	UF[a]+=UF[b];
	UF[b]=a;
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%lf%lf%lf%lf",x+i,y+i,z+i,r+i);
		int ind=0;
		event[ind++]=0;
		for(int i=0;i<a;i++){
			event[ind++]=z[i]-r[i];
			event[ind++]=z[i]+r[i];
		}
		for(int i=0;i<a;i++)
			for(int j=i+1;j<a;j++){
				if(dist(x[i],y[i],z[i],x[j],y[j],z[j])>r[i]+r[j])continue;
				if(Abs(r[i]-r[j])>dist(x[i],y[i],z[i],x[j],y[j],z[j]))continue;
				pair<Pt,Pt> inter=pCC(Pt(0.0,z[i]),r[i],Pt(dist(x[i],y[i],0,x[j],y[j],0),z[j]),r[j]);
				event[ind++]=inter.first.y;
				event[ind++]=inter.second.y;
			}
		event[ind++]=50000;
		std::sort(event,event+ind);
		int at=0;
		int last=0;
		for(int i=0;i<ind;i++){
			if(i&&event[i]-event[i-1]<EPS)continue;
			double M=(event[i]+event[i-1])/2;
			for(int j=0;j<a;j++)UF[j]=-1;
			for(int j=0;j<a;j++){
				if(M+EPS<z[j]-r[j]||M-EPS>z[j]+r[j])continue;
				for(int k=j+1;k<a;k++){
					if(M+EPS<z[k]-r[k]||M-EPS>z[k]+r[k])continue;
					if(dist(x[j],y[j],0,x[k],y[k],0)<sqrt(r[j]*r[j]-(z[j]-M)*(z[j]-M))+sqrt(r[k]*r[k]-(z[k]-M)*(z[k]-M)))UNION(j,k);
				}
			}
			int count=0;
			for(int j=0;j<a;j++){
				if(M+EPS<z[j]-r[j]||M-EPS>z[j]+r[j])continue;
				//printf("(%d,%d) ",j,UF[j]);
				if(UF[j]<0)count++;
			}
			if(last!=count){
				if(last<count)ans[at++]=1;
				else ans[at++]=0;
			}
		//	printf("%f %d\n",M,count);
			last=count;
		}
		printf("%d\n",at);
		for(int i=0;i<at;i++)printf("%d",ans[i]);
		printf("\n");
	}
}

Measured memory_bytes: 1104
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        if (n < 3) {
            System.out.println(0);
            return;
        }
        Arrays.sort(a);
        int c = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                for (int k = j + 1; k < n; k++) {
                    if ((a[i] != a[j]) && (a[j] != a[k]) && (a[k] != a[i])) {
                        if (a[i] + a[j] > a[k]) {
                            // System.out.println("found pair at" + a[i] + " " + a[j] + " " + a[k]);
                            c++;
                        }
                    }
                }
            }
        }
        System.out.println(c);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 33200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    vi PQR;
    PQR.resize(3);
    cin >> PQR[0] >> PQR[1] >> PQR[2];
    sort(ALL(PQR));
    cout << PQR[0] + PQR[1] << endl;

    // system("pause");
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
  string S;
  cin >> S;
  int l = S.length();
  string T;
  for(int i = 0; i < l; ++i){
    if(S[i] != 'x') T += S[i];
  }
  string T_rev = T;
  reverse(T_rev.begin(), T_rev.end());
  if(T != T_rev){
    cout << -1 << endl;
    return 0;
  }
  int i = 0, k = l-1, ans = 0;
  while(i < k){
    if(S[i] == 'x' && S[k] != 'x'){
      ++ans;
      ++i;
    }else if(S[k] == 'x' && S[i] != 'x'){
      ++ans;
      --k;
    }else{
      ++i;
      --k;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
N=int(input())

rllist=[]
for _ in range(N):
  X,L=map(int,input().split())
  rllist.append((X+L,X-L))
rllist.sort()
#print(rllist)

answer=0
max_r=-float("inf")
for r,l in rllist:
  #print(max_r,l)
  if max_r<=l:
    answer+=1
    max_r=max(max_r,r)
  
print(answer)

Measured memory_bytes: 22804
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll c[50][26] = {};
int main() {
	ll n; cin >> n;
	rep(i, 0, n) {
		string s; cin >> s;
		rep(j, 0, s.size()) {
			c[i][s[j] - 'a']++;
		}
	}

	rep(i, 0, 26) {
		ll minV = 1 << 21;
		rep(k, 0, n) {
			minV = min(c[k][i], minV);
		}
		rep(v, 0, minV) {
			cout << (char)(i + 'a');
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    try {
      int n = sc.nextInt();
      int r = sc.nextInt();
      System.out.println(n >= 10 ? r : r + 100 * (10 - n));
    } finally {
      sc.close();
    }
  }
}

Measured memory_bytes: 35688
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pi = pair<int, int>;
template <typename T>
using Pq = priority_queue<T>;
template <typename T>
using pQ = priority_queue<T, vector<T>, greater<T>>;

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> N >> K;
    vi a(N);
    cin >> a;
    vi h = a;
    h.push_back(0);
    sort(ALL(h));
    UNIQUE(h);
    map<int, int> mp;
    M = h.size();
    REP(i, M) {
        mp[h[i]] = i;
    }
    auto dp = make_vec<int>(N + 1, K + 10, M, LLINF);
    dp[0][0][0] = 0;
    REP(n, N) {
        int nxtm = mp[a[n]];
        REP(k, K + 1) {
            REP(m, M) {
                if (dp[n][k][m] == LLINF)
                    continue;
                dump(h[m], h[nxtm], nxtm);
                chmin(dp[n + 1][k][nxtm], dp[n][k][m] + max(0LL, h[nxtm] - h[m]));
                chmin(dp[n + 1][k + 1][m], dp[n][k][m]);
            }
        }
    }
    cout << *min_element(ALL(dp[N][K])) << endl;
}

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

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

using Graph = vector<vector<int>>;

ll kzyou(ll a,ll k){//aのk乗を返す
    ll zyou = 1;
    for(ll i = 1;i<=k;i++){
        zyou *= a;
    }
    return zyou;
}
typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

int main(){
  string S;
  cin >> S;
  int N = S.size();
  int ans = 0;
  if(N%2 == 0){
   rep(i,N/2){
    if(S[i] != S[N-1-i]) ans++;
   }
   cout << ans << endl;
  }
   else{
    rep(i,N/2+1){
    if(S[i] != S[N-1-i]) ans++;
    }
    cout << ans << endl;
  }
 }

Measured memory_bytes: 256
N = int(input())

#lst = []
#for i in range(N):
#    lst.append(int(input()))

lst =[int(input()) for i in range (N)]
lstA = sorted(lst,reverse=True)

for i in range(N):
    if lst[i] == lstA[0]:
        print(lstA[1])
    else:
        print(lstA[0])


Measured memory_bytes: 14192
import java.util.Arrays;
//List of Top 3 Hills
import java.util.Scanner;

class Main{
    public static void main(String[] a){
        Scanner sc = new Scanner(System.in);
        int hight[];
        hight = new int[10];
        
//        System.out.println("hight.length="+hight.length);
        for(int i=0; i<hight.length; i++) {
            hight[i]=sc.nextInt();
        }
//        System.out.println("in end");
        Arrays.sort(hight);

        for(int i=0; i<3; i++) {
            System.out.println(hight[(hight.length-1-i)]);
        }

    }
}

Measured memory_bytes: 17312
/**
 * Created by karayuu on 2018/12/08
 */
fun main(args: Array<String>) {
    val (r, g, b) = readLine()!!.split(" ").map { it.toInt() }
    val num = r * 100 + g * 10 + b //ポイントはここ。位取り記数法で変換する

    if (num % 4 == 0) {
        println("YES")
    } else {
        println("NO")
    }
}

Measured memory_bytes: 37936
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 15 + 5;
const int ALL = (1<<15) + 5;
const int inf = 0x3f3f3f3f;

inline void chk_max(int &a,int b){ if(a<b) a=b;}

int lb[ALL];
#define bit(x,i) (((x)>>(i))&1)
#define lowbit(x) ((x)&-(x))

int g[MAXN][MAXN];
int cost[ALL],f[ALL][MAXN];

int main(void)
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1; i<=m; ++i)
	{
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		g[u][v]=g[v][u]=w;
	}
	
	int all = (1<<n)-1;
	
	for(int mask=0; mask<=all; ++mask)
	{
		for(int i=1; i<=n; ++i) if(bit(mask,i-1))
			for(int j=1; j<i; ++j) if(bit(mask,j-1))
				cost[mask]+=g[i][j];
	}
	
	for(int mask=0; mask<=all; ++mask)
	{
		for(int i=1; i<=n; ++i) f[mask][i]=-inf;
		if(mask&1) f[mask][1]=cost[mask];
	}
	int ans=0;
	for(int mask=1; mask<=all; mask+=2)
	{
		if(bit(mask,n-1))
		{
			chk_max(ans,f[mask][n]);
			continue;
		}
		for(int i=1; i<=n; ++i) if(bit(mask,i-1))
		{
			if(f[mask][i]==-inf) continue;
			for(int mask2=all^mask; mask2; mask2=(mask2-1)&(all^mask))
			{
				for(int j=1; j<=n; ++j) if(bit(mask2,j-1))
					if(g[i][j]>0)
						chk_max(f[mask|mask2][j], f[mask][i]+g[i][j]+cost[mask2]);
			}
		}
	}
	
	printf("%d",cost[all]-ans);
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define ll long long
// #define FAST cin.tie(0)->sync_with_stdio(0);cout.tie(0)->sync_with_stdio(0);
#define pb push_back
using namespace std;
int x[4]={0,0,1,-1};
int y[4]={1,-1,0,0};
int main() {
    // FAST
    ll h,w,k;cin>>h>>w>>k;
    ll x1,x2,y1,y2;cin>>x1>>y1>>x2>>y2;
    char grid[h][w];
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin>>grid[i][j];
    ll dist[h][w];
    ll INF=(ll)1e10;
    memset(dist,INF,sizeof(dist));
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) dist[i][j]=INF;
    queue<pair<ll,ll>> q;
    --x1;--x2;--y1;--y2;
    dist[x1][y1]=0;
    q.push({x1,y1});
    while(!q.empty())
    {
        pair<ll,ll> t = q.front();
        q.pop();
        ll curx=t.first, cury=t.second;
        // cout<<curx<<" "<<cury<<endl;
        if(curx==x2 && cury==y2)
        {
            cout<<dist[x2][y2];
            return 0;
        }
        for(int i=0;i<4;i++)
        {
            for(int j=1;j<=k;j++)
            {
                
                ll xt=curx+x[i]*j,yt=cury+y[i]*j;
                // cout<<xt<<"-"<<yt<<endl;
                if(xt>=h || xt<0 || yt>=w || yt<0) break;
                if(grid[xt][yt]=='@') break;
                // cout<<"$"<<dist[xt][yt]<<endl;
                if(dist[xt][yt]!=INF && dist[xt][yt]<=dist[curx][cury])
                {
                    break;
                }
                // cout<<"$"<<dist[xt][yt]<<endl;
                if(dist[xt][yt]!=INF) continue;
                dist[xt][yt]=dist[curx][cury]+1;
                // cout<<"$"<<dist[xt][yt]<<endl;
                q.push({xt,yt});
            }
        }
    }
    cout<<-1;
    return 0;

}


Measured memory_bytes: 13920
#include <iostream>
#include <cstdio>
#define N 30000
using namespace std;

int n, p, a[N];
int main()
{
	int i;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf("%d", &p);
		a[p] = i - n;
	}
	for (i = 1; i <= n; i++) printf("%d ", a[i] + i * N);
	puts("");
	for (i = 1; i <= n; i++) printf("%d ", (n - i + 1) * N);
    return 0;
}

Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;

int main(){
  int a,b,WD;
  while(cin>>a>>b){
    if(a==0){WD=8;break;}
    else if ((a==1)||(a==4)||(a==7))WD=(b+3)%7;
    else if ((a==2)||(a==8))WD=(b+6)%7;
    else if ((a==3)||(a==11))WD=b%7;
    else if (a==5)WD=(b+5)%7;
    else if (a==6)WD=(b+1)%7;
    else if ((a==9)||(a==12))WD=(b+2)%7;
    else if (a==10)WD=(b+4)%7;
    if(WD==0){
      cout <<"Sunday"<<endl;
    }
    else if(WD==1){
      cout <<"Monday"<<endl;
    }
    else if(WD==2){
      cout <<"Tuesday"<<endl;
    }
    else if(WD==3){
      cout <<"Wednesday"<<endl;
    }
    else if(WD==4){
      cout <<"Thursday"<<endl;
    }
    else if(WD==5){
      cout <<"Friday"<<endl;
    }
     else if(WD==6){
      cout <<"Saturday"<<endl;
    }
  }
  return 0;
}




Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;
typedef pair<string, int> P;
int n;
map<int, int> m;
int main()
{
    cin >> n;
    vector<P> v(n);
    rep(i, n)
    {
        string s;
        int p;
        cin >> s >> p;
        m[p] = i + 1;
        v[i] = P(s, p);
    }
    sort(v.begin(), v.end());
    string s = v[0].first;
    vector<int> p;
    p.push_back(v[0].second);
    for (int i = 1; i < n; i++)
    {
        if (v[i].first == s)
        {
            p.push_back(v[i].second);
        }
        else
        {
            s = v[i].first;
            sort(p.begin(), p.end(), greater<int>());
            rep(j, p.size())
            {
                cout << m[p[j]] << endl;
            }
            p.clear();
            p.push_back(v[i].second);
        }
    }
    sort(p.begin(), p.end(), greater<int>());
    rep(j, p.size())
    {
        cout << m[p[j]] << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	if (a == 1) a = 14;
	if (b == 1) b = 14;
	
	if (a>b) printf("Alice\n");
	else if (a==b) printf("Draw\n");
	else printf("Bob\n");
	
	return 0;
}

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

#define repeat(i,n) for (int i = 0; i < (n); ++i)
#define repeat_rev(i,n) for (int i = (n)-1; 0 <= i; ++i)

#define MAX_N 100
#define MAX_W 10000

struct item { int v, w; };
int N, W;
item t[MAX_N];
int dp[2][MAX_W+1];

int main() {
    cin >> N >> W;
    repeat (i,N) cin >> t[i].v >> t[i].w;
    int *cur = dp[0]; fill(cur,cur+W+1,0);
    int *prv = dp[1];
    repeat (n,N) {
        swap(cur,prv);
        repeat (w,W+1) cur[w] = max(prv[w], (0 <= w-t[n].w ? cur[w-t[n].w]+t[n].v : 0));
    }
    repeat_rev (i,W+1) if (cur[i]) {
        cout << cur[i] << endl;
        break;
    }
    return 0;
}

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

int main(){
  char a,b;
  cin >> a >> b;
  
  if(a>b) {
    cout << ">" << endl;
  }
  else if(a<b){
    cout << "<" << endl;
  }
  else {
    cout << "=" << endl;
  }
}


Measured memory_bytes: 256
N=int(input())
A=[0]
a=list(map(int,input().split()))
A+=a
A+=[0]
S=[0]
for i in range(N):
    S.append(S[-1]+abs(A[i+1]-A[i]))
S.append(S[-1]+abs(A[i+1]))
for i in range(N):
    print(S[i]+abs(A[i+2]-A[i])+S[-1]-S[i+2])

Measured memory_bytes: 13920
import math
def main():
	n ,d = map(int,input().split())
	arr = [ ]
	for _ in range(n):
		arr.append(list(map(int,input().split())))
	ans = 0
	for i in range(n):
		for j in range(i+1,n):
			cnt  = 0	
			for k in range(d):
				cnt += (arr[i][k]-arr[j][k])*(arr[i][k]-arr[j][k])
			if math.sqrt(cnt)==int(math.sqrt(cnt)):
				ans+=1
	print(ans)
	return



main()


Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int R, C, N;
vector<pair<int, int> > inp;

bool isin(int x, int y, int &len) {
	if (y == 0) {
		len = x;
		return true;
	}
	if (x == R) {
		len = R + y;
		return true;
	}
	if (y == C) {
		len = R + C + (R - x);
		return true;
	}
	if (x == 0) {
		len = R * 2 + C + (C - y);
		return true;
	}
	return false;
}

bool isok() {
	//COUT(inp);

	stack<int> st;
	st.push(-1);
	for (int i = 0; i < inp.size(); ++i) {
		int cur = st.top();
		int next = inp[i].second;

		if (cur == next) {
			st.pop();
		}
		else {
			st.push(next);
		}
	}
	return (st.size() == 1);
}

int main() {
	while (cin >> R >> C >> N) {
		inp.clear();
		for (int i = 0; i < N; ++i) {
			int x[2], y[2], len[2];
			cin >> x[0] >> y[0] >> x[1] >> y[1];
			if (!isin(x[0], y[0], len[0])) continue;
			if (!isin(x[1], y[1], len[1])) continue;

			inp.push_back(make_pair(len[0], i));
			inp.push_back(make_pair(len[1], i));
		}
		sort(inp.begin(), inp.end());

		if (isok()) puts("YES");
		else puts("NO");
	}
}



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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int e = a/d;
    if(a%d>0){e++;}
    int f = c/b;
    if(c%b>0){f++;}

    if(e>=f){cout << "Yes" << endl;}
    else{cout << "No" << endl;} 
}

Measured memory_bytes: 3596
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int sum = 0;
    for(int i = 0; i < n; i++){
      int x = sc.nextInt();
      sum += 2*Math.min(x,Math.abs(x-k));
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,n) for(i=a;i<n;i++)
#define ll long long int 
int main() {
        ll n,s=0,s1=0,i,j;
        cin>>n;
        ll a[n],b[n];
        f(i,0,n){
        cin>>a[i];
        s+=a[i];
        if(i%2==0 && i!=(n-1))
        s1+=a[i]*2;
        }
        // cout << s1<<endl;
        b[n-1]=s-s1;
        for(i=n-2;i>=0;i--)
        {
            b[i]=a[i]*2-b[i+1];
        }
        f(i,0,n)
        cout << b[i]<<" ";
	return 0;
}

Measured memory_bytes: 2816
h, w, z = map(int ,input().split())
s = []
for i in range(h):
    s.append(list(input()))
ans = int(1e9+7)


for i2 in range(2**(h-1)):
    d = [True] * (h-1)
    for j2 in range(h-1):
        if (i2 >> j2) & 1:
            d[j2] = False
    d.append(False)


    val = 0
    for i in range(len(d)-1):
        if d[i] == False:
            val += 1
    #print(val,d)
    l = []
    lis = []
    for i in range(h):
        l.append(i)
        if d[i] == False:
            lis.append(l)
            l = []

    flg2 = True#横がiのときにcnt2の要素がkを超えるとFalse
    flg = True#cntの要素がkを超えるとFalse
    cnt = [0] * len(lis)#全体での1の個数
    for i in range(w):
        cnt2 = [0] * len(lis)#iでの1の個数
        for j in range(len(lis)):
            for k in lis[j]:
                if s[k][i] == '1':#高さがkで横がiの時、
                    cnt[j] += 1#lis[j]を1たす
                    cnt2[j] += 1
            if cnt[j] > z:
                flg = False
            if cnt2[j] > z:
                flg2 = False
        if flg == False:
            for j in range(len(cnt)):
                cnt[j] = cnt2[j]
            flg = True
            val += 1
        #print(cnt,cnt2)
        #print(i,val)
    if flg2 == True:
        ans = min(ans,val)
    #print(val,d,lis,flg)
print(ans)


Measured memory_bytes: 49244
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] Count = new int[26];
		for (int i = 0; i < 26; i++) {
			Count[i] = 0;
		}
		while (sc.hasNextLine()) {
			String S = sc.nextLine();
			for (int i = 0; i < S.length(); i++) {
				char c = Character.toLowerCase(S.charAt(i));
				if (c >= 'a' && c <= 'z') {
					Count[c - 'a']++;
				}
			}
		}
		for (int i = 0; i < 26; i++) {
			System.out.println((char)('a' + i) + " : " + Count[i]);
		}
	}
}



Measured memory_bytes: 26164
#include <stdio.h>

int ascending(void const *a,void const *b)
{
    return (*(int*)a-*(int*)b);
}
int main()
{
    int b,c,i,j,k;

    int a[3];

    scanf("%d %d %d",&a[0],&a[1],&a[2]);

    qsort(a,3,sizeof(int),ascending);

    printf("%d\n",a[0]+a[1]);

}


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

int main() {
    int n, q; cin >> n >> q;
    vector<vector<int>> v(n);
    while (q--) {
        int com; cin >> com;
        if (com == 0) {
            int t, x; cin >> t >> x; v[t].emplace_back(x);
        } else if (com == 1) {
            int t; cin >> t;
            int i = 0; for (int x: v[t]) cout << (i++ ? " " : "") << x;
            cout << endl;
        } else {
            int t; cin >> t; v[t].clear();
        }
    }
    return 0;
}


Measured memory_bytes: 5776
package main

import (
	"fmt"
)

// go run ./main.go < in

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

	inputs := make(map[string]int)
	for i := 0; i < n; i++ {
		var str string
		fmt.Scan(&str)
		inputs[str] = 0
	}

	fmt.Println(len(inputs))
}

Measured memory_bytes: 23692
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
using namespace std;

int main() {
    int N;
    cin >> N;
    long long t = 0, a = 0;
    for (int i = 0; i < N; ++i) {
        int T, A;
        cin >> T >> A;
        if (i == 0) {
            t = T;
            a = A;
        } else {
            long long mx = max((t + T - 1) / T, (a + A - 1) / A);
            t = T * mx;
            a = A * mx;
        }
    }
    cout << t + a << endl;
    return 0;
}


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

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    // int n;
    // cin >> n;
    // priority_queue<int, vector<int>, greater<int> > q;
    // rep(i, n) {
    //     int a;
    //     cin >> a;
    //     q.push(a);
    // }
    // while (q.size() > 1) {
    //     int m = q.top(); // 残っているモンスターのうち体力が最も低いものが攻撃する
    //     q.pop();
    //     rep(i, q.size()) {
    //         int a = q.top();
    //         q.pop();
    //         if (a % m != 0) {
    //             a %= m;
    //             q.push(a);
    //         }
    //     }
    //     q.push(m);
    // }
    // cout << q.top() << endl;
    // 全モンスターの体力の最大公約数が答えになる
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        if (i == 0) continue;
        a[i] = gcd(a[i], a[i-1]);
    }
    cout << a[n-1] << endl;
}

Measured memory_bytes: 3784
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int C = scanner.nextInt();
		int D = scanner.nextInt();
		int count = 0;

		//③④スイッチを押している時間がかぶらない時
		if (B < C || D < A) {
			count = 0;
		//①②スイッチを押している時間がどちらかに完全に含まれるとき
		} else if ((A <= C && B >= D) || (C <= A && D >= B)) {
			count = (B-A <= D-C) ? B-A : D-C;

		//⑤⑥スイッチを押している時間が一部かぶるとき
		} else {
			if (B == C || D == A) {
				count = 0;
			} else if (A < C) {
				count = Math.abs(C - B);
			} else {
				count = Math.abs(D - A);
			}
		}
		System.out.println(count);

	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
long long int MOD = 1e9 + 7;

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

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

    map<long long int, long long int> prime_power;
    for(int i=0; i<n; i++){
        int m = a[i];
        for (long long int p=2; p*p<=m; p++) {
            if(m % p != 0) continue;// break and proceed to p+1

            long long int power = 0;
            while(m % p == 0){
                power += 1;
                m /= p;
            }
            prime_power[p] = max(prime_power[p], power);
        }

        // n has been divided by all primes (with power) smaller than sqrt(n)
        if(m != 1){
            if(!prime_power.count(m)) prime_power[m] = 1;
        }
    }

    long long int lcm = 1;
    for(auto pp : prime_power){
        //cout << pp.first << " " << pp.second << endl;
        for(int i=0; i<pp.second; i++){
            lcm *= pp.first;
            lcm %= MOD;
        }
    }

    vector<long long int> inverse(1e6+1,1);
    for (int i=2; i<=1e6; i++){
        inverse[i] = MOD - inverse[MOD % i] * (MOD / i) % MOD;
    }

    long long int ans = 0;
    for(int i=0; i<n; i++){
        ans += lcm * inverse[a[i]];
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8704
n, m = map(int, input().split())

def calc_divisors(n):
    res = []
    i = 1
    while i * i <= n:
        if n % i == 0:
            res.append(i)
            res.append(n // i)
        i += 1
    res = list(set(res))
    return res

divisors = calc_divisors(m)
divisors.sort(reverse=True)

for divisor in divisors:
    if m >= n * divisor:
        print(divisor)
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    double pi=3.14159265258;
    int n;
    cin>>n;
    n*=2;
    cout<<fixed<<setprecision(10);
    cout<<n*pi<<endl;
}


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

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,m,num;
struct data
{
	int l,r; 
}a[100005];
bool cmp(data a,data b)
{
	return (a.l<b.l)||(a.l==b.l&&a.r>b.r);
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
		cin>>a[i].l>>a[i].r;
	sort(a+1,a+1+m,cmp);
	int s=0,l=a[1].l,r=a[1].r;
	a[m+1].l=0;a[m+1].r=n+1;
	for(int i=1;i<=m+1;i++)
		if(a[i].l>=l&&a[i].l<r||a[i].r>l&&a[i].r<=r)
		{
			l=max(l,a[i].l);r=min(r,a[i].r);
		}else
		{
		  l=a[i].l;r=a[i].r;num++;
	    }
	cout<<num<<endl;
	return 0;
}


Measured memory_bytes: 1024
def min(a,b);a < b ? a : b;end
INF = 10**12

h,w = gets.split.map(&:to_i)
s = Array.new(h){ gets.chomp }
dp = Array.new(h){ Array.new(w, INF) }
dp[0][0] = 0

h.times do |y|
  w.times do |x|
    if y != h - 1
      diff = s[y+1][x] == s[y][x] ? 0 : 1
      dp[y+1][x] = min(dp[y+1][x], dp[y][x] + diff)
    end
    
    if x != w - 1
      diff = s[y][x+1] == s[y][x] ? 0 : 1
      dp[y][x+1] = min(dp[y][x+1], dp[y][x] + diff)
    end
  end
end

ans = 0
ans += 1 if s[0][0] == "#"
ans += 1 if s[-1][-1] == "#"
ans += dp[-1][-1]
puts ans / 2

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

typedef long long ll;

int main() {
    int H1, H2;
    int M1, M2;
    int K;
    int total = 0;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    if (M1 > M2) {
        M2 += 60;
        H2--;
    }
    total += M2 - M1;
    total += 60 * (H2-H1);
    cout << total - K << endl;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

int main() {
	double n,k;cin>>n>>k;
	double ans=0;
	for(double i=1; i<=n; i++){
		double p; p=i;
		double a; a = 1/n;
		while(p<k){
           p*=2;
		   a*=0.5;
		}
		ans += a;
	}
	cout<<fixed<<setprecision(15)<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;cin>>c;
  if (c == 'A') cout << 'T' << endl;
  else if (c == 'T') cout << 'A' << endl;
  else if (c == 'G') cout << 'C' << endl;
  else if (c == 'C') cout << 'G' << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define md 1000000007
#define fat 998244353 
#define INF 1e9
double PI=3.1415926535;
const int N =  (int)(1 * 1e6 + 10);
using namespace std;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}

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

    if(s[s.length()-1]=='s')
    {
        s+="es";
    }
    else
    {
        s+="s";
    }
    cout<<s<<endl;
}

Measured memory_bytes: 3628
-- [Char]あるいは String を Int にする
toInt :: (String -> Int)
toInt x = read x ::Int

--入力を受け取り、[Int]にする
getInts = do
  x <- getLine
  let y = (map $ toInt) $ words x -- 半角スペースで分割してInt にする
  return y

eat :: Int -> Int -> (Int, Int)
eat x k | k == 0    = (x, k)
        | x >= k    = (x-k, 0)
        | otherwise = (0, k-x)

main = do
    [a, b, k] <- getInts
    let (ra, rk) = eat a k
    let rb = fst $ eat b rk 
    putStrLn $ (show ra) ++ " " ++ (show rb)

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

int main() {

    string s;
    cin >> s;

    if ( s[0] == s[1] && s[2] == s[3] ) {
        if ( s[0] != s[2] ) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if ( s[0] == s[2] && s[1] == s[3] ) {
        if ( s[0] != s[1] ) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if ( s[0] == s[3] && s[1] == s[2] ) {
        if ( s[0] != s[1] ) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;

}

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

template<class Type>
Type gcd(Type x, Type y)
{
	if (x < y) swap(x, y);
	while (y != 0) {
		Type tmp = x;
		x = y;
		y = tmp % y;
	}
	return x;
}

int main()
{
	int n;
	cin >> n;
	int ans;
	cin >> ans;
	for (int i = 1; i < n; i++) {
		int a;
		cin >> a;
		ans = gcd(ans, a);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

int main(){
    ll n; cin>>n;
    vector<ll>a(n);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        if(i%2==0)sum+=a[i];
        else sum-=a[i];
    }
    vector<ll>ans(n);
    ans[0]=sum;
    rep(i,n-1){
        ans[i+1]=2*a[i]-ans[i];
    }
    rep(i,n){
        cout<<ans[i]<<" ";
    }
    cout<<endl;

}








































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

int main(){
  int N;
  cin >> N;
  for(int i=1;i<=N;i++){
    double X=i*(108.0/100);
    if(X==N){
      cout << i << endl;
      return 0;
    }else if((abs(X-N)<1)&&(X>N)){
      cout << i << endl;
      return 0;
    }
    // //cout << i*(108.0/100) << endl;
  }
  cout << ":(" << endl;
  return 0;
}


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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

bool my_compare(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

int main() {
  ll N, M;
  cin >> N >> M;

  vector<pair<int, int>> p(M);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    p[i] = make_pair(a, b);
  }
  sort(p.begin(), p.end(), my_compare);

  ll ans = 1;
  int a, b;
  b = p[0].second;
  for (int i = 1; i < M; i++) {
    if (p[i].first >= b) {
      b = p[i].second;
      ans++;
    }
  }

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

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC102.A
{
    class Program
    {
        static void Main ()
        {
            var sc = new Scanner ();
            int a = sc.Nextint ();
            int b = sc.Nextint ();
            if (a + b == 15) Console.WriteLine ('+');
            else if (a * b == 15) Console.WriteLine ('*');
            else Console.WriteLine ('x');
        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner ()
        {
            s = new string[0];
            i = 0;
        }

        public string Next ()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine ();
            while (st == "") st = Console.ReadLine ();
            s = st.Split (cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next ();
            i = 0;
            return s[i++];
        }

        public int Nextint ()
        {
            return int.Parse (Next ());
        }
        public int[] Arrayint (int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint () + add;
            }
            return Array;
        }

        public long NextLong ()
        {
            return long.Parse (Next ());
        }

        public long[] ArrayLong (int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong () + add;
            }
            return Array;
        }

        public double NextDouble ()
        {
            return double.Parse (Next ());
        }

        public double[] ArrayDouble (long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble () + add;
            }
            return Array;
        }

        public decimal NextDecimal ()
        {
            return decimal.Parse (Next ());
        }

        public decimal[] ArrayDecimal (long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal ();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int A, B;
  cin >> A >> B;
  int ans = A + A - 1;
  ans = max(ans, A + B);
  ans = max(ans, B + B - 1);
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<long double> A(n);
  for (int i = 0; i < n; ++i){
  	cin >> A[i];
  }
  long double sum = 0.0;
  for (auto& a : A){
  	sum += 1.0/a;
  }
  cout << 1.0/sum;
}


Measured memory_bytes: 888
N, K = map(int, input().split())
sunuke = [True]*N
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        sunuke[a-1] = False

ans = 0
for i in range(N):
    if sunuke[i]:
        ans += 1
print(ans)

Measured memory_bytes: 9192
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] a=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		const long o=1;
		int g=0,m=s[0]*(s[0]+1)/2;
		long[] h=new long[m];
		
		for(int i=0;i<s[0];i++){
			long q=0;
			for(int j=i;j<s[0];j++){
				q+=a[j];
				h[g]=q;
				g++;
			}
		}
		long b=0;
		for(int i=39;i>=0;i--){
			long p=0;
			b|=o<<i;
			for(int j=0;j<m;j++){
				if((h[j]&b)==b){p++;}
			}
			if(p<s[1]){b-=o<<i;}
		}
		Console.WriteLine(b);
	}
}

Measured memory_bytes: 14944
#include"iostream"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"iomanip"
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;cin>>n;
    int min1=1e7,max1=-1e7;
    while(n--)
    {
        int x;cin>>x;
        min1=min(min1,x);
        max1=max(max1,x);
    }
    cout<<max1-min1<<'\n';
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		
		if(n.charAt(0) == n.charAt(2)){
			System.out.println("Yes");
		} else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23892
def indexIsValid(S, ni):
    for i in range(len(S)):
        if ni[i] >= len(S[i]):
            return False

    return True

def goToNextCharacterIndex(S, ni, current_c):
    for i in range(len(S)):
        while S[i][ni[i]] == current_c:
            ni[i] += 1

            # end of search
            if ni[i] >= len(S[i]):
                return False

    return True

def allSameCharacter(S, ni):
    result = True
    for i in range(len(S) - 1):
        result = result and (S[i][ni[i]] == S[i+1][ni[i+1]])

    return result


if __name__ == "__main__":
    n = int(input())
    S = [input() for i in range(n)]

    # list of sorted characters list (2D array)
    S_sorted = [sorted(list(S[i])) for i in range(n)]

    # character index for S[i]
    ni = [0 for i in range(n)]

    result = ""
    continue_search = True
    for c in "abcdefghijklmnopqrstuvwxyz":
        if not continue_search:
            break
        
        while allSameCharacter(S_sorted, ni):
            result += S_sorted[0][ni[0]]
            ni = list(map(lambda x : x + 1, ni))

            if not indexIsValid(S_sorted, ni):
                continue_search = False
                break

        if not continue_search:
            break
            
        continue_search = goToNextCharacterIndex(S_sorted, ni, c)

    print(result)


Measured memory_bytes: 3064
#include <stdio.h>
#define INFNITY 900000
#define N 100
#define W 0
#define G 1
#define B 2


int data[N][N];

void dijkstra(int);

int main(){
  int n,i,j,p,q,r,m;

  scanf("%d",&n);

for(i=0;i<n;i++){//初期化
  for(j=0;j<n;j++){
    data[i][j]=INFNITY;
  }
}

  for(i=0;i<n;i++){
    scanf("%d%d",&p,&q);
    for(j=0;j<q;j++){
        scanf("%d%d",&r,&m);
        data[p][r]=m;
    }
  }
    
  dijkstra(n);

  return 0;
}


void dijkstra(int n){//ダイクストラ                                                             
  int i,p[N],d[N],color[N],minv,u;

  for(i=0;i<n;i++){
    d[i]=INFNITY;
    color[i]=W;
      }

     d[0]=0;

 while(1){
    minv=INFNITY;
    u=-1;

    for(i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=B){
        u=i;
        minv=d[i];
      }
    }

    if(u==-1) break;

    color[u]=B;
    for(i=0;i<n;i++){
      if(color[i]!=B && data[u][i]!=INFNITY){
        if(d[i]>data[u][i]+d[u]){
          d[i]=data[u][i]+d[u];
          color[i]=G;
        }
      }
    }
  }
    for(i=0;i<n;i++){
      printf("%d %d\n",i,d[i]);
    }
  


  }






Measured memory_bytes: 2052
from functools import reduce

n, k = map(int, input().split())
mod = 10**9 + 7
res = [0] * k


def ncrf(i, j):
    num = reduce(lambda x, y: x * y % mod, range(i, i - j, -1))
    den = reduce(lambda x, y: x * y % mod, range(1, j + 1))
    return num * pow(den, mod - 2, mod) % mod

for d in range(1, k + 1):
    if d == 1:
        print(ncrf(n - k + 1, d))
    else:
        print(ncrf(n - k + 1, d) * ncrf(k - 1, d - 1) % mod)


Measured memory_bytes: 3940
#include<iostream>
#include<string>
#include<stack>
using namespace std;
int main()
{
    string s;
    stack<char> c;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'S') c.push('S');
        else{
            if(c.empty()) c.push('T');
            else if(c.top() == 'T') c.push('T');
            else c.pop();
        }
    }
    cout << c.size() << endl;
    return 0;
}

Measured memory_bytes: 644
def c_back_and_forth():
    sx, sy, tx, ty = [int(i) for i in input().split()]
    
    ans = ''
    # (sx,sy)→(tx,ty)
    ans += 'U' * abs(ty - sy) + 'R' * abs(tx - sx)
    # (tx,ty)→(sx,sy)
    ans += 'D' * abs(ty - sy) + 'L' * abs(tx - sx)
    # (sx,sy)→(tx,ty)
    ans += ('L' + 'U' * (abs(ty - sy) + 1)
            + 'R' * (abs(tx - sx) + 1) + 'D')
    # (tx,ty)→(sx,sy)
    ans += ('R' + 'D' * (abs(ty - sy) + 1)
            + 'L' * (abs(tx - sx) + 1) + 'U')
    return ans

print(c_back_and_forth())

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;

#define db(x) cerr << #x << " == " << x << endl
#define all(container) container.begin(), container.end()
#define mp(i,j) make_pair(i,j)
#define pb push_back

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vii;
  
template<typename T>
void print_vector_debug(const T& t) {
	cout << "[DEBUG] VECTOR:";
	for (auto i = t.cbegin(); i != t.cend(); ++i) {
		if ((i + 1) != t.cend()) {
			cout << *i << " ";
		} else {
			cout << *i << endl;
		}
	}
}

#define MAXN 105
#define MAXK 100005

int N, K;
int vals[MAXN];
int dp[MAXK][2], vis[MAXK][2];

int solve(int r, int t)
{
	if (vis[r][t])
	{
		return dp[r][t];
	}
	vis[r][t] = 1;
	
	int res;
	if (t == 0)
	{
		res = 0;
		for (int i = 0; i < N; i++)
		{
			if (r - vals[i] >= 0)
			{
				res |= solve(r - vals[i], !(bool)t);
			}
		}
	}
	else
	{
		res = 1;
		for (int i = 0; i < N; i++)
		{
			if (r - vals[i] >= 0)
			{
				res &= solve(r - vals[i], !(bool)t);
			}
		}
	}
	
	dp[r][t] = res;
	return res;
}

int main() 
{
	scanf("%d%d", &N, &K);
	
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &vals[i]);
	}
	
	if (solve(K, 0) == 1)
	{
		printf("First\n");
	}
	else
	{
		printf("Second\n");
	}
	return 0;
}


Measured memory_bytes: 8064