akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main() {
    int c[3][3];
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> c[i][j];
        }
    }
    int a[3], b[3];
    //参考 公式解説
    a[0] = 0;
    for (int i = 0; i < 3; ++i) {
        b[i] = c[0][i] - a[0];
    }
    for (int i = 1; i < 3; ++i) {
        a[i] = c[i][0] - b[0];
    }
    for (int i = 1; i < 3; ++i) {
        if (c[i][1] - b[1] != a[i]) {
            cout << "No" << endl;
            return 0;
        }
        if (c[i][2] - b[2] != a[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

#define EPS (1e-7)
#define INF (1<<26)
#define PI (acos(-1))

#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

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; }

using ll = long long;

int dp[41][401][401];
int a[41], b[41], c[41];

int main() {
  int n, ma, mb; cin >> n >> ma >> mb;
  REP(i,n) cin >> a[i] >> b[i] >> c[i];
  REP(i,41) REP(j, 401) REP(k, 401) dp[i][j][k] = INF;
  dp[0][0][0] = 0;
  REP(i,n) REP(j,401) REP(k,401) {
    if (dp[i][j][k] == INF) continue;
    chmin(dp[i+1][j][k], dp[i][j][k]);
    chmin(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k] + c[i]);
  }

  int ans = INF;
  for (int i = 1; i <= 400; ++i) for (int j = 1; j <= 400; ++j) {
    if (i*mb == j*ma) chmin(ans, dp[n][i][j]);
  }

  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 25984
o=input("")
e=input("")
s=[]
l1=len(o)
l2=len(e)
if(l1<l2):
    p=l1
else:
    p=l2
for i in range(p):
    s.append(o[i])
    s.append(e[i])

if(l1==l2):
    print(''.join(s))
elif(l1<l2):
    s.append(e[l2-1])
    print(''.join(s))
else:
    s.append(o[l1-1])
    print(''.join(s))
    

    


Measured memory_bytes: 3064
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (groupBy, sortBy, sort)
import Data.Function (on)

main :: IO ()
main = do
  n <- unsafeSignedDecimal <$> T.getLine :: IO Int
  sps <- sequence . replicate n $ fmap unsafeSignedDecimal . unsafeListToTuple . T.words <$> T.getLine :: IO [(T.Text, Int)]
  let
    spis = zipWith (\(s, p) i -> (s, (p, i))) sps [1..n]
  mapM_ print . concat . map (map snd . reverse . sortBy (compare `on` fst) . map snd) . groupBy ((==) `on` fst) . sortBy (compare `on` fst) $ spis

unsafeListToTuple :: [T.Text] -> (T.Text, T.Text)
unsafeListToTuple (x : y : _) = (x, y)

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 764
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var a = new int[5];
        for (int i = 0; i < a.Length; i++)
            a[i] = int.Parse(ReadLine());

        var k = int.Parse(ReadLine());

        var ok = true;

        for (int i = 0; i < a.Length - 1; i++)
        {
            for (int j = i + 1; j < a.Length; j++)
            {
                if(a[j] - a[i] > k)
                {
                    ok = false;
                    goto LOOP_END;
                }
            }
        }
    LOOP_END:

        WriteLine(ok ? "Yay!" : ":(");
    }
}


Measured memory_bytes: 27420
def main():
    A = map(int, input().split())
    A = map(lambda x: x % 3, A)

    r = 0
    for x in A:
        r = (r + x) % 3
        if x == 0 or r == 0:
            print('Possible')
            return

    print('Impossible')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main()
{
   long a,b,c;
   long i,j,k;
   long cnt = 0;
   long left,right,mid;
   long ans = 0;
   static char str[102][1003];
   char p[1003];
   char tmp;
   long h,m,s;

   scanf("%ld %ld %ld",&a,&b,&c);
   if (a < b && b < c)
      printf("Yes\n");
   else
      printf("No\n");

   return 0;
}

Measured memory_bytes: 1008
n=int(input())
s=[]
x=input().strip().split()
for i in range(n):
	s.append(int(x[i]))
q=int(input())
t=[]
y=input().strip().split()
for j in range(q):
	t.append(int(y[j]))
	
if n<q:
	tmp=s
	s=t
	t=tmp
	
count=0

for i in range(len(t)):
	for j in range(len(s)):
		if t[i]==s[j]:
			count+=1
			break

print(count)



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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 3e5 + 9, M = 4e5 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int n, nxt[N];
vector<pii> seg;

ll dp[N];

ll solve(int i){
    if(i == n)  return 1;

    ll &ret = dp[i];
    if(~ret)    return ret;

    ret = solve(i + 1) + solve(nxt[i]);

    while(ret >= 998244353) ret -= 998244353;

    return ret;
}

int main(){
    init();

    cin >> n;
    for(int i = 0;i < n;i++){
        int x, d;   cin >> x >> d;
        seg.push_back({x, x + d - 1});
    }

    sort(seg.begin(), seg.end());

    for(int i = n - 1;i >= 0;i--){
        int j = i + 1;
        while(j < n && seg[i].S >= seg[j].F)   j = nxt[j];
        nxt[i] = j;
    }


    memset(dp, -1, sizeof dp);

    cout << solve(0);
}

Measured memory_bytes: 11376
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string.h>
#include <functional>
using namespace std;

