akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var n, c int
	fmt.Scan(&n)
	s := make([]int, n)
	for i, _ := range s {
		fmt.Scan(&s[i])
	}
	flag := true
	for {
		for _, num := range s {
			if num%2 != 0 {
				flag = false
				break
			}
		}
		if flag == false {
			break
		}
		for i, num := range s {
			s[i] = num / 2
		}
		c++
	}
	fmt.Println(c)
}


Measured memory_bytes: 512
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
	int h,w;
	cin >> h >> w;
	map<char,int> m;

	rep(i,0,h)rep(j,0,w){
	    char c;
	    cin >> c;
	    m[c]++;
	}

    int num4 = (h/2) * (w/2);

    for(auto it:m){
        if(it.sd >= 4 && num4 > 0){
            int del = it.sd /4;
            if(del > num4)del = num4;
            
            num4 -= del;
            m[it.ft] = it.sd - (4*del);
        }
    }

    int num2 = 0;
    if(w%2 == 1)num2 += h/2;
	if(h%2 == 1)num2 += w/2;

	if(num2 > 0){
        for(auto it:m){
            if(it.sd >= 2 && num2 > 0){
                int del = it.sd /2;
                if(del > num2)del = num2;
            
                num2 -= del;
                m[it.ft] = it.sd - (2*del);
            }
        }
	}

	if(num4 == 0 && num2 == 0)Yes;
	else No;
	

	return  0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

if N == 1:
    if M == 1:
        print(1)
    else:
        print((N-2)*(M-2)*(-1))
else:
    if M == 1:
        print((N-2)*(M-2)*(-1))
    else:
        print((N-2)*(M-2))

Measured memory_bytes: 9172
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int m, f, r;
		while (true) {
			m = stdIn.nextInt();
			f = stdIn.nextInt();
			r = stdIn.nextInt();
			if (m == -1 && f == -1 && r == -1) {
				break;
			}
			if (m == -1 || f == -1) {
				System.out.println("F");
			} else if (m + f >= 80) {
				System.out.println("A");
			} else if (m + f >= 65) {
				System.out.println("B");
			} else if (m + f >= 50) {
				System.out.println("C");
			} else if (m + f >= 30 && r >= 50) {
				System.out.println("C");
			} else if (m + f >= 30) {
				System.out.println("D");
			} else if (m + f < 30) {
				System.out.println("F");
			}
		}
		stdIn.close();
	}
}



Measured memory_bytes: 26252
#include <iostream>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int cnt = 0;
  bool zoro = false;
  for (int i = 0; i < N; i++) {
    int D[2];
    cin >> D[0] >> D[1];
    if (D[0]==D[1]) {
      cnt++;
      if (cnt >= 3) {
        zoro = true;
      }
    } else {
      cnt = 0;
    }
  }
  if (zoro) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3600
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
	
int gcd(int a, int b){
	if(b > a)swap(a, b);
	while(a > b && b != 0){
		a %= b;
		if(b > a)swap(a, b);
		//deb(a, b);
	}
	return a;
}

int main(){
	FIO
	
	int a, b;cin >> a >> b;
	cout << gcd(a, b) << '\n';
	return 0;
}



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

#define MAX 2000001
#define VMAX 10000

