akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


int s[15];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	if (n == 1) {
		cout << 1 << " " << 1 << endl; return 0;
	}
	vector<int>a(n); 
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		s[a[i]/400]++;
	}
	int sum = 0;
	rep(i, 8) {
		if (s[i] > 0) {
			sum++;
		}
	}
	
		int sum2 = 0;
		for (int i = 8; i < 15; i++) {
			if (s[i] > 0) {
				sum2 += s[i];
			}
		}
		if(sum!=0)cout << sum << " " << sum + sum2 << endl;
		else cout << 1 <<" " <<sum + sum2 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int n = b - a;
		System.out.println((n * (n - 1))/2 - a);
	}
}

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

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> p(n);
    for(int i=0; i<n; i++){
        cin >> p.at(i);
    }
    ll sum_p=0;
    for(int i=0; i<k; i++){
        sum_p+=p.at(i);
    }
    ll max_sum=sum_p;
    for(int i=0; i<n-k; i++){
        sum_p = sum_p - p.at(i) + p.at(i+k);
        if(sum_p > max_sum){
            max_sum = sum_p;
        }
    }
    if((k+max_sum) % 2 == 0){
        cout << (k+max_sum)/2 << endl;
    }
    else{
        cout<<fixed<<setprecision(8)<<(k+max_sum)/2+0.50000000<< endl;
    }
}


Measured memory_bytes: 4804
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define MP make_pair 
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef const void CV;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
const int INF = (int)1e9;
const int mod = (int)1e9+7;
const int MAX = (int)2e5+5;
map<LL, int>check;
int store[MAX];
int main(void){
	DRI(n);
	LL ans = 0;
	LL sum = 0;
	rep1(i, 1, n+1) scanf("%d", store + i);
	rep1(i, 1, n+1){
		check[ sum ]++;
		sum += store[i];
		ans += check[ sum ];
	}
	printf("%lld", ans);
	return 0;
}


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