typedef pair<int, int> P;
const int INF = 1e+9;

int main() {
	int n;
	while(cin >> n && n){
		int s, prev = 0, ans = 0, m[100001] = {0}, r = 0, l = 0;
		scanf("%d", &prev);
		l = prev & 1;
		m[r] = 1;
		for(int i = 2; i <= n; ++i){
			scanf("%d", &s);
			
			if(prev == s){
				m[r]++;
			}
			else{
				if(i % 2){
					m[++r] = 1;
				}
				else{
					if(r == 0){
						m[r]++;
						l ^= 1;
					}
					else{
						m[r - 1] += m[r] + 1;
						r--;
					}
				}
			}
			prev = s;
		}
		if(l == 1){
			for(int i = 1; i <= r; i += 2)
				ans += m[i];
		}
		else{
			for(int i = 0; i <= r; i += 2)
				ans += m[i];
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1632
def main():
    N = int(input())
    a = list(map(int,input().split()))
    col_list = [0]*8
    free = 0
    for i in range(N):
        if a[i] < 3200:
            col = a[i]//400
            col_list[col] += 1
        else:
            free += 1
    non_col = col_list.count(0)
    print(max(1,8-non_col),8-non_col+free)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
 
int main(){
  int N, sum = 0, min = 999;
  cin >> N;
  REP(i,N) {
    int s;
    cin >> s;
    sum += s;
    if(s % 10 != 0 && min > s) {
      min = s;
    }
  }
  if(sum % 10 != 0) {
    cout << sum << endl;
  } else if(min != 999) {
    cout << sum - min << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int count = 0;
    if (N >= 105) count++;
    if (N >= 135) count++;
    if (N >= 165) count++;
    if (N >= 189) count++;
    if (N >= 195) count++;
    System.out.println(count);
  }
}


Measured memory_bytes: 23892
N = list(map(int, list(input())))
# print(N)
intN = int("".join(list(map(str, N))))
sumN = sum(N)

for x in range(len(N)):
    if x == 0:
        N[x] = N[x] - 1
    else:
        N[x] = 9
intN2 = int("".join(list(map(str, N))))
sumN2 = sum(N)
print(max(sumN, sumN2))


Measured memory_bytes: 38256
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;
#define n_max 100000

#define rep(i,n) for(int i = 0; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

int main() {
    int n;
    int ans = 0;
    string s;
    char pre;

    cin >> n >> s;
    
    rep(i,n){
        if(s[i] != pre) {
            ans++;
            pre = s[i];
        }
    }
    cout << ans << endl;
}


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

class UF {
public:
    vector<int> p;
    UF(size_t n) : p(n) {
        for(size_t i=0; i<n; i++)
            p[i] = i;
    };
    int find(int x) {
        if(p[x] == x) return x;
        return p[x] = find(p[x]);
    };
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        p[x] = y;
    };
};

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

    vector<int> p(n);
    for(auto &x: p) cin >> x, x--;

    UF uf(n);

    for(int i=0; i<m; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        uf.unite(x, y);
    }

    long res = 0;
    for(int i=0; i<n; i++)
        res += uf.find(i) == uf.find(p[i]);
    cout << res << endl;
}


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

namespace TYC
{
	typedef long long ll;
	typedef pair<int, int> pii;

	const int N = 1e5 + 5, INF = 0x3f3f3f3f;

	int n, m, L[N], R[N], A[N];
	vector<int> E[N];

	void dfs(const int u, const int f)
	{
		for (int v : E[u])
			if (v != f)
			{
				dfs(v, u);
				int l = max(-INF, L[v] - 1);
				int r = min(INF, R[v] + 1);
				if (R[u] < l || L[u] > r)
				{
					puts("No");
					exit(0);
				}
				L[u] = max(L[u], l);
				R[u] = min(R[u], r);
			}
		if (L[u] > R[u])
		{
			puts("No");
			exit(0);
		}
	}

	void getans(const int u, const int f)
	{
		for (int v : E[u])
			if (v != f)
			{
				if (A[v] == -1)
				{
					if (L[v] <= A[u] - 1 && A[u] - 1 <= R[v])
						A[v] = A[u] - 1;
					else
						A[v] = A[u] + 1;
				}
				getans(v, u);
			}
	}

	void work()
	{
		scanf("%d", &n);
		for (int i = 1, u, v; i < n; i++)
		{
			scanf("%d%d", &u, &v);
			E[u].push_back(v);
			E[v].push_back(u);
		}
		scanf("%d", &m);
		for (int i = 1; i <= n; i++)
			A[i] = -1, L[i] = -INF, R[i] = INF;
		for (int i = 1, a, b; i <= m; i++)
		{
			scanf("%d%d", &a, &b);
			L[a] = R[a] = A[a] = b;
		}
		dfs(1, 0);
		if (A[1] == -1)
			A[1] = L[1];
		getans(1, 0);
		for (int i = 1; i <= n; i++)
			if (A[i] < L[i] || R[i] < A[i])
			{
				puts("No");
				exit(0);
			}
		puts("Yes");
		for (int i = 1; i <= n; i++)
			printf("%d\n", A[i]);
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 13824
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define MAX 10000003
#define pb push_back
// #define mp make_pair
#define mem(x,y) memset(x,y,sizeof(x))
#define lcm(a,b) (a*b)/__gcd(a,b)
#define set_bit_count(x) __builtin_popcount(x)
#define str_rev(str) reverse(str.begin(),str.end())
#define loop(i,x,y) for(ll i=x;i<y;i++)
#define rloop(i,x,y) for(ll i=x-1;i>=y;i--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fastio;
    int n,m;
    cin>>n>>m;
    int sum=0,val;
    for(int i=0;i<m;i++)
    {
        cin>>val;
        sum+=val;
    }
    if(n-sum>=0)
        cout << n-sum << endl;
    else
        cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N,c1=0,c2=0,c3=0,c4=0;
	cin >> N;
	vector<string> S(N);

	for (int i = 0;i < N;i++) {
		cin >> S[i];
		if (S[i].compare("AC")==0)c1++;
		if (S[i].compare("WA")==0)c2++;
		if (S[i].compare("TLE")==0)c3++;
		if (S[i].compare("RE")==0)c4++;
	}
	cout << "AC " << "x " << c1 << endl;
	cout << "WA " << "x " << c2 << endl;
	cout << "TLE " << "x " << c3 << endl;
	cout << "RE " << "x " << c4 << endl;
	return 0;
}

Measured memory_bytes: 6268
s = input()
t = input()
l = len(s)
m = len(t)
ans=l
for i in range(l-m+1):
  count = 0
  for j in range(m):
    if s[i+j]==t[j]:
      count+=1
  ans = min(m-count,ans)
print(ans)
  

Measured memory_bytes: 8984
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
	int n, x;
	int a = 0;
	int way[30000] = { 0 };
	int N[100] = { 0 };
	int X[300] = { 0 };
	for (;; a++){
		cin >> n >> x;
		N[a] += n;
		X[a] += x;
		if (N[a] == 0 && X[a] == 0){
			break;
		}
	}
	for (int b = 0; b < a; b++){
		for (int i = 1; i <= N[b]; i++){
			for (int j = 2; j <= N[b]; j++){
				for (int k = 3; k <= N[b]; k++){
					if (i<j&&j<k&&i + j + k == X[b]){
						way[b] += 1;
					}
				}
			}
		}
	}
	for (int w = 0; w < a; w++){
		cout << way[w] << endl;
	}
	return 0;
	}


Measured memory_bytes: 3220
#include<stdio.h>
#define N 100
#define INF 2140000000
#define min(x,y) ((x)<=(y)?(x):(y))

int n;

int matrixchainmultiplication(int *a){
  int i,j,k,l,m[N+1][N+1];

  for(i=1;i<=n;i++) m[i][i]=0;
  for(i=2;i<=n;i++){
    for(j=1;j<=n-i+1;j++){
      k=j+i-1;
      m[j][k]=INF;
      for(l=j;l<=k-1;l++){
        m[j][k]=min(m[j][k],m[j][l]+m[l+1][k]+a[j-1]*a[l]*a[k]);
      }
    }
  }
      return m[1][n];
}

int main(){
  int a[N+1],i;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d%d",&a[i],&a[i+1]);

  printf("%d\n",matrixchainmultiplication(a));

    return 0;
}


Measured memory_bytes: 2108
//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <atcoder/all>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 998244353;
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}

ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[200005],R[200005],coef[200005];
void make(){
	F[0] = 1;
	for(int i=1;i<200005;i++) F[i] = F[i-1]*i%mod;
	for(int i=0;i<200005;i++) R[i] = modpow(F[i],mod-2);
	coef[0] = 1;
	for(int i=2;i<200005;i+=2){
		coef[i] = coef[i-2] * i % mod * (i-1) % mod * R[2] % mod;
	}
	for(int i=0;i<200005;i++) coef[i] = coef[i] * R[i/2] % mod;
}
ll C(int a,int b){
	return F[a]*R[b]%mod*R[a-b]%mod;
}
int n, h[100005];

