akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#define nmax 200005
using namespace std;
int n, nod1, viz1[nmax], viz2[nmax], maxi1, maxi2, nod2;
vector <int> v[nmax];
void dfs1(int nod)
{
    for(auto it=v[nod].begin(); it!=v[nod].end(); ++it)
        if(!viz1[*it])
          {
              viz1[*(it)]=viz1[nod]+1;
              if(maxi1< (viz1[*(it)])) {nod1=*(it); maxi1=viz1[*(it)];}
              dfs1(*it);
          }
}
void dfs2(int nod)
{
    for(auto it=v[nod].begin(); it!=v[nod].end(); ++it)
        if(!viz2[*it])
          {
              viz2[*(it)]=viz2[nod]+1;
              if(maxi2< (viz2[*(it)])) {nod2=*(it); maxi2=viz2[*(it)];}
              dfs2(*it);
          }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int i, x, y;
    cin>>n;
    for(i=1; i<n; i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    maxi1=1;
    nod1=1;
    viz1[1]=1;
    dfs1(1);

    viz2[nod1]=1;
    maxi2=1;
    dfs2(nod1);

    if(maxi2%3==2) cout<<"Second\n";
    else cout<<"First\n";
    return 0;
}

Measured memory_bytes: 19072
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.append(X)
y.append(Y)
# print(x)
# print(y)
print("No War" if max(x)<min(y) else "War")
# if max(x) < min(y):
#     print('No war')
# else:
#     print('War')

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

#define rep(i,k,n) for(int i = k; i < n; i++)  
#define repp(i,a,n,k) for(typeof(a) i=a;i!=n;i+=k)

#define int long long
#define all(a) a.begin(),a.end()       

#define pb push_back
typedef long long ll; 
typedef pair<int, int> ii;
typedef pair<int,ii > iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<char> vchar;

#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)

#define ff first
#define ss second

#define lb lower_bound
#define ub upper_bound
#define me max_element

#define INF 1000000000
//#define mod 998244353
#define mod 1000000007
#define endl "\n"


  


int modPow(int a, int b);
int modInv(int a);     




void solve(){
    string s; cin >> s;
    int cnt = 0;
    int ans = 0;
    rep(i,0,s.length()){
        if(s[i]=='R')cnt++;
        else cnt =0;
        ans = max(ans, cnt);
    }
    cout << ans;

}


// Recheck if it is 2^9 or 10^9 
//check for long long overflow
//while adding and subs check if mod becomes -ve
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;




signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed;
    //cout <<setprecision(6);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
  //  int test=1; cin >> test; while(test--)
    solve();
}

int modPow(int a, int b){
    if(b==0)return 1;
    if(b%2==0){
        int x = a*a;
        x%=mod;
        return modPow(x,b/2);
    }
    return (a*modPow(a,b-1))%mod;
}


int modInv(int a){
    return modPow(a,mod-2);
}





Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=998244353;
const LL LINF=1LL<<62;

vector<LL> fact;
vector<LL> inver(300001);

LL combination(LL n,LL r){
    if(n<0||r<0||n<r) return 0;
    return fact[n]%mod*inver[n-r]%mod*inver[r]%mod;
}

LL fpow(LL a, LL n){
    int x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}

int main(){
    int N;
    LL A,B;
    cin >> N >> A >> B;
    if(A<B) swap(A,B);
    LL K;
    cin >> K;
    LL u,v;
    LL s=1;
    fact.push_back(1);
    for(int i=1;i<=300000;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[300000]=fpow(fact[300000],mod-2);
    for(int i=299999;i>=0;i--){
        inver[i]=inver[i+1]*(i+1)%mod;
    }
    LL ans=0;
    for(LL i=0;i<=N;i++){
        if(K-i*B<0) break;
        if((K-i*B)%A==0){
            u=(K-i*B)/A;
            v=i;
            ans=(ans+combination(N,u)*combination(N,v))%mod;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8816
#include<stdio.h>

int draw(int,int);

int main(){
	int i,j,H[100],W[100];
	
	for(i=0;;i++){
		scanf("%d %d",&H[i],&W[i]);
		if(H[i]==0 && W[i]==0) break;
	}
	for(i=0;;i++){
		if(H[i]==0 && W[i]==0) break;
		draw(H[i],W[i]);		
	}
	return 0;
}

int draw(int H,int W){
	int i,j;
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
}

Measured memory_bytes: 1816
import itertools
N, *A = map(int,input().split())
l = [int(input()) for i in range(N)]
li =  itertools.product(range(4), repeat=N)

ans = float("inf")
for i in li:
  cnt = [0]*3
  length = [0]*3
  for k in range(N):
    if i[k] == 3: 
      continue
    cnt[i[k]] += 1
    length[i[k]] += l[k]
  if min(cnt) > 0:
    cost = sum([abs(length[i]-A[i]) +10*cnt[i] for i in range(3)]) -30
    ans = min(ans, cost)
  
print(ans)

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

using namespace std;
using ll = long long;

int dp[101][4][4][4];

int mod = 1'000'000'007;

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

    // 長さ0の文字列は1である
    dp[0][3][3][3] = 1;

    for (int len = 0; len < N; len++) {
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                for (int k = 0; k < 4; k++) {
                    if (dp[len][i][j][k] == 0) {
                        continue;
                    }

                    for (int a = 0; a < 4; a++) {
                        if (a == 2 && i == 1 && j == 0) {
                            continue;
                        }
                        if (a == 2 && i == 0 && j == 1) {
                            continue;
                        }
                        if (a == 1 && i == 2 && j == 0) {
                            continue;
                        }
                        if (a == 2 && i == 1 && k == 0) {
                            continue;
                        }
                        if (a == 2 && j == 1 && k == 0) {
                            continue;
                        }

                        dp[len+1][a][i][j] += dp[len][i][j][k];
                        dp[len+1][a][i][j] %= mod;
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                ans += dp[N][i][j][k];
                ans %= mod;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <stdio.h>

#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    
    int ans = 0;
    for (int i = 0; i<n; i++ ) {
        for (int j = i+1; j<n; j++) {
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
    

}


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

bool ck(long long x,long long ps)
{
    return (bool)(x & (1LL<<ps));
}

int main()
{

        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,mod=1000000007;
        long long x=0,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;

        scanf("%lld",&n);

        qr[0]=1;

        for(i=1;i<=61;i++)
        {
            qr[i]=(qr[i-1]*2)%mod;
        }

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

            scanf("%lld",&a); v.push_back(a);

            for(j=0;j<=61;j++)
            {
                if(ck(a,j)==true)
                {
                    mp[j]++;
                }
                else
                {
                    nq[j]++;
                }

            }


        }


        for(i=0;i<n-1;i++)
        {

            a=v[i];

            for(j=0;j<=61;j++)
            {

               if(ck(a,j)==true)
               {
                   fr=qr[j];  g=nq[j]; sc=(fr*g)%mod; ans=(ans+sc)%mod;  mp[j]--;

               }
               else
               {
                   fr=qr[j];  g=mp[j];  sc=(fr*g)%mod; ans=(ans+sc)%mod;  nq[j]--;

               }



            }


        }



        printf("%lld\n",ans);





    return 0;
}





Measured memory_bytes: 7456
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string s;
  cin >> s;
  int ans = INF;
  auto allc = [](string t,char c) {
    for(char tc:t) {
      if(tc!=c) return false;
    }
    return true;
  };
  rep(i,26) {
    int c = i+'a';
    int cnt=0;
    string t(s);
    while(!allc(t,c)) {
      rep(i,sz(t)-1) {
        if(t[i+1]==c) {
          t[i]=c;
        }
      }
      t.pop_back();
      cnt++;
    }
    chmin(ans,cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from math import *
a, b, h, m = map(int, input().split())

m = m * 6
h = h * 5 * 6 + (30 * m / 360)

if h == m:
    print(abs(b - a))
    exit()

if abs(h - m) == 180:
# if abs(h - m) == 30:
    print(a + b)
    exit()

a1, a2 = 0, 0
x1, y1, x2, y2 = 0,0,0,0

# print('h, m:', h, m)

if h == 0:
    x1 = 0
    y1 = a
elif 0 < h < 90:
    a1 = tan(radians(90 - h))
    x1 = (a ** 2 / (1 + a1 ** 2)) ** 0.5
    y1 = a1 * x1
elif h == 90:
    x1 = a
    y1 = 0
elif 90 < h < 180:
    a1 = -tan(radians(h - 90))
    x1 = (a ** 2 / (1 + a1 ** 2)) ** 0.5
    y1 = a1 * x1
if h == 180:
    x1 = 0
    y1 = -a
if 180 < h < 270:
    a1 = tan(radians(270 - h))
    x1 = -((a ** 2 / (1 + a1 ** 2)) ** 0.5)
    y1 = a1 * x1
if h == 270:
    x1 = -a
    y1 = 0
if 270 < h < 360:
    a1 = -tan(radians(h - 270))
    x1 = -((a ** 2 / (1 + a1 ** 2)) ** 0.5)
    y1 = a1 * x1

# print('x1, y1:', x1, y1)

if m == 0:
    x2 = 0
    y2 = b
elif 0 < m < 90:
    a2 = tan(radians(90 - m))
    x2 = (b ** 2 / (1 + a2 ** 2)) ** 0.5
    y2 = a2 * x2
elif m == 90:
    x2 = b
    y2 = 0
elif 90 < m < 180:
    a2 = -tan(radians(m - 90))
    x2 = (b ** 2 / (1 + a2 ** 2)) ** 0.5
    y2 = a2 * x2
if m == 180:
    x2 = 0
    y2 = -b
if 180 < m < 270:
    # print('here')
    a2 = tan(radians(270 - m))
    x2 = -((b ** 2 / (1 + a2 ** 2)) ** 0.5)
    y2 = a2 * x2
if m == 270:
    x2 = -b
    y2 = 0
if 270 < m < 360:
    a2 = -tan(radians(m - 270))
    x2 = -((b ** 2 / (1 + a2 ** 2)) ** 0.5)
    y2 = a2 * x2

# print('a1, a2:', a1, a2)
# print('x1, y1:', x1, y1)
# print('x2, y2:', x2, y2)

print(((x1-x2)**2 + (y1-y2)**2)**0.5)

Measured memory_bytes: 9544
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int M=100005;
typedef long long LL;
template<class T>void Min(T &x,T y){
	if(x>y)x=y;
}
LL val[M],cnt[M];
int n,m,beg,x;
int main(){
	scanf("%d %d",&n,&m),n--;
	scanf("%d",&x);
	for(int i=1;i<=n;i++){
		scanf("%d",&beg);
		if(beg>x){
			val[1]+=beg-x,val[x+1]-=beg-x;
			if(beg<m)val[beg+1]+=beg-x;
			if(x+1<=beg)val[x+1]+=1+beg,val[beg+1]-=1+beg,cnt[x+1]++,cnt[beg+1]--;
		}else {
			val[beg+1]+=m-x+beg,val[x+1]-=m-x+beg;
			if(x<m)val[x+1]+=1+m+beg,cnt[x+1]++;
			val[1]+=1+beg,val[beg+1]-=1+beg,cnt[1]++,cnt[beg+1]--;
		}x=beg;
	}
	LL ans=val[1]-cnt[1]*1;
	for(int i=2;i<=m;i++)val[i]+=val[i-1],cnt[i]+=cnt[i-1],Min(ans,val[i]-i*cnt[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
   int a,b;
   cin>>a>>b;
   if((a<=9 && a>=1) && (b<=9 && b>=1)){
     cout<<(a*b)<<endl;
   }
  else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <cstring>
using namespace std;
 
char area[200][200];
 
typedef pair<int, int> P;
#define x first
#define y second
/* struct P{
    int x, y;
};*/
 
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
 
int main()
{
    int w, h, area_sum;
     
    while (scanf("%d%d", &h, &w), h + w){
         
        memset(area, 0, sizeof(area));
         
        area_sum = 0;
        for (int i = 1; i <= h; i++){
            for (int j = 1; j <= w; j++){
				scanf(" %c", &area[j][i]);
            }
        }
         
        for (int i = 1; i <= h; i++){
            for (int j = 1; j <= w; j++){
                if (area[j][i]){
					//printf("%d %d\n", j, i);
                    queue<P> que;
                    que.push(P(j, i));
                    while (que.size()){
                        P st = que.front();
                        que.pop();
                        if (area[st.x][st.y] == 0)continue;
                        for (int dir = 0; dir < 4; dir++){
                            if (area[st.x][st.y] == area[st.x + dx[dir]][st.y + dy[dir]]){
                                que.push(P(st.x + dx[dir], st.y + dy[dir]));
                            }
                        }
                        area[st.x][st.y] = 0;
                         
                    }
                    area_sum++;
                }
            }
        }
		
		for (int i = 1; i <= 3; i++){
			for (int j = 1; j <= 10; j++){
				//printf("%d ", area[j][i]);
			}
			//puts("");
		}
         
        printf("%d\n", area_sum);
    }
}

Measured memory_bytes: 1096
#include <stdio.h>

int l[1001][2];
int dp[20001];

int main() {
	
	int h, n, min = 987654321, i, j;
	
	scanf("%d %d", &h, &n);
	
	for (i = 1; i < 20001; i++)
		dp[i] = 987654321;
	
	for (i = 0; i < n; i++)
		scanf("%d %d", &l[i][0], &l[i][1]);

	for (i = 0; i <= h; i++)
	{
		for (j = 0; j < n; j++)
		{
			if (dp[i + l[j][0]] > dp[i] + l[j][1])
				dp[i + l[j][0]] = dp[i] + l[j][1];
		}
	}
	
	for (i = h; i < 20001; i++)
		if (dp[i] < min)
			min = dp[i];

	printf("%d", min);
	
	return 0;
}

Measured memory_bytes: 256
while True:
    student = int(input())
    if student == 0: exit()
    data=[int(item) for item in input().split()]
    tmp=0
    ave = sum(data)/len(data)
    for item in data:
        tmp += (item - ave) ** 2
    #二乗和の平均の平方根が標準偏差
    sigma=(tmp/len(data))**(0.5)
    print(sigma)


Measured memory_bytes: 5680
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAXN = 300;
const int MOD = 998244353;

inline int add(int x, int y) {x += y; return x >= MOD ? x - MOD : x;}
inline int sub(int x, int y) {x -= y; return x < 0 ? x + MOD : x;}
inline int mul(int x, int y) {return (int)(1LL * x * y % MOD);}

int pow_mod(int b, int p) {
	int ret = 1;
	for(int i=p;i;i>>=1,b=mul(b,b))
		if( i & 1 ) ret = mul(ret, b);
	return ret;
}

int a[MAXN + 5], s, m, K;
int dp[2][MAXN + 5][MAXN + 5];
int solve() {
	int t = 0; dp[0][0][0] = 1;
	for(int i=m;i>=1;i--) {
		for(int k=0;k<=t;k++)
			for(int j=0;j<=t;j++)
				dp[1][k][j] = dp[0][k][j], dp[0][k][j] = 0;
		
		for(int k=0;k<=t;k++) {
			dp[0][k][t] = dp[1][k][t];
			for(int j=t-1;j>=0;j--)
				dp[0][k][j] = add(dp[0][k][j + 1], dp[1][k][j]);
		}
		
		for(int k=0;k<=t;k++)
			for(int j=0;j<=t;j++)
				for(int l=1;l<=a[i];l++)
					dp[0][k+l][j+l] = add(dp[0][k+l][j+l], dp[1][k][j]);
		
		t += a[i];
	}
	
	int lim = min(K, s), ans = 0;
	for(int i=0;i<=lim;i++)
		ans = add(ans, dp[0][i][0]);
	return ans;
}

char S[MAXN + 5]; int n;
int main() {
	scanf("%s%d", S, &K), n = strlen(S);
	
	int cnt = 0;
	for(int i=0;i<n;i++) {
		if( S[i] == '0' )
			a[++m] = cnt, cnt = 0;
		else cnt++, s++;
	}
	a[++m] = cnt, printf("%d\n", solve());
}

Measured memory_bytes: 2388
#include <stdio.h>

int main(){
    int a,b,res1,res2,res3;
    
    scanf("%d %d",&a,&b);
    
    res1=a+b;
    res2=a-b;
    res3=a*b;
    
    if(res1>=res2 && res1>=res3){
        printf("%d\n",res1);
    }
    
    else if(res2>=res1 && res2>=res3){
        printf("%d\n",res2);
    }
    
    else if(res3>=res1 && res3>=res2){
        printf("%d\n",res3);
    }
    
    return 0;
}

Measured memory_bytes: 128
// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define in(x) 		scanf("%d", &x)
#define echo(x)		printf("%d", x)
#define inf 		(int)(1e18)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;

#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}

// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };


// Code from Here -------------------------------------------------------------------------------


signed main() {
	tezz

	
	int n;
	cin >> n;
	int ans=0;
	vi arr(n);
	for(int i=0; i<n; i++){
		cin >> arr[i];
		ans ^= arr[i];
	}
	for(int i=0; i<n; i++){
		cout << (ans^arr[i]) << " ";
	}

	return 0;
}  


Measured memory_bytes: 4764
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(O: str, E: str):
    ret = [None] * (len(O) + len(E))
    for i in range(len(O)):
        ret[i * 2] = O[i]
    for i in range(len(E)):
        ret[i * 2 + 1] = E[i]
    print(''.join(ret))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    O = next(tokens)  # type: str
    E = next(tokens)  # type: str
    solve(O, E)

if __name__ == '__main__':
    main()


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

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

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int> >;
using vii = vector<pair<int, int> >;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	int x, y, z, k; cin >> x >> y >> z >> k;
	vl a(x), b(y), c(z);

	rep(i, x) cin >> a[i];
	rep(i, y) cin >> b[i];
	rep(i, z) cin >> c[i];

	priority_queue<ll> ans;

	vector<ll> tmp;
	rep(i, x) {
		rep(j, y) {
			tmp.push_back(a[i] + b[j]);
		}
	}

	if (tmp.size() > k) {
		sort(DESC(tmp));
		tmp.resize(k);
	}

	rep(i, tmp.size()) {
		rep(j, z) {
			ans.push(tmp[i] + c[j]);
		}
	}

	rep(i, k) {
		ll hoge = ans.top(); ans.pop();
		cout << hoge << endl;
	}
}

Measured memory_bytes: 43240
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();

		int[][] A = new int[n][m];
		int[][] B = new int[m][l];
		long C;

		for(int i = 0;i < n;i++){
			for(int j = 0;j < m;j++){
				A[i][j] = scan.nextInt();
			}
		}
		for(int i = 0;i < m;i++){
			for(int j = 0;j < l;j++){
				B[i][j] = scan.nextInt();
			}
		}
		for(int i = 0;i < n;i++){
			for(int j = 0;j < l;j++){
				C = 0;
				for(int k = 0;k < m;k++){
					C += A[i][k]*B[k][j];
				}
				if(j != 0){
					System.out.print(" ");
				}
				System.out.print(C);
			}
			System.out.println("");
		}
	}

}

Measured memory_bytes: 55512
main :: IO ()
main = do
  s <- getLine :: IO String
  print . f $ s

f :: String -> Int
f "SUN" = 7
f "MON" = 6
f "TUE" = 5
f "WED" = 4
f "THU" = 3
f "FRI" = 2
f "SAT" = 1


Measured memory_bytes: 380
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nab = readln.split.to!(int[]);
    auto N = nab[0];
    auto A = nab[1];
    auto B = nab[2];
    auto vs = readln.split.to!(double[]);
    sort!"a > b"(vs);
    auto cs = new double[](N);
    cs[0] = vs[0];
    foreach (i; 1..N) cs[i] = cs[i-1] + vs[i];

    double l = 0, r = 10.0^^15+1;
    foreach (_i; 0..100) {
        auto m = (l+r)/2;
        if (cs[A-1] / A >= m) goto ok;
        r = m;
        continue;
        ok:
        l = m;
    }
    writefln("%.12f", l);

    auto pt = new long[][](N+1, N+1);
    pt[0][0] = 1;
    foreach (i; 1..N+1) {
        pt[i][0] = 1;
        pt[i][i] = 1;
        foreach (j; 1..i) {
            pt[i][j] = pt[i-1][j-1] + pt[i-1][j];
        }
    }

    if (vs[0] == vs[A-1]) {
        long n;
        foreach (v; vs) if (v == vs[0]) ++n;
        long s;
        foreach (k; A..min(B, n)+1) s += pt[n][k];
        writeln(s);
    } else {
        long k, n;
        foreach (i, v; vs) if (v == vs[A-1]) {
            ++n;
            if (i < A) ++k;
        }
        writeln(pt[n][k]);
    }
}

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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
	s64 a,b;
	cin >> a >> b;
	
	cout << (abs(a-b) <= 1 ? "Brown" : "Alice") << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define ef(i,u) for(int i=b[u];i;i=nxt[i])
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,b,a) for(int i=b;i>=a;--i)
#define gcd(a,b) __gcd(a,b)
#define MEM(a,x) memset(a,x,sizeof(a))
#define VI vector<int>
#define PII pair<int,int>
#define ull unsigned long long
#define ll long long
#define fi first
#define se second
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int n,m,a[N];
int main(){
    cin>>n>>m;
    int x;
    rep(i,1,m){
        read(x);
        n-=x;
    }
    if(n<0)puts("-1");
    else cout<<n<<'\n';
	return 0;
}


Measured memory_bytes: 3644
//Ridge
#include <iostream>

using namespace std;

static const int drow[4] = {1, 0, -1, 0};
static const int dcol[4] = {0, 1, 0, -1};
static const int NIL = -1;
static const int RIDGE = -2;

struct Area {
    int h, type;
    Area() {}
    Area(int h, int type): h(h), type(type) {}
};


int main() {
    int H, W, h;
    cin >> H >> W;
    Area A[H][W];
    int order[H * W];
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> h;
            A[i][j] = Area(h, i * W + j);
            order[A[i][j].h - 1] = i * W + j;
        }
    }

    for(int k = 0; k < H * W; k++) {
        int i = order[k] / W;
        int j = order[k] % W;
        int cnt = 0;
        int type = NIL;
        for(int l = 0; l < 4; l++) {
            int si = i + drow[l];
            int sj = j + dcol[l];
            if(si >= 0 && sj >= 0 && si < H && sj < W) {
                if(A[i][j].h > A[si][sj].h) {
                    if(A[si][sj].type == RIDGE) {
                        type = RIDGE;
                        break;
                    } else if(type != NIL && type != A[si][sj].type) {
                        type = RIDGE;
                        break;
                    } else {
                        type = A[si][sj].type;
                    }
                }
            }
        }
        if(type != NIL) A[i][j].type = type;
    }

    int cnt = 0;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(A[i][j].type == RIDGE) cnt++;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 14796
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,Y;
  cin>>N>>Y;
  for(int i=0;i<=N;i++)
    for(int j=0;i+j<=N;j++)
      if(i*1000+j*5000+(N-i-j)*10000==Y){
        cout<<N-i-j<<' '<<j<<' '<<i<<endl;
        return 0;
      }
  puts("-1 -1 -1");
}

Measured memory_bytes: 3612
N = int(input())
L = list(map(int,input().split()))
Gu = []
Ki = []
x = 0
for i in L:
    if i % 2 == 0:
        Gu.append(i)
for i in Gu:
    if i % 3 == 0 or i % 5 == 0:
        x += 0
    else:
        x += 1
if x > 0:
    print('DENIED')
if x == 0:
    print('APPROVED')

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

using namespace std;

int n;

#define intt long long

int main() {

	cin >> n;
	vector <int> a(n + 1);
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	intt ans = 0;
	for (int i = 2; i <= n; i ++) {
		ans += max(0, a[i - 1] - a[i]);
		a[i] += max(0, a[i - 1] - a[i]);
	}
	cout << ans << '\n';
	return 0;
}

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n, m; cin >> n >> m;
    vector<string> alis(n), blis(m);
    REP(i, 0, n){cin >> alis[i];}
    REP(i, 0, m){cin >> blis[i];}
    int ans = 0;
    REP(i, 0, n-m+1){
        REP(l, 0, n-m+1){
            int f = 1;
            REP(j, 0, m){
                REP(k, 0, m){
                    if(alis[j+i][k+l] != blis[j][k]){
                        f = 0;
                    }
                }
            }
            ans += f;
        }
    }
    if(ans > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>
#include <string>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;

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

const int MAX_N = 30;
const int MAX_M = 30;

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

    int cnt[M];

    rep(i, M) cnt[i] = 0;
    
    rep(i, N){
        int k;
        cin >> k;
        rep(j, k){
            int pref;
            cin >> pref;
            cnt[pref - 1] ++;
        }
    }
    
    int answer = 0;
    rep(i, M) if (cnt[i] == N) answer ++;

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace ConsoleApp
{
    class Program
    {

        static void Main(string[] args)
        {
            var a = new int[3, 3];
            var exi = new bool[3, 3];
            for (int i = 0; i < 3;i++)
            {
                var ar = ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < 3;j++)
                {
                    a[i, j] = ar[j];
                }
            }

            var n = int.Parse(ReadLine());
            var b = new int[n];
            for (int i = 0; i < n;i++)
                b[i] = int.Parse(ReadLine());

            for (int i = 0; i < n;i++)
            {
                for (int x = 0; x < 3;x++)
                    for (int y = 0; y < 3;y++)
                    {
                        if (b[i] == a[x, y])
                        {
                            exi[x, y] = true;
                            break;
                        }
                    }

            }

            //judge
            for (int i = 0; i < 3; i++)
            {
                if (exi[i, 0] && exi[i, 1] && exi[i, 2]) { WriteLine("Yes"); return; }
                if (exi[0,i] && exi[1,i] && exi[2,i]){WriteLine("Yes"); return; }

            }
            if(exi[0,0] && exi[1,1] && exi[2,2] ){ WriteLine("Yes"); return; }
            if (exi[0, 2] && exi[1, 1] && exi[2, 0]) { WriteLine("Yes"); return; }

            WriteLine("No");
        }   
        
       

    }

}


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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    ll n;
    cin >> n;
    n--;
    string ans = "";
    while (1) {
        ans = (char)('a' + (n % 26LL)) + ans;
        if (n < 26)
            break;
        n /= 26LL;
        n--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7;

void solve(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<ll> dp(n);
    for(int i = n - 1; i >= 0; i--){
        if(i == n - 1)
            dp[i] = a[i];
        else
            dp[i] = dp[i + 1] + a[i];
      		dp[i] %= MOD;
    }
    ll res = 0;
    for(int i = 0; i < n - 1; i++){
        ll temp = (a[i] * dp[i + 1]) % MOD;
        res = (res + temp) % MOD;
    }
    cout << res << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6364
#include<iostream>
int n, a[200021], b[200021]; long long f;
signed main() {
	scanf("%d", &n);
	for(int i = 1; i <= (n);i++) {
		scanf("%d", &a[i]);
		f += b[a[i]]++;
	}
	for(int i = 1; i <= (n);i++) printf("%lld\n", f - b[a[i]] + 1);
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
#define allr(vec) vec.rbegin(),vec.rend()
using namespace std;

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; }

using ll=int64_t;

using vb=vector<bool>;
using vc=vector<char>;
using vs=vector<string>;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

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

  int N,M; cin >>N >>M;
  vll a(N),b(N);
  rep(i,0,N) {
    ll x,y; cin >>x >>y;
    a[i]=x;
    b[i]=y;
  }
  vll c(M),d(M);
  rep(i,0,M) {
    ll x,y; cin >>x >>y;
    c[i]=x;
    d[i]=y;
  }

  rep(i,0,N) {
    ll check=LLONG_MAX;
    int ans=0;
    rep(j,0,M) {
      ll temp=abs(a[i]-c[j])+abs(b[i]-d[j]);
      if (temp<check) {
        chmin(check,temp);
        ans=j+1;
      }
    }
    cout <<ans <<'\n';
  }

  return 0;
}


Measured memory_bytes: 3572
N, A, B = list(map(int, input().split()))
S = str(input())
c = 0
b = 0
for s in S:
    if s == 'a' and c < (A+B):
        print('Yes')
        c += 1
    elif s == 'b' and c < (A+B) and b < B:
        print('Yes')
        c += 1
        b += 1
    else:
        print('No')


Measured memory_bytes: 4016
r, c = map(int, input().split())
li = []
last_r =[0 for _ in range(c + 1)]
for i in range(r):
    li.append([int(x) for x in input().split()])
    li[i].append(sum(li[i]))
    for j in range(c+1):
        last_r[j] +=li[i][j]
li.append(last_r)
for i in li:
    print(*i)

Measured memory_bytes: 8236
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll l,r,d; cin >> l >> r >> d;
  
  cout << r/d - (l-1)/d << endl;
  
  
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC089_A();
        }

        static void ABC089_A()
        {
            Console.WriteLine((int)(int.Parse(Console.ReadLine()) / 3));
        }
    }
}

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

int main()
{
    long long h,n;
    cin>>h>>n;
    
    long long s=0LL;
    for(long long i=0;i<n;i++){
        long long x;
        cin>>x;
        s+=x;
    }
    
    if(s>=h) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
    
    //cout<<ceil((double)h/n)<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

    string s;
    cin >> s;
    REP(i, s.length()) {
      if (s[i] == '9') {
        cout << '1';
      }
      else {
        cout << '9';
      }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int i,j,k,n,m,l,count1=0;
void ABC130(void);
void ABC131(void);
void ABC132(void);
void ABC133(void);
void ABC134(void);
void ABC135(void);
void ABC136(void);
void ABC137(void);
void ABC138(void);
void ABC139(void);

int main(void){
    ABC138();
}

void ABC138(){
    double sum=0;
    cin>>n;
    vector<double> vec(n);
    for(i=0;i<n;i++){
        cin>>vec[i];
        sum+=1/vec[i];
    }
    printf("%lf\n",1/sum);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int const INF = 1e9;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int H, N; std::cin >> H >> N;
  std::vector<int> A(N), B(N);
  std::vector<int> dp(H+1, INF);
  dp[0] = 0;
  for(int i = 0; i < N; ++i) {
    int A, B; std::cin >> A >> B;
    // use (A, B)
    for(int j = A; j <= H; ++j) dp[j] = std::min(dp[j], dp[j-A]+B);
    // over kill
    for(int j = A-1; j > 0; --j) dp[H] = std::min(dp[H], dp[H-j]+B);
  }
  fin(dp[H]);
  return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

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

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;
#define MAX_N 1000000
const ll P = 1000000007;
ll dp[MAX_N];

void init(){
	rep(i,MAX_N){
		dp[i] = -1;
	}
	dp[0] = 1;
	dp[1] = 1;
}

ll fuctorial(ll num){
	if(num == 0) return 1;
	if(num == 1) return 1;
	if( dp[num] != -1) return dp[num];
	dp[num] = (fuctorial(num-1)*num)%P;
	return dp[num];
}

int main()
{
	init();
	ll n;
	cin>>n;
	cout<<fuctorial(n)<<endl;
	return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace  std ;
using db  = double;
using ll  = long long;
using ull = unsigned long long; 
using pII = pair <int, int>;
using pLL = pair <ll, ll>;
#define s(x) ((int)(x).size())
#define deb(x) cout << x << endl
#define deb1(x) cout << #x <<" "<< x << endl
#define deb2(x,y) cout << #x <<" "<< x <<" "<< #y <<" "<< y << endl
int main()
{
	string s;
     cin >> s;
     string s1="es",s2="s";
     if(s[s(s)-1]=='s') deb(s+s1);
     else deb(s+s2);

				
}		




Measured memory_bytes: 3584
from functools import lru_cache
n=int(input())
k=int(input())
@lru_cache(None)
def cal(n,k):
  if n<10:
    if k==0: return 1
    if k==1: return n
    return 0
  q,r=divmod(n,10)
  ret=0
  if k>=1:
    ret+=cal(q,k-1)*r
    ret+=cal(q-1,k-1)*(9-r)
  ret+=cal(q,k)
  return ret

print(cal(n,k))

Measured memory_bytes: 3940
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int i=1;
		while(true){
        	String x=br.readLine();
        	if(x.equals("0")) break;
        	sb.append("Case "+i+": "+x+"\n");
        	if(i%50==0){
        		System.out.print(sb.toString());
        		sb.setLength(0);
        	}
    		i++;
        }
		System.out.print(sb.toString());
	}
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    string s;
    int K;
    cin >> s >> K;

    set<string> set_s;

    for(int ik = 0; ik < K; ik++){
      for(int i = 0; i < s.length()-ik; i++){
        set_s.insert(s.substr(i, ik+1));
      }
    }
    auto itr = set_s.begin(); 
    for(int i = 0; i < K-1; i++){
      itr++;
    }

    cout << *itr << endl;

    return 0;
}


Measured memory_bytes: 1664
S = input()
T = input()
ev = []
for i in range(len(S) - len(T) + 1):
  commit = 0
  for j in range(len(T)):
    if S[i + j] == T[j]:
      commit += 1
  ev.append(commit)

ev.sort(reverse=True)
print(len(T) - ev[0])

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

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

    if(a != b){
        cout << 2 * max(a,b) - 1 << endl;
    }
    if(a == b){
        cout << 2 * max(a,b) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
h,w,k1=map(int,input().split())
c=[]
ans=0
for i in range(h):
    c.append(list(input()))
for i in range(2**(h+w)):
    lh=[]
    lw=[]
    num=0
    for j in range(h):
        if (i >> j) & 1:
            lh.append(j)
    for j in range(h,h+w):
        if (i >> j) & 1:
            lw.append(j-h)
    for j in range(len(lh)):
        for kk in range(len(lw)):
            if c[lh[j]][lw[kk]]=="#":
                num+=1
    if num==k1:
        ans+=1
print(ans)


Measured memory_bytes: 9164
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a; i <= b; ++i)
#define PER(i, a, b) for (int i = a; i >= b; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;

const int N = 300005;
int n, m, va[N], vb[N];

int main(){
	cin >> n >> m;
	REP(i, 1, m){
		int u, v;
		cin >> u >> v;
		if (u > v) swap(u, v);
		if (u == 1) va[v] = 1;
		if (v == n) vb[u] = 1;
	}
	REP(i, 1, n) if (va[i] && vb[i])
		return puts("POSSIBLE"), 0;
	puts("IMPOSSIBLE");
	return 0;
}

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

typedef long long ll;

using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    //  --------------------------------------
    
    string S; cin >> S;
    int zero_counter = 0;
    int one_counter = 0;
    
    for (int i = 0; i < S.size(); i++) {
//        cout << S[i] << "\n";
        if (S[i] == '0') {
            zero_counter += 1;
        }else{
            one_counter += 1;
        }
    }
//    cout << zero_counter << " " << one_counter << "\n";
    cout << min(zero_counter, one_counter)*2 << "\n";
    
}



Measured memory_bytes: 512