int main() {
	int a,b,ans;
	char op;

	while(1){
		cin >> a >> op >> b;
		if(op == '?'){
			break;
		}else if(op == '+'){
			ans = a + b;
			cout << ans << endl;
		}else if(op == '-'){
			ans = a - b;
			cout << ans << endl;
		}else if(op == '*'){
			ans = a * b;
			cout << ans << endl;
		}else if(op == '/'){
			ans = a / b;
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3068
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int main() {
    int h, w;
    cin >> h >> w;

    string s;
    for (int i = 0; i < h; i++) {
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import math

n = int(input())


def primes(x):
    if x < 2:
        return []

    primes = [i for i in range(x)]
    primes[1] = 0

    for prime in primes:
        if prime > math.sqrt(x):
            break
        if prime == 0:
            continue
        for non_prime in range(2 * prime, x, prime):
            primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]


ans = []
for p in primes(55555):
    if p % 5 == 1:
        ans.append(p)
    if len(ans) == n:
        break

print(' '.join([str(x) for x in ans]))

Measured memory_bytes: 5272
#ABC 45C - たくさんの数式
def main():
    s = (input())
    n = len(s)
    total = 0
    for i in range(2**(n-1)):
        op = [""]*(n-1)
        for j in range(n-1):
            if ((i >>j)) & 1:
                op[n-1-1-j] = "+"
        formula = ""
        for p_s, p_o in zip(s, op + [""]):
            formula += (p_s + p_o)
        total += eval(formula)
    print(total)
main()

Measured memory_bytes: 3060
from math import sqrt

max_lr = 10 ** 5

sieve = [True] * (max_lr + 1)
sieve[0] = False
sieve[1] = False
for i in range(2, int(sqrt(max_lr)) + 1):
    if not sieve[i]:
        continue
    for j in range(i * i, max_lr + 1, i):
        sieve[j] = False

cs = [0] * (max_lr + 1)
for i in range(3, max_lr + 1, 2):
    if sieve[i] and sieve[(i + 1) // 2]:
        cs[i] = 1
for i in range(1, max_lr + 1):
    cs[i] += cs[i - 1]

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(cs[r] - cs[l - 1])


Measured memory_bytes: 7156
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define pie 3.14159265358979323846
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
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 RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
bool greater_pair(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first!=b.first){
        return a.first>b.first;
    }else{
        return a.second>b.second;
    }
}
int main() {
    ios::sync_with_stdio(false);
    int N=in();
    map<string,int> mp;

    REP(i,N){
        string s=in<string>();
        mp[s]++;
    }
    cout<<mp.size()<<endl;

    return 0;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

ll const MAX_N = 100000;
vector<ll> prime;	//i番目の素数
bool is_prime[MAX_N + 1];	//is_prime[i]がtrueならばiは素数

							//n以下の素数の数を返す
void sieve(ll n) {
	REP(i, n + 1) {
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	FOR(i, 2, n + 1) {
		if (is_prime[i]) {
			prime.push_back(i);
			for (int j = 2 * i; j <= n; j += i) {
				is_prime[j] = false;
			}
		}
	}
}

int main() {
	ll q;
	vector<ll> v(MAX_N + 1, 0);

	cin >> q;

	sieve(100000);

	REP(i, prime.size()) {
		if (is_prime[(prime[i] + 1) / 2]) {
			v[prime[i]] = 1;
		}
	}

	FOR(i, 1, v.size()) {
		v[i] += v[i - 1];
	}

	REP(i, q) {
		ll l, r;
		cin >> l >> r;
		cout << v[r] - v[l - 1] << endl;
	}
}

Measured memory_bytes: 1664
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define what_is(x) cerr << #x << " is " << x << endl;
#define pii pair < ll , ll >
#define fi first
#define se second
using namespace std;
typedef long long ll;
ll N, ans;
int main()
{
    optimiza_io
    cin >> N;
    for(ll i = 2; i * i <= N; i ++){
        if(N % i != 0)
            continue;
        ll cnt = 0;
        while(N % i == 0){
            N /= i;
            cnt++;
        }
        ll x = 1;
        while(cnt >= x){
            cnt -= x;
            ans++;
            x++;
        }
    }
    if(N != 1)
        ans++;
        
    cout << ans << "\n";
    return 0;
}

// CHECAR LIMITES 

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int left = A + B;
  int right = C + D;
  if (left > right) cout << "Left" << endl;
  else if (left < right) cout << "Right" << endl;
  else cout << "Balanced" << endl;
  
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    cout << min(n%k,k-n%k) << endl;
    return 0;
}


Measured memory_bytes: 256
nums = [int(x) for x in list(input())]

for bit in range(1 << 3):
    t = str(nums[0])
    s = nums[0]
    for i in range(3):
        if (bit >> i) & 1:
            s += nums[i + 1]
            t += "+" + str(nums[i + 1])
        else:
            s -= nums[i + 1]
            t += "-" + str(nums[i + 1])

    if s == 7:
        t += "=7"
        print(t)
        break

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

int main(){

    int x;
    cin >> x;

    if((400<=x) && (x<=599)) cout << 8 << endl;
    else if((600<=x) && (x<=799)) cout << 7 << endl;
    else if((800<=x) && (x<=999)) cout << 6 << endl;
    else if((1000<=x) && (x<=1199)) cout << 5 << endl;
    else if((1200<=x) && (x<=1399)) cout << 4 << endl;
    else if((1400<=x) && (x<=1599)) cout << 3 << endl;
    else if((1600<=x) && (x<=1799)) cout << 2 << endl;
    else if((1800<=x) && (x<=1999)) cout << 1 << endl;
    else;

    return 0;
}

Measured memory_bytes: 3560
#include <cstdlib>
#include <iostream>


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

  char a, b;
  std::cin >> a >> b;
  std::cout << (a == b ? 'H' : 'D') << std::endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a = IL()

cnt = 0
for i in range(3):
  for j in range(i+1,3):
    if a[i] == a[j]:
      cnt += 1
if cnt == 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38384
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;
	std::vector<LL>a(N), b(N), c(N);
	rep(i, N - 1) in >> a[i] >> b[i];
	rep(i, N) in >> c[i];

	LL ansN = 0;
	std::sort(c.rbegin(), c.rend());
	for (LL i = 1; i < N; ++i) ansN += c[i];

	std::queue<LL>queue;
	std::vector<std::vector<LL>>G(N + 1);
	rep(i, N - 1)
	{
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	std::vector<LL>ansA(N + 1);
	std::vector<bool>vis(N + 1, false);
	LL seek = 0;
	queue.push(1);
	while (!queue.empty())
	{
		LL v = queue.front(); queue.pop();
		ansA[v] = c[seek];
		++seek;
		vis[v] = true;
		for (LL u : G[v])
		{
			if (!vis[u]) queue.push(u);
		}
	}

	out << ansN << std::endl;
	rep(i, N) out << ansA[i + 1] << (i < N - 1 ? " " : "\n");
}


Measured memory_bytes: 1280
m,n,l = 1,1,1

K,S = list(map(int,input().split()))

rangeX,rangeY,rangeZ = K,K,K

W=S

cnt = 0
for i in range(min(W//m+1,rangeX+1)):
    for j in range( min((W-m*i)//n+1,rangeY+1)):
        if  (lambda d,m: m==0 and d<=rangeZ)(*divmod((W-m*i-n*j),l)):
            cnt +=1
print(cnt)

Measured memory_bytes: 42988
//g++ -std=c++14 test.cpp -o test.out

//ポイント：
//いもす法
//操作をシミュレートすると、高々lon(N)回程度で数列が収束することに気付けるか
//数列は合計値、下限、上限に注目

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
//const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,K;
LL A[200000];

LL ans[200000];

void solve(){
	auto sanitizer = [&](LL x){
		if(x<0) x = 0;
		if(x>N) x = N;
		return x;
	};
	for(int _=0;_<K;_++){
		//いもす法
		vector<LL> d_imos(N+1,0);
		for(int i=0;i<N;i++){
			d_imos[sanitizer(i-A[i])]++;
			d_imos[sanitizer(i+A[i]+1)]--;
		}
		vector<LL> imos(N,1);//電球は少なくとも自分自身を照らしている　よってデフォで1としておく
		imos[0] = d_imos[0];
		for(int i=1;i<N;i++) imos[i] = imos[i-1] + d_imos[i];

		LL sum = 0;
		for(int i=0;i<N;i++){
			A[i] = imos[i];
			sum += imos[i];
		}
		if(sum==N*N) break;
	}

	for(int i=0;i<N;i++) ans[i] = A[i];
}

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

    solve();

    for(int i=0;i<N;i++) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 7604
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    !n <- readLn :: IO Int
    xs <- L.unfoldr (B.readInt.B.dropWhile isSpace) <$> B.getLine
    putStr.unlines.map show$solve n xs

solve :: Int -> [Int] -> [Int]
solve n xs = map (\x -> bool medR medL $ x > medL) xs
  where
    !sorted = L.sort xs
    !medL = sorted !! ((n - 1) `div` 2)
    !medR = sorted !! ((n - 1) `div` 2 + 1)



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    unordered_map<string, int> mp;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s] = 1;
    }
    int m;
    cin >> m;
    bool close = true;
    rep(i, m) {
        string s;
        cin >> s;
        if (mp[s] == 0) {
            cout << "Unknown " << s << endl;
        } else if (close) {
            cout << "Opened by " << s << endl;
            close = false;
        } else{
            cout << "Closed by " << s << endl;
            close = true;
        }
    }

    return 0;
}

Measured memory_bytes: 3252
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int a = sc.nextInt();
	    int b = sc.nextInt();
	    if(a > 9 || b > 9) {
	        System.out.println(-1);
	    }else {
	        System.out.println(a * b);
	    }
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s;
	cin >> s;
	if ((s[0] == '9') || (s[1] == '9')) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


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

int n, a, k, x, d[100005];
int main() {
	cin >> n;
	while(n--) {
		scanf("%d", &a);
		x = upper_bound(d, d+k, a, greater<int>()) - d;
		d[x] = a;
		if(x==k) ++k;
	}
	cout << k;
	return 0;
}

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

int main(){
	int N, M;
	cin >> N >> M;
	int A[N];
	int i,j;
	for(i=0;i<N;i++) cin >> A[i];
	long long sum[N];
	sum[0] = A[0];
	long ans = 0;
	if(sum[0]%M==0) ans++;
	//(余り、そのあまりとなるものの個数)のペアで保存
	map<int, int> cnt;
	cnt[sum[0]%M]++;
	for(i=1;i<N;i++){
		sum[i] = sum[i-1]+ A[i];
		ans = ans + cnt[sum[i]%M];
		cnt[sum[i]%M]++;
		
		if(sum[i]%M==0) ans++;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main()
{
	int n, k, res;

	cin >> n >> k;

	res = 1;
	for (int i = 0; i < n; ++i)
		if (res < k)
			res *= 2;
		else
			res += k;

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
long long int n,ans=0,i;
  scanf("%lld",&n);
 
  for(i=1;i<=n;i++){
   if(i%3!=0){
     if(i%5!=0){
        if(i%3!=0||i%5!=0){
          ans=ans+i;
        }
     }
      
    }
  }
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 1732
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<"IMPOSSIBLE"<<endl;return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
//19234567892927;
const int mod=1e9+7;
const llint big=1e13+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
//順番??関係ないね
int main(void){
	int i,j,n,m;
	string str;cin>>str;
	m=str.size();
	vector<int>sa(m/2);
	vector<int>imsa(m/2+1);
	cin>>n;
	for(i=0;i<m/2;i++){sa[i]=str[i]-str[m-i-1];}//これを0にする
	for(i=1;i<m/2;i++){imsa[i]=sa[i]-sa[i-1];}
	imsa[m/2]=-sa[m/2-1];
	imsa[0]=sa[0];
	//imsaを0にする
	//for(auto it:imsa){cerr<<"imsa"<<it<<endl;}
	vector<int> oya(m/2+1);
	vector<int> ran(m/2+1);
	for(i=0;i<oya.size();i++){oya[i]=i;}
	for(i=0;i<n;i++){
		int l,r;cin>>l>>r;
		l=min(l-1,m-(l-1));
		r=min(r,m-r);
		//cerr<<"de l,r="<<l<<" "<<r<<endl;
		//lとrを津図ける
		while(l!=oya[l]){l=oya[l];}
		while(r!=oya[r]){r=oya[r];}
		if(l==r){continue;}
		if(ran[l]<ran[r]){swap(l,r);}
		oya[r]=l;
		if(ran[l]==ran[r]){ran[l]++;}
	}
	vector<int>go(m/2+1,-1);//次の頂点
	vector<int>mae(m/2+1,-1);//それにおとずれたもの
	for(i=0;i<oya.size();i++){
		int gen=i;
		while(gen!=oya[gen]){gen=oya[gen];}
		if(mae[gen]!=-1){go[mae[gen]]=i;}
		mae[gen]=i;
	}
	//imsaをすべて0にしよう
	for(i=0;i<imsa.size();i++){
		if(go[i]==-1&&imsa[i]%26!=0){cout<<"NO"<<endl;return 0;}
		if(go[i]!=-1){imsa[go[i]]+=imsa[i];}
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 1728
use std::collections::HashSet;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn factors(n: usize) -> Vec<usize> {
    let mut f = HashSet::new();
    for i in 1..n {
        if i * i > n {
            break;
        }
        if n % i == 0 {
            f.insert(i);
            f.insert(n / i);
        }
    }
    let mut f = f.iter().map(|&v| v).collect::<Vec<_>>();
    f.sort();
    f
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut count = 0;
    let mut b = Vec::with_capacity(n);
    let mut c = vec![0; n];
    for i in (0..n).rev() {
        let k = i + 1;
        if c[i] % 2 != a[i] {
            count += 1;
            b.push(k);
            for f in factors(k) {
                c[f - 1] += 1;
            }
        }
    }
    b.reverse();
    println!("{}", count);
    for bi in b {
        println!("{}", bi);
    }
}


Measured memory_bytes: 11132
import java.util.*;
public class Main{
public static void main(String[] args){
String[] days={"MON","TUE","WED","THU","FRI","SAT","SUN"};
Scanner s=new Scanner(System.in);
  String in=s.next();
  int mark;
 	for(int i=0;i<days.length;i++){
    if(in.equals(days[i])){
      int ans=6-i;
      if(ans==0)
        ans=7;
    System.out.println(ans);
      break;}
    }
}
}

Measured memory_bytes: 23252
str = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
input_field = [int(i) for i in str.split(", ")]
print(input_field[int(input()) - 1])

Measured memory_bytes: 2940
#include <iostream>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;

int main()
{
    //freopen("test.txt", "r", stdin);
    int n, m;
    while(cin >> n >> m){
        cout << (n - 1) * (m - 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc, out);

		out.flush();
	}
	
	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		char[] c = String.valueOf(n).toCharArray();
		
		if((c[0] == c[1] && c[1] == c[2]) || (c[1] == c[2] && c[2] == c[3])) {
			out.println("Yes");
		}else{
			out.println("No");
		}
	}
	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

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

int main() {
	//入力
	int N;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}

	//処理
	int ans = 0;
	//これまで最も高かった山
	int MaxHeight = -1;

	//i 今見ている山
	for (int i = 0; i < N; i++)
	{
		//今までで一番高い山を見つけたら、答えに1を足して、高さを更新する
		if (MaxHeight <= H[i]) {
			ans++;
			MaxHeight = H[i];
		}
	}

	//出力
	cout << ans << endl;
}



Measured memory_bytes: 256
/***************************************** START OF TEMPLATE *********************************************/

#include<bits/stdc++.h>

using namespace std;

#define  SPEED          ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  newl           cout<<"\n";
#define  f              first
#define  s              second
#define  pb             push_back
#define  mp             make_pair
#define  sym(s)         s="#"+s+"#";   
#define  all(x)         (x).begin(),(x).end()
#define  alll(x, n)     x+1, x+n+1
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  mset1d(a,n,v)  foo(i,0,n+5)a[i]=v;
#define  mset2d(a,n,m,v)foo(i,0,n+5)foo(j,0,m+5)a[i][j]=v;
#define  INP(a,n)       foo(i,1,n) cin>>a[i];
#define  deb1d(a,n)     foo(i,1,n)cout<<a[i]<<" ";newl;
#define  deb2d(a,n,m)   foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}    
#define  debm(a)        for(auto it: a)cout<<"{"<<it.f<<","<<it.s<<"}, ";newl;
#define  debp(a,n)      foo(i,1,n)cout<<"{"<<a[i].f<<","<<a[i].s<<"}, ";newl;
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<" ";newl;
#define  deb2(a,b)      cout<<a<<" "<<b<<" ";newl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<" ";newl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d;newl;
#define  ll             long long
#define  ld             long double
#define  pll            pair<ll,ll>
#define  vll            vector<ll>
#define  vpll           vector<pll>

const ld   PI    =  3.14159265358979323846; 
const ll   MOD   =  1e+9+7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  1e+6+8;

vll adj[N]; ll vis[N];
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

ll test_cases = 1; randomINIT;

/************************************************************************************** *******************/
/***************************************** VARIABLE DECLARATIONS *****************************************/
ll n, k, a[N], p[N];


/***************************************** FUNCTION IMPLEMENTATIONS **************************************/
vll dec_to_base(ll num, ll base, ll sz){
    vll res;
    while(num>0){
        res.pb(num%base);
        num /= base;
    }
    ll cur = res.size();
    foo(i,1,sz-cur)res.pb(0);
    reverse(all(res));
    return res;
}

/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc){
   cin>>n;
   ll ind = lower_bound(alll(p,14), n)-p-1;
   n-=p[ind];
   vll v = dec_to_base(n-1,26,ind+1);
   for(auto it: v) cout<<char(it+'a');
   
}

int main(){
    SPEED;
    p[0]=0;
    foo(i,1,13){
        p[i]+=p[i-1]+pow(26,i);
    }
    p[14]=INF;
    //cin>>test_cases;
    foo(i,1,test_cases){
        MAIN(i);
    }
}

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

int main() {
  int n,k;
  cin >> n>>k;
  map<string,int>memo;
  rep(i,n){
    string s;
    cin>>s;
    memo[s]++;
  }
  for(auto p:memo){
    auto k=p.first;
    auto v=p.second;
    while(v--){
      cout<<k;
    }
  }
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>

using namespace std;
int main() {

    int A,B;
    cin>>A>>B;

    cout<<(3*A+B)/2<<endl;
}



Measured memory_bytes: 256
fn main() {
    let n: usize = {
        let mut buffer = String::new();
        std::io::stdin().read_line(&mut buffer).unwrap();

        buffer.trim().parse().unwrap()
    };

    let nums: Vec<isize> = {
        let mut buffer = String::new();
        std::io::stdin().read_line(&mut buffer).unwrap();

        buffer.split_whitespace().map(|i|i.parse().unwrap()).collect()
    };

    assert_eq!(n, nums.len());

    let mut avg = 0.0;
    for i in nums.clone() {
        avg += i as f32 / n as f32;
    }
    let avg = avg.round() as isize;

    let mut sum = 0;
    for i in nums.clone() {
        sum += (avg - i).abs().pow(2);
    }
    let sum = sum;

    println!("{:?}", sum);
}


Measured memory_bytes: 508
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map{|i|i.to_i-1}
end

N, b_list = gets_n_and_i_list
a_list = []
dpp b_list

N.times do |i|
  (b_list.size).downto(0) do |j|
    if j == b_list[j]
      a_list.push(j+1)
      b_list.delete_at(j)
      break
    end
  end
end

if a_list.size == N
  a_list.reverse_each do |a|
    puts a
  end
else
  puts -1
end


Measured memory_bytes: 4092
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;


int bubblesort(int A[], int N) {

    int cnt = 0;
    bool flag = true;
    
    while (flag) {
        
        flag = false;

        for (int i = N - 1; i > 0; i--) {
        
            if (A[i - 1] > A[i]) {

                cnt++;

                swap(A[i - 1], A[i]);
                flag = true;
        
            }
        }
    }

    return cnt;
}

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

    int cnt = bubblesort(A, N);

    cout << A[0];
    for (int i = 1; i < N; i++)
        cout << " " << A[i];
    cout << '\n';
    cout << cnt << '\n';

    return 0;
}


Measured memory_bytes: 3120
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	int a, b, x;
	scanf("%d%d%d", &a,&b, &x);

	if (a + b - x >= 0 && a<=x) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main() {
	
	int n;
	
	while(cin >> n) {
	
	int A[7] = {0};
	
	if( n == 0)
	break;
	
	for(int i=0;i<n;i++) {
		
		int age;
		
		cin >> age;
		
		if( age >= 60)
		A[6]++;
		
		else
		A[age/10]++;
	}
	for(int i=0;i<7;i++)
	cout << A[i] << "\n";
	
}
	return 0;
}


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

int main(){
	
	int a,n[100000];
    long long sum=0;
    cin>>a;
    
	for(int i=0;i<a;i++){
	cin>>n[i];
	}
	
	for(int i=0;i<a-1;i++){
	for(int j=i+1;j<a;j++){
		sum+=n[i]*n[j];
	
	}
	}
	
	
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DBP
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fst first
#define snd second
#define fore(x,a,b) for(int x=(a), qwerty=(b); x<qwerty; x++)
#define pb push_back
#define mset(a,v) memset((a),(v),sizeof(a))
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

const int N=3005;
int dp[N][N];
string s,t,mjhun;

int solve(int i,int j) {
	if(i<0)return j+1;
	if(j<0)return i+1;
	if(dp[i][j]!=-1)return dp[i][j];
	int r=0;
	if(s[i]==t[j])r=solve(i-1,j-1);
	else r=1+min(solve(i-1,j),solve(i,j-1));
	dp[i][j]=r;
	return r;
}

void build(int i,int j) {
	if(i<0||j<0)return;
	if(s[i]==t[j])mjhun+=s[i],build(i-1,j-1);
	else if(!i)build(i,j-1);
	else if (!j)build(i-1,j);
	else if(dp[i-1][j] < dp[i][j-1])build(i-1,j);
	else build(i,j-1);
}

int main(){FIN;
	mset(dp,-1);
	cin>>s>>t;
	solve(s.length()-1,t.length()-1);
	build(s.length()-1,t.length()-1	);
	reverse(mjhun.begin(),mjhun.end());
	cout<<mjhun<<endl;
	//fore(i,0,s.length()+1)fore(j,0,t.length()+1)cout<<i<<" "<<j<<" : "<<dp[i][j]<<endl;
}	

Measured memory_bytes: 35840
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
  int i,n;
  double ans=0.0;
  
  cin >> n;
  int a[n];
  for(i=0;i<n;++i)cin >> a[i];

  for(i=0;i<n;i++)ans += (double)1/a[i];
  ans = 1.0/ans;

  printf("%.10f\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;//溢出会变成负值 
typedef long double ldb;
typedef unsigned long long ull;//自动取模2^64
const double pi=acos(-1.0);
const int mod = 1e9+7; // 998244353;
const int inf = 0x7fffffff;//2^31-1
const ll INF = 0x7fffffffffffffff;
const int dx[]={-1,0,1,0},dy[]={0,1,0,-1};
//ll begin_time=clock();    ll end_time=clock();  cout<<"time = "<<end_time-begin_time<<" ms!"<<endl;
//bool operator < (const mmp &a) const{return x<a.x||x==a.x&&y<a.y;}       //map<int,map<int,int> >z;
//map<int,int>::iterator it;for(it=z.begin();it!=z.end();it++)printf("%d %d\n",it->first,it->second);
//ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}  //快速幂取模 
//lower_bound(begin,end,num); 第一个>=num的数字  upper_bound(begin,end,num); 第一个>num的数字 返回地址 
//freopen("input.in","r",stdin);     freopen("output.out","w",stdout);      //文件读写提交 
//reverse(s.begin(),s.end());   //反转字符串        floor(); 向下取整  ceil(); 向上取证 
//数轴上n个点移动到同一位置，移动到该组数字的中位数的总距离最短 
bool isPrime(int n){if(n==2||n==3)return 1;if(n%6!=1&&n%6!=5)return 0;
int t=sqrt(n);for(int i=5;i<=t;i+=6)if(n%i==0||n%(i+2)==0)return 0;return 1;}//判断素数 


int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	ll a,b,c,d,e,f,g,T;  
//	cin>>T;
	//while(T--)
	{
		cin>>a>>b;c=0;
		int z[a+10];
		for(int i=0;i<a;i++)cin>>z[i];
		sort(z,z+a);
		for(int i=0;i<b;i++)c+=z[i];
		cout<<c<<endl;
	}
	
}



Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
main(){
  string s;
  int k;
  cin>>s>>k;
  if(s[0]!='1'){
    cout<<s[0];
    return 0;
  }else{
    for(int i=1;i<k;i++){
      if(s[i]!='1'){
        cout<<s[i];
        return 0;
      }
    }
    cout<<'1';
    return 0;
  }
}

Measured memory_bytes: 256
x = int(input())
flag = True
while flag:
    if x == 2:
        x += 1
        break
    for i in range(2,x//2+2):
        if x%i == 0:
            break
        if i == x//2+1:
            flag = False
            break
    x += 1
print(x-1)

Measured memory_bytes: 2940
class Array
  include Comparable
end

n = gets.to_s.to_i

cnt = 0
3.upto(n.to_s.size) do |i|
  [3, 5, 7].repeated_permutation(i) do |a|
    break if a.join.to_i > n
    cnt += 1 if a.include?(3) && a.include?(5) && a.include?(7)
  end
end

puts cnt

Measured memory_bytes: 1916
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */
int powz(int v,int k) { int r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }

signed main() {
	std::string s;
	int k;
	std::cin >> s >> k;
	int n = s.size();

	std::function<int(int,int)> f = [&] (int i, int j) -> int {
		if(j==0) return 1;
		if(i==n) return 0;
		int d = s[i]-'0';
		if(d==0) return f(i+1,j);
		// f(i+1,j-1) + (d-1)*pow(9,j-1)*(n-i-1)C(j-1) + pow(9,j)*(n-i-1)Cj
		int x = (d-1)*powz(9,j-1);
		if(n-i-1>=j-1) {
			rep(xx,j-1) {
				x*=n-i-1-xx;
				x/=xx+1;
			}
		} else x=0;

		int y = powz(9,j);
		if(n-i-1>=j) {
			rep(yy,j) {
				y*=n-i-1-yy;
				y/=yy+1;
			}
		} else y=0;
		return f(i+1,j-1) + x + y;
	};
	print(f(0,k));

	return 0;
}


Measured memory_bytes: 384
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def prime_numbers(n):
    if n < 2:
        return []

    m = (n + 1) // 2
    p = [1] * m
    for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
        if p[i]:
            p[2 * i * (i + 1) :: 2 * i + 1] = [0] * (((m - 1) - 2 * i * (i + 1)) // (2 * i + 1) + 1)

    a = [2 * i + 1 for i in range(m) if p[i]]
    a[0] = 2
    return a


def main():
    N = int(readline())

    P = prime_numbers(55555)

    A = []
    for p in P:
        if p % 5 == 1:
            A.append(p)
            if len(A) == N:
                break

    print(' '.join(map(str, A)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  char a; cin>>a;
  if(a=='a'||a=='b'||a=='c'||a=='d'||a=='e'||a=='f'||a=='g'||a=='h'||a=='i'||a=='j'||a=='k'||a=='l'||a=='m'||a=='n'||a=='o'||a=='p'||a=='q'||a=='r'||a=='s'||a=='t'||a=='u'||a=='v'||a=='w'||a=='x'||a=='y'||a=='z'){
    cout << 'a';
  }
    else cout << 'A';
}

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

int main() {
  int n;
  scanf("%d", &n);
  int rev = 0;
  int A = n;
  while (n != 0) {
    rev = 10 * rev + n % 10;
    n /= 10;
  }
  if (rev == A) 
    puts("Yes");
  else
    puts("No");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	int sum = 0;
	string s, ans = "CODEFESTIVAL2016";
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != ans[i])
			sum++;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
#include <assert.h>
#include <cstring>
#include <set>

using namespace std;

typedef long long ll;

int main()
{
    int N;
    vector<int> v;
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        int temp;
        cin >> temp;
        v.push_back(temp);
    }
    sort(v.begin(),v.end());
    
    int ans = 0;
    for(int i = 0; i < N-2; i++)
    {
        int j = i+1;
        int k = i+2;
        while(j < k && k < N)
        {
            j = k-1;
            while(v[i]+v[j] > v[k] && j > i)
            {
                if(v[i] != v[j] && v[j] != v[k])
                    ans++;
                j--;
            }
            k++;
        }
    }
    cout << ans;
    
}

Measured memory_bytes: 3584
//30
#include<iostream>
#include<complex>
#include<cmath>

using namespace std;

typedef complex<double> P;

int main(){
  for(int n;cin>>n,n;){
    P p[300];
    for(int i=0;i<n;i++){
      double x,y;
      cin>>x>>y;
      p[i]=P(x,y);
    }
    int ans=1;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i==j||abs(p[i]-p[j])>2)continue;
	P c=p[i]+polar(1.,arg(p[j]-p[i])+acos(abs(p[j]-p[i])/2));
	int cc=0;
	for(int k=0;k<n;k++){
	  cc+=abs(p[k]-c)<1+1e-9;
	}
	if(ans<cc){
	  ans=cc;
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1372
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const int INF = 0x3f3f3f3f;
ll max(ll a, ll b){return a > b ? a : b;}
ll min(ll a, ll b){return a < b ? a : b;}

int mpow(int b, int e)
{
    int ret=1;
    for(int i=0; i<e; i++)
    {
        ret=ret*b%mod;
    }
    return ret;
}

ll dp[100001];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, w, w1, val;
    cin >> n >> w;
    for(int i=1; i<=n; i++)
    {
        cin >> w1 >> val;
        for(int j=w-w1; j>=0; j--)
        {
            if(dp[j]) dp[j+w1] = max(dp[j+w1], dp[j]+val);
        }
        dp[w1] = max(dp[w1], val);
    }
    ll ans=0;
    for(int i=1; i<=w; i++) ans = max(ans, dp[i]);
    cout << ans;
}

Measured memory_bytes: 1024
s = set(list(input()))
if len(s) == 3 or len(s) == 1:
  print('No')
elif 'N' in s and 'S' in s and 'E' in s and 'W' in s:
  print('Yes')
elif len(s) == 2:
  if 'N' in s and 'S' in s:
    print('Yes')
  elif 'W' in s and 'E' in s:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 3064