akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

struct edge {
    int next,to;
};

const int maxn=(int)(2e5)+5;
int fr[maxn];
int f[maxn];
vector<int> vi[maxn];
edge e[maxn<<1];
int tote=0;

inline void addone(int u,int v) {
    ++tote;
    e[tote].next=fr[u];fr[u]=tote;e[tote].to=v;
}

inline void addedge(int u,int v) {
    addone(u,v);addone(v,u);
}

void dfs(int x,int fa) {
    RAL(i,x) if(e[i].to!=fa) {
        dfs(e[i].to,x);
        vi[x].push_back(f[e[i].to]);
    }
    sort(vi[x].begin(),vi[x].end());
    for(int j=0;j<vi[x].size();j++) f[x]=max(f[x],vi[x][j])+1;
}

int main() {
    int n;
    read(n);
    memset(fr,-1,sizeof(fr));
    REP(i,2,n) {
        int x;
        read(x);
        addedge(x,i);
    }
    dfs(1,0);
    printf("%d\n",f[1]);
    return 0;
}

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

int main () {
  int ans = 0 ;
  int line[5] ;
  int pre = 0 ;
  bool a = true ;
  for(int i = 0 ; i < 5 ; i++ ) {
    cin >> line[i] ;
    if(line[i]%10 != 0 ) a = false ;
  }
  if(!a){
    pre = 9 ;
    for(int i = 0 ; i < 5 ; i++ ){
    int b = min(pre,line[i]%10) ;
    if(b != 0) pre = b ;
    }
  }
  sort(line,line+5) ;
  for(int i = 0; i < 5 ; i++ ){
    ans += ( line[i] - 1 ) / 10 + 1 ;
  }
  if(!a){
    cout << ans * 10 -(10- pre) <<   endl ;
  } else {
    cout << ans * 10 << endl ;
  }
}

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Bits
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,m,q] <- getIntList
    qs <- replicateM q $ do
        [a,b,c,d] <- getIntList
        return (a-1,b-1,c,d)
    let xss = mkl n m
    let ans = maximum $ map (solve qs) xss
    print ans

mkl 1 m = map (:[]) [1..m]
mkl k m = [h:l |l <- mkl (k-1) m, h <- [1..head l]]

solve qs xs = foldl' (\s (a,b,c,d) -> s + if xs' VU.! b - xs' VU.! a == c then d else 0 ) 0 qs
     where xs' = VU.fromList xs

Measured memory_bytes: 5164
// 2011/09/26 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		string str;
		cin >> str;

		for(int i=0; i<n; i++){
			ostringstream os;
			char p = str[0];
			int cnt = 1;
			for(int j=1; j<str.size(); j++)
				if(str[j]==p)
					cnt++;
				else{
					os << cnt;
					os << p;
					p = str[j];
					cnt = 1;
				}
			os << cnt;
			os << p;
			str = os.str();
		}

		cout << str << endl;
	}

	return 0;
}

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

    int a,b,c;

    int A = sc.nextInt();
    int B = sc.nextInt();

    a = A+B;
    b = A-B;
    c = A*B;

    if((a>=b)&&(a>=c)){
      System.out.println(a);
      System.exit(0);
    }
    if((b>=a)&&(b>=c)){
      System.out.println(b);
      System.exit(0);
    }
    if((c>=a)&&(c>=b)){
      System.out.println(c);
      System.exit(0);
    }

  }
}

Measured memory_bytes: 23892
#include <stdio.h>
using namespace std;