struct S{
	vector<int>vec;
	bool operator < (const S & a) const{
		return vec.size() > a.vec.size();
	}
};
int main(){
	make();
	cin >> n;
	repn(i, 2*n){
		int a; cin >> a; h[a] ++;
	}
	priority_queue<S>que;
	rep(i, 100005){
		vector<int>vec({1});
		ll cur = 1;
		for(int j=1;j*2<=h[i];j++){
			cur = cur * (h[i]+2-j*2) % mod * (h[i]+1-j*2) % mod * R[2] % mod;
			vec.pb((int)(cur * R[j] % mod));
		}
		que.push(S{vec});
	}
	while(que.size() >= 2){
		auto a = que.top(); que.pop();
		auto b = que.top(); que.pop();
		
		auto c = convolution(a.vec, b.vec);
		que.push(S{c});
	}
	auto X = que.top().vec;
	ll ans = 0;
	for(int i=0;i<X.size();i++){
		if(i%2==0) ans += 1LL * X[i] * coef[2*n-i*2] % mod;
		else ans -= 1LL * X[i] * coef[2*n-i*2] % mod;
	}
	cout << (ans%mod+mod)%mod << '\n';
}

Measured memory_bytes: 15068
#include <bits/stdc++.h>
#define ll long long
#define M 1000000007 
#define MM 998244353
#define PI 3.14159265 
using namespace std;

