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

#define int long long
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);

int parent[200005];
int rnk[200005];
int n;

int find(int x){
	while(x!=parent[x]){
		x = parent[x];
	}
	return x;
}

void merge(int x, int y){
	int a = find(x);
	int b = find(y);
	if(a==b)
	return;
	if(rnk[a]<rnk[b]){
		swap(a,b);
	}
	parent[b] = a;
	rnk[a]+=rnk[b];
	rnk[b]=0;
}

main(){
	FIO
	int t;
	t=1;
	while(t--){
		int m;
		cin>>n>>m;
		for(int i=1;i<=n;i++){
			parent[i] = i;
			rnk[i] = 1;
		}
		int i,j,k;
		for(i=0;i<m;i++){
			cin>>j>>k;
			merge(j,k);
		}
		k=0;
		for(i=1;i<=n;i++){
			k = max(k,rnk[i]);
		}
		cout<<k<<endl;
	}
}

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

int main() {
  int k;cin>>k;
  int ans=0;
  for(int a=1;a<=k;a++){
    for(int b=1;b<=k;b++){
      for(int c=1;c<=k;c++){
        ans+=gcd(gcd(a,b),c);
      }
    }
  }
  cout<<ans<<endl;
}

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

int main (void) {
    int n;
    scanf("%d", &n);

    if ( n == 1 )
        printf("Hello World\n");
    else {
        int a, b;
        scanf("%d%d", &a, &b);
        printf("%d\n", a+b);
    }
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define pr(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 200010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

int main() {
    ll N, x;
    cin >> N >> x;
    ll a[MAX];
    ll i;
    
    for(i=1; i<2*N; i++) {
        a[i]=i;
    }
    
    if(x==1 || x==2*N-1) {
        puts("No");
    }else {
        puts("Yes");
        swap(a[x], a[N]);
        swap(a[1], a[N-1]);
        swap(a[2*N-1], a[N+1]);
        for(i=1; i<2*N; i++)
            pr(a[i]);
    }
    
    
    
}


Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int h,w;
  while(1){
    cin>>h>>w;
    if(h==0)break;
    rep(i,h){
      rep(j,w)
	if((i+j)%2)cout<<".";
	else cout<<"#";
      cout<<endl;
    }
    cout<<endl;
  }
}



Measured memory_bytes: 3084
N,A,B = map(int,input().split())

number_turn = N //(A + B)
nokori = N % (A + B)

if nokori <= A: #nokoriが全てAの場合
	print((number_turn * A) + nokori)
else: #nokoriがAとBの両方の場合
	print((number_turn * A) + A)


Measured memory_bytes: 9184
#include <stdio.h>
#include <string.h>
int judge(const char t[], const char h[]){
        int i;
        for(i = 0; i < strlen(t) || i < strlen(h); i++){
                if(t[i] == h[i])
                        continue;
                else if(t[i] > h[i])
                        return 1;
                else
                        return -1;
        }
                return 0;
}
int main(void){
        int i,n;
        int tp = 0, hp = 0;
        char t[101],h[101];
        scanf("%d",&n);
        for(i=0;i<n;i++){
                scanf("%s %s",t,h);
                if(judge(t,h) == 0){
                        tp++;
                        hp++;
                }else if(judge(t,h) == 1)
                        tp += 3;
                else
                        hp += 3;
        }
        printf("%d %d\n",tp,hp);
        return 0;
}


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

int main(){
    int r,g,b;
    cin>>r>>g>>b;
    int sum;
    sum=r*100+g*10+b;
    if(sum%4==0){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int cnt[2][100000], M[2], Q[2], m[2], q[2];
int n;
int main() {
	cin>>n;
	for (int i = 1, x, p; i <= n; i++) {
		cin>>x; p = i % 2;
		cnt[p][x]++;
		if (M[p] < cnt[p][x]) M[p] = cnt[p][x], Q[p] = x;
	}
	if (Q[0] != Q[1]) {
		cout<<n - M[0] - M[1];
		return 0;
	}
	for (int i = 1; i <= 100000; i++) {
		if (m[0] < cnt[0][i] && i != Q[0]) m[0] = cnt[0][i], q[0] = i;
		if (m[1] < cnt[1][i] && i != Q[1]) m[1] = cnt[1][i], q[1] = i;
	}
	if (M[0] - m[0] > M[1] - m[1]) cout<< n - M[0] - m[1];
	else cout<<n - m[0] - M[1];
	return 0;
}

Measured memory_bytes: 4364
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
bool _predicate(int a,const int& element) {
	return (element == a); // This will cause all elements to be deleted that are larger than 3
}
int main() {
	int n,m;
	cin >> n >> m;
	//vector<P> path(m);
	vector<vector<int>> path(n, vector<int>());
	int a, b;
	
	rep(i, m) {
		//cin >> path[i].first >> path[i].second;
		cin >> a >> b;
		a--;
		b--;
		path[a].push_back(b);
		path[b].push_back(a);
		//cout << a << b << endl;
	}
	/*rep(i, n) {
		cout << i << " ;" << endl;
		for (int j : path[i]) {
			cout << j << " ";
		}
		cout << endl;
	}*/
	a = 0;
	//vector<bool> hasgone(m, false);
	vector<P> hasgone(n, make_pair(-1, INT_MAX));
	hasgone[0] = make_pair(-1, 0);
	priority_queue<P, vector<P>, greater<P>>  que;
	que.push(P(0, 0));
	
	while (!que.empty()) {
		P p = que.top();
		que.pop();
		a = p.second;
		//cout << a << endl;
		if (hasgone[a].second < p.first)continue;
		for (int i : path[a]) {
			//if (hasgone[i].first == -1)visited.push_back(i);
			if (hasgone[i].second > hasgone[a].second + 1) {

				//cout <<i<<" "<<a<<" "<< hasgone[i].second <<" "<< hasgone[a].second + 1 << endl;
				hasgone[i] = make_pair(a, hasgone[a].second + 1);
				que.push(P(hasgone[i].second, i));

			}
		}
		
	}
	cout << "Yes" << endl;
	for (int i = 1; i < n; i++) {
		cout << hasgone[i].first+1 << endl;
	}
}


Measured memory_bytes: 10772
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    int a,b,c,d,e,n;
   cin >> n;
   while(n--)
   {
             cin >> a >> b >> c;
             if(c > b && c > a )
             {
               d= (a*a) + (b * b);
               e = (c*c);
             }
             else if( b > c && b > a )
             {
                  d = (a * a) + (c *c);
                  e = (b*b);
                  
             }
             else if(a > c && a > b)
             {
                  d = (b* b) + (c*c);
                  e = (a*a);
             }
             else{
                   d= (a*a) + (b * b);
               e = (c*c);
                  
                  }
             
             if( d == e)
             {
                 cout << "YES\n" ;
                 
             }
             else 
             {
                  cout << "NO\n";
             }
   }
    return 0;
}

Measured memory_bytes: 1120
N = int(input())
A = list(map(int, input().split()))

MOD = 10 ** 9 + 7

def gcd(x, y):
  while y: x, y = y, x % y
  return x

def lcm(x, y):
  return x * y // gcd(x, y)

tmp = A[0]
for i in range(1, N):
  tmp = lcm(A[i], tmp)
tmp %= MOD

answer = 0
for a in A:
  answer += tmp * pow(a, MOD - 2, MOD)
  
print(answer % MOD)


Measured memory_bytes: 41692
#include <iostream>

using namespace std;

long calc_next(long x, long r, long D){
    return r*x-D;
}

int main(void){
    // Your code here!
    long long r,D,x;
    std::cin >> r >> D >> x;
    
    for(int i=0; i<10; ++i){
        x = calc_next(x, r, D);
        std::cout << x << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int N, Q;
int A[100000], B[100000], C[100000];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++)
    cin >> A[i];
  cin >> Q;
  for (int i = 0; i < Q; i++)
    cin >> B[i] >> C[i];

  long long int sum = 0;
  unordered_map<int, int> map;
  for (int i = 0; i < N; i++) {
    sum += A[i];
    if (map.find(A[i]) != map.cend())
      map[A[i]]++;
    else
      map[A[i]] = 1;
  }

  for (int i = 0; i < Q; i++) {
    if (map.find(B[i]) != map.cend()) {
      sum += (C[i] - B[i]) * map[B[i]];
      if (map.find(C[i]) != map.cend()) {
        map[C[i]] += map[B[i]];
      } else {
        map[C[i]] = map[B[i]];
      }
      map[B[i]] = 0;
    }
    cout << sum << endl;
  }

  return 0;
}

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

long long g(long long x){
    return x*(x+1)/2;
}

int main(){
    long long n;
    cin >> n;
    long long ans=0;
    for(long long i=1;i<=n;i++){
        ans+=i*g(n/i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iterator>
#include<set>
#include<sstream>
#define rep(i,n) for(i=0;i<n;i++);
#define endl "\n"
#define ll long long
#define N 200050
using namespace std;

int main()
{
   int d,i,m,p=0,q=0,r=0,l;
 int n,x,a,b,c;
    int j;



    cin>>a>>b;
    vector<int> v2(b,a),v1(a,b);
    if(v2[0]>v1[0])
        for(auto &k :v1)
            cout<<k;
    if(v2[0]<v1[0])
                for(auto &k:v2)
                    cout<<k;
    if(a==b)
        for(i=0;i<a;i++)
            cout<<a;



}

Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AthleteProgramming2
{
    
    class Program
    {
        static void Main()
        {
            string str;
            while ((str = Console.ReadLine()) != null)
            {
                int area = 0;
                int d = int.Parse(str);
                for(int i = d; i < 600; i += d)
                {
                    area += d * (i * i);
                }
                Console.WriteLine(area);
            }
        }

        

    }
}

Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main(){
	int a, b, c;
  	string op;
    c = 1;
  	while(c){
      cin >> a >> op >> b;
      if (op == "?") c = 0;
      else{
        if ( op == "+" ){
        	cout << a + b << endl;
        }
        else if ( op == "-" ){
        	cout << a - b << endl;
        } 
        else if ( op == "*" ){
        	cout << a * b << endl;
        } 
        else if ( op == "/" ){
        	cout << a / b << endl;
        } 
      }
    }
    return 0;
}


Measured memory_bytes: 3148
import math
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
m = len(set(a))
nans = 0
tbl = list(Counter(a).values())
tbl2 = Counter(a)
for i in range(m):
    if tbl[i] >= 2:
        nans += math.factorial(tbl[i])//(math.factorial(tbl[i]-2)*math.factorial(2))
for i in range(n):
    num = a[i]
    numcnt = tbl2[num]
    print(nans-(numcnt-1))

Measured memory_bytes: 27152
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    int a,b,c;
    cin>>a>>b>>c;

    cout<<c<<' '<<a<<' '<<b<<endl;


}

Measured memory_bytes: 256
import sys
k, n = map(int, sys.stdin.readline().split())
an = list(map(int, sys.stdin.readline().split()))

dai = an[0]+k-an[-1]

for i in range(1, n):
    if an[i]-an[i-1]>dai:
        dai = an[i]-an[i-1]

print(k-dai)

Measured memory_bytes: 31512
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a[]=new int [3];
		a[0]=scan.nextInt();
		a[1]=scan.nextInt();
		a[2]=scan.nextInt();
		int b=scan.nextInt();
		for(int i=0;i!=b;i++) {
			Arrays.sort(a);
			a[2]*=2;
		}
		int ans=0;
		for(int i=0;i!=3;i++) {
			ans+=a[i];
		}
		System.out.println(ans);
	}
	}


Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>

using namespace std;
using ll = long long int;
int main(){

int N;
cin >> N;

vector<string> s;
for(int i=0;i<N;i++){
    string t;cin >> t;
    for(int j=0;j<i;j++){
        if(t==s[j]){cout << "No";return 0;}
    }
    if(i!=0){
        if(t[0]!=(*(s[i-1].end()-1))){
            cout << "No";return 0;
        }
    }
    s.push_back(t);
}

cout << "Yes";
return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		for(; sc.hasNext();){
			Scanner c=new Scanner(sc.nextLine());
			LinkedList<Double> stack=new LinkedList<Double>();
			for(; c.hasNext();){
				String s=c.next();
				if(Character.isDigit(s.charAt(0))||s.length()>1){
					stack.addFirst(Double.parseDouble(s));
				}else{
					double d2=stack.removeFirst();
					double d1=stack.removeFirst();
					double d=0;
					// double d1=0,d2=0,d=0;
					switch(s.charAt(0)){
					case '+':
						d=d1+d2;
						break;
					case '-':
						d=d1-d2;
						break;
					case '*':
						d=d1*d2;
						break;
					case '/':
						d=d1/d2;
						break;
					}
					stack.addFirst(d);
				}
			}
			println(stack.removeFirst()+"");
		}
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <algorithm>
#include <cstring>

typedef long long ll;

int n;
int a[20005], b[20005];

int main() {
	scanf("%d", &n);
	for (int p, i = 1; i <= n; ++i) {
		scanf("%d", &p);
		
		a[p] = p * n - n + i;
		b[p] = (n - p + 1) * n - n + i;
	}
	
	for (int i = 1; i <= n; ++i) printf(i == n ? "%d\n" : "%d ", a[i]);
	for (int i = 1; i <= n; ++i) printf(i == n ? "%d\n" : "%d ", b[i]);
	
	return 0;
}


Measured memory_bytes: 640
#include <cstdio>
int main(){
  int N,cnt=0;
  char S[51];
  scanf("%d %s",&N,S);
  for(int i=0;i+2<N;i++){
    if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C')cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 128
n = int(input())
b = [int(i) for i in input().split()]
a = list()

while len(b) > 0 and n-1 >= 0:
    if b[n-1] == n:
        b.pop(n-1)
        a.insert(0, n)
        n = len(b)
        continue
    n -= 1

if len(b) == 0:
    [print(i) for i in a]
else:
    print(-1)



Measured memory_bytes: 3060
A, B, K = gets.split.map(&:to_i)

w1 = []
1.upto(A) { |i| w1 << i if A % i == 0 }

w2 = []
1.upto(B) { |i| w2 << i if B % i == 0 }

puts (w1 & w2)[-K]


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int d,g; cin>>d>>g;
  	vector<int> p(d);
  	vector<int> c(d);
  	for(int i=0;i<d;i++) cin>>p[i]>>c[i];
  	int getscore=0,ans=1001,temp=0,plus=0,no=-1;
  	
  	for(int i=0;i<(1<<d);i++){
    	getscore=0;
      	temp=0;
      	no=-1;
      	for(int j=0;j<d;j++){
        	if(i&(1<<j)){
            	getscore+=(j+1)*100*p[j]+c[j];
              	temp+=p[j];
            }else{
            	no=j;
            }
        }
   
      	if(getscore<g){
          	if(no==-1)continue;
         	//追加したら超えるのか？無理なのか？
          	plus=((g-getscore+(no+1)*100-1)/((no+1)*100));
          	if(plus>p[no]) continue;
          	else temp+=plus;
        }
      	ans=min(ans,temp);    
    }
  	cout<<ans<<endl;  	
}


Measured memory_bytes: 256
import sys, math
#import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
#from bisect import bisect_left as bl, bisect_right as br, insort
#from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.buffer.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
#sys.setrecursionlimit(100000)
INF = float('inf')
mod = 998244353
#from decimal import Decimal

l=mdata()
for i in range(5):
    if l[i]==0:
        out(i+1)
        exit()




Measured memory_bytes: 65080
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define REEP(i, N) for(ll i = N - 1; i >= 0; --i)
#define FOR(i,m,n) for(ll i = m; i < n; ++i)
#define RFOR(i,m,n) for(ll i = n - 1; i >= m; --i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define PB push_back
#define KIRIAGE(a, b) a += (b - a % b) % b // a ??? b ????????°????????§?¢???????
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;} // a / b ??\??????????°???´??°
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
int main(void) {
    while(true) {
        int n, r;
        cin>>n>>r;
        vector<ll> card(n);
        REP(i, n) {
            card[i] = n - i;
        }
        if(n==0&&r==0) return 0;
        REP(i, r) {
            int p, c;
            cin>>p>>c;
            vector<ll> hoge(p - 1);
            REP(i, p - 1) hoge[i] = card[i];
            REP(i, c) card[i] = card[p - 1 + i];
            REP(i, p - 1) card[c + i] = hoge[i];
        }
        cout<<card[0]<<endl;
    }
}


Measured memory_bytes: 3100
N = int(input())
A = list(map(int, input().split()))
 
def gcd(a,b):
  if b==0:
    return a
  else:
  	return gcd(b, a%b)

L=[]
R=[]
L.append(0)
R.append(0)

for i in range(N):
  L.append(gcd(L[i],A[i]))
  R.append(gcd(R[i],A[N-i-1]))

R.reverse()

Res=[]
for i in range(N):
  Res.append(gcd(L[i],R[i+1]))
print(max(Res))

Measured memory_bytes: 14076
N = int(input())
s = [input() for i in range(N)]


ba = 0
a = 0
b = 0
ans = 0
#ただsをつなげていく(元々入ってたABを数えるため)
simples = ''
#前の最後がaだったか
a_flag = False
#最後に引く
bias = 0
for i in range(N):
    simples += s[i]
    if s[i][-1]=="A" and s[i][0]=="B":
        if a_flag:
            bias += 1
        a_flag = True
        ba += 1
    elif s[i][-1]=="A":
        a_flag = True
        a += 1
    elif s[i][0]=="B":
        if a_flag:
            bias += 1
            a_flag = False
        b += 1
    else:
        a_flag = False
        continue

ans += simples.count("AB") - bias
if a>0 or b > 0:
    ans += ba
    ans += min(a,b)

if a==0 and b == 0:
    if ba > 1:
        ans += ba-1

print(ans)


    


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

typedef long long ll;
const int maxn = 2e5 + 5;
char a[maxn];
int sum[maxn];

int main()
{
	while (scanf("%s", a) == 1)
	{
		memset(sum, 0, sizeof sum);
		int n = strlen(a);
		ll ans = (ll)n * (n + 1) / 2 + 1;
		for (int i = 0; i < n; i++)
		{
			sum[a[i] - 'a']++;
			ans -= sum[a[i] - 'a'];
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1280
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{//try{
	auto tokens = split(my_readln());
	auto N = to!ulong(tokens[0]);

	long[] h;
	foreach (token; split(my_readln()))
	{
		h ~= to!long(token);
	}

	ulong[] costs;
	costs.length = N;
	fill(costs, ulong.max);
	costs[0] = 0;
	foreach (i; 0..N-2)
	{
		costs[i+1] = min(costs[i+1], costs[i] + abs(h[i] - h[i+1]));
		costs[i+2] = min(costs[i+2], costs[i] + abs(h[i] - h[i+2]));
	}
	costs[N-1] = min(costs[N-1], costs[N-2] + abs(h[N-2] - h[N-1]));

	writeln(costs[N-1]);
	stdout.flush();
	/*}catch (Throwable e)
	{
	writeln(e.toString());
	}
	readln();*/
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define INF 1e9
struct Edge{int a,b,c;};

int main(void){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> g(n);
    int d[n][n];
    rep(i,n)rep(j,n) d[i][j] = INF;
    rep(i,n) d[i][i] = 0;

    vector<Edge> ve;
    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        d[a][b] = d[b][a] = c;
        ve.push_back({a,b,c});
    }
    rep(k,n)rep(i,n)rep(j,n){
        if( d[i][j] > d[i][k] + d[k][j]){
            d[i][j] = d[i][k] + d[k][j];
        }
    }
    int cnt = 0;
    for(auto e : ve){
        bool use = false;
        rep(s,n)rep(t,n)if(s!=t){
            if(d[s][t] == d[s][e.a] + e.c + d[e.b][t]){
                use = true;
            }
        }
        if(!use) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    man = [0] * N

    for x in A:
        man[x - 1] += 1

    for i in man:
        print(i)
    

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N - 2 + 1)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 89496
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  string s;
  cin>>s;

  int ssize = s.size();
  if(s[0] != 'A'){
    cout<<"WA"<<endl;
    return 0;
  }

  int cnt = 0;

  for(int i=1;i<ssize;i++){
    if(isupper(s[i])){
      if(s[i] != 'C'){
        cout<<"WA"<<endl;
        return 0;
      }else if(i==1||i==ssize-1){
        cout<<"WA"<<endl;
        return 0;
      }else{
        cnt++;
      }
    }
  }

  if(cnt==1){
    cout<<"AC"<<endl;
  }else{
    cout<<"WA"<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int ac, wa, tle, re;
  ac = 0;
  wa = 0;
  tle = 0;
  re = 0;
  for (int i = 0; i < N; i++) {
    string result;
    cin >> result;
    if(result == "AC") {
      ac++;
    }
    else if (result == "WA") {
      wa++;
    }
    else if (result == "TLE") {
      tle++;
    }
    else {
      re++;
    }
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N, a[200009], b[200009], ans = 0; vector<int>p[30];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) scanf("%d", &a[i]);
	for (int i = 0; i < N; i++) scanf("%d", &b[i]);
	for (int i = 0; i <= 29; i++) {
		p[i].resize(N);
		for (int j = 0; j < N; j++) { p[i][j] = b[j] % (1 << i); }
		sort(p[i].begin(), p[i].end());
	}
	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = 0; j <= 28; j++) {
			sum = (a[i] & ((2 << j) - 1));
			int LL = (3 << j) - sum; LL %= (2 << j);
			int RR = LL + (1 << j);
			if (RR < (2 << j)) {
				int pos1 = lower_bound(p[j + 1].begin(), p[j + 1].end(), LL) - p[j + 1].begin();
				int pos2 = lower_bound(p[j + 1].begin(), p[j + 1].end(), RR) - p[j + 1].begin();
				if ((pos2 - pos1) % 2 == 1) {
					ans ^= (1 << j);
				}
			}
			else {
				int pos1 = lower_bound(p[j + 1].begin(), p[j + 1].end(), RR - (2 << j)) - p[j + 1].begin();
				int pos2 = lower_bound(p[j + 1].begin(), p[j + 1].end(), LL) - p[j + 1].begin();
				if ((N - (pos2 - pos1)) % 2 == 1) {
					ans ^= (1 << j);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 27392
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		int c = a/b;
		int d = a%b;


        System.out.print(c + " " + d + " " );

        System.out.printf("%.5f",(double)a/b);
	}
}


Measured memory_bytes: 26424
package main

import "fmt"

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

	c := 4
	d := 7
	e := c + d

	buy := "No"
	cn = n

	for k, v := range map[int][]int{c: {d, e}, d: {c, e}, e: {c, d}} {
		cn = n
		for cn >= 0 {
			for _, vv := range v {
				if cn%vv == 0 {
					buy = "Yes"
					break
				}

			}
			cn -= k
		}
	}

	fmt.Println(buy)
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M){
    if(N==M)cout<<YES;else cout<<NO;
    cout<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
//Created by:Coding_lover(17-06-2020 11:32:09)
#include <bits/stdc++.h>
#define ll long long
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define INF LLONG_MAX
#define f first
#define s second
#define LB lower_bound
#define UB upper_bound
#define pi pair<long long,long long>
#define pii pair<long long,pi>
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define vc vector
#define vll vector<long long>
#define rep(i, a, n) for (ll i = a; i < (long long)n; ++i)
#define repe(i, a, n) for (ll i = a; i <= (long long)n; ++i)
#define repr(i, n, a) for (ll i = n; i > (long long)a; --i)
#define repre(i, n, a) for (ll i = n; i >= (long long)a; --i)
using namespace std;
int main() {
  FASTER;
  ll t;
  t=1;
  //cin >> t;
  while (t--) {
  	ll n;
  	cin>>n;
  	vll a(n),b(n),c(n);
  	rep(i,0,n)cin>>a[i]>>b[i]>>c[i];
  	vll dpa(n),dpb(n),dpc(n);
  	dpa[0]=a[0],dpb[0]=b[0],dpc[0]=c[0];
  	rep(i,1,n)
  	{
  		dpa[i]=max(dpb[i-1]+a[i],dpc[i-1]+a[i]);
  		dpb[i]=max(dpa[i-1]+b[i],dpc[i-1]+b[i]);
  		dpc[i]=max(dpa[i-1]+c[i],dpb[i-1]+c[i]);
  	}
  	cout<<max(dpa[n-1],max(dpb[n-1],dpc[n-1]))<<endl;
  }
  return 0;
}


Measured memory_bytes: 4992
#include<cstdio>

const int N_MAX = 1e5;
int n, k;
char s[N_MAX + 1];

int main() {
    scanf("%d %d", &n, &k);
    scanf("%s", s);
    char t = (s[0] == 'L') ? 'R' : 'L';
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1]) ans++;
    }
    for (int i = 1, cnt = 0; i < n; i++) {
        if (s[i] == t) {
            ans += 2;
            if (i == n - 1) ans--;
            while (s[i + 1] == t) {
                i++;
                if (i == n - 1) ans--;
            }
            if (++cnt == k) break;
        }
    }

    printf("%d\n", ans);
    return 0;
}            


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	inputArray, _ := toIntArray(splitInput(scanner, " "))
	n := inputArray[0]
	st := splitInput(scanner, " ")
	s := st[0]
	t := st[1]

	for i := 0; i < n; i++ {
		fmt.Printf("%s", s[i:i+1])
		fmt.Printf("%s", t[i:i+1])
	}
	fmt.Println()
}

func splitInput(scanner *bufio.Scanner, sep string) []string {
	scanner.Scan()
	return strings.Split(scanner.Text(), sep)
}

func toIntArray(str []string) ([]int, error) {
	length := len(str)
	resVal := make([]int, length)
	var err error
	for i := 0; i < length; i++ {
		resVal[i], err = strconv.Atoi(str[i])
		if err != nil {
			return nil, err
		}
	}
	return resVal, nil
}


Measured memory_bytes: 640
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String[] line = s.nextLine().split(" ");
		int productCnt = Integer.parseInt(line[0]);
		int capa = Integer.parseInt(line[1]);
		int[][] product = new int[productCnt][2];
		for(int i=0 ; i<productCnt ; i++) {
			line = s.nextLine().split(" ");
			product[i][0] = Integer.parseInt(line[0]);
			product[i][1] = Integer.parseInt(line[1]);
		}
		System.out.println(solve(productCnt, capa, product));
	}

	public static int solve(int productCnt, int capa, int[][] product) {
		int[][] result = new int[capa+1][productCnt+1];
		for(int i=1 ; i<=productCnt ; i++) {
			for(int j=1 ; j<=capa ; j++) {
				if(j<product[i-1][1]) {
					result[j][i] = result[j][i-1];
				}else {
					result[j][i] = Math.max(result[j][i-1],product[i-1][0] + result[j-product[i-1][1]][i-1]);
				}
			}
		}
		return result[capa][productCnt];
	}
}

Measured memory_bytes: 24292
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        int t = sc.nextInt();

        int result = 0;
        if (x - t > 0) result = x - t;

        System.out.println(result);
    }
}


