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

using namespace std;

const int N = 10;

int n;
int x[N], y[N];
int a[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];
    int tot = 1;
    for (int i = 1; i <= n; i++) {
        a[i] = i;
        tot *= i;
    }
    double res = 0;
    while (1) {
        double now = 0;

        auto sq = [](int u) {
            return u * u;
        };

        for (int i = 1; i < n; i++) {
            int u = a[i];
            int v = a[i + 1];
            now += sqrt(sq(x[u] - x[v]) + sq(y[u] - y[v]));
        }
        res += now;
        if (!next_permutation(a + 1, a + n + 1)) break;
    }
    cout << fixed << setprecision(10) << res / tot << endl; 
    return 0;
}

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

        String s = sc.next();

        if(Objects.equals(s, "SUN")){
            System.out.println("7");
        }else if(Objects.equals(s, "MON")){
            System.out.println("6");
        }else if(Objects.equals(s, "TUE")){
            System.out.println("5");
        }else if(Objects.equals(s, "WED")){
            System.out.println("4");
        }else if(Objects.equals(s, "THU")){
            System.out.println("3");
        }else if(Objects.equals(s, "FRI")){
            System.out.println("2");
        }else if(Objects.equals(s, "SAT")){
            System.out.println("1");
        }
        }
    }

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

int main(void){
    int N;
    int K;
    scanf("%d %d",&N, &K);
    int a[N];
    int i,j,temp;
    
    if(1<=K && K<=N && N<=50){
        for(i=1; i<=N; ++i){
            scanf("%d",&a[i]);
        }
        
        for(i=2; i<=N; ++i){
            j = i;
            while(j>=2 && a[j-1] > a[j]){
                temp = a[j-1];
                a[j-1] = a[j];
                a[j] = temp;
                j--;
            }
        }
        
        int answer;
        for(i=N-K+1; i<=N; ++i){
            answer += a[i];
        }

        printf("%d",answer);
    } else {
        exit(1);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    if(s=="SUN")
    {
        cout<<7;
    }
    else if(s=="MON")
    {
        cout<<6;
    }
    else if(s=="TUE")
    {
        cout<<5;
    }
    else if(s=="WED")
    {
        cout<<4;
    }
    else if(s=="THU")
    {
        cout<<3;
    }
    else if(s=="FRI")
    {
        cout<<2;
    }
    else if(s=="SAT")
    {
        cout<<1;
    }
}

Measured memory_bytes: 3556
#190901B
A, B = map(int, input().split())
ans=0
if B == 1:
    ans = 0
else:
    if A == 2:
        ans = B -1
    else:
        if B%(A-1)==1:
            ans = (B-1)//(A-1)
        else:
            ans = (B-1)//(A-1)+1
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vec vector <ll>
#define pa pair<ll,ll>
#define mp make_pair
#define pb push_back
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	vec red,green,color;
	ll x,y,r,g,c;
	cin>>x>>y>>r>>g>>c;
	red.resize(r+1);
	green.resize(g+1);
	color.resize(c+1);
	ll i;
	vec result;
	for(i=0;i<r;i++)
		cin>>red[i];
	for(i=0;i<g;i++)
		cin>>green[i];
	for(i=0;i<c;i++)
		cin>>color[i];
	sort(red.begin(), red.end(),greater<ll>());
	sort(green.begin(), green.end(),greater<ll>());
	sort(color.begin(), color.end(),greater<ll>());
	if(x<=r)
	{
		for(i=0;i<x;i++)
			result.pb(red[i]);
	}
	else
	{
		for(i=0;i<r;i++)
			result.pb(red[i]);
		for(i=0;i<x-r;i++)
		{
			result.pb(*(color.begin()));
			color.erase(color.begin());
		}
	}
	if(y<=g)
	{
		for(i=0;i<y;i++)
			result.pb(green[i]);
	}
	else
	{
		for(i=0;i<g;i++)
			result.pb(green[i]);
		for(i=0;i<y-g;i++)
		{
			result.pb(*(color.begin()));
			color.erase(color.begin());
		}	
	}
	sort(result.begin(), result.end());
	i=0;
	ll j=0;
	while(i<color.size() && j<result.size())
	{
		if(color[i]>result[j])
		{
			result[j]=color[i];
			i++;
			j++;
		}
		else
			break;
	}
	ll sum=0;
	for(auto i: result)
		sum+=i;
	cout<<sum;
	return 0;
}

Measured memory_bytes: 4852
N = int(input())

for h in range(1, 3500+1):
  for n in range(1, 3500+1):
    if 4*h*n - N*n - N*h == 0:
      continue
    w = (N*h*n) // (4*h*n - N*n - N*h)
    if w < 1 or w > 3500:
      continue
    if 4*h*n*w == N*(n*w + h*w + n*h):
      print(h, n, w)
      exit()

Measured memory_bytes: 42492
import numpy as np
import sys
n, m = map(int, input().split())
if n >= m:
    print(0)
    sys.exit()
x = [int(i) for i in input().split()]
x = np.array(sorted(x))
diff = np.abs(np.diff(x))
diff = sorted(diff)
if n == 1:
    print(sum(diff))