int main()
{
	int x;

	cin >> x;

	if (x == 0)
	{
		cout << 1;
	}
	else
	{
		cout << 0;
	}

  	return 0;
}

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


void DFS(const vector<vector<int>> &G,int v,vector<bool> &seen,vector<int> &ans){//深さ優先探索。
//引数は順にグラフ、始点(注目点)、探索済みかどうか、各点の持つ値を記録するカウンタ
  
  ans[v]=true;
 
  for(auto next_v : G[v]){
    if(seen[next_v]) continue;
    DFS(G,next_v,seen,ans);
  } 
  return ;
  ans[v]++;
 
}

int main() {

int N; cin >> N ;

vector<int> A(N);

for(int i=1;i<N;i++){
  cin >> A[i];
  A[i]--;
}

vector<int> ans(N,0);

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

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

  return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, w, a, b);
  if (a > b) swap(a, b);

  cout << max(0, b - (a + w)) << endl;

  return 0;
}

Measured memory_bytes: 256
x = gets.split.map( &:to_i )
x.sort!

r1 = x[ 2 ] - x[ 1 ]
r2 = x[ 2 ] - ( x[ 0 ] + r1 )
if r2.even? then
  r3 = r2 / 2
else
  r3 = r2 / 2 + 2
end

p r1 + r3


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
#include <cmath>
#include <iomanip> //setprecision(2)
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
        int a,b,k;
        cin >> a >> b >> k;
        rep(i,k){
                if(i%2==0) {
                        if(a%2==1) {
                                a--;
                        }
                        a/=2;
                        b +=a;
                }else{
                        if(b%2==1) {
                                b--;
                        }
                        b/=2;
                        a +=b;
                }
        }
        cout << a << " " << b <<endl;
}


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

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

using namespace std;

int main()
{
	map<char,string> ID;
	ID['A'] = "00000";
	ID['B'] = "00001";
    ID['C'] = "00010";
    ID['D'] = "00011";
    ID['E'] = "00100";
    ID['F'] = "00101";
    ID['G'] = "00110";
    ID['H'] = "00111";
    ID['I'] = "01000";
    ID['J'] = "01001";
    ID['K'] = "01010";
    ID['L'] = "01011";
    ID['M'] = "01100";
    ID['N'] = "01101";
    ID['O'] = "01110";
    ID['P'] = "01111";
    ID['Q'] = "10000";
    ID['R'] = "10001";
    ID['S'] = "10010";
    ID['T'] = "10011";
    ID['U'] = "10100";
    ID['V'] = "10101";
    ID['W'] = "10110";
    ID['X'] = "10111";
    ID['Y'] = "11000";
    ID['Z'] = "11001";
    ID[' '] = "11010";
    ID['.'] = "11011";
    ID[','] = "11100";
    ID['-'] = "11101";
    ID['\''] = "11110";
    ID['?'] = "11111";

	map<string,char> Id;
	Id["101"] = ' ';
	Id["000000"] = '\'';
	Id["000011"] = ',';
	Id["10010001"] = '-';
	Id["010001"] = '.';
	Id["000001"] = '?';
	Id["100101"] = 'A';
	Id["10011010"] = 'B';

	Id["0101"] = 'C';
	Id["0001"] = 'D';
	Id["110"] = 'E';
	Id["01001"] = 'F';
	Id["10011011"] = 'G';
	Id["010000"] = 'H';
	Id["0111"] = 'I';
	Id["10011000"] = 'J';

	Id["0110"] = 'K';
	Id["00100"] = 'L';
	Id["10011001"] = 'M';
	Id["10011110"] = 'N';
	Id["00101"] = 'O';
	Id["111"] = 'P';
	Id["10011111"] = 'Q';
	Id["1000"] = 'R';
	
	Id["00110"] = 'S';
	Id["00111"] = 'T';
	Id["10011100"] = 'U';
	Id["10011101"] = 'V';
	Id["000010"] = 'W';
	Id["10010010"] = 'X';
	Id["10010011"] = 'Y';
	Id["10010000"] = 'Z';
	
	string s;
	while(getline(cin,s))
	{
		if(cin.eof()) break;

		string temp;
		rep(i,s.size())
		{
			temp += ID[s[i]];
		}

		string id = "";
		vector<char> ans;
		rep(i,temp.size())
		{
			id += temp[i];
			if(Id.count(id) != 0)
			{
				ans.push_back(Id[id]);
				id = "";
			}
		}

		rep(i,ans.size())
		{
			cout << ans[i];
		}

		cout << endl;
	}
	return 0;
}

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

int main()
{
	int a,b;
	cin >> a >> b;

	if (a < b) {
		cout << "a < b" << endl;
	}
	if (a > b) {
		cout << "a > b" << endl;
	}
	if(a == b) {
		cout << "a == b" << endl;
	}
	
    return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    cout << (n + 1 ) * n / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s; cin >> s;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '*') {
			cout << ans << endl; return 0;
		}
		if (s[i] == '(')ans++;
		else if (s[i] == ')')ans--;
	}
}


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

int m, f, r;