int main(void)
{
  unsigned short *A, *B;
  
  int C[VMAX+1];
  int n, i, j;
  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=0;i<=VMAX;i++) C[i] = 0;
  
  for(i=0;i<n;i++) {
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  
  for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];
  
  for(j=1;j<=n;j++) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i=1;i<=n;i++) {
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 9660
import math
import bisect
  
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

def get_like_2017(N):
  nums = set([i for i in range(2,N+1)])
  for i in range(2, int(math.sqrt(N))+1):
    for j in range(2,int(N//i)+1):
      if i*j in nums: nums.remove(i*j)
  
  nums_like_2017 = set([])
  for num in nums:
    if is_prime(int((num+1)/2)) is True:  nums_like_2017.add(num)
  return nums_like_2017

nums_like_2017 = sorted(list(get_like_2017(10**5)))

Q = int(input())
for _ in range(Q):
  l,r = map(int, input().split())
  idx_l = bisect.bisect_left(nums_like_2017, l)
  idx_r = bisect.bisect_right(nums_like_2017, r)
 
  print(idx_r-idx_l)
    

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

using namespace std;

int main(){
    string s;
    cin>>s;
    if(s[0]=='S'){
        cout<<"Cloudy\n";
    }else if(s[0]=='R'){
        cout<<"Sunny\n";
    }else{
        cout<<"Rainy\n";
    }
    return 0;
}

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

int dp[60050];
const int INF=1001001001;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>a(m);
    for(int i=0; i<m; ++i)cin>>a[i];
    for(int i=0; i<50050; ++i)dp[i]=INF;
    dp[0]=0;
    for(int i=0; i<=n; ++i){
        for(int j=0; j<m; ++j){
            dp[i+a[j]]=min(dp[i+a[j]],dp[i]+1);
        }
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 3308
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long  //comment it out when MLE
//# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 1000000000
# define mm 1000000007
# define pi acos(-1)
# define fi first
# define se second

using namespace std;

signed main()
{
    gok

       int r;
       cin>>r;
       cout<<fixed<<setprecision(10)<<2*pi*r;



















      return 0;
    }


Measured memory_bytes: 3820
#include<iostream>
#define N 50
void InsertionSort(int a[],int n){
	int j,p;
	int temp;
	for(p = 1; p < n; p += 1){
		temp = a[p];
		for (j = p; j > 0 && a[j - 1] > temp; j -= 1){
			a[j] = a[j - 1];
		}
		a[j] = temp;
	}
}
int main (){
	int a[N];
	int n,k;
	int sum = 0;
	scanf ("%d%d",&n,&k);
	for (int i = 0; i < n; i += 1){
		scanf ("%d",&a[i]);
	}
	InsertionSort(a,n);
	for (int i = n-1; i > n-k-1; i -= 1){
		sum += a[i];
	}
	
	printf ("%d\n",sum);
	return 0;
} 

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

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

    int a, b, c;
    cin >> a >> b >> c;
    if (a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3212
#include<stdio.h>
int a[1000],b[1000],c[1000] = {0};
int main(void)
{
 int n;
 int index = 0;
 scanf("%d",&n);
 int i;
 int count = 0;
 for(i = 1;i<=n;i++) scanf("%d",&a[i]);
 for(i = 1;i<=n;i++) {
  scanf("%d",&b[i]);
  count += b[i];
  }
 for(i = 1;i<n;i++) scanf("%d",&c[i]);
 for(i = 1;i<=n;i++)
 {
	  if(a[i]+1 == a[i+1])
	  {
	   		count += c[a[i]]; 
	  }
 }
 printf("%d",count);
 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

 
int main() {
    int c[3][3];
    rep(i,3) rep(j,3) cin >> c[i][j];

    int a[3], b[3];
    a[0] = 0;
    rep(j,3) b[j] = c[0][j];
    rep(i,3) a[i] = c[i][0] - b[0];

    string res = "Yes";
    rep(i,3) rep(j,3) {
        if (a[i] + b[j] != c[i][j]) {
            res = "No";
            break;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
	    String S = scanner.next();
	    int kotae = 0;
	    
	    for(int i=0; i<=3; i++) {
	    	if(S.substring(i, i+1).equals("+")) {
	    		kotae++;
	    	}else {
	    		kotae--;
	    	}
	    }
	    System.out.println(kotae);

	}

}

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

bool check(string s) {

	bool result = true;
	for (int i = 0; i < s.size() / 2; i++) {		
		if (s[i] != s[s.size() - i - 1]) {
			result = false;
		}	
	}
	return result;
}

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

	int n = s.size();

	string s_front = s.substr(0, (n - 1) / 2);
	string s_rear = s.substr((n - 1) / 2 + 1);
	
	bool can1, can2, can3;

	can1 = check(s);
	can2 = check(s_front);
	can3 = check(s_rear);

	string ans = "No";
	if (can1 && can2 && can3) ans = "Yes";

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = str(input())
b = str(input())
c = str(input())
count = 0
for i in range(n):
    if a[i]==b[i]==c[i]:
        count += 0
    elif a[i]==b[i] or b[i]==c[i] or c[i]==a[i]:
        count += 1
    else:
        count += 2
print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int A, B;
	cin >> A >> B;
	string S;
	cin >> S;
	int Z = S.size();
	int cnt = 0;
	vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
	for (int i = 0; i < A; i++) {
		rep(j, 10) {
			if (S[i] == NUM[j]) {
				cnt++;
			}
		}
	}
	if (cnt != A) {
		cout << "No" << endl;
		return 0;
	}
	cnt = 0;
	if (S[A] != '-') {
		cout << "No" << endl;
		return 0;
	}
	for (int i = A + 1; i < Z; i++) {
		rep(j, 10) {
			if (S[i] == NUM[j]) {
				cnt++;
			}
		}
	}
	if (cnt != B) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>))
import Control.Monad (replicateM,unless)
import Control.Monad.State
import Data.Array.IArray
import Data.Array.IO

type Field = Array Position Char
type VisitField = IOArray Position Bool
type Position = (Int, Int)
type SearchState = (Field, VisitField, Position)
type SearchAction = StateT SearchState IO

main = do
    [h,w] <- map read.words<$>getLine
    unless (h == 0) $ do
                field  <- getField h w
                vfield <- newArray ((0,0),(h,w)) False
                position <- evalStateT searchGoal (field,vfield,(0,0))
                printResult position
                main

printResult pos
  | pos == (-1, -1) = putStrLn "LOOP"
  | otherwise       = putStrLn.unwords.map show $ [snd pos, fst pos]
                      
getField :: Int -> Int -> IO Field
getField h w = do
  tiles <- replicateM h getLine
  let ix = [(i,j) | i <- [0..h-1], j <- [0..w-1]]
  return $ array ((0,0),(h,w)) $ zip ix (concat tiles)

searchGoal :: SearchAction Position
searchGoal = do
  goal <- checkGoal
  if goal then returnPosition
          else do
            move
            searchGoal

checkGoal :: SearchAction Bool
checkGoal = do
  (f, vf, pos) <- get
  if f ! pos == '.' then return True
                    else do
                      loop <- lift $ readArray vf pos
                      if loop then put (f,vf,(-1,-1)) >> return True
                              else return False

returnPosition :: SearchAction Position
returnPosition = get >>= \(f,vf,pos) -> return pos


move :: SearchAction ()
move = do
  (f,vf,pos) <- get
  case f ! pos of
       '^' -> goUp
       'v' -> goDown
       '>' -> goRight
       '<' -> goLeft

goUp :: SearchAction ()
[goUp,goDown,goRight,goLeft] = map goAction [up,down,right,left]

goAction :: (Position -> Position) -> SearchAction ()
goAction func = do
  (f, vf, pos) <- get
  lift $ writeArray vf pos True
  put (f, vf, func pos)

up :: (Int,Int) -> (Int,Int)
up    (x,y) = (x-1, y)
down  (x,y) = (x+1, y)
right (x,y) = (x, y+1)
left  (x,y) = (x, y-1)

Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
int main(){
    int n;cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    ll ans=lcm(a[0],a[1]);
    repi(i,2,n){
        ans=lcm(a[i],ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3168
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
	int n, l;
  	cin >> n >> l;
  	vector<string>words;
  	while(n--){
    	string w;
      	cin >> w;
      	words.push_back(w);
    }
  sort(words.begin(),words.end());
  string ans="";
  for(int i=0;i<words.size();++i){
  	ans+=words[i];
  }
  cout << ans << endl;  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    long long int t;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            std::deque<long long int> deq;
            for (int i=0;i<n;i++) {
                cin>>t;
                deq.emplace_back(t);
            }
            sort(deq.begin(),deq.end());
            std::deque<long long int> S(n+1,0);
            for (int i=0;i<n;i++) {
                S[i+1]=S[i]+deq[i];
            }
            long long int sum=0;
            for (int i=0;i<n;i++) {
                sum+=S[i];
            }
            cout<<sum<<endl;
        }
    }
}


Measured memory_bytes: 3232
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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 maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw_2(62,1);


int main(){
    ll N,M; cin>>N>>M;
    vector<ll> ans(N+1,INF);
    rep(i,M){
        ll s,c; cin>>s>>c;
        if(ans[s]==INF) ans[s]=c;
        else if(ans[s]!=c){
            cout<<-1<<endl;
            return 0;
        }
    }
    
    if(N==1){
        if(ans[1]!=INF) cout<<ans[1];
        else cout<<0;
    }
    else{
        if(ans[1]==0){
            cout<<-1;
            return 0;
        }
        else if(ans[1]==INF) cout<<1;
        else cout<<ans[1];
        
        FOR(i,2,N+1){
            if(ans[i]==INF) cout<<0;
            else cout<<ans[i];
        }
    }
}



Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> weights(n);
    for (size_t i = 0; i < n; ++i) cin >> weights[i];
    sort(weights.begin(), weights.end());
    int num = 0;
    for (size_t i = 0; i < n; ++i) {
        ++num;
        x = x - weights[i];
        if (x < 0) break;
    }
    if (x != 0) --num;
    cout << num << endl;
    return EXIT_SUCCESS;
}

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

int main(){
  long long int a,b;
  double A=1,x,k,pi=3.141592653589793;
  cin>>a>>b>>x;
  k=(a*a*b)-x;
  if(k<(a*a*b)/2){
  double l=k*2/(a*a);
  A=180.0*atan2(l,a)/pi;
      printf("%.10lf\n", A);
  }
  else{
    double l=x*2/(a*b);
    A=180.0*atan2(b,l)/pi;
      printf("%.10lf\n", A);
  }

}

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

c = []
for i in range(n):
    x, y = map(int, input().split())
    c.append((x, y))

dist = [[] for i in range(n)]
s = 0
for i, (x, y) in enumerate(c):
    for x0, y0 in c:
        s += ((x0-x)**2 + (y0-y)**2)**0.5



print(s / n)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
 
 
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int N; cin >> N;

  string s;
  cout << 0 << endl;
  flush(cout);

  cin >> s;
  if(s == "Vacant"){
    return 0;
  }

  if(s == "Female"){

    int lb = 0, ub = N;
    for(int i=0; i<19; i++){
      int mid = (lb+ub) >> 1;
      
      cout << mid << endl;
      flush(cout);
      string t;
      cin >> t;

      if(t == "Vacant"){
        return 0;
      }
      if(mid % 2 == 1){
        if(t == "Male"){
          lb = mid;
        }else{
          ub = mid+1;
        }
      }else{
        if(t == "Male"){
          ub = mid+1;
        }else{
          lb = mid;
        }
      }
    }
  }else{

    int lb = 0, ub = N;
    for(int i=0; i<19; i++){
      int mid = (lb+ub) >> 1;
      
      cout << mid << endl;
      flush(cout);
      string t;
      cin >> t;

      if(t == "Vacant"){
        return 0;
      }
      if(mid % 2 == 1){
        if(t == "Male"){
          ub = mid+1;
        }else{
          lb = mid;
        }
      }else{
        if(t == "Male"){
          lb = mid;
        }else{
          ub = mid+1;
        }
      }
    }
  }
  
  return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


int main() {
    int D; cin >> D;
    switch (D) {
        case 25:
            cout << "Christmas" << endl;
            break;
        case 24:
            cout << "Christmas Eve" << endl;
            break;
        case 23:
            cout << "Christmas Eve Eve" << endl;
            break;
        case 22:
            cout << "Christmas Eve Eve Eve" << endl;
            break;
        default:
            break;
    }

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include <cstdio>
using namespace std;
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}
int main()
{
	fast();
	int x ;
	long long a[88] = {0};
	a[0] = 2, a[1] = 1;

	cin >> x;
	for (int i = 2;i <= x;i++)
	{
		a[i] += a[i - 1] + a[i - 2];
	}
	cout << a[x] << endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.ARC086
{
    class NonDecreasing
    {
        public static void Main()
        {
            var n = int.Parse(ReadLine());
            var nums = ReadLine().Trim().Split(' ').Select(_ => int.Parse(_)).ToArray();
            var min = nums.Min();
            var max = nums.Max();
            var minIndex = 0;
            var maxIndex = 0;
            for (var i = 0; i < nums.Count(); ++i)
            {
                if (nums[i] == min) minIndex = i + 1;
                if (nums[i] == max) maxIndex = i + 1;
            }
            WriteLine(2 * n - 1);
            if (min + max >= 0)
            {
                for (var i = 1; i <= n; ++i)
                {
                    WriteLine($"{maxIndex} {i}");
                }
                for (var i = 1; i < n; ++i)
                {
                    WriteLine($"{i} {i + 1}");
                }
            }
            else
            {
                for (var i = 1; i <= n; ++i)
                {
                    WriteLine($"{minIndex} {i}");
                }
                for (var i = n; i > 1; --i)
                {
                    WriteLine($"{i} {i - 1}");
                }
            }
        }
    }
}


Measured memory_bytes: 13396
S,T=(0..2).map{(?0+gets).chars.map{|c|$.+=c<?B?1:2}};puts$<.map{|l|a,b,c,d=l.split.map &:to_i;(S[b]-S[a-1]-T[d]+T[c-1])%3<1?:YES: :NO}

Measured memory_bytes: 23532
package main

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

// Scane Standard Input
var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	r := make(map[string]int)
	r = initMap(r)

	for {
		s := nextLine()
		if s == "" {
			break
		}

		for _, ss := range s {
			if ('a' <= ss && ss <= 'z') || ('A' <= ss && ss <= 'Z') {
				tmp := strings.ToLower(string(ss))
				r[tmp] = r[tmp] + 1
			}
		}
	}
	a := List{}
	for k, v := range r {
		e := Entry{k, v}
		a = append(a, e)
	}
	sort.Sort(a)

	for _, e := range a {
		fmt.Println(e.key + " : " + strconv.Itoa(e.value))
	}
}

func initMap(m map[string]int) map[string]int {
	for i := 0; i < 26; i++ {
		m[string(rune('a'+i))] = 0
	}
	return m
}

// 以下Keyをソートするためのコード
type Entry struct {
	key   string
	value int
}

type List []Entry

func (l List) Len() int {
	return len(l)
}
func (l List) Swap(i, j int) {
	l[i], l[j] = l[j], l[i]
}
func (l List) Less(i, j int) bool {
	return (l[i].key < l[j].key)
}



Measured memory_bytes: 1124
let solve ans w v =
  let rec duduwa ans j k = function
    | [] -> doit ans (j + 1, [(v.(j), k)])
    | (ch, cj) :: y' when ch >= v.(j) -> duduwa (if ch * (j - cj) > ans then ch * (j - cj) else ans) j cj y'
    | ys -> doit ans (j + 1, (v.(j), k) :: ys)
  and doit ans = function
    | (j, xs) when j = w -> List.fold_left (fun acc (ch, cj) -> if ch * (w - cj) > acc then ch * (w - cj) else acc) ans xs
    | (j, []) -> doit ans (j + 1, [(v.(j), j)])
    | (j, ((ch, _) :: _ as xs)) when ch = v.(j) -> doit ans (j + 1, xs)
    | (j, ((ch, _) :: _ as xs)) when ch < v.(j) -> doit ans (j + 1, (v.(j), j) :: xs)
    | (j, xs) -> duduwa ans j j xs in
  doit ans (0, [])

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let read () = List.map int_of_string (split_on_char ' ' (read_line ()))

let () =
  match read () with
  | [h; w] ->
    let v0 = Array.make w 0 in
    let v1 = Array.make w 0 in
    let rec doit i ans =
      if i = h then ans
      else
        let rec duduwa j = function
          | [] -> Array.iteri (fun i e -> v0.(i) <- e) v1; doit (i + 1) (solve ans w v1)
          | x::xs ->
            v1.(j) <- if x = 1 then 0 else v0.(j) + 1;
            duduwa (j + 1) xs in
        duduwa 0 (read ()) in
    Printf.printf "%d\n" (doit 0 0)
  | _ -> ()

Measured memory_bytes: 5104
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    int maximum = 0,last = 0;
    REP(i,N){
        cin >> A[i];
        maximum = max(maximum,A[i]);
        if(maximum == A[i])last = i;
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    REP(i,N){
        if(i == last){
            cout <<A[1]<< "\n";
        }else{
            cout <<maximum<< "\n";
        }
    }
cout << "\n";
}

Measured memory_bytes: 2432
//AtCoder Beginner Contest 174
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e6 + 5;
const double E = 1e-9;

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

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*ifstream cin("input.txt");
	ofstream cout("output.txt");*/
	int k;
	cin >> k;
	ll seven = 0;
	for (int i = 0; i < N; i++)
	{
		seven = seven * 10 + 7;
		seven %= k;
		if (seven % k)
			continue;
		else
		{
			cout << (i + 1);
			return 0;
		}
	}
	cout << -1;
	return 0;
}
//02-08-2020 20:34:46
//------------------------------------------------------------------------------

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int N;
	vector<int> a;

	cin >> N;
	a.resize(N);
	for(int i = 0; i < N; i++)
		cin >> a[i];

	llong ans = inf;
	for(int i = -100; i <= 100; i++){
		llong res = 0;
		for(int j = 0; j < N; j++)
			res += (a[j]-i)*(a[j]-i);
		ans = min(ans, res);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
//using System.Collections;
//using System.Collections.Generic;
using System.Linq;

namespace solution
{
  class Class1
  {
    static void Main()
    {
      var i = Console.ReadLine().Split().Select(int.Parse).ToArray();
      int r = i[0];
      int c = i[1];
      int[][] sheet = new int[r][];
      int sum = 0;
      int total = 0;

      for (int a = 0; a < r; a++)
      {
        sheet[a] = Console.ReadLine().Split().Select(int.Parse).ToArray();
      }

      for (int a = 0; a < r; a++)
      {
        for (int b = 0; b < c; b++)
        {
          sum += sheet[a][b];
          Console.Write("{0} ", sheet[a][b]);
        }
        Console.WriteLine(sum);
        total += sum;
        sum = 0;
      }

      for (int a = 0; a < c; a++)
      {
        for (int b = 0; b < r; b++)
        {
          sum += sheet[b][a];
        }
        Console.Write("{0} ", sum);
        sum = 0;
      }
      Console.WriteLine(total);
    }
  }
}


Measured memory_bytes: 9916
#include<bits/stdc++.h>
using namespace std ;
#define ll long long 
#define pb push_back
#define in(x) int x; cin>>x;
#define ln(x) long long x; cin>>x;
#define memf(a) memset(a,false,sizeof(a))
#define F first
#define S second
#define endl "\n"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
int main()
{
	fast
	int n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	ll ans=0;
	for(int i=1;i<n;i++)
	{
		if(a[i-1]>a[i])
		{
			ans+=(a[i-1]-a[i]);
			a[i]=a[i-1];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5212
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int h,w;
  cin>>h>>w;
  char mine[h][w];
  char ans[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
    cin>>mine[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int count=0;
      if(mine[i][j]=='#'){
        ans[i][j]='#';
        continue;
      }
      if(i-1>=0){
        if(j-1>=0&&mine[i-1][j-1]=='#')  count++;
        if(j+1<w&&mine[i-1][j+1]=='#')  count++;
        if(mine[i-1][j]=='#') count++;
      }
      if(j-1>=0&&mine[i][j-1]=='#')  count++;
      if(j+1<w&&mine[i][j+1]=='#')  count++;
      if(i+1<h){
        if(j-1>=0&&mine[i+1][j-1]=='#')  count++;
        if(j+1<w&&mine[i+1][j+1]=='#')  count++;
        if(mine[i+1][j]=='#') count++;
      }
      ans[i][j]=count+'0';
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
    cout<<ans[i][j];
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        
        int[] b = new int[m];
        for(int j=0; j<m; j++) b[j] = sc.nextInt();
        
        int[][] a = new int[n][m];
        for(int i=0; i<n; i++)
            for(int j=0; j<m; j++) a[i][j] = sc.nextInt();
        
        int count = 0;
        for(int i=0; i<n; i++) {
            int score = c;
            for(int j=0; j<m; j++) 
                score += b[j] * a[i][j];
            
            if(score > 0) count++;
        }
        
        out.println(count);
    }
}


Measured memory_bytes: 23892
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    N = II()

    for i in range(int(N**0.5),0,-1):
        if N % i == 0:
            print(max(len(str(N//i)),len(str(i))))
            return

    

if __name__ == '__main__':
    main()

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

int main() {
    int H, W; cin >> H >> W;
    vector<vector<int>> c(10, vector<int>(10));
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }
    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    int ans = 0;
    vector<vector<int>> A(H, vector<int>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int a; cin >> a;
            if (a!= -1) ans += c[a][1];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        s: chars,
    }
    use std::collections::HashSet;
    let k = s.clone();
    let mut s= s;
    let uniq_n: HashSet<char> = s.drain(..).collect();
    if uniq_n.len() == k.len() {
        println!("yes");
    } else {
        println!("no");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
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;}


int const INF = 1001001001;


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

string X;
cin >> X;

stack<char> st;
rep(i,X.size()) {
    if(st.empty()) st.push(X[i]);
    else {
        if(st.top() == 'S' && X[i] == 'T') st.pop();
        else st.push(X[i]);
    }
}
cout << st.size() << endl;
return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1005, maxm = 200005;

int n, m, num[maxn][maxn];
bool go[maxn][maxn], go2[maxn][maxn];

pii p[maxm];

vector<int> G[maxn];

bool vis[maxn];
int vis2[maxn], vis3[maxn];

void dfs1(int x, int rt)
{
	vis[x] = 1;
	if(x != rt)
		go[rt][x] = 1;
	int id;	
	for(int i = 0; i < (int)G[x].size(); ++i)
	{
		id = G[x][i];
		if(vis[id])	continue;
		dfs1(id, rt);
	}
}

void dfs2(int x)
{
	int id;
	for(int i = 0; i < (int)G[x].size(); ++i)
	{
		id = G[x][i];
		if(vis2[id])	continue;
		vis2[id] = num[x][id];
		dfs2(id);
	}
}

void dfs3(int x)
{
	int id;
	for(int i = (int)G[x].size() - 1; i >= 0; --i)
	{
		id = G[x][i];
		if(vis3[id])	continue;
		vis3[id] = num[x][id];
		dfs3(id);
	}
}

int main()
{
	scanf("%d%d", &n, &m);
	int u, v;	
	for(int i = 1; i <= m; ++i)
	{
		scanf("%d%d", &u, &v);
		memset(vis, 0, sizeof(vis));
		G[u].push_back(v);
		num[u][v] = i;
		p[i] = make_pair(u, v);
	}
	for(int i = 1; i <= n; ++i)
	{
		dfs1(i, i);
		vis2[i] = vis3[i] = -1;	
		dfs2(i);
		dfs3(i);
		int id;
		for(int j = 0; j < (int)G[i].size(); ++j)
		{
			id = G[i][j];
			if(vis2[id] != num[i][id] || vis3[id] != num[i][id])
			{
				go2[i][id] = 1;
			}
		}
		memset(vis, 0, sizeof(vis));
		memset(vis2, 0, sizeof(vis2));
		memset(vis3, 0, sizeof(vis3));
	}
	for(int i = 1; i <= m; ++i)
	{
		u = p[i].first;
		v = p[i].second;
		printf("%s\n", (go[v][u] && !go2[u][v]) || (!go[v][u] && go2[u][v])? "diff": "same");
	}
	return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

#define MAX 500000
int L[MAX/2 + 2], R[MAX/2 + 2];
int cnt;


signed main()
{   
    gearup;
    int n;cin >> n;
    vl a(n); 
    rep(i,n) cin >> a[i];
    double res = 0;
    rep(i,n){
        res += 1.0/a[i];
    }
    cout << fixed << setprecision(6) << 1.0/res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	int h,w;
	while(1){
		cin>>h>>w;
		if(w==0 && h==0) break;
		char tile[100][100]={0};
		for(int i=0;i<h;i++){
			string str;
			cin>>str;
			for(int j=0;j<w;j++){
				tile[i][j]=str[j];
			}
		}
		int x=0,y=0,k=0;
		while(1){
			k++;
			if(tile[y][x]=='>')	     x++;
			else if(tile[y][x]=='<') x--;
			else if(tile[y][x]=='^') y--;
			else if(tile[y][x]=='v') y++;
			else if(tile[y][x]=='.'){
				cout<<x<<" "<<y<<endl;
				break;
			}
			if(k==10000){
				cout<<"LOOP"<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
  int D,N;
  cin >> D >> N;
  if(D==0&&N!=100)  cout << N << endl;
  else if(D==1&&N!=100) cout << N*100 << endl;
  else if(D==2&&N!=100) cout << N*100*100 << endl;
  else if(D==0)  cout << N+1 << endl;
  else if(D==1) cout << (N+1)*100 << endl;
  else if(D==2) cout << (N+1)*100*100 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
const int N = 100*1000+5;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    string s,t;
    cin >> s >>t;
    cout << t << s;
    return 0;
}


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

using namespace std;

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

    int ans = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] != t[i]) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
/*
given a array of ints, return minimum cost from 0 to n-1
each can go from i+1 or i+2

dp[i] = min(dp[i-1] + abs(A[i]-A[i-1], dp[i-2] + abs(A[i]-A[i-2]))

dp
*/

int main() {
    const int INF = 1e9+7;
    int n;
    int k;
	scanf("%d%d", &n, &k);
	vector<int> A;
	for (int i = 0; i < n; i++) {
	    int num;
	    scanf("%d", &num);
	    A.push_back(num);
	}
	vector<int> dp(n, INF);
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
	    for (int j = 1; j <= k; j++) {
	        if (i-j >= 0) {
	            dp[i] = min(dp[i], dp[i-j] + abs(A[i] - A[i-j]));    
	        }
	    }
	}
	printf("%d", dp[n-1]);
}


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

#define zero(a) memset(a,0,sizeof(a))
#define inff(a,n) fill(a,a+n+1,inf)
#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define write(x) printf("%d\n",x)
int main(void)
{
	//freopen("C:\\Users\\YuXiaoKang\\Desktop\\test.txt","r",stdin);
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	string s;
	cin>>s;
	int N=s.length()/2;
	int cnt=0;
	for(int i=0;i<s.length();i++)
    {
        if(s[i]=='p')
        {
            cnt++;
        }
    }
    cout << N-cnt<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int popcount(T n) { return n ? 1 + popcount(n & (n - 1)) : 0; }
#endif
#ifdef __GNUC__
template <class T> int popcount(T n);
template <> int popcount(unsigned int n) { return n ? __builtin_popcount(n) : 0; }
template <> int popcount(int n) { return n ? __builtin_popcount(n) : 0; }
template <> int popcount(unsigned long long n) { return n ? __builtin_popcountll(n) : 0; }
template <> int popcount(long long n) { return n ? __builtin_popcountll(n) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

template <class T> void print(T a, int n, int br = 1, const string& deli = ", ") { cout << "{ "; for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } cout << " }"; while (br--) cout << endl; }
template <class T> void print(const vector<T>& v, int br = 1, const string& deli = ", ") { print(v, v.size(), br, deli); }




int main()
{
	ios::sync_with_stdio(false);

	int T;
	cin >> T;
	while (T--)
	{
		string s;
		cin >> s;
		vector<int> v(s.size());
		for (int i = 0; i < s.size(); ++i)
			v[i] = s[i] - '0';

		int turn = 0;
		for (; v.size() > 1; ++turn)
		{
			int a = v.back(); v.pop_back();
			int b = v.back(); v.pop_back();
			int t = a + b;
			if (t >= 10)
			{
				v.push_back(1);
				t -= 10;
			}
			v.push_back(t);
		}

		cout << (turn % 2 == 0 ? "Audrey" : "Fabre") << " wins." << endl;
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 0, b = 0, c, d, n, k = 0, ans = 0;
string s, t;


int main()
{
	cin >> s;
	Cout(Yes(s[2] == s[3] && s[4] == s[5]));
	

	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map(String::toInt)
    var ary = Array<Long>(k){0}
    var ans = 0L
    (1..n).forEach {i ->  ary[i%k] += 1}
    (0 until k).forEach { a ->
        var b = (k-a) % k
        var c = (k-a) % k
        if ((b+c) % k != 0) return@forEach
        ans += ary[a] * ary[b] * ary[c]
    }
    println(ans)
}

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

typedef long long ll;
typedef long double ld;

ld dp[305][305][305];

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n;
    cin >> n;
    int a = 0, b = 0, c = 0;
    for(int i=1; i<=n; i++){
        int x;
        cin >> x;
        if(x == 1) a++;
        else if(x == 2) b++;
        else if(x == 3) c++;
    }
    for(int k=0; k<=c; k++){
        for(int j=0; j<=b+c; j++){
            for(int i=0; i<=a+b+c; i++){
                if(i == 0 && j == 0 && k == 0) continue;
                dp[i][j][k] = 1;
                if(i >= 1) dp[i][j][k] += dp[i-1][j][k]*i/n;
                if(j >= 1) dp[i][j][k] += dp[i+1][j-1][k]*j/n;
                if(k >= 1) dp[i][j][k] += dp[i][j+1][k-1]*k/n;
                dp[i][j][k] *= 1.0*n/(i+j+k);
            }
        }
    }
    cout << dp[a][b][c];
    return 0;
}


Measured memory_bytes: 438528