int gcd(int m, int n)
{
    if (n == 0)
    {
        return m;
    }
    else
    {
        return gcd(n, m % n);
    }
}
int main()
{
    int n, ans = 0;
    scanf("%d", &n);
    int a, b, c = 1;
    for (a = 1; a <= n; a++)
    {
        for (b = 1; b <= n; b++)
        {
            for (c = 1; c <= n; c++)
            {
                ans += gcd(gcd(a, b), c);
            }
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 1728
#include <iostream>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(void){
  int N, M;
  cin >> N >> M;
  int X[M];
  rep(i, M)
    cin >> X[i];
  //ここまで入力

  //巡る点よりコマの方が多ければ移動はしなくてもよい
  if(N > M){
    cout << 0 << endl;
    return 0;
  }
    
  //昇順にソート
  sort(X, X+M);

  //隣り合う二地点間の距離
  int dis[M-1];
  rep(i, M-1)
    dis[i] = X[i+1] - X[i];

  //二地点間の距離のうち，
  //コマがN-1個あることより
  //距離の大きい方からN-1個は通らなくてもよい
  // (コマで役割を分担して通らないようにできる)
  sort(dis, dis+M-1);
  int ans = 0;
  rep(i, (M-1)-(N-1) )
    ans += dis[i];
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k;
	string s;
	cin >> k >> s;
	if(s.size()<=k) cout << s << endl;
	else cout << s.substr(0,k) << "..." << endl;
}

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

vector<vector<long long int>>M;

long long int FIRSTCOST;
long long int H, W, S;

typedef pair<long long int, long long int> RETURN;
typedef pair<pair<long long int, long long int>, pair<long long int, long long int>> PPLLPLL;

long long int cost( PPLLPLL  P ) {
	return M[P.first.first][P.first.second] + M[P.second.first][P.second.second] - M[P.first.first][P.second.second] - M[P.second.first][P.first.second];
}

map<PPLLPLL, RETURN>dp;

RETURN saiki( PPLLPLL P ) {
	if( FIRSTCOST - cost( P ) > S ) {
		return make_pair( -1, -1 );
	}
	if( dp.count( P ) != 0 ) {
		return dp[P];
	}
	//cout << FIRSTCOST - cost( P ) << " " << S << endl;
	RETURN ret = make_pair( 1, S - (FIRSTCOST - cost( P )) );
	for( size_t i = P.first.first + 1; i < P.second.first; i++ ) {
		PPLLPLL up = P, down = P;
		up.second.first = i;
		down.first.first = i;
		auto retup = saiki( up );
		auto retdown = saiki( down );
		if( retup.first != -1 && retdown.first != -1 ) {
			RETURN retmemo = make_pair( retup.first + retdown.first, min( retup.second, retdown.second ) );
			if( ret.first < retmemo.first || (ret.first == retmemo.first&&ret.second < retmemo.second) ) {
				ret = retmemo;
			}
		}
	}
	for( size_t j = P.first.second + 1; j < P.second.second; j++ ) {
		PPLLPLL right = P, left = P;
		left.second.second = j;
		right.first.second = j;
		auto retleft = saiki( left );
		auto retright = saiki( right );
		if( retleft.first != -1 && retright.first != -1 ) {
			RETURN retmemo = make_pair( retleft.first + retright.first, min( retleft.second, retright.second ) );
			if( ret.first < retmemo.first || (ret.first == retmemo.first&&ret.second < retmemo.second) ) {
				ret = retmemo;
			}
		}
	}
	return dp[P] = ret;
}

int main() {
	while( cin >> H >> W >> S, H || W || S ) {
		dp.clear();
		M = vector<vector<long long int>>( H + 1, vector<long long int>( W + 1 ) );
		for( size_t i = 1; i <= H; i++ ) {
			for( size_t j = 1; j <= W; j++ ) {
				cin >> M[i][j];
			}
		}
		for( size_t i = 0; i < H + 1; i++ ) {
			for( size_t j = 1; j < W + 1; j++ ) {
				M[i][j] += M[i][j - 1];
			}
		}

		for( size_t i = 0; i < W + 1; i++ ) {
			for( size_t j = 1; j < H + 1; j++ ) {
				M[j][i] += M[j - 1][i];
			}
		}

		PPLLPLL firstX = make_pair( make_pair( 0, 0 ), make_pair( H, W ) );
		FIRSTCOST = cost( firstX );
		auto ans = saiki( firstX );
		cout << ans.first << " " << ans.second << endl;
	}
}

Measured memory_bytes: 29132
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
#define dwn(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	int n, t, a;
	cin >> n >> t >> a;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	vector<double> b(n);
	rep(i, n) {
		b[i] = t - h[i] * 0.006;
	}
	rep(i, n) {
		b[i] = abs(a - b[i]);
	}
	double mi = INF;
	int ans;
	rep(i, n) {
		if (mi > b[i]) {
			mi = b[i];
			ans = i + 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n;
ll x,b[100005],l[100005],u[100005];
vector<pair<ll,int>>vec;
vector<ll>rui;
int pos[100005];

int main(){
	scanf("%d%lld",&n,&x);
	ll cur = 0;
	rep(i,n){
		scanf("%lld%lld%lld",&b[i],&l[i],&u[i]);
		cur -= b[i]*l[i];
		vec.pb(mp(u[i]*(x-b[i])+l[i]*b[i],i));
	}
	sort(vec.begin(),vec.end(),greater<pair<ll,int>>());
	rep(i,vec.size()){
		ll cur = 0;
		if(i) cur = rui.back();
		cur += vec[i].fi;
		rui.pb(cur);
		pos[vec[i].sc] = i;
	}
	ll ans = 1e18;
	rep(i,n){
		int lb = -1,ub = n;
		while(ub-lb > 1){
			int mid = (lb+ub)/2;
			ll sum = 0;
			if(pos[i] >= mid) sum = (mid?rui[mid-1]:0);
			else sum = rui[mid]-(u[i]*(x-b[i])+l[i]*b[i]);
			if(cur+sum+(u[i]*(x-b[i])+l[i]*b[i]) >= 0) ub = mid;
			else lb = mid;
		}
		assert(ub != n);
		ll res = 1LL * ub * x;
		{
			ll sum = 0;
			if(pos[i] >= ub) sum = (ub?rui[ub-1]:0);
			else sum = rui[ub]-(u[i]*(x-b[i])+l[i]*b[i]);
			
			ll need = -cur-sum;
			if(need <= 0){
				ans = min(ans,res);
			}
			else if(need <= l[i]*b[i]){
				ans = min(ans,res+(need+l[i]-1)/l[i]);
			}
			else{
				assert(need <= l[i]*b[i]+u[i]*(x-b[i]));
				need -= l[i]*b[i];
				ans = min(ans,res+b[i]+(need+u[i]-1)/u[i]);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  bool check = true;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    if(a % 2 == 1) check = false;
  }

  if(check) cout << "second" << endl;
  else cout << "first" << endl;

  return 0;
}

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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var ly = Enumerable.Range(0, 3001)
				.Select(i => (i % 4 == 0 && (i % 400 == 0 || i % 100 != 0))).ToArray();
			var ab = new int[2];
			var f = false;
			while ((ab = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray()).Sum() > 0)
			{
				if (f) Console.WriteLine();
				var u = new List<int>();
				for (int i = ab[0]; i <= ab[1]; i++)
					if(ly[i])
						u.Add(i);
				if(u.Count>0)
					for(int i=0;i<u.Count;i++)
						Console.WriteLine(u[i]);
				else
					Console.WriteLine("NA");
				f = true;
			}
		}
	}
}

Measured memory_bytes: 6012
// test1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
    int n, t;
    cin >> n >> t;
    if (n >9) {
        cout << t << endl;
    }
    else {
        cout<<(10 - n) * 100 + t << endl;
    }
    
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
int main()
{
	int a, b;
	int c = 0;
	char op;
	while (cin >> a >> op >> b, op != '?') {
		if (op == '+') {
			c = a + b;
		}
		if (op=='-'){
			c = a - b;
		}
		if (op == '*') {
			c = a * b;
		}
		if (op == '/') {
			c = a / b;
		}
		cout << c << endl;

	}
}



Measured memory_bytes: 3056
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

int n;
int dp[30];

char s[N];

vector < int > v[26];

int go(int pos){
  if(pos > 25){
    return 1;
  }
  if(dp[pos] != -1){
    return dp[pos];
  }
  int ret = 0;
  if(v[pos].size() == 0){
    ret = go(pos + 1) % mod;
  } else {
    ret = 1ll * v[pos].size() * go(pos + 1) % mod + go(pos + 1);
    ret %= mod;
  }
  return dp[pos] = ret;
}

int main(){
  fastScan(n);
  scanf("%s", s);
  for(int i = 0; s[i] ; i++){
    v[s[i] - 'a'].pb(i);
  }
  memset(dp, -1, sizeof dp);
  printf("%d\n", (go(0) - 1 + mod) % mod);
}


Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
struct Can {
		long long int a, b;
	};
	typedef struct Can C;
	
int myCompare(C c1, C c2) {
	return c1.a < c2.a;
}

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

	vector<C> v;
	for (int i = 0; i < n; i++) {
		C temp;
		cin >> temp.a >> temp.b;
		v.push_back(temp);
	}
	sort(v.begin(), v.end(), myCompare);
	long long int res = 0;
	for (int i = 0; i < n; i++) {
		if (m > v[i].b) {
			m -= v[i].b;
			res += v[i].b * v[i].a;
		}
		else {
			res += m * v[i].a;
			break;
		}
	}
	cout << res;

}

Measured memory_bytes: 2420
#include<iostream>
#include<vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    cin>>N;
    if(N==3){
      cout<<"YES"<<endl;
    }else if(N==5){
      cout<<"YES"<<endl;
    }else if(N==7){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
    
    return 0;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main() {
    int n, m;
    cin >> n >> m;
    vector<ll>a(n);
    vector<pll>b(m);
    ll sum = 0;
    rep(i, 0, n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    rep(i, 0, m)cin >> b[i].second >> b[i].first;
    sort(b.begin(),b.end(),greater<pll>());
    int j = 0,t = 0;
    rep(i, 0, n){
        if(i+1>b[j].second+t){
            t += b[j].second;
            j++;
        }
        if(j == m){
            sum += a[i];
            continue;
        }
        sum += max(a[i],b[j].first); 
    }
    cout << sum << endl;
}

Measured memory_bytes: 2560
# 解説を参考に作成

# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(X, Y, Z, K, As, Bs, Cs):
    ABs = []
    for A in As:
        for B in Bs:
            ABs.append(A + B)
    ABs.sort(reverse=True)
    ABCs = []
    for i in range(min(X * Y, K)):
        AB = ABs[i]
        for C in Cs:
            ABCs.append(AB + C)
    ABCs.sort(reverse=True)
    for i in range(K):
        print(ABCs[i])


if __name__ == '__main__':
    # S = input()
    # N = int(input())
    X, Y, Z, K = map(int, input().split())
    As = [int(i) for i in input().split()]
    Bs = [int(i) for i in input().split()]
    Cs = [int(i) for i in input().split()]
    # import random
    # X, Y, Z, K = 1000,1000,1000,3000
    # As = [random.randint(1, 10 ** 10) for _ in range(X)]
    # Bs = [random.randint(1, 10 ** 10) for _ in range(Y)]
    # Cs = [random.randint(1, 10 ** 10) for _ in range(Z)]
    solve(X, Y, Z, K, As, Bs, Cs)


Measured memory_bytes: 217640
#include<bits/stdc++.h>
using namespace std;
namespace Flandle_Scarlet
{
    #define N 1010
    #define MEM(x,a) memset(x,a,sizeof(x))
    #define CLS(x) memset(x,0,sizeof(x))
    int n,m;
    int a[N][N];
    void R1(int &x)
    {
        x=0;char c=getchar();int f=1;
        while(c<'0' or c>'9') f=(c=='-')?-1:1,c=getchar();
        while(c>='0' and c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
        x=(f==1)?x:-x;
    }
    void Input()
    {
        R1(n),R1(m);
        for(int i=1;i<=n;++i)
        {
            for(int j=1;j<=m;++j)
            {
                R1(a[i][j]);
            }
        }
    }

    struct node
    {
        int id;//identifier
        int cnt;//favourite count
    }sport[N];bool operator<(node a,node b){return a.cnt>b.cnt;}
    bool vis[N];
    void Soviet()
    {
        //choose all
        for(int i=1;i<=n;++i)
        {
            ++sport[a[i][1]].cnt;
            sport[i].id=i;
        }

        int ans=0x3f3f3f3f;
        for(int i=1;i<=m;++i)
        {
            sort(sport+1,sport+m+1);
            //sport[1] have the max cnt
            ans=min(ans,sport[1].cnt);

            vis[sport[1].id]=1;//delete the most popular sport
            CLS(sport);
            for(int i=1;i<=m;++i)
            {
                sport[i].id=i;
            }
            for(int i=1;i<=n;++i)//for each player
            {
                for(int j=1;j<=m;++j)//find the favourite sport in all remaining sport
                {
                    if (!vis[a[i][j]])
                    {
                        ++sport[a[i][j]].cnt;
                        break;
                    }
                }
            }
        }
        printf("%d\n",ans);
    }
    void IsMyWife()
    {
        if (0)
        {
            freopen("","r",stdin);
            freopen("","w",stdout);
        }
        Input();
        Soviet();
    }
};
int main()
{
    Flandle_Scarlet::IsMyWife();
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

struct sieve
{
    int n;
    vector<int> f, primes;

    sieve(int n = 1) : n(n), f(n + 1)
    {
        for (int i = 2; i <= n; i++)
        {
            if (f[i])
                continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = (ll)i * (ll)i; j <= n; j += i)
            {
                if (!f[j])
                    f[j] = i;
            }
        }
    }

    bool isPrime(int x)
    {
        return f[x] == x;
    }
};

int main()
{
    int Q;
    cin >> Q;
    int largest = 0;
    vector<P> q(Q);
    rep(i, Q)
    {
        cin >> q[i].first >> q[i].second;
        largest = max(largest, q[i].second);
    }
    sieve s(largest);
    vector<int> simCount(largest + 1);
    for (int i = 3; i <= largest; i += 2)
    {
        simCount[i] = simCount[i - 2];
        simCount[i - 1] = simCount[i - 2];
        if (s.isPrime(i) && s.isPrime((i + 1) / 2))
        {
            simCount[i]++;
        }
    }

    rep(i, Q)
    {
        cout << (simCount[q[i].second] - simCount[q[i].first - 1]) << endl;
    }

    return 0;
}

Measured memory_bytes: 2304
#include <stdio.h>
#define H 250

struct a{
  int id;
  int k;
  int pk;
  int lk;
  int rk; 
};

int main()
{
  struct a node[H];
  int i, h;

  scanf("%d",&h);
  for(i=0;i<h;i++){
    scanf("%d",&node[i].k);
    node[i].id=i+1;
  }

  for(i=0;i<h;i++){
    if(i!=0){
      node[i].pk=node[node[i].id/2-1].k;
    }
    if((i+1)*2<=h){
      node[i].lk=node[2*node[i].id-1].k;
    }
    if((i+1)*2+1<=h){
      node[i].rk=node[2*node[i].id].k;
    }
  }

  for(i=0;i<h;i++){
    if(i==0) printf("node %d: key = %d, left key = %d, right key = %d, \n", i+1, node[i].k, node[i].lk, node[i].rk);

    else if((i+1)*2>h) printf("node %d: key = %d, parent key = %d, \n", i+1, node[i].k, node[i].pk);

    else if((i+1)*2+1>h) printf("node %d: key = %d, parent key = %d, left key = %d, \n", i+1, node[i].k, node[i].pk, node[i].lk);

    else printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n",i+1,node[i].k, node[i].pk, node[i].lk,node[i].rk);
  }
  return 0;
}


Measured memory_bytes: 2112
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = []
for i in range(n):
    a.append(list(map(int, input().split())))

ans=0
for target in a:
    re=c
    for i in range(len(target)):
        re+=(b[i]*target[i])
    
    if re > 0:
        ans+=1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
using namespace std;
 //for study
int n, a[100005];
string s;
int main() {
	int i, k;
	cin>>s;
	n = s.size();
	for(i=0; i<n; i++) {
		if(s[i]=='R') k = i;
		else a[k + (i-k)%2]++;
	}
	for(i=n-1; i>=0; i--) {
		if(s[i]=='L') k = i;
		else a[k - (k-i)%2]++;
	}
	for(i=0; i<n; i++) printf("%d ", a[i]);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

bool isPrime(int n){
  for(int i=2;i*i<=n;++i)
    if(n%i==0) return false;
  return n!=1;
}

int main(){
  int a,d,n;

  while(cin>>a>>d>>n,a,d,n){
    int cnt=0;
    if(isPrime(a)==true)
      cnt++;
    while(cnt<n){
      a+=d;
      if(isPrime(a)==true)
	cnt++;
    }
    cout<<a<<endl;
  }
}

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

uint64_t getZ() {
  uint64_t v = 0; int c;
  while((c = getchar_unlocked()) >= '0') v=v*10+c-'0';
  return v;
}

int main() {
  int N = getZ();
  int ans = 0, tmp = 0, pH = 0;
  for(int i = 0; i < N; ++i) {
    int H = getZ();
    if(H <= pH) ++tmp;
    else {
      ans = std::max(ans, tmp);
      tmp = 0;
    }
    pH = H;
  }
  ans = std::max(ans, tmp);
  fin(ans);
  return 0;
}


Measured memory_bytes: 256
import copy
a = list(map(int,input().split()))
nokori  = copy.copy(a)
count = max(a)
nokori.remove(count)
"""
if a[0] == a[1] == a[2]:
    print("No")
"""
if int(nokori[0] + nokori[1]) == count:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3444
n=int(input())
p=list(map(int, input().split()))
t=0
for i in range(n):
    if i!=0 and i!=n-1:
      l=[p[i-1], p[i], p[i+1]]
      l.sort()
      if l[1]==p[i]:
          t+=1
print(t)


Measured memory_bytes: 2940
S=input()
lenS=len(S)+1
ans="Yes"
if lenS % 2!=0 :
	for i in range(2,lenS,2) :
		if (S[i-2]!="h" or S[i-1]!="i") :
			ans="No"
			break
else:
	ans="No"
print(ans)

Measured memory_bytes: 2940
#include<iostream>
#include <bits/stdc++.h>
#include <cstdio>
#include<set>
using namespace std;
int main()
{
    string S;
    
    cin >> S;
    
    if (S == "Sunny"){
        cout << "Cloudy";
    }
    if (S == "Cloudy"){
        cout << "Rainy";
    }
    if (S == "Rainy"){
        cout << "Sunny";
    }
    return 0;
}


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

cnt_w = [0] * (N+1) # 左からWの数
cnt_e = [0] * (N+1) # 右からEの数
for i in range(N):
    if S[i] == "W":
        cnt_w[i+1] = cnt_w[i] + 1 
    else:
        cnt_w[i+1] = cnt_w[i]
for i in range(N-1,-1,-1):
    if S[i] == "E":
        cnt_e[i] = cnt_e[i+1] + 1 
    else:
        cnt_e[i] = cnt_e[i+1]

# print("W",cnt_w)
# print("E",cnt_e)
ans = [w+e for w,e in zip(cnt_w,cnt_e)]
print(min(ans))

Measured memory_bytes: 29724
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C(I) cout<<(I)<<endl

ll n,m,a,b,c,x,y,z,aa[100010],ba[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc;
vector<ll> va,vb,vc;

int gcd(ll tara,ll tarb){ //最大公約数
    ll am=1;
    while(am){
        am=tara%tarb;
        tara=tarb;
        tarb=am;
    }
    return tara;
}


ll nCr(ll maxnum,ll target){
    if(maxnum==target or target==0)return 1;
    else{
        maxnum++;
        ll numerator=1,denominator=1,gc=0;
        for(ll i=1;i<=target;i++){
            denominator*=i;
            numerator*=(maxnum-i);
            gc=gcd(numerator,denominator);
            denominator/=gc;
            numerator/=gc;
        }
        return numerator/denominator;
    }
}



int main(){
    cin>>n>>a;
    
    for(int i=0;i<n;i++){
        cin>>aa[i];
        ba[aa[i]%2]++;
    }
    x=0; // 1を偶数個選ぶ
    y=0; // 1を奇数個選ぶ
    z=0; // 0を選ぶ
    
    for(int i=0;i<=ba[0];i++){
        z+=nCr(ba[0],i);
    }
    
    for(int i=0;i<=ba[1];i++){
        if(i%2==0){
            x+=nCr(ba[1],i);
        }
        else{
            y+=nCr(ba[1],i);
        }
    }
    C(z*(a ? y:x));
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    
    int r, c, i, j, A[100][100], x=0, y=0, z=0;
    
    scanf("%d %d", &r, &c);
    
    for(i=0; i<r; i++){
        for(j=0; j<c; j++){
            scanf("%d", &A[i][j]);
        }
    }
    
    for(i=0; i<r; i++){
        for(j=0; j<c; j++){
            printf("%d ", A[i][j]);
            x=x+A[i][j];
            if(j==c-1){
                printf("%d\n",x);
                x=0;
            }
        }
        if(i==r-1){
            for(j=0; j<c; j++){
                for(i=0; i<r; i++){
                    y=y+A[i][j];
                }
                printf("%d ", y);
                z=z+y;
                y=0;
            }
            printf("%d\n", z);
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  int n;
  cin >> n;
  if (n % 2  == 0){
    cout << n/ 2 << '\n';
  }
  else{
    cout << n / 2 + 1 << '\n';
  }
  return 0;   
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
//#include<cstdio>//"scanf("%lf",&(double));printf("%f",(double));"
//#include<iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
//#include<string>//"reverse(s's it,s's it)"
//#include<functional>//"greater<T>" "sort(a,a+n,greater<int>());""
//#include<cmath>//"abs" "sqrt"
//#include<numeric>//"accumulate(inputit,inputit,init,(optional) object)"
//#include<algorithm>//"lower_bound(it,it,v)" "next_permutation(a,a+n)"
//"reverse(v's it,v's it)"(v: vector)
//#include<cassert>//"assert(cond);": error if cond doesn't hold.
using namespace std;
#define pb push_back//also for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert//also use as v.is(v's it,w's it,w's it);//Be careful in topcoder
#define ps push//stack,(priority) queue,//Be careful in topcoder.
#define fr front//queue//for priority, use top().//Be careful in topcoder.
typedef long long ll;//not necessarily//Be careful in topcoder.
typedef pair<int,int> pii;//Be careful in topcoder.
//Add other types in the same way.
const ll M = 1000000007;//can be changed
ll mod(ll a){	return (a + M) % M;	}//M can be a variable
void plmod(ll &a,ll b){	a = (a + b + M) % M;	return;	}
void mnmod(ll &a,ll b){	a = (a - b + M) % M;	return;	}
void mlmod(ll &a,ll b){	a = (a * b) % M;  	return;	}
//Caution! you may need sth larger than "+M"!
void chmax(int &a,int b){	a = max(a, b);	return;	}
void chmin(int &a,int b){	a = min(a, b);	return;	}
//These 2 could be better in long long

#define MAX_N 100000

int n,a[MAX_N];

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        int x;
        scanf("%d",&x);
        if(x%2!=0) goto first;
    }
    printf("second\n");
    return 0;
first:
    printf("first\n");
    return 0;
}


Measured memory_bytes: 256
n = int(input())
b = [int(i) for i in input().split()]
#b.append(b[len(b-1)])
#print(b)
b.append(100000)
#print(b)
a = b[0]
for i in range(n-1):
  a += min(b[i],b[i+1])
  #print(b[i],b[i+1],a)
print(a)

Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
	int ans;
	int b, r, g, c, s, t;
	
	while (1){
		ans = 100;
		
		scanf("%d%d%d%d%d%d", &b, &r, &g, &c, &s, &t);
		if (t == 0){
			break;
		}
		
		ans -= (t - s - (b * 5) - (r * 3)) * 3 + ((b * 5) + (r * 3)) * 2;
		ans += c * 2;
		ans += g * 7;
		ans += r * 60;
		ans += b * 90;
		
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define mkpr make_pair
#define ft first
#define sd second

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template<class T>
inline void read(T &x) {
    x=0; int f=0; char ch=getchar();
    while(!isdigit(ch)) {if(ch=='-') f=1; if(ch==EOF) return; ch=getchar();}
    while(isdigit(ch)) {x=x*10+(ch-'0'); ch=getchar();} if(f) x=-x;
}

/***********************************************************/

const int MAXN=100011;
int a[MAXN], b[MAXN], c[MAXN], d[MAXN], vis[MAXN];
int fa[MAXN], pre[MAXN];
int n, m;

inline int getfa(int x) {
    return fa[x]==x ? x : fa[x]=getfa(fa[x]);
}

int main() {
    scanf("%d", &n);
    for(int i=1;i<=n;++i) {
        scanf("%d", &a[i]);
        a[n+1]^=a[i];
    }
    for(int i=1;i<=n;++i) {
        scanf("%d", &b[i]);
        b[n+1]^=b[i];
    }
    for(int i=1;i<=n+1;++i) {
        fa[i]=i;
        c[i]=a[i];
        d[i]=b[i];
    }
    sort(c+1, c+2+n);
    sort(d+1, d+2+n);
    for(int i=1;i<=n+1;++i) {
        if(c[i]!=d[i]) {
            puts("-1");
            return 0;
        }
    }
    int cnt=0, ans=0;
    for(int i=1;i<=n+1;++i) {
        if(a[i]!=b[i]) ++cnt;
    }
    ans=cnt;
    int sz=unique(c+1, c+2+n)-c-1;
    for(int i=1;i<=n+1;++i) {
        a[i]=lower_bound(c+1, c+sz+1, a[i])-c;
        b[i]=lower_bound(c+1, c+sz+1, b[i])-c;
        // V[a[i]].push_back(i);
        if(i<=n && a[i]==b[i]) continue;
        if(pre[a[i]]) {
            int fx=getfa(i), fy=getfa(pre[a[i]]);
            if(fx!=fy) {
                --cnt;
                fa[fx]=fy;
            }
        } else {
            pre[a[i]]=i;
        }
    }
    for(int i=1;i<=n+1;++i) {
        if(a[i]!=b[i]) {
            int fx=getfa(i), fy=getfa(pre[b[i]]);
            if(fx!=fy) {
                --cnt;
                fa[fx]=fy;
            }
        }
    }
    // cerr<<cnt<<endl;
    ans+=cnt;
    if(a[n+1]!=b[n+1]) {
        printf("%d\n", ans-2);
    } else {
        printf("%d\n", ans);
    }
    return 0;
}

/**
4
5 6 6 7
6 5 7 6
----------
5


5
5 2 0 6 7
2 5 6 6 0
----------
5
**/

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

#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9;
const ll INF = 1e18;

int n, m;
int tree[800010];
int lazy[800010];

void propagate(int node, int s, int e) {
	if(!lazy[node]) return;

	tree[node] = s - lazy[node];

	if(s != e) {
		lazy[node*2] = lazy[node*2+1] = lazy[node];
	}

	lazy[node] = 0;
}

void update(int node, int s, int e, int l, int r, int x) {
	propagate(node, s, e);

	if(r < s || e < l) return;
	if(l <= s && e <= r) {
		lazy[node] = x;
		propagate(node, s, e);
		return;
	}

	update(node*2, s, (s+e)/2, l, r, x);
	update(node*2+1, (s+e)/2+1, e, l, r, x);

	tree[node] = min(tree[node*2], tree[node*2+1]);
}

int cal(int node, int s, int e, int l, int r) {
	propagate(node, s, e);

	if(r < s || e < l) return inf;
	if(l <= s && e <= r) return tree[node];

	return min(cal(node*2, s, (s+e)/2, l, r), cal(node*2+1, (s+e)/2+1, e, l, r));
}

int main() {
	fast;

	cin >> n >> m;

	int s = 1;

	for(int i=1; i<=n; i++) {
		int a, b;
		cin >> a >> b;

		if(a <= s) {
			if(b >= s) update(1, 1, m, 1, max(b, s-1), -inf);

			s = max(s, b + 1);
		}
		else {
			int k = a - 1 - cal(1, 1, m, a-1, a-1);
			update(1, 1, m, a, b, k);
		}

		if(cal(1, 1, m, 1, m) >= inf) cout << "-1\n";
		else cout << i + cal(1, 1, m, 1, m) << "\n";
	}
}

Measured memory_bytes: 7764
X, Y, Z, k = (int(x) for x in input().split())
A = list(int(x) for x in input().split())
B = list(int(x) for x in input().split())
C = list(int(x) for x in input().split())

AB = []
for x in range(X):
    for y in range(Y):
        AB.append(A[x] + B[y])
AB.sort(reverse=True)
C.sort(reverse=True)

ANS = []
for i in range(min(k, X * Y)):
    for z in range(Z):
        ANS.append(AB[i] + C[z])
ANS.sort(reverse=True)

for ans in ANS[:k]:
    print(ans)


Measured memory_bytes: 214432
# -*- coding: utf-8 -*-
# 入力
a, b, c, d = map(int, input().split())

# 処理
dist_ab = abs(b - a)
dist_bc = abs(c - b)
dist_ac = abs(c - a)

if dist_ac <= d or (dist_ab <= d and dist_bc <= d):
    ans = 'Yes'
else:
    ans = 'No'

# 出力
print(ans)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    int b,c=0,k=0,n,h,w,m,ans=0,max=-10;
    string s,s2;
    cin >> n; 
    int j=0;
    for(int i=1; i<=n; i++){
        j = i;
        while(j%2==0){
            j = j / 2;
            c++;
        }
        if (max < c){
            max = c;
            ans = i;
        }
        c=0;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N - 1));
    for(int i=0; i<N; ++i) {
        for(int j=0; j+1<N; ++j) {
            cin >> A[i][j];
            --A[i][j];
        }
    }

    vector<int> head(N, 0);
    vector<int> day(N, 0);
    while(true) {
        bool done = true;
        for(int i=0; i<N; ++i) {
            if(head[i] != N - 1) done = false; 
        }
        if(done) break;

        bool flag = true;
        for(int i=0; i<N; ++i) {
            if(head[i] == N - 1) continue;
            int c = A[i][head[i]];
            if(A[c][head[c]] == i) {
                head[c] += 1;
                head[i] += 1;
                int tmp = max(day[i], day[c]) + 1;
                day[i] = tmp;
                day[c] = tmp;
                flag = false;
            }
        }
        if(flag) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    int res = 0;
    for(int i=0; i<N; ++i) res = max(res, day[i]);
    cout << res << endl;
}

Measured memory_bytes: 4224
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


int main()
{
    
    int N;
    cin >> N;
    vector<int> p(N);
    int cnt = 0;
    vector<int> down(2);
    for(int i=0;i<N;i++)
    {
        cin >> p[i];
        if(i > 0 && p[i-1] > p[i])
        {
            if(cnt >= 2)
            {
                cout << "NO" << endl;
                return 0;
            }
            down[cnt] = i;
            cnt++;
        }
    }
    if(cnt == 0)
    {
        cout << "YES" << endl;
        return 0;
    }
    int flag = 0;
    for(int i=0;i<cnt;i++)
    {
        for(int j=i+1;j<cnt;j++)
        {
            swap(p[down[i]-1], p[down[j]]);
            ////
//            for(int a=0;a<N;a++) cout << p[a] << " ";
//            cout << endl;
            ////
            int l = max(0, down[i]-2);
            int r = min(N-1, down[i]+1);
            for(int k = l;k < r; k++)
            {
                if(p[k] > p[k+1]) flag = 1;
            }
            l = max(0, down[j]-2);
            r = min(N-1, down[j]+1);
            for(int k = l;k < r; k++)
            {
                if(p[k] > p[k+1]) flag = 1;
            }
            if(flag == 0)
            {
                cout << "YES" << endl;
                return 0;
            }
            flag = 0;
            swap(p[down[i]-1], p[down[j]]);
        }
    }
    
    cout << "NO" << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
# AtCoder Group Contest

# input process
N = int(input())
a_list = list(map(int, input().split()))

# initialization
a_list = sorted(a_list, reverse=True)
a_max = 0

# sum process
for i in range(2*N): # 2 ~ 2Nまで
    if not i%2==0:
        a_max += a_list[i]

print(a_max)


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

using namespace std;

/**/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define wt(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define wt(x...)
#endif
/**/

#define LL long long
const int MAXN = 212345;
const int INF  = 0x3f3f3f3f;



int main () {

	ios_base::sync_with_stdio(false);  cin.tie(NULL); 

	int n;
	cin >> n;

	std::vector<double> v;

	for (int i = 0; i < n; ++i) {
		double x;
		cin >> x;
		v.push_back(x);
	}

	double ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += (1.0/v[i]);
	}

	ans = (1.0 / ans);

	cout << fixed << setprecision (10) << ans << '\n';



	return 0;
}



Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

vll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;
ll d[base10_5+10];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    cin >> M;
    rep(ni,N+10) A.push_back(1);
    rep(mi,M){
        cin >> ltmp;
        A[ltmp]=0;
    }
    d[1] = 1 * A[1];
    d[2] = (d[1] + 1) * A[2];
    for( ll ni = 3 ; ni <=N ; ni++ ){
        d[ni] = d[ni-1] + d[ni-2];
        d[ni] *= A[ni];
        d[ni] %= MOD;
    }

    cout << d[N] << endl;


}

Measured memory_bytes: 4772
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <list>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, a, b, color[100008];

int main(){
	cin >> n;
	vector<list<ll>> edge(n+1);
	for(ll i = 1; i <= n-1; i++){
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	
	for(ll i = 2; i <= n-1; i++){color[i] = 0;}
	color[1] = -1;
	color[n] = 1;
	queue<ll> fennec, snuke;
	fennec.push(1);
	snuke.push(n);
	ll cntb = 1;
	ll cntw = 1;
	
	while(!fennec.empty() || !snuke.empty()){
		ll ite = fennec.size();
		for(ll i = 1; i <= ite; i++){
			ll at = fennec.front(); fennec.pop();
			for(ll next : edge[at]){
				if(color[next] == 0){
					color[next] = -1;
					cntb++;
					fennec.push(next);
				}
			}
		}
		
		ite = snuke.size();
		for(ll i = 1; i <= ite; i++){
			ll at = snuke.front(); snuke.pop();
			for(ll next : edge[at]){
				if(color[next] == 0){
					color[next] = 1;
					cntw++;
					snuke.push(next);
				}
			}
		}
	}	
	
	string ans = "Fennec";
	if(cntb <= cntw){ans = "Snuke";}
	cout << ans << endl;
	/*for(ll i = 1; i <= n; i++){
		for(ll j : edge[i]){
			cout << j << " ";
		}
		cout << endl;
	}*/
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> v(n);
  for (int i = 0; i < n; i++) {
    int x, l;
    cin >> x >> l;
    v[i] = make_pair(x+l, x-l);
  }

  sort(v.begin(), v.end());
  int p = v[0].first, ans = 1;
  for (int i = 1; i < n; i++) {
    if (p <= v[i].second) {
      p = v[i].first;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int n;
long long sum=0;

int main(){
    cin >> n;
    for(int i=1;i<n+1;i++) {
        if((i%3 != 0) & (i%5 != 0)){
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
#include <cmath>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main() {
  int N, M;
  cin >> N >> M;
  
  Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

  vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
  queue<int> que;

  // 初期条件 (頂点 0 を初期ノードとする)
  dist[0] = 0;
  que.push(0); // 0 を橙色頂点にする

  int ans[200010];
  
  // BFS 開始 (キューが空になるまで探索を行う)
  while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
            ans[nv] = v;
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
  //for (int v = 0; v < N; ++v) cout << v << ": " << dist[v] << endl;
  cout << "Yes" << endl;
  for (int v = 1; v < N; ++v) cout << ans[v]+1 << endl;
  
}

Measured memory_bytes: 10712
#include <iostream>
#include <vector>
#include <map>
using namespace std;
//see answer
int main() {
	int N, K;
	cin >> N >> K;
	vector<long long>A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	map<long long, int> Nums;
	for (int i = 0; i < N; i++) {
		long long now = 0;
		for (int j = i; j < N; j++) {
			now += A[j];
			Nums[now]++;
		}
	}
	long long ans = 0;
	int num = 0;
	for (int k = 40; k >= 0; k--) {
		ans += (1ll << k);
		num = 0;
		for (auto p : Nums) {
			if ((p.first & ans) == ans) num += p.second;
		}
		if (num < K) ans -= (1ll << k);
	}
	cout << ans << endl;
}

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

int main(){
  string s;
  cin>>s;
  int count=0;
  vector< char > vect1,vect2;
  for(int i=0;i<s.length();i++){
    if(i&1){
      vect1.push_back('1');
      vect2.push_back('0');
    }
    else{
      vect1.push_back('0');
      vect2.push_back('1');
    }
  }
  /*for(int i=0;i<s.length();i++){
    cout<<vect1[i];
  }
  cout<<"\n";
  for(int i=0;i<s.length();i++){
    cout<<vect2[i];
  }*/
  int count1=0,count2=0;
  for(int i=0;i<s.length();i++){
    if(vect1[i]!=s[i]){
      count1++;
    }
    else if(vect2[i]!=s[i]){
      count2++;
    }
  }
  cout<<min(count1,count2);

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
  int n, k; cin >> n >> k;
  string s; cin >> s;

  s[k-1] = tolower(s[k-1]);

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256