int main() {
    for (;m+f+r!=-3;) {
        cin >> m >> f >> r;
        if (m != -1 && f != -1) {
            if (m+f >= 80) cout << "A";
            else if (m+f >= 65) cout << "B";
            else if (m+f >= 50) cout << "C";
            else if (m+f >=30 && r >= 50) cout << "C";
            else if (m+f >=30) cout << "D";
            else if (m+f+r != -3) cout << "F";
        }
        else if (m+f+r != -3) cout << "F";
        if (m+f+r != -3) cout << endl;
    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
#define ll long long
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	if(n >= 30)
		cout << "Yes";
	else
		cout << "No";
}	


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

int a[10][5];
int check(int i,int j,int res){
	if(a[i][j] == 0)return 0;
	if(j == 4)return res;
	if(a[i][j] != a[i][j+1])return res;
	if(a[i][j] == a[i][j+1])return check(i,j+1,res+1);
}

int main(){
	int n,x,m;
	int count;
	int score;
	while(1){
		cin >> n;
		if(n == 0)break;
		for(int i = 0;i < 10;i++){
			for(int j = 0;j < 5;j++){
				a[i][j] = 0;
			}
		}
		m = 0;
		for(int i = 10 - n;i < 10;i++){
			for(int j = 0;j < 5;j++){
				cin >> a[i][j];
			}
			m++;
		}

		score = 0;
		while(1){
			/*
		for(int i = 0;i < 10;i++){
			for(int j = 0;j < 5;j++){
				cout << a[i][j] <<" ";
			}
			cout << endl;
		}
			*/
			count = 0;
			m = 0;
			for(int i = 9;m < n;i--){
				for(int j = 0;j < 5;j++){
					x = check(i,j,1);
					if(x > 2){
						count++;
						score += a[i][j] * x; 
						for(int k = j;k < j + x;k++){
							a[i][k] = 0;
						}
						break;
					}
				}
				m++;
			}
			//cout << count <<endl;
			if(count == 0)break;
			for(int k = 0;k < count;k++){
				for(int j = 0;j < 5;j++){
					m = 0;
					for(int i = 9;m < n;i--){
						if(a[i][j] == 0)swap(a[i][j],a[i-1][j]);
						m++;
					}
				}
			}
		}

		cout << score <<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
int main(){
  int  a1,a2,a3;
  cin >> a1 >> a2 >> a3;
  if((a1+a2+a3)>21){
      cout << "bust" <<endl;
  }
  else{
      cout << "win" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    long h,sum=0;
    cin>>h>>n;
    int temp;
    for(int i=0;i<n;i++){
        cin>>temp;
        sum+=temp;
    }
    if(sum>=h)
        cout<<"Yes";
    else
        cout<<"No";    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int ans;
int x, y;

int main(void) {
    cin >> x >> y;

    rep(i, 0, 100) rep(j, 0, 100) {
        if (i+j==x && 2*i+4*j==y) {
            puts("Yes");
            return 0;
        }
    }

    puts("No");
    return 0;
}



Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int count4 = 0;
    int count2 = 0;
    for (int i = 0; i < N; i++) {
      int a = scanner.nextInt();
      if (a % 4 == 0) {
        count4++;
      } else if (a % 2 == 0) count2++;
    }

    if (solve(N, count2, count4)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

  private static boolean solve(int N, int count2, int count4) {
    if (count2 == N) return true;
    if (count2 > 1) {
      N -= count2 - 1;
    }
    return count4 >= N / 2;
  }
}


Measured memory_bytes: 49268
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;

const int maxn = 100000 + 10;

vector<ll> al[maxn];
ll dist[maxn], a[maxn], b[maxn], c[maxn];
bool vis[maxn];

struct node{
    ll n, d;
    node(): n(0), d(0){}
    node(ll tn, ll td): n(tn), d(td){}
};

struct cmp{
    bool operator ()(const ll &l1, const ll &l2){
        return dist[l1] > dist[l2];
    }
};

int main(){
    ll N, Q, K;
    memset(vis, 0, sizeof vis);
    scanf("%lld", &N);
    for (ll i = 1; i < N; ++i){
        scanf("%lld%lld%lld", &a[i], &b[i], &c[i]);
        al[a[i]].push_back(i);
        al[b[i]].push_back(i);
    }
    scanf("%lld%lld", &Q, &K);
    priority_queue<ll, vector<ll>, cmp> q;
    dist[K] = 0;
    vis[K] = true;
    q.push(K);
    ll cur, t;
    while (!q.empty()){
        cur = q.top();
        q.pop();
        for (ll i = 0; i < al[cur].size(); ++i){
            t = a[al[cur][i]];
            if (t == cur){
                t = b[al[cur][i]];
            }
            if (!vis[t]){
                vis[t] = true;
                dist[t] = dist[cur] + c[al[cur][i]];
                q.push(t);
            }
        }
    }
    ll x, y;
    for (ll i = 0; i < Q; ++i){
        scanf("%lld%lld", &x, &y);
        printf("%lld\n", dist[x] + dist[y]);
    }
    //system("pause");
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

int main(){
    ll n,k;
    cin >> n >> k;
    ll a[n] = {};
    rep(i,0,n){
        cin >> a[i];
        a[i]--;
    }
    vector<ll> vec;
    bool is_visited[n] = {false};

    ll index = 0;
    rep(i,0,n){
        if(is_visited[a[index]]){
            rep(j,0,vec.size()){
                if(vec[j] == a[index]){
                    if(j > 0) vec.erase(vec.begin(),vec.begin()+j);
                    break;
                }
            }
            break;
        }
        index = a[index];
        vec.push_back(index);
        is_visited[index] = true;
        k--;
        if(k == 0){
            cout << index+1 << endl;
            return 0;
        }
    }

    if(k % vec.size() != 0) cout << vec[k % vec.size() - 1]+1 << endl;
    else cout << vec[vec.size()-1]+1 << endl;

}


Measured memory_bytes: 7124
n = gets.to_i
array = []
n.times do
  line = gets.split.map(&:to_i)
  array << line
end

cnt = 0

array.each do |i|
  if i[0] == i[1]
    cnt += 1
    if cnt == 3
      break
    end
  else
    cnt = 0
  end
end

if cnt >= 3
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 14388
#include <bits/stdc++.h>
#define local freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;
typedef long long int ll;

int main(void){
	//local;
	fast;
	int n, k; cin >> n >> k;
	int p[n];
	int pos = -1;
	for (int i = 0; i < n; ++i){
		cin >> p[i];
		if (p[i] == 1) pos = i;
	}
	int ans = 1e8;
	for (int i = pos; i >= 0 and i >= pos-k+1; --i){
		int cur = 1;
		int left = i;
		int right = (n-1-(i+k-1));
		cur += (left+k-2)/(k-1) + (right+k-2)/(k-1);
		ans = min(ans, cur);
	}
	cout << ans << '\n';
}

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

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    char c;
    cin >> c;

    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel" << endl;
    else cout << "consonant" << endl;

    return 0;
}

Measured memory_bytes: 256
N, X, Y = map(int, input().split())
ans = [0]*N
for i in range(1, N):
    for j in range(i+1, N+1):
        d = min(j - i, abs(X - i) + 1 + abs(Y - j))
        ans[d] += 1
for i in range(1, N):
    print(ans[i])


Measured memory_bytes: 46428
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back

int main()
{
    ll n, q, m, a = 2, k, x, i, tc, j, ans = 1, l, sum = 0;
    cin >> n >> k;
    if(n % k == 0)
        cout << 0 << endl;
//    else if(n < k)
//        cout << n << endl;
//    else if(abs(n - k) >= n)
//        cout << n << endl;
    else{
        cout << min(n % k, k - (n % k)) << endl;
    }

    return 0;
}


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

using namespace std;

using ll = long long;

const int MAXV = 100000;

const ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    vector<int> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];
    sort(s.begin(), s.end(), greater<>());

    vector<ll> dp(MAXV + 1, 0);
    dp[x] = 1;
    for (int i = 0; i < n; i++) {
        vector<ll> ndp(MAXV + 1, 0);
        for (int j = 0; j <= MAXV; j++) {
            if (dp[j] == 0) continue;
            (ndp[j % s[i]] += dp[j]) %= MOD;
            (ndp[j] += dp[j] * (n - i - 1) % MOD) %= MOD;
        }
        dp = move(ndp);
    }

    ll ans = 0;
    for (int i = 0; i <= MAXV; i++) {
        (ans += dp[i] * i % MOD) %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define endl '\n'
#ifndef _WINDOWS
// no getchar_unlocked on Windows so just call getchar
#define getchar getchar_unlocked
#endif

template <typename Func>
inline void loop(int e, Func&& f) {
    for (int i = 0; i < e; i++) {
        std::forward<Func>(f)(i);
    }
}
template <typename Func>
inline void loop(int s, int e, Func&& f) {
    for (int i = s; i < e; i++) {
        std::forward<Func>(f)(i);
    }
}
template <typename T>
inline void scanpn(T& num) {
    int c;
    num = 0;
    c = getchar();
    // bool negative = false;
    // if (c == '-') {
    // 	negative = true;
    // 	c = getchar();
    // }
    for (; (c > 47 && c < 58); c = getchar()) num = num * 10 + c - 48;
    // if (negative)
    //     number = -number;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    unordered_set<string> dict;
    string s;
    while (n--) {
        cin >> s;
        dict.insert(s);
    }
    cout << dict.size() << endl;
    return 0;
}


Measured memory_bytes: 17672
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N,M;
	cin >> N >> M;
	vector<int> cnt(26,0);
	for(int i =0; i < N; i++) {
		string s;
		cin >> s;
		for(int j =0; j < M; j++) cnt[s[j]-'a']++;
	}
	int s1 =(N%2 && M%2), s2 =0, s4 =0;
	if(N%2) s2 +=(M-s1)/2;
	if(M%2) s2 +=(N-s1)/2;
	s4 =(N*M-s2*2-s1)/4;
	int c[] ={0,0,0};
	for(int i =0; i < 26; i++) {
		c[0] +=cnt[i]%2;
		cnt[i] -=cnt[i]%2;
		c[1] +=(cnt[i]/2)%2;
		cnt[i] -=((cnt[i]/2)%2)*2;
		c[2] +=cnt[i]/4;
	}
	if(s4 > c[2]) {
		cout << "No\n";
		return 0;
	}
	c[2] -=s4;
	c[1] +=c[2]*2;
	if(s2 > c[1]) {
		cout << "No\n";
		return 0;
	}
	c[1] -=s2;
	c[0] +=c[1]*2;
	if(s1 > c[0]) {
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,n;
  int a[50];
  scanf("%d",&n);
  a[0]=1;
  a[1]=1;
  for(i=2;i<=n;i++){
    a[i]=a[i-1]+a[i-2];
  }
  printf("%d\n",a[n]);
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair 
#define pb push_back 
#define F first 
#define S second 
#define f(i,n) for(int i=0;i<n;i++) 

using namespace std;

void test(){
	ll n,k;
	cin>>n>>k;
	ll a[n];
	f(i,n)cin>>a[i];
	sort(a,a+n);
	ll sum = 0;
	f(i,k)sum+=a[i];
	cout<<sum<<"\n";
}

int main(){
	int tests = 1;
//	cin>>tests;
	while(tests--){
		test();
	}
}

Measured memory_bytes: 3612
K = int(input())

X = [0] * 20
l = 0

for _ in range(K):
  for i in range(l + 2):
    if X[i] < 9 and (i >= l or X[i] < X[i + 1] + 1):
      if i > l:
        l = i
      X[i] += 1
      for j in range(i - 1, -1, -1):
        X[j] = max(X[j + 1] - 1, 0)
      break

print(''.join(str(x) for x in X[l::-1]))

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

struct dian
{
    int x;
    int y;
}d[10];

double length(dian a,dian b)
{
    double x2=(a.x-b.x)*(a.x-b.x);
    double y2=(a.y-b.y)*(a.y-b.y);
    return sqrt(y2+x2);
}

int main()
{
    double bian[10000];
    int n;
    while(cin>>n)
    {
        int i;
        for(i=0;i<n;i++)
            cin>>d[i].x>>d[i].y;
        int k=0;
        for(i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                bian[k]=length(d[i],d[j]);
                k++;
            }
        }
        double AllLength=0;
        for(i=0;i<k;i++)
            AllLength+=bian[i];
        printf("%.10f\n",AllLength/n*2);
    }
    return 0;
}


Measured memory_bytes: 256
while(1):
    hoge = list(map(int,input().split()))
    w,h = hoge[0],hoge[1]
    if w == 0 and h == 0:
        break
    for i in range(w):
        if i == 0 or i == w-1:
            print("#"*h)
        else:
            print("#" + "."*(h-2) + "#")
    print("")


Measured memory_bytes: 5616
#include <iostream>
#include <iomanip>
using namespace std;
using ll = long long;
int main()
{
    ll a,b,x;
    cin >> a >> b>> x;
    ll ans0=(a-1)/x;
    ll ans1=b/x;
    if(a==0){
        cout << ans1+1;
    }else{
        cout<<ans1-ans0;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1<<30
struct edge{int to,cost;};
vector<edge> G[101];
int d[101];
bool visited[101];

void dijkstra(int n){
  fill(d+1,d+101,INF);
  memset(visited,false,sizeof(visited));
  for(int i=0;i<n;++i){
    int id=-1;
    for(int j=0;j<n;++j){
      if(!visited[j])
        if(id==-1||d[id]>d[j]) id=j;
    }
    visited[id]=true;
    for(int j=0;j<G[id].size();++j){
      edge e=G[id][j];
      d[e.to]=min(d[e.to],d[id]+e.cost);
    }
  }
}
int main(){
  int n; cin>>n;
  for(int i=0;i<n;++i){
    int u,k; cin>>u>>k;
    for(int j=0;j<k;++j){
      int c,v; cin>>c>>v;
      edge e; e.to=c, e.cost=v;
      G[u].push_back(e);
    }
  }
  dijkstra(n);
  for(int i=0;i<n;++i) cout<<i<<" "<<d[i]<<endl;
  return 0;
}

Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#define MIN(a, b) ((a<b) ? a : b)
#define MAX(a, b) ((a>b) ? a : b)

int int_sort(const void*a, const void*b) {
  return (*(int*)a - *(int*)b);
}

int main(void) {
  int N, K;
  scanf("%d%d", &N, &K);
  int V[50];
  for(int i = 0; i < N; i++) {
    scanf("%d", &V[i]);
  }

  int max = 0;
  for(int k = 0; k < K; k++) {
    int n = MIN((K - k), N);
    for(int j = 0; j <= n; j++) {
      int tmp = 0;
      int neg[50];
      int nnum = 0;
      for(int l = 0; l < j; l++) {
	tmp += V[l];
	if(V[l] < 0) {
	  neg[nnum++] = V[l];
	}
      }
      for(int r = 0; r < (n-j); r++) {
	tmp += V[N-1-r];
	if(V[N-1-r] < 0) {
	  neg[nnum++] = V[N-1-r];
	}
      }
      qsort(neg, nnum, sizeof(int), int_sort);
      int tmax = MIN(k, nnum);
      for(int t = 0; t < tmax; t++) {
	tmp -= neg[t];
      }
      max = MAX(max, tmp);
    }
  }

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


Measured memory_bytes: 128
N=gets.to_i
require 'prime'

class Array
  def upper_bound(x)
    bsearch_index { |v| v > x }
  end

  def lower_bound(x)
    bsearch_index { |v| v >= x }
  end
end

class Integer
  def divisor_list
    return [] if self <= 0
    return [1] if self == 1

    prime_division.map.with_index { |(base, k), i|
      s = i.zero? ? 0 : 1
      (s..k).map { |n| base ** n }
    }.inject { |res, e| res + res.flat_map { |t| e.map { |v| t * v } } }.sort
  end
end

l=N.divisor_list
p l.map{|x|N/x<x-1?x-1:0}.inject :+

Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int INF = 2e9;

int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    if(s[k-1] == 'A') s[k-1] = 'a';
    if(s[k-1] == 'B') s[k-1] = 'b';
    if(s[k-1] == 'C') s[k-1] = 'c';
    cout << s << endl;
}

Measured memory_bytes: 256
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

x1, y1, x2, y2 = nl()

xd = x2 - x1
yd = y2 - y1
print(x2 - yd, y2 + xd, x2 - yd - xd, y2 + xd - yd)


Measured memory_bytes: 3060
n=int(input())
s=input()
q=int(input())

query=[]
for i in range(q):
    query.append(input())

ide_ele = set()

def segfunc(x, y):
    return x | y

class SegTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        # param k: index(0-index)
        # param x: update value
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1
    def query(self, l, r):
        #[l, r)segfunc, 0-index
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

al = [{s[i]} for i in range(n)]
seg = SegTree(al, segfunc, ide_ele)

for q in query:
    que,a,b=q.split()

    if que == "1":
        seg.update(int(a)-1,set(b))
    else:
        ret=seg.query(int(a)-1,int(b))
        print(len(ret))

Measured memory_bytes: 369960
import java.util.*;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		Integer[] a = { 1, 3, 5, 7, 8, 10, 12 };
		int m = 0, n = 0;

		if (Arrays.asList(a).contains(x)) {
			m = 1;
		}
		if (Arrays.asList(a).contains(y)) {
			n = 1;
		}

		if ((m + n) % 2 == 0 && x != 2 && y != 2) {
			System.out.print("Yes");
		} else {
			System.out.print("No");
		}
	}
}


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


int main(void){
    int n, k;
    cin>>n>>k;
    vector<int> v(n);
    rep(i, n) {
        int a;
        cin>>a;
        --a;
        v[a]++;
    }
    sort(v.begin(), v.end(), greater<int>());
    int ans=0;
    for(int i= k;i<n;i++) ans+=v[i];
    cout<<ans<<endl; 
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
 
int main() {
    int n;
    cin >> n;
    int max = 0;
    int maxi = 1;
    for (int i = 1; i <= n; i++) {
        int j = i;
        int count = 0;
        while (1) {
            if (j % 2 == 0) {
                j = j / 2;
                count++;
            }
            else {
                break;
            }
        }
        if (count > max) {
            max = count;
            maxi = i;
        }
    }
    cout << maxi << endl;
}

Measured memory_bytes: 256
using DataStructures
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  N = readint()[1]

  if N%1000 == 0
    println(0)
  else
    println(1000 - N%1000)
  end

end

main()

Measured memory_bytes: 185276
from collections import deque
b = deque()
n = int(input())
ns = map(int, input().split())
for i, j in enumerate(ns):
    if i%2 == 0:
        b.append(j)
    else:
        b.appendleft(j)
b = list(map(str, b))
if i%2 == 0:
    b = b[::-1]
    print(' '.join(b))
else:
    print(' '.join(b))

Measured memory_bytes: 25540
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string A,B,C;
  cin>>A>>B>>C;
  cout<<(char)toupper(A.at(0))<<(char)toupper(B.at(0))<<(char)toupper(C.at(0))<<endl;
  return 0;
}

           

Measured memory_bytes: 256
import java.util.*;

/**
 * Created by ml_qi on 2016/9/20.
 */
public class Main {


    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        Long result = 0L;
        int k = 1;
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            if (i == 0) {
                result += a - 1;
                k++;
            } else {
                if (a == k) {
                    k++;
                } else {
                    result += (a - 1) / k;
                }
            }
        }
        System.out.println(result);
    }


}


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

typedef pair<int, int> P;
#define rep(i, n) for(int i = 0; i < n; i++)
int nums[100];
int c[17];

bool get_chair(int n, int x){
  rep(i, 17 - n + 1){
    bool ok = true;
    rep(j, n){
      if(c[i+j] > 0) ok = false;
    }
    if(ok){
      rep(j, n) c[i+j] = x;
      return true;
    }
  }
  return false;
}

int main(){
  int n;
  int t = 0;
  fill(c, c + 17, 0);
  queue<int> que;
  while(t < 500 || !que.empty()){

    if(t < 500 && t % 5 == 0){
      que.push(t/5);
    
    }

    while(!que.empty()){
      int a = que.front();

      if(a % 5 == 1){
	if(get_chair(5, (a % 2) * 17 + (a % 3) * 3 + 19)){
	  nums[a] = t - a * 5;
	  que.pop();
	}else break;
      }else{
	if(get_chair(2, (a % 2) * 17 + (a % 3) * 3 + 19)){
	  nums[a] = t - a * 5;
	  que.pop();
	}else break;
      }
    }

    rep(i, 17) if(c[i] > 0) c[i]--;
    t++;
  }

  while(cin >> n){
    cout << nums[n] << endl;
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();
        String[] str = new String[n];
        str = s.split("");
        str[k - 1] = str[k - 1].toLowerCase();
        for (int i = 0; i < n; i++) {
            System.out.print(str[i]);
        }
    }
}

Measured memory_bytes: 21844