Measured memory_bytes: 20948
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int n;
int match[25][25];
int dp[2097160][25];
long solve(int mask, int pos)
{
    //cout<<mask<<endl;
    if(mask == (1<<n)-1)
        return 1;

    if(pos == n && mask!= (1<<n)-1)
        return 0;
    
    if(dp[mask][pos]!=-1)
        return dp[mask][pos];
    
    int ans = 0;
    for(int i=0; i<n; i++)
    {        
        if(match[pos][i]==1) // compatible
        {            
            // Check if not already taken
            if(!(mask & (1<<i))) 
            {                
                ans = (ans+solve(mask|(1<<i), pos+1))%MOD;
            }
        }
    }
    dp[mask][pos] = ans;
    return ans;   

}

int main()
{    
    
    cin>>n; 
     
    memset(dp,-1,sizeof(dp));
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            cin>>match[i][j];
        }
    }    
    cout<<solve(0,0)<<endl;
    
    return 0;
}

Measured memory_bytes: 205184
#include<bits/stdc++.h>
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);
#define vs              v.size()
#define sot(v)        sort(v.begin(),v.end())
#define rev(v)        reverse(v.begin(),v.end())
#define ii                pair<int,int>
#define ll                long long
#define ull              unsigned long long
#define pb              push_back
#define mpp          make_pair
#define Okay         0
#define pi               3.14159