else:
    print(sum(diff[:-n + 1]))

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

using namespace std;
using ll = long long;

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    vector<ll> d(N);
    REP(i,0,N) cin >> d[i];

    ll hp = 0;
    REP(i,0,N){
        REP(j,i+1,N){
            hp += d[i] * d[j];
        }
    }

    _PR(hp);

    return 0;
}

/*



*/

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

int main(){
	int N;
	while(cin>>N,N){
		int ans = 0;
		for(int i=0;i<N;i++){
			int X,Y,H,W; cin>>X>>Y>>H>>W;
			int b = X+Y+H;
			if(b<=60 && W<=2) ans += 600;
			else if(b<=80 && W<=5) ans += 800;
			else if(b<=100 && W<=10) ans += 1000;
			else if(b<=120 && W<=15) ans += 1200;
			else if(b<=140 && W<=20) ans += 1400;
			else if(b<=160 && W<=25) ans += 1600;
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

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

  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      cin >> a[i][j];

  vector<vector<ll>> dp(h, vector<ll>(w, 0));
  dp[0][0] = 1;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (i == 0 && j == 0)
        continue;
      if (j > 0 && a[i][j - 1] == '.') {
        dp[i][j] += dp[i][j - 1];
        dp[i][j] %= MOD;
      }
      if (i > 0 && a[i - 1][j] == '.') {
        dp[i][j] += dp[i - 1][j];
        dp[i][j] %= MOD;
      }
    }
  }

  cout << dp[h - 1][w - 1] << endl;

  return 0;
}


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

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printArray(arr) for (int i = 0; i<size(arr); i++) cout << arr[i] << " ";cout << '\n'
#define printVerdict(verdict) cout << (verdict ? "Yes": "No") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)
#define phi_v 1.618034

const ll inf = 0x3f3f3f3f;

template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) {cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n';}
template <class T1, class T2>
void printPair(pair<T1, T2> p) {cout << p.first << " " << p.second << '\n';}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	ll d; cin >> n >> d;
	int cnt = 0;
	for (int i = 0; i<n; i++) {
		ll x,y; cin >> x >> y;
		ll dist = x*x + y*y;
		cnt += dist <= d*d;
	}
	cout << cnt << '\n';
}


Measured memory_bytes: 3628
from math import tan, radians, pi

A, B, X = map(int, input().split())

def angle_to_max_water(angle):
    c = A*tan(radians(angle))
    if c <= B:
        return A*B - (A*c/2)
    else:
        d = B*tan(radians(90-angle))
        # print(d)
        return B*d/2

l, r = 0, 90
for i in range(30):
    mid = (l+r)/2
    # print(mid, angle_to_max_water(mid))
    if angle_to_max_water(mid) <= X/A:
        r = mid
    else:
        l = mid
    # print(l, r)

print(r)

Measured memory_bytes: 3316
n, q = map(int, input().split())
bit = [0] * (n + 4)


def add(a, i):
    while i <= n:
        bit[i] += a
        i += i & -i


def query(i):
    res = 0
    while i > 0:
        res += bit[i]
        i -= i & -i
    return res


a = list(map(int, input().split()))
la = [-1] * n
li = [list(map(int, input().split())) + [_] for _ in range(q)]
li.sort(key=lambda x: x[1])
idx = 0
ans = [0] * q
for l, r, xxx in li:
    l -= 1
    for i in range(idx, r):
        if la[a[i] - 1] == -1:
            add(1, i + 1)
        else:
            add(-1, la[a[i] - 1] + 1)
            add(1, i + 1)
        la[a[i] - 1] = i
    idx = r
    ans[xxx] = query(r) - query(l)
for res in ans:
    print(res)


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

int main(){
  int a[128] = {}, i = 0, x, y;
  char in[100];
  while(scanf("%s", in) != EOF){
    switch(*in){
    case '+':
      x = a[--i];
      y = a[--i];
      a[i++] = y + x;;
      break;
    case '-':
      x = a[--i];
      y = a[--i];
      a[i++] = y - x;
      break;
    case '*':
      x = a[--i];
      y = a[--i];
      a[i++] = y * x;
      break;
    default:
      a[i++] = atoi(in);
      break;
    }
  }
  printf("%d\n", a[--i]);
  return 0;
}

Measured memory_bytes: 548
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;


    UnionFind(ll N): par(N), siz(N, 1LL) {
        for (ll i = 0; i < N; ++i) par[i] = i;
    }

    void init(ll N) {
        par.resize(N);
        siz.assign(N, 1LL);
        for (ll i = 0; i < N; ++i) par[i] = i;
    }


    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }


    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll N,M; cin >> N >> M;
    UnionFind tree(N);
    rep(i,0,M){
        int a,b; cin >> a >> b;
        a--; b--;
        if(!tree.same(a,b)) tree.unite(a,b);
    }

    ll ans = 0;

    rep(i,0,N) chmax(ans, tree.size(i));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6360
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a, b;
	cin >> n >> a >> b;
	int ans = min(n*a, b);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (h, n) = readIntegerList()
    val a = readIntegerList().sum()
    if (h <= a) {
        println("Yes")
    } else {
        println("No")
    }
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 48268
N,M = list(map(int,input().split()))
XY = [list(map(int,input().split())) for _ in range(M)]
L1 = [1]*N
L2 = [0]*N
L2[0] = 1
for xy in XY:
    if L2[xy[0]-1] == 1:
        L2[xy[1]-1] = 1
    L1[xy[0]-1] -= 1
    L1[xy[1]-1] += 1
    if L1[xy[0]-1] == 0:
        L2[xy[0]-1] = 0
print(sum(L2))

Measured memory_bytes: 28836
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,i,d;
  cin >> a >> b >> c;
  if (a <= b && a <= c && c <= b) {
    cout << "Yes" << endl;
  }
  else if (b <= a && b <= c && c <= a) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)

input=lambda: sys.stdin.readline().rstrip() 

n, q = map(int, input().split())

lv =[[] for _ in range(n)]
ans=[0] * (n)

def dfs(v,p=-1):
    for u in lv[v]:
        if u == p: continue
        ans[u] += ans[v]
        dfs(u,v)

for _ in range(n-1):
    a,b = map(int,input().split())
    lv[a-1].append(b-1)
    lv[b-1].append(a-1)

for _ in range(q):
    p,x = map(int,input().split())
    ans[p-1] += x

dfs(0)

print(*ans)
# for i in ans:print(i)

Measured memory_bytes: 268416
import sys
 
import numba as nb
import numpy as np
 
input = sys.stdin.readline
 
 
@nb.njit("i8[:](i8,i8,i8[:])", cache=True)
def solve(N, K, A):
    for _ in range(min(41, K)):
        A_cumsum = np.zeros(shape=N, dtype=np.int64)
        for i in range(N):
            A_cumsum[max(0, i - A[i])] += 1
            b = i + A[i] + 1
            if N - 1 < b:
                pass
            else:
                A_cumsum[b] -= 1
        A = np.cumsum(A_cumsum)
    return A
 
 
def main():
    N, K = map(int, input().split())
    A = np.array(input().split(), dtype=np.int64)
 
    ans = solve(N, K, A)
 
    print(" ".join(map(str, ans)))
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 129124
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		Double x1 = scan.nextDouble();
		Double y1 = scan.nextDouble();
		Double x2 = scan.nextDouble();
		Double y2 = scan.nextDouble();
		Double distance = Math.hypot(x1 - x2, y1 - y2);
		System.out.println(String.format("%.8f", distance));
	}
}

Measured memory_bytes: 28016
/*
Date: 3/9/2020
Context: ZR3月省选集训
if (sum[x] >= 2 * max[x]) {
	f[x] = sum[x] / 2;
}
else {
	int u = mp[x];
	sum[x] - max[x] + max(0 \leq k \leq f[u], 2 * k \leq 2 * max[u] - sum[u]);
}
*/
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2000 + 10;
char ch[N];
int mx[N], sum[N], f[N], ver[N * 2], head[N], nex[N * 2], tot, mp[N], ans;
int n, dist, cnt[N];
inline void add(int x, int y) {
	ver[++tot] = y;
	nex[tot] = head[x];
	head[x] = tot;
}
void dfs(int x, int fa) {
	
	for (int i = head[x]; i; i = nex[i]) {
		int y = ver[i];
		if (y == fa) continue;
		dfs(y, x);
		cnt[x] += cnt[y];
		sum[x] += sum[y] + cnt[y];
		if (sum[y] + cnt[y] > mx[x]) { 
			mp[x] = y;
			mx[x] = sum[y] + cnt[y];
		}
		/*
		mistake:
		if (sum[y] > mx[x]) {
			mp[x] = y;
			mx[x] = sum[y];
		}
		*/
	
	}
	if (ch[x] == '1') {
		cnt[x]++;
	}
	if (head[x] == 0) return;

	if (sum[x] - mx[x] >= mx[x]) {

		f[x] = sum[x] / 2;
	}
	else {
		int u = mp[x];
		f[x] = sum[x] - mx[x] + min(f[u], (2 * mx[x] - sum[x]) / 2);
	}
	// cout << "dfs::x " << x << endl;
}

inline void solve(int x) {
	memset(mx, 0, sizeof(mx));
	memset(sum, 0, sizeof(sum));
	memset(cnt, 0, sizeof(cnt));
	dist = 0;
	dfs(x, 0);

	if (sum[x] % 2) return;
	if (f[x] == sum[x] / 2) {
		ans = min(f[x], ans);
	}
}
signed main() {
	ans = 1e9 + 7;
	ios::sync_with_stdio(0);
	cin >> n;
	cin >> ch + 1;
	for (int i = 1, u, v; i <= n - 1; i++) {
		cin >> u >> v;
		add(u, v);
		add(v, u);
	}
	for (int i = 1; i <= n; i++) {
		solve(i);
	}
	if (ans == 1e9 + 7) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 512
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[100001];
	rep(k, 8) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	ll M = getint();
	ll P[100000];
	rep(i, N) {
		P[i] = (ll)getint() << 30;
		P[i] += getint();
	}

	ll kotae = 0;
	pakuri_sort(N, P);
	rep(j, N) {
		if (M) {
			ll k = min(M, P[j] & (1 << 30) - 1);
			kotae += k * (P[j] >> 30);
			M -= k;
		}
	}
	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 1792
N,M = map(int,input().split())
L =[]
R =[]
for _ in range(M):
    L_,R_ = map(int,input().split())
    L.append(L_)
    R.append(R_)
Lmax = 0
Rmin = 10**6
for i in range(M):
    Lmax = max(Lmax,L[i])
    Rmin = min(Rmin,R[i])
if Rmin-Lmax < 0:
    print(0)
    exit()
print(Rmin-Lmax+1)

Measured memory_bytes: 11016
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		Map<Character, Boolean> map = new HashMap<Character, Boolean>() {
			{
				put('a', false);
				put('b', false);
				put('c', false);
				put('d', false);
				put('e', false);
				put('f', false);
				put('g', false);
				put('h', false);
				put('i', false);
				put('j', false);
				put('k', false);
				put('l', false);
				put('m', false);
				put('n', false);
				put('o', false);
				put('p', false);
				put('q', false);
				put('r', false);
				put('s', false);
				put('t', false);
				put('u', false);
				put('v', false);
				put('w', false);
				put('x', false);
				put('y', false);
				put('z', false);
			}
		};
		for(int i=0; i<S.length(); i++) {
			if(!map.get(S.charAt(i))) {
				map.put(S.charAt(i), true);
			}
		}
		for(Map.Entry<Character, Boolean> entry : map.entrySet()) {
			if(!entry.getValue()) {
				System.out.println(entry.getKey());
				return;
			}
		}
		System.out.println("None");
	}

}


Measured memory_bytes: 27588
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
 
using ull = unsigned long long int;
using ll = long long int;
using du = double;
using ld = long du;
using vi = vector<int>;
using vll = vector<ll>;
using vld = vector<ld>;
using vdu = vector<du>;
using vs = vector<string>;
using vc = vector<char>;
using si = set<int>;
using sll = set<ll>;
using sdu = set<du>;
using sld = set<ld>;
using pii = pair<int, int>;
using pll = pair<ll,ll>;
using pdu = pair<du,du>;
using pld = pair<ld,ld>;
using pis = pair<int,string>;
 
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define sp(x) setprecision(x)<<fixed
#define loop(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pi acos(-1)
#define meme(a,x) memset(a,x,sizeof(a))
#define all(a) a.begin(),a.end()
 
//debugger
 
#ifdef KAIZER
#include "debug.h"
#else
#define debug(x...)
#endif
//debugger
 
//functions
bool check_pow(ll a)
{
    if((a&(a-1))==0) return true;
    else return false;
}
ld my_pow(ld a,int b)
{
    ld ans=1;
    for(int i=0;i<b;i++) ans*=a;
    return ans;
}
ll digits(ll a)
{
    string line=to_string(a);
    return line.size();
}
bool prime_check(ll a)
{
    bool flag=true;
    for(ll i=2;i<=sqrt(a);i++)
    {
        if(a%i==0) {flag=false; break;}
    }
    return flag;
}
bool comp(const pair<int,int> &a , const pair<int,int> &b)
{
    if(a.ff!=b.ff) return a.ff>b.ff;
    else return a.ss<b.ss;
}
bool comp2(const ll &a, const ll &b)
{
     return a>b;
}
 
//functions

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FASTIO;
    ll n,i=1;
    cin>>n;
    while(i<=n) i*=2;
    i/=2;
    cout<<i<<endl;
}

Measured memory_bytes: 3620
dataset = (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)
k = int(input())
print(dataset[k-1])

Measured memory_bytes: 3060
from collections import deque
import sys
input = sys.stdin.readline

n = int(input())
graph = {i: deque() for i in range(1, n+1)}

for i in range(n):
    u, k, *v = map(int, input().split())
    v.sort()
    for vi in v:
        graph[u].append(vi)

seen = [0]*(n+1)
queue = deque()
dist = [-1]*(n+1)
def bfs(v):
    dist[v] = 0
    seen[v] = 1
    queue.append(v)
    while queue:
        q = queue[0]
        if not graph[q]:
            queue.popleft()
            continue
        g = graph[q].popleft()
        if seen[g]:
            continue
        seen[g] = 1
        dist[g] = dist[q] + 1
        queue.append(g)

bfs(1)
for id, d in enumerate(dist):
    if id == 0:
        continue
    print(id, d)


Measured memory_bytes: 6076
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

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

using namespace std;

int my_gcd(int a, int b){   
    if (b != 0) return my_gcd(b, a%b);
    else    return a;
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> R(N), L(N);
    int ans = 1;

    rep(i, N) cin >> A[i];
    rep(i, N-1) L[i+1] = my_gcd(L[i],A[i]);
    for (int i=N-1; i>=1; i--) R[i-1] = my_gcd(R[i],A[i]);
    rep(i, N)   ans = max(ans, my_gcd(R[i],L[i])); 
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1408
#include <iostream>

#define Nmax int(1e5 + 1)
using namespace std;

char S[Nmax];
long long nr_B,nr_R,i;

int main() {
    ios_base::sync_with_stdio(0);
    cin >> S;
    for(i = 0; S[i]; ++i)
        if(S[i] == '1')
            nr_B++;
        else
            nr_R++;
    cout << 2 * min(nr_B,nr_R);
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    map<char, int > counter;
    REP(i,4)
        counter[s[i]]++;
    
    // bool flag = true;
    if (SIZE(counter) != 2)
    {
        cout << "No" << endl;
        return 0;
    }
    if (counter.at(s[0]) != 2)
    {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
sum_n = (1/2)*n*(n+1)
sum_3 = (1/2)*(n//3)*(n//3+1)*3
sum_5 = (1/2)*(n//5)*(n//5+1)*5
sum_15 = (1/2)*(n//15)*(n//15+1)*15
print(str(int(sum_n+sum_15-sum_3-sum_5)))

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
constexpr int Nbit= 200'000;
constexpr int sNbit= 21;

int nextX(const bitset<sNbit> &bsX, int popX){
  bitset<sNbit> X= bsX;

  int mod= 0;
  int base_mod= 1;
  while(X.count() > 0){
    if(X.test(0)){
      mod= (mod+ base_mod) % popX;
    }

    base_mod= (2* base_mod) % popX;
    X >>= 1;
  }

  return mod;
}

int init(const bitset<Nbit> &bsX, vector<int> *base_mod, int div){
  if(div==0){ return 0; }
  else{
    const size_t N= (int)base_mod->size();

    bitset<Nbit> X= bsX;
    int mod= 0;
    base_mod->at(0)= 1 % div;
    for(size_t i=0; i<N; i++){
      if(X.test(0)){
        mod= (mod+ base_mod->at(i)) % div;
      }

      if(i+1 < N){
        base_mod->at(i+1)= (2* base_mod->at(i)) % div;
      }
      X >>= 1;
    }

    return mod;
  }
}

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

  const bitset<Nbit> bsX(X);
  const int popX= (int)bsX.count();

  vector<int> offset_plus1(N);
  vector<int> offset_minus1(N);

  const int mod_popXplus1 = init(bsX, &offset_plus1 , popX+ 1);
  const int mod_popXminus1= init(bsX, &offset_minus1, popX- 1);
  
  for(int i=1; i<=N; i++){
    int bit_i= (bsX.test(N-i)) ? 0
                               : 1;
    int popXi= (bit_i==1) ? popX+ 1
                          : popX- 1;

    bitset<sNbit> bsXi;
    int ans_i= 0;
    while(popXi > 0){
      ans_i++;
      if(ans_i==1){
        int next= (bit_i==1) ? (mod_popXplus1+ offset_plus1.at(N-i)) % popXi
                             : (((mod_popXminus1- offset_minus1.at(N-i)) % popXi)+ popXi) % popXi;
        bsXi= bitset<sNbit>(next);
        popXi= (int)bsXi.count();
      }
      else{
        int next= nextX(bsXi, popXi);

        bsXi= bitset<sNbit>(next);
        popXi= (int)bsXi.count();
      }
    }

    cout << ans_i << endl;
  }
}

Measured memory_bytes: 5168
#include <iostream>

using namespace std;

int main() {
	int n;
	
	while (cin >> n) {
		int cnt = 0;
		for (int a = 0; a <= 9; ++a) {
			for (int b = 0; b <= 9; ++b) {
				for (int c = 0; c <= 9; ++c) {
					for (int d = 0; d <= 9; ++d) {
						if ((a + b + c + d) == n)
							cnt++;
					}
				}
			}
		}
		cout << cnt << endl;
	}
}


Measured memory_bytes: 3060
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define MAX_V 100
#define min(a, b) ((a) < (b) ? (a) : (b))

const int INF = 100000000;
int cost[MAX_V][MAX_V];
int V;

int
prim()
{
	int mincost[MAX_V];
	bool used[MAX_V];
	int u, v;
	int i;

	for (i = 0; i < V; ++i)
	{
		mincost[i] = INF;
		used[i] = false;
	}

	int res = 0;
	mincost[0] = 0;
	while (true)
	{
		v = -1;
		for (u = 0; u < V; ++u)
		{
			if (!used[u] && (v == -1 || mincost[u] < mincost[v]))
				v = u;
		}

		if (v == -1)
			break;

		used[v] = true;
		res += mincost[v];
		for (u = 0; u < V; ++u)
			mincost[u] = min(mincost[u], cost[v][u]);
	}

	return res;
}

int
main(int argc, char** argv)
{
	int c;
	int i, j;

	scanf("%d", &V);
	for (i = 0; i < V; ++i)
	{
		for (j = 0; j < V; ++j)
		{
			scanf("%d", &c);
			cost[i][j] = (c != -1) ? c : INF;
		}
	}

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



Measured memory_bytes: 2108
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array

main :: IO ()
main = do
  (n:m:_) <- fmap (map read . words) getLine :: IO [Int]
  as <- fmap (map read . words) getLine :: IO [Int]
  print $ solve' n as

cost = IntMap.fromList $ zip [1..] [2,5,5,4,5,6,3,7,6]

calc :: [Int] -> Integer
calc as = foldl' (\acc (x, y) -> acc + (fromIntegral x) * y) 0 $ zip (sort as) $ map (10^) [0..]

solve' :: Int -> [Int] -> Integer
solve' n as = calc . snd $ dp!n
  where
    value = IntMap.fromList . filter (\(c, a) -> elem a as) $ zip [2,5,5,4,5,6,3,7,6] [1..] 
    costs = map (\a -> cost IntMap.! a) as
    mincost = minimum costs
    dp = listArray (mincost, n) $ map f [mincost..n] :: Array Int (Int, [Int])
    f :: Int -> (Int, [Int])
    f i | i == mincost = (1, [value IntMap.! mincost])
        | otherwise = select (0, []) $ [ new c | c <- costs]
        where
          new c | i - c >= mincost = (prevl+1, x:prevx)
                | otherwise = (0,[])
                where
                  x = value IntMap.! c
                  (prevl, prevx) = dp!(i - c)
          
          select ret [] = ret
          select (maxl, maxx) (x:xs)
            | maxl < l = select (l, cx) xs
            | maxl > l = select (maxl, maxx) xs
            | maxl == l = if maxx < cx 
                          then select (l, cx) xs
                          else select (maxl, maxx) xs
              where (l, cx) = x 


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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) (in).begin(),(in).end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  REP(i,n)cin >>  a.at(i);
  REP(i,n)cin >>  b.at(i);
  REP(i,n-1)cin >>  c.at(i);
  int ans=0;
  REP(i,n){
    ans += b.at(a.at(i)-1);
    if(i!=n-1)if(a.at(i+1)-a.at(i)==1)ans += c.at(a.at(i)-1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
///////////////////////___combination___////////////////////
vector<ll> fac, finv, inv;
void COMinit(const int MAX = 5000000, const ll &MOD = MOD){
  fac.resize(MAX);finv.resize(MAX);inv.resize(MAX);
  fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
  repd(i,2,MAX){
    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;
}

///////////////////////////////////////////////////////////
int n,k,a[1100];queue<int> q, r;
signed main(){
  cin>>n>>k;
  rep(i,n)cin>>a[i];
  int sum = 0;
  rep(i,n){
    sum = 0;
    repd(j,i,n){
      sum += a[j];
      q.push(sum);
    }
  }
  for(int i = 63;i >= 0;i--){
    q.push(-1);
    while(q.front() != -1){
      if(q.front()&(1LL<<i)){
        q.push(q.front());q.pop();
      }else{
        r.push(q.front());q.pop();
      }
    }
    q.pop();
    if(q.size() >= k){
      while(!r.empty()){
        r.pop();
      }
    }else{
      while(!r.empty()){
        q.push(r.front());r.pop();
      }
    }
  }
  
  int ans = ~0LL;
  rep(i,k){
    ans &= q.front();q.pop();
  }
  cout << ans << endl;
}



Measured memory_bytes: 4580
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
using namespace std;
#define ASCIIBASE 97

int xCode = (int)'x' - ASCIIBASE;

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

int main()
{
    
    string s = "";
    vector<int> beforeIndex;
    int counter = 0;
    cin >> s;
    string copyS = s;

    bool even = s.size() % 2 == 0;

    for (int i = 0; i < s.size(); i++)
    {
        beforeIndex.push_back(counter);
        if (s[i] == 'x')
        {
            s.erase(s.begin() + i);
            beforeIndex.erase(beforeIndex.begin() + i);
            i--;
        }
        counter++;
    }

    if (!check(s))
    {
        cout << -1;
        return 0;
    }

    vector<int> L;
    vector<int> R;

    if(s.size() % 2 == 0)
    {
        int center1 = beforeIndex[s.size() / 2- 1];
        int center2 = beforeIndex[s.size() / 2];
        int XCounter = 0;
        for (int i = 0; i <= center1; i++)
        {
            if(copyS[i] != 'x')
            {
                L.push_back(XCounter);
                XCounter = 0;
            }
            else
            {
                XCounter++;
            }
        }
        for (int i = copyS.size() - 1; i >= center2;i--)
        {
            if(copyS[i] != 'x')
            {
                R.push_back(XCounter);
                XCounter = 0;
            }
            else
            {
                XCounter++;
            }
        }
    }
    else
    {
        int center = beforeIndex[s.size() / 2];
        int XCounter = 0;
        for (int i = 0; i <= center; i++)
        {
            if (copyS[i] != 'x')
            {
                L.push_back(XCounter);
                XCounter = 0;
            }
            else
            {
                XCounter++;
            }
        }
        for (int i = copyS.size() - 1; i >= center; i--)
        {
            if (copyS[i] != 'x')
            {
                R.push_back(XCounter);
                XCounter = 0;
            }
            else
            {
                XCounter++;
            }
        }
    }

    int answer = 0;
    for (int i = 0; i < L.size();i++)
    {
        answer += abs(L[i] - R[i]);
    }

    cout << answer;
    return 0;

}

Measured memory_bytes: 1528
#include <stdio.h>

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long stock = 0, money = 1000;
  int flag = 0;
  for (long i = 0; i < n; i++) {
    if (flag == 0) {
      if (i != n-1 && a[i] < a[i+1]) {
        stock += money/a[i];
        money %= a[i];
        flag = 1;
      }
    } else {
      if (i == n-1 || (i != n-1 && a[i] > a[i+1])) {
        money += stock*a[i];
        stock = 0;
        flag = 0;
      }
    }
  }
  printf("%ld\n", money);

  return 0;
}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int n;
  string s;
  cin >> n >> s;

  string ans = "";
  ans += s[0];
  rep(i, 1, n) {
    if (ans[ans.size() - 1] != s[i]) ans += s[i];
  }
  cout << ans.size() << endl;
}


Measured memory_bytes: 592
#include <stdio.h>
#define N 100
#define INF 1000000
 
int n, a[N][N];

int MST(void);
 
int main(){
  int i, j;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d",&a[i][j]);
    }
  }
  printf("%d\n",MST());
   
  return 0;
}
 
int MST(){
  
  int i, j, u, v, d[N], pi[N], color[N], min, sum = 0;

  for(u = 0; u < n; u++){
    d[u] = INF;
    pi[u] = -1;
    color[u] = 0;
  }
  d[0] = 0;
   
  while(1){
    min = INF;
    for(i = 0; i < n; i++){
      if(color[i] != 2 && min > d[i]){
    u = i;
    min = d[i];
      }
    }
     
    if(min == INF) break;
 
    color[u] = 2;
     
    for(v = 0; v < n; v++){
      if(color[v] != 2 && a[u][v] < d[v] && a[u][v] != -1){
    pi[v] = u;
    d[v] = a[u][v];
      }
    }
  }
 
  for(i = 0; i < n; i++){
    if(pi[i] != -1) sum += a[i][pi[i]];
  }
 
  return sum;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
constexpr ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

string s;
void solve() {
    cin >> s;

    int n = sz(s);
    vector<ll> vec(n + 1, 0);
    rep(i, n)
        if (s[i] == '<') vec[i + 1] = vec[i] + 1;
    repd(i, n)
        if (s[i] == '>') maxs(vec[i], vec[i + 1] + 1);

    ll ans = 0;
    rep(i, n + 1)
        ans += vec[i];
    cout << ans << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 4764
N = int(input())
S = list(input())
 
numE = S.count('E')
numTurn = numE
numW = 0
 
for dir in S:
    if dir == 'E':
        numE -= 1
    else:
        numW += 1
    if numTurn > numE + numW:
        numTurn = numE + numW
 
print(numTurn)

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

using namespace std;
int x[10] , y[10] , n;
int sq(int x)
{
    return x * x;
}
double dst(int i1 , int i2)
{
    return sqrt(sq(x[i1] - x[i2]) + sq(y[i1] - y[i2]));
}
int main() {
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> x[i] >> y[i];
    vector<int> permut(n);
    for(int i = 0; i < permut.size(); i++)
        permut[i] = i;
    int cnt = 0;
    double tot = 0;
    do{
        cnt++;
        double dist = 0;
        for(int i = 0; i < permut.size() - 1; i++)
            dist += dst(permut[i] , permut[i + 1]);
        tot += dist;
    }while(next_permutation(permut.begin() , permut.end()));
    cout << fixed << setprecision(10) << tot / cnt;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;

public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		HashMap<Integer, Long>	hash = new HashMap<Integer, Long>();
		LinkedHashSet<Integer>	keys = new LinkedHashSet<Integer>();
		int						cnt  = 0;

		while((cnt = parseCnt()) != 0) {
			int	res = 0;

			hash.clear();
			keys.clear();

			for (int l = 0; l < cnt; l++) {
				int[]	head = parseData();
				long	val  = (long)head[1] * (long)head[2];

				if (hash.containsKey(head[0])) {
					val += hash.get(head[0]);
				}

				hash.put(head[0], val);
				if (val >= (long)1000000) {
					keys.add(head[0]);
				}
			}

			res = keys.size();
			if (res == 0) {
				System.out.println("NA");
			} else {
				Iterator<Integer>	iter = keys.iterator();
				for (int i = 0; i < keys.size(); i++) {
					System.out.println(iter.next());
				}
			}
		}
	}

	private static int parseCnt() {
		int		cnt = 0;
		String	str = null;

		if ((str = parseStdin()) != null) {
			cnt = Integer.parseInt(str);
		}

		return cnt;
	}

	private static int[] parseData() {
		int[]	data = null;
		String	str  = null;

		if ((str = parseStdin()) != null) {
			String[]	lines = str.split(" ");

			if (lines.length > 0) {
				data = new int[lines.length];
				data[0] = Integer.parseInt(lines[0]);
				data[1] = Integer.parseInt(lines[1]);
				data[2] = Integer.parseInt(lines[2]);
			}
		}

		return data;
	}

	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (tmp != null) {
            	if (!tmp.isEmpty()) {
            		stdin = tmp;
            	}
        	}
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

Measured memory_bytes: 25100
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d;
int main()
{
	cin>>a>>b>>c>>d;
	if(c==1||d==1)
	{
		cout<<0;
		return 0;
	}
	long long cy=0,dy=0;
	cy=b/c-a/c;
	if(a%c==0)
	cy++;
	dy=b/d-a/d;
	if(a%d==0)
	dy++;
	long long dc=c/__gcd(c,d)*d,dcy=0;
	dcy=b/dc-a/dc;
	if(a%dc==0)
	dcy++;
	long long ans=dy-dcy+cy;
	ans=(b-a+1)-ans;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF (1<<30)

int main(void){
	int num[200000],a,i,n,k,ans=0;
	cin >> n >> k;
	fill(num,num+200000,0);
	for(i=0; i<n; i++){
		cin >> a;
		a--;
		num[a]++;
	}
	sort(num,num+200000);
	for(i=199999-k; i>=0; i--){
		ans += num[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1152
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        double cnt = 0;
        for (int i = 1; i <= n; ++i) {
            if (i % 3 != 0 && i % 5 != 0)
                cnt += i;
        }
        DecimalFormat ft = new DecimalFormat("####");
        System.out.print(ft.format(cnt));
    }
}


Measured memory_bytes: 36012
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef vector<double> vd;
typedef vector<vd> vvd;
typedef complex<double> Point;
const double EPS=1e-10;
const double INFTY=1e10;

void WarshallFloyd(vvd& dist,vvi& next)
{
	int n=dist.size();
	
	rep(i,n) rep(j,n)
		next[i][j]=j;
	
	rep(k,n) rep(i,n) rep(j,n){
		if(dist[i][j]>dist[i][k]+dist[k][j]){
			dist[i][j]=dist[i][k]+dist[k][j];
			next[i][j]=next[i][k];
		}
	}
}

int main()
{
	for(int n;cin>>n,n;){
		vi b(n);
		vector<Point> p(n);
		rep(i,n)
			cin>>b[i]>>real(p[i])>>imag(p[i]);

		vvd dist(n,vd(n,INFTY));
		rep(i,n) rep(j,n)
			if(abs(p[i]-p[j])<50+EPS)
				dist[i][j]=abs(p[i]-p[j]);
		vvi next(n,vi(n));
		WarshallFloyd(dist,next);
		
		int m; cin>>m;
		rep(i,m){
			int s,g; cin>>s>>g;
			int si=-1,gi=-1;
			rep(i,n){
				if(b[i]==s) si=i;
				if(b[i]==g) gi=i;
			}
			if(abs(dist[si][gi]-INFTY)<EPS)
				cout<<"NA"<<endl;
			else{
				for(int j=si;j!=gi;j=next[j][gi])
					cout<<b[j]<<" ";
				cout<<g<<endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

ll n,a[100010],s=0,s2=0,c=0;

void init(){
	cin>>n;
	rep(i,n)cin>>a[i];
}

int main(void){
	init();
	rep(i,n)s ^= a[i];
	rep(i,n)a[i] &= ~s;  // 興味深くないbitを消す
	ll rank=0;
	irep(i,60){
		int j;
		bool found=false;
		for(j=rank;j<n;j++){
			if(1 & (a[j]>>i)){
				break;
			}
		}
		if(j==n)continue;
		if(j>rank)swap(a[rank],a[j]);
		for(j=rank+1;j<n;j++) {
			if(1 & (a[j]>>i))a[j] ^= a[rank];
		}
		rank++;
	}
	rep(i,n)s2=max(s2,s2^a[i]);
	// rep(i,n){
	// 	rep(j,60)cerr<<(1 & (a[i]>>j))<<" ";
	// 	cerr<<endl;
	// }
	cout<<s+2*s2<<endl;
	return 0;
}

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



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

	vector<pair<long long,long long>> V(N);
	vector<pair<long long,long long>> P(0);
	for(int i=0;i<N;i++){
		cin>>V[i].first>>V[i].second;
	}
	if(N==1){
		cout<<1<<endl;
		return 0;
	}
	sort(V.begin(),V.end());
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			P.push_back(make_pair(V[i].first-V[j].first,V[i].second-V[j].second));
			P.push_back(make_pair(V[j].first-V[i].first,V[j].second-V[i].second));
		}
	}
	long long mini = 999999999;
	for(int i=0;i<P.size();i++){
		long long x = P[i].first;
		long long y = P[i].second;
		long long cnt = 0;
		for(int j=0;j<N;j++){
			bool f = false;
			for(int k=0;k<j;k++){
				if(V[k].first==V[j].first+x&&V[k].second==V[j].second+y){
					f=true;
					break;
				}
			}
			if(!f)cnt++;
		}
		mini = min(cnt,mini);
	}
	cout<<mini<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  vector<string> youbi = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

  string s;
  cin >> s;
  for (int i = 0; i < youbi.size(); i++) {
    if (s == youbi[i]) {
      cout << ((i == 0) ? 7 : (7-i)) << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll d,n,ans,i;
    cin>>d>>n;
   // ans=pow(100,d)*n;
    ans=1;
    for(i=0;i<d;i++)
    {
        ans=(ans%ll(1e9+7))*100;
    }
    if(n==100)
    {
        ans=(ans%ll(1e9+7))*(n+1);
        cout<<ans;
    }
    else
    {
        ans=(ans%ll(1e9+7))*n;
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 256