static ll int inf = 1e9;
const int cont = 10e5+10;
using namespace std;

void solve(){
   ll a, b,c,d,n,k;
   cin>>a>>b>>c;
   int ans = 0;
   int time = 0;
   while(a>ans){
    time += c;
    ans += b;
   }
   cout<<time<<endl;

}

int main(){
    Fast;

    solve();

	return Okay;
}



Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
   int n;
   cin >> n;
   cout << 800 * n - (n / 15) * 200 << endl;
   return 0;
}


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

int main(){
    int x,y;
    cin >> x >> y;
    for(int i = 0; i <= x; i++){
        if(i*2+(x-i)*4 == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(void)
{
        int n,i;
        char s[100];
        scanf("%d",&n);
        for(i=0;i<n;i++)
                scanf("%c",&s[i]);
        for(i=0;i<n;i++){
                if(s[i]=='Y'){
                        printf("Four\n");
                        return 0;
                }
        }
        printf("Three\n");

        return 0;
}


Measured memory_bytes: 128
main :-
	read_num(N),
	read_n_num_list(N, L),
        findall(_, make_triangle(N, L, _, _, _), Triangles),
        length(Triangles, Ans),
	write(Ans),
	nl,
	halt.


% A, B, Cの三辺を持つ三角形ができるか？
triangle(A, B, C) :-
	max_list([A, B, C], Max),
	select(Max, [A, B, C], Rest),
	sumlist(Rest, Sum),
	Max < Sum,
        !.

make_triangle(N, List, A, B, C) :-
        numlist(1, N, IndexList),
	member(I, IndexList),
        IPlusOne is I + 1,
        numlist(IPlusOne, N, IndexListForJ),
        member(J, IndexListForJ),
        JPlusOne is J + 1,
        numlist(JPlusOne, N, IndexListForK),
        member(K, IndexListForK),
        
        nth1(I, List, A),
        nth1(J, List, B),
        nth1(K, List, C),
        is_set([A, B, C]),
        triangle(A, B, C).

read_n_num_list(Num, List) :-
	read_n_num_list_aux(Num, [], List),
	!.
read_n_num_list_aux(0, List, List).
read_n_num_list_aux(Num, Old, Accum) :-
	read_num(NewItem),
	NewNum is Num - 1,
	append(Old, [NewItem], NewList),
	read_n_num_list_aux(NewNum, NewList, Accum).
	

read_str(S) :-
        read_string(current_input, ' \n', '', _, S).

read_num(N) :-
	read_str(S),
	number_string(N, S).



Measured memory_bytes: 16872
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
string s;
ll dp[100001][13];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    reverse(ALL(s));
    int a[6] = {1, 10, 9, 12, 3, 4};
    for (int i = 0; i < 13; i++)
    {
        for (int j = 0; j <= s.size(); j++)
        {
            dp[j][i] = 0;
        }
    }
    if (s[0] == '?')
    {
        for (int i = 0; i < 13; i++)
        {
            if (i <= 9)
                dp[1][i] = 1;
            else
            {
                dp[1][i] = 0;
            }
        }
    }
    else
    {
        for (int i = 0; i < 13; i++)
        {
            if (s[0] - '0' == i)
            {
                dp[1][i] = 1;
            }
            else
            {
                dp[1][i] = 0;
            }
        }
    }
    for (int i = 2; i <= s.size(); i++)
    {
        if (s[i - 1] == '?')
        {
            /* ll temp = 0;
            for (int j = 0; j < 13; j++)
            {
                temp += dp[i - 1][j];
                temp %= 1000000007;
            }
            for (int j = 0; j < 13; j++)
            {
                dp[i][j] = temp;
                dp[i][j] %= 1000000007;
            }
            */
            for (int k = 0; k <= 9; k++)
            {
                int ch = (k * a[(i - 1) % 6]) % 13;
                for (int j = 0; j < 13; j++)
                {
                    dp[i][(j + ch) % 13] += dp[i - 1][j];
                    dp[i][(j + ch) % 13] %= 1000000007;
                }
            }
        }
        else
        {
            int temp = s[i - 1] - '0';
            int ch = (temp * a[(i - 1) % 6]) % 13;
            for (int j = 0; j < 13; j++)
            {

                dp[i][(j + ch) % 13] += dp[i - 1][j];
            }
        }
        /* for (int j = 0; j < 13; j++)
        {
            cout << dp[i][j] << "\n";
        }
        */
    }
    cout << dp[s.size()][5] << "\n";
}

Measured memory_bytes: 10604
#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

const double PI  = 3.141592653589793238463;
const int MOD = 1000000007;
const Int INF = numeric_limits<Int>::max() / 3;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec){
        is >> x;
    }
    return is;
}

template<typename T>
string join(const vector<T>& vec, string sep = " "){
    stringstream ss;
    for(int i = 0; i < vec.size(); i++){
        ss << vec[i] << (i + 1 == vec.size() ? "" : sep);
    }
    return ss.str();
}

int solve(int n, int m){
    int pi = 1 << m;
    return pi * (m * 1900 + (n - m) * 100);
}

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    cout << solve(n, m) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <memory.h>
using namespace std;
typedef long long ll;
typedef long double ldbl;

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  printf("%d", (int)ceil(0.5 * (a + b)));
  return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

vector<tuple<int, int, int>> P;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	int N, x, y, h;
	cin >> N;
	P.resize(N);
	for (int i = 0; i < N; i++) {
		cin >> x >> y >> h;
		P[i] = tie(x, y, h);
	}
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			int H = 0x7fffffff;
			bool valid = true;
			for (auto p : P) {
				tie(x, y, h) = p;
				H = min(H, h + abs(x - i) + abs(y - j));
			}
			for (auto p : P) {
				tie(x, y, h) = p;
				if (h != max(H - abs(x - i) - abs(y - j), 0)) {
					valid = false;
					break;
				}
			}
			if (valid) {
				cout << i << ' ' << j << ' ' << H << '\n';
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int n;
    cin>>n;
    vector<double>a(n);
    rep(i,n) cin>>a[i];
    double ans = 1;
    double div = 0;
    rep(i,n) {
        ans *= a[i];
    }
    rep(i,n) {
        div += ans/a[i];
    }
    cout<<ans/div<<endl;

    return 0;
}


Measured memory_bytes: 3804
#include<iostream>

int monthes(int i){
  if(i==2){
    return 29;
  }
  if(i==4||i==6||i==9||i==11){
    return 30;
  }else{
    return 31;
  }
}

int main(){
  int month,day,sum;

  while(std::cin >> month >> day){
    if(month==0){
      break;
    }
    sum = 0;
    for(int i=1;i<month;i++){
      sum += monthes(i);
    }
    sum += day-1;
    switch(sum%7){
      case 0: std::cout << "Thursday" << std::endl; break;
      case 1: std::cout << "Friday" << std::endl; break;
      case 2: std::cout << "Saturday" << std::endl; break;
      case 3: std::cout << "Sunday" << std::endl; break;
      case 4: std::cout << "Monday" << std::endl; break;
      case 5: std::cout << "Tuesday" << std::endl; break;
      case 6: std::cout << "Wednesday" << std::endl; break;
    }
  }
}

Measured memory_bytes: 2992
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, K := ReadInt(), ReadInt()
	as := ReadInts(N)
	dp := make([]bool, K+1)
	for i := 1; i < K+1; i++ {
		for _, a := range as {
			dp[i] = Cond(i-a >= 0 && !dp[i-a], true, dp[i])
		}
	}
	if dp[K] {
		fmt.Println("First")
	} else {
		fmt.Println("Second")
	}
}

func Cond(c bool, a, b bool) bool {
	if c {
		return a
	}
	return b
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1976
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			double l = cin.Int();

			double ans = (l / 3) * (l / 3) * (l / 3);
			Console.WriteLine(ans);
		}
	}

	public static class Helper
	{
		public static void UpdateMin32<T>(T array, int index, int value) where T : IList<int>
			=> array[index] = Math.Min(array[index], value);
		public static void UpdateMax32<T>(T array, int index, int value) where T : IList<int>
			=> array[index] = Math.Max(array[index], value);
		public static void UpdateMin64<T>(T array, int index, long value) where T : IList<long>
			=> array[index] = Math.Min(array[index], value);
		public static void UpdateMax64<T>(T array, int index, long value) where T : IList<long>
			=> array[index] = Math.Max(array[index], value);

		public static T[] Array<T>(int n, Func<int, T> init)
			=> Enumerable.Range(0, n).Select(x => init(x)).ToArray();
		public static List<T> List<T>(int n, Func<int, T> init)
			=> Enumerable.Range(0, n).Select(x => init(x)).ToList();
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

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

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

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

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
// #define DEBUG 100
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll >;
 
const ll oo = 1e18 + 7;
const ll mod = 1e9 + 7,maxn = 1e5 + 100, maxm = 1e5+100;
const double PI = acos(-1);

int main (){
    ios_base::sync_with_stdio(false);
    ll n, x, m, tam;
    cin >> n >> x >> m;
    vector<ll> vs;
    set<ll> st;

    while (!st.count(x)){
        st.insert(x);
        vs.push_back(x);
        x = (x*x)%m;
    }
    for (int i=0; i<(int)vs.size(); i++){
        if (vs[i] == x) {
            tam = i;
            break;
        }
        if (i) vs[i]+=vs[i-1];
    }
    ll ans, t = vs.size();

    if (n <= tam){
        cout << vs[n-1] << endl;
        return 0;
    }

    if (tam) ans = vs[tam-1];
    else ans = 0;
    n -= tam;

    for (ll i=tam;i<t;i++){
        ans += n/(t-tam)*vs[i];
        if (i - tam + 1 <= n%(t-tam))ans+=vs[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5952
#include <stdio.h>

int main(void) {
	
	char buf[128];
	int i;
	
	gets(buf);
	
	while(buf[i] != '\0'){
		if(buf[i] >= 97 && buf[i] <=122)
		buf[i] = buf[i] - 32;
		i++;
	}
	
	printf("%s\n",buf);
	
	return 0;
}

Measured memory_bytes: 524
#include <stdio.h>
#include <algorithm>
int n, m, x, y;
int a[100000];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	std::sort(a, a + n);
	while (a[n - 1 - m] > m)m++;
	x = a[n - m] - m + 1;
	for (int i = 0; i <= n - m; i++) {
		if (a[i] >= m)y++;
	}
	if (x % 2 && y % 2) printf("Second\n");
	else printf("First\n");
}

Measured memory_bytes: 1964