akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int main() {
	int n, i;
	char str[1001], *pt;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		getchar();
		scanf("%[^\n]*s", str);
		pt = str;
		while (*pt) {
			if (*pt == 'H')
				if (*(pt + 1) == 'o'&&*(pt + 2) == 's'&&*(pt + 3) == 'h'&&*(pt + 4) == 'i'&&*(pt + 5) == 'n'&&*(pt + 6) == 'o')
					*(pt + 6) = 'a';
			pt++;
		}			
		printf("%s\n", str);
	}
	return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void)
{
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB"){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math
a, b, x = map(int, input().split())
A, B = a**2, b**2
print(math.degrees(math.asin((B / ((2 * x / (a * b))**2 + B))**0.5) if 2 * x <=
                   a * a * b else math.acos((A / ((2 * (a * a * b - x) / A)**2 + A))**0.5)))


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

vector<vector<int>> graph(100000);
vector<bool> done(100000);
void dfs(int v, vector<int> &t) {
    if (done.at(v)) return;

    done.at(v) = true;
    for (int to: graph.at(v)) {
        dfs(to, t);
    }
    t.push_back(v);
} 
void topological_sort(int n, vector<int> &t) {
    for (int i = 0; i < n; i++) {
        dfs(i, t);
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> rgraph(n);
    for (int i = 0; i < n - 1 + m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph.at(a).push_back(b);
        rgraph.at(b).push_back(a);
    }

    vector<int> t;
    topological_sort(n, t);

    vector<int> new_num(n);
    for (int i = n - 1; i >= 0; i--) {
        new_num.at(t.at(i)) = n - i;
    }
    
    for (int i = 0; i < n; i++) {
        int max_num = -1;
        int par = -1;
        for (int p: rgraph.at(i)) {
            if (max_num < new_num.at(p)) {
                par = p;
                max_num = new_num.at(p);
            }
        }
        cout << par + 1 << endl;
    }
}

Measured memory_bytes: 15868
w, h, n = map(int, input().split())
lst = [[1 for i in range(w)] for j in range(h)]

for x in range(n):
    x, y, a = map(int, input().split())
    for idx_y, yy in enumerate(lst):
        for idx_x, _ in enumerate(yy):
            if a == 1 and idx_x < x:
                lst[idx_y][idx_x] = 0
            elif a == 2 and idx_x >= x:
                lst[idx_y][idx_x] = 0
            elif a == 3 and idx_y < y:
                lst[idx_y][idx_x] = 0
            elif a == 4 and idx_y >= y:
                lst[idx_y][idx_x] = 0

print(sum([sum(x) for x in lst]))


Measured memory_bytes: 3064
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip> 
typedef long long LL;
const int mod = 1000000009;
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n;
    while (cin >> n)
    {
        int* p = new int[n + 1],ans=0,max1,min1;
        for (int i = 0; i < n; i++)
            cin >> p[i];
        for (int i = 1; i < n - 1; i++)
        {
            max1 = max(p[i - 1], p[i + 1]);
            min1 = min(p[i - 1], p[i + 1]);
            if (p[i] > min1&& p[i] < max1)
                ans++;
        }
        cout << ans << '\n';
    }
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
void N(int dice[]);
void E(int dice[]);
void S(int dice[]);
void W(int dice[]);
void turn(int dice[]);
int main(void){
	int dice1[6],dice2[6],dice3[6];
	int i,j,flag=0;
	scanf("%d %d %d %d %d %d",&dice1[0],&dice1[1],&dice1[2],&dice1[3],&dice1[4],&dice1[5]);
	scanf("%d %d %d %d %d %d",&dice2[0],&dice2[1],&dice2[2],&dice2[3],&dice2[4],&dice2[5]);
	for(i=0;i<6;i++){
		if(dice1[0]==dice2[i]){
			memcpy(dice3,dice2,sizeof(int)*6);
			switch(i){
			case 0:
				break;
			case 1:
				N(dice3);
				break;
			case 2:
				W(dice3);
				break;
			case 3:
				E(dice3);
				break;
			case 4:
				S(dice3);
				break;
			case 5:
				N(dice3);
				N(dice3);
				break;
			}
			for(j=0;j<4;j++){
				if(dice1[0]==dice3[0] && dice1[1]==dice3[1] && dice1[2]==dice3[2] && dice1[3]==dice3[3] && dice1[4]==dice3[4] && dice1[5]==dice3[5]){
					flag=1;
					break;
				}
				else turn(dice3);
			}
		}
		if(flag==1) break;
	}
	if(flag==1) printf("Yes\n");
	else printf("No\n");

	return 0;
}
void N(int dice[]){
	int tmp;
	tmp=dice[0];
	dice[0]=dice[1];
	dice[1]=dice[5];
	dice[5]=dice[4];
	dice[4]=tmp; 
}
void E(int dice[]){
	int tmp;
	tmp=dice[0];
	dice[0]=dice[3];
	dice[3]=dice[5];
	dice[5]=dice[2];
	dice[2]=tmp;
}
void S(int dice[]){
	int tmp;
	tmp=dice[0];
	dice[0]=dice[4];
	dice[4]=dice[5];
	dice[5]=dice[1];
	dice[1]=tmp;
}
void W(int dice[]){
	int tmp;
	tmp=dice[0];
	dice[0]=dice[2];
	dice[2]=dice[5];
	dice[5]=dice[3];
	dice[3]=tmp;
}
void turn(int dice[]){
	int tmp;
	tmp=dice[1];
	dice[1]=dice[2];
	dice[2]=dice[4];
	dice[4]=dice[3];
	dice[3]=tmp;
}



Measured memory_bytes: 2096
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""

from collections import deque
import math
from collections import deque, defaultdict
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():
    N, M = wi()
    G = defaultdict(list)
    for i in range(M):
        a, b = map(int, input().split())
        G[a].append(b)
        G[b].append(a)

    #print(G)
    q = deque()
    q.append(1)
    visit = [False]*N
    dis = [-1] * N
    dis[0] = 0
    while q:
        p = q.popleft()
        visit[p-1] = True
        for n_p in G[p]:
            if visit[n_p-1] != True:
                dis[n_p-1] = p
                visit[n_p-1] = True
                q.append(n_p)

    if all(visit) == True:
        print('Yes')
        for i in range(2, N+1):
            print(dis[i-1])
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 105960
import numpy as np
n,m=map(int,input().split())
x=list(map(int,input().split()))

arr=np.array(sorted(x))
dif=np.diff(arr)

lis=dif.tolist()
lis=sorted(lis,reverse=True)

for i in range(n-1):
    if len(lis)>0:
        lis.pop(0)

print(sum(lis))

Measured memory_bytes: 23044
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

using namespace std;
typedef long long ll;

const ll MOD = 998244353;

int N, K;
int L[10], R[10];

ll cnt[500005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> K;
    for(int i = 0; i < K; i++){
        cin >> L[i] >> R[i];
    }
    cnt[0] = 1;
    cnt[1] = -1;
    for(int i = 0; i < N; i++){
        if(i > 0) cnt[i] += cnt[i-1];
        cnt[i] %= MOD;
        for(int j = 0; j < K; j++){
            cnt[i+L[j]] += cnt[i];
            cnt[i+L[j]] %= MOD;
            cnt[i+R[j]+1] -= cnt[i];
            cnt[i+R[j]+1] %= MOD;
        }
    }
    cout << (cnt[N-1]+MOD)%MOD << endl;
}

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

int main(){
    ll n,m,k;
    cin >> n >> m >> k;
    ll a[n];
    rep(i,n){
        cin >> a[i];
    }
    ll b[m];
    rep(i,m){
        cin >> b[i];
    }
    ll ans = 0;
    ll tot = 0;
    rep(i,m) tot += b[i];
    ll j = m;
    for(int i=0; i<=n; i++){
        while(j>0 && tot > k){
            j--;
            tot -= b[j];
        }
        if(tot>k) break;
        ans = max(ans, i+j);
        if(i==n) break;
        tot += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 6736
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll p=pow(10,9)+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      
    x = x % p;  
   while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 

ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
}
ll isPalindrome(string str) 
{ 
    // Start from leftmost and rightmost corners of str 
    int l = 0; 
    int h = str.length() - 1; 
  
    // Keep comparing characters while they are same 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
           
            return 0; 
        } 
    } 
    return 1;
} 


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    ll i;
    ll ans=1;
   
    cin>>s;
    ans=isPalindrome(s);
    
    
  ll n=s.length();
    char a[100],c[100];
   i=0;
   ll j=(n-3)/2;
   while(j>i)
   {
       if(s[i++]!=s[j--])
       {
       ans*=0;
       break;
       }
   }
    j=n-1;
     i=(n+1)/2;
        while(j>i)
        {
            if(s[i++]!=s[j--])
            {
                ans*=0;
                break;
            }
        }

    
    

   
 

    if(ans)
    cout<<"Yes";
    else
    cout<<"No";
 
    
}
    



Measured memory_bytes: 256
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Bad")
    elif q == 0:print("Good")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

#n = ip()                                     #入力整数1つ
#n,x,b= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(m)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#a.pop(0)は10^5あるときTLEしやすい!注意!抜くなら逆ソート!
if a[0] == a[1] or a[1] == a[2] or a[2] == a[3]:
    j(1)
j(0)

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

using namespace std;

int main(){
    string S;
    cin >> S;
    int n = S.size();
    bool ok = true;
    for(int i=0; i<n; i++){
        if(i%2 == 1){
            if(S[i] == 'R') ok = false;
        }
        else{
            if(S[i] == 'L') ok = false;
        }
    }
    cout << (ok? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <queue>
#include <vector>
#include <string>
#include<iostream>
#include<cstdio>
#include<iomanip>
#define rep(i,m,n) for(i = (m); i < (n); i++)
#define print(x) cout << (x) << endl;
using std::cout;
using std::cin;
using std::endl;
using namespace std;

//coffeemilk_8610

int main() {
  int a,b,ans;
  cin>>a>>b;
  if(a>=13) {
    ans=b;
  }
  if(a<13){
    if(a<=5){
      ans=0;
    }
    else{
      ans=b/2;
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

int cnt;

void InsertionSort(int[] arr, int n, int g){
	for(int i = g; i < n; ++i){
		int v = arr[i];
		int j = i - g;
		while (j >= 0 && arr[j] > v){
			arr[j+g] = arr[j];
			j -= g;
			++cnt;
		}
		arr[j+g] = v;
	}
}

void ShellSort(int[] arr, int n){
	cnt = 0;
	int m;
	int[] g;
	for(int i = 1; ; ){
		g ~= i;
		i = 3*i + 1;
		if(i > n) break;
	}
	reverse(g);
	m = g.length.to!int();
	//writeln("m : ",m);
	writeln(m);
	for(int i = 0; i < m; ++i){
		//write("g[", i ,"] : ", g[i]);
		write(g[i]);
		if(i == m-1)	writeln();
		else	write(" ");
	}

	for(int i = 0; i < m; ++i){
		InsertionSort(arr, n, g[i]);
	}
}

int main(string[] argv)
{
	auto n = readln.chomp.to!int();
	int[] arr;

	for(int i = 0; i < n; ++i){
		arr ~= readln.chomp.to!int();
	}

	ShellSort(arr, n);
	//writeln("cnt : ", cnt);
	writeln(cnt);
	foreach(e; arr){
		writeln(e);
	}

    return 0;
}

Measured memory_bytes: 7136
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

l1 = [1,3,5,7,8,10,12]
l2 = [4,6,9,11]
x,y = iim()

if (x in l1 and y in l1) or (x in l2 and y in l2):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;
const int mod=1000000007;
int main(){
    int n;
    ll ans=1;
    cin>>n;
    FOR(i,1,n+1){
        ans=(ans*i)%mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){

	int N,a,b;

//	int p = scanf("%d", &N);
//	p = scanf("%d %d", &a,&b);

	cin >> N;
	cin >> a;
	cin >> b; 
	
	if( (b-a) % 2 == 0 ){

		printf("Alice");

	}

	else{

		printf("Borys");

	}

	return 0;

}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	int n,T,i;cin>>n>>T;
	vector<int>D(n);
	for(i=0;i<n;i++){cin>>D[i];}
	SO(D);
	llint ans=1;
	for(i=0;i<n;i++){ans*=(i+1)-LBI(D,D[i]-T);ans%=mod;}
	cout<<ans<<endl;
	return 0;
}



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

int main(){
    int k,n;
    int res=1001001001;
    cin >> k >> n;
    vector <int> a(n);
    for (int i=0;i<n;i++){
        int tmp;
        cin >> a[i];
    }
    res=min(res,min((a[n-1]-a[0]),(a[0]+k-a[1])));
    for (int i=1;i<n-1;i++){
        int tmp_min=min(k-a[i]+a[i-1],k-a[i+1]+a[i]);
        res=min(res,tmp_min);
    }
    res=min(res,min((a[n-1]-a[0]),(k-a[n-1]+a[n-2])));
    
    
    cout << res << endl;
}

Measured memory_bytes: 1024
/**
 *    Author:   ElProfesor
 *	       
**/

#include<bits/stdc++.h>

using namespace std;
 
// Competetive Template:
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
typedef vector <lli> vl;
typedef vector <string> vs;
typedef vector < pair <long, long> > vll;

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

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ba  back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define gcd __gcd
#define maxe *max_element
#define mine *min_element
#define deb debug
 
#define forz(i,n) for(lli i=0; i<n; i++)
#define rep(i,k,n) for (lli i = k; i < n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)

// Printing Data :
#define pvec(v) forz(i,v.si) cout<<v[i]<<" "; cout<<endl;
#define parr(arr, n) forz(i,n) cout<<arr[i]<<" "; cout<<endl;
#define p1(i) cout<<i<<endl;
#define p2(i, j) cout<<i<<" "<<j<<endl;
#define p3(i, j, k) cout<<i<<" "<<j<<" "<<k<<endl;
#define p4(i, j, k, l) cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;

typedef pair <lli,lli> pll;
 
// CODE BEGINS :

int main()
{
    kira; 

    lli n; cin>>n;
    set <string> s;
    // lli arr[n];
    forz(i,n) 
    {
        string str; cin>>str;
        s.insert(str);
    }

    p1(s.si);

    return 0;
}




















































Measured memory_bytes: 19284
#include<stdio.h>
#include<string.h>
int main(void){
    int n,tp=0,hp=0;
    int i,count,j,alen,blen;
    char a[101];
    char b[101];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",&a);
        scanf("%s",&b);
        j = 0;
        if(a[j] > b[j]) tp+=3;
        else if(a[j] < b[j]) hp+=3;
        else while(a[j] == b[j]){
            j++;
            if(a[j] > b[j]) tp+=3;
            else if(a[j] < b[j]) hp+=3;
            if(a[j] == 0 && b[j] == 0){
                hp++;
                tp++;
                break;
            }
        }
    }
    printf("%d %d\n",tp,hp);

    return 0;
}

Measured memory_bytes: 596
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
int main() {
	int a;
	string b;
	cin >> a >> b;
	int ans = 0;
	REP(t, 2) {
		reverse(b.begin(), b.end());
		for (int i = 0; i < b.length(); ++i) {
			if (b[i] == '.') {
				for (int q = i - 1; q >= 0; --q) {
					if (b[q] == 'W') {
						int ok = 1;
						for (int t = q - 1; t >= 0; --t) {
							if (b[t] == '.') break;
							if (b[t] == 'B') {
								ok = 0;
								break;
							}
						}
						for (int t = i + 1; t < b.length(); ++t) {
							if (b[t] == '.') break;
							if (b[t] == 'B') {
								ok = 0;
								break;
							}
						}
						if (ok == 1) {
							ans = max(ans, i - q - 1);
						}
						break;
					}
					else if (b[q] == '.') break;
				}
			}
		}
	}
	cout << ans << endl;
}


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

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for(long long i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
int main() {
    long long ans = 1;
    long long A, B;
    cin >> A >> B;
    long long MIN = min(A, B), MAX = max(A, B);
    vector<long long> a = divisor(MIN);
    queue<long long> q;
    for(long long x : a) {
        if(MAX % x == 0)
            q.push(x);
    }
    q.pop();
    while(!q.empty()) {
        long long x = q.front();
        ans++;
        long long s = q.size();
        for(int i = 0; i < s; i++) {
            long long y = q.front();
            q.pop();
            if(y % x != 0)
                q.push(y);
        }
    }

    cout << ans << endl;
}

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

 int cnt_digits(int64_t N){
 int digits=0;

 while(N>0){
 N/=10;
 digits++;
 }

 return digits;
 }

int main() {
  int64_t N;
  cin >> N;
  
 int ans=cnt_digits(N); 

 for(int64_t A=1;A*A<=N;++A){
 if(N%A!=0) continue;
 int64_t B=N/A;

 int cur=max(cnt_digits(A),cnt_digits(B));

 if(ans>cur){
 ans=cur;
 }
   
 }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int N,M,L,i,j,k,ans;
  scanf("%d %d\n",&N,&M);
  int cnt[M];
  for(i=0;i<M;i++) cnt[i]=0;
  for(i=0;i<N;i++){
    scanf("%d ",&L);
  	for(j=0;j<L-1;j++){
      scanf("%d ",&k);
      cnt[k-1]++;
	}
    scanf("%d\n",&k);
    cnt[k-1]++;
  }
  ans=0;
  for(i=0;i<M;i++){
    if(cnt[i]==N) ans++;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
typedef struct{
	int d,v;
}num_t;
int main(){
	int N,M;
	while(1){
		scanf("%d %d",&N,&M);
		if(N==0&&M==0)break;
		num_t a[N];
		int max[100]={};
	for(int i=0;i<N;i++){
		scanf("%d %d",&a[i].d,&a[i].v);
	}
	for(int i=0;i<N;i++){
		for(int j=1;j<=M;j++){
			if(a[i].d==j){
				if(max[j-1]<a[i].v){
				max[j-1]=a[i].v;
				}
			}
		}
	}
	int x=0;
	for(int i=0;i<M;i++){
		x=x+max[i];
	}
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 2616
#include <stdio.h>
int main() {
  int i=-1, j=0, k, l, n, A[100000];
  scanf("%d", &n);
  for(l = 0; l < n; l++) {
    scanf("%d", &A[l]);
  }
  for(j = 0; j < n-1; j++) {
    if(A[j] <= A[n-1]) {
      i++;
      k = A[j];
      A[j] = A[i];
      A[i] = k;
    }
  }
  
  k = A[n-1];
  A[n-1] = A[i+1];
  A[i+1] = k;
  for(j = 0; j < n; j++) {
    if(j == i+1) printf("[%d] ", A[j]);
    else {
      printf("%d", A[j]);
      if(j != n-1) printf(" ");
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 992
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int a,b;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>a>>b;
    if(a<=0 && b>=0){
        cout<<"Zero"<<endl;
        return 0;
    }
    if(a>0){
        cout<<"Positive"<<endl;
    }
    if(a<0){
        a=a-(min(-1,b))+1;
        if(a&1){
            cout<<"Negative"<<endl;
        }
        else cout<<"Positive"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    string s;
    cin>>s;
    int p=0;
    rep(i,0,s.size()){
        if(s[i]=='p')p++;
    }
    cout<<s.size()/2-p<<endl;
    
    return 0;
}


Measured memory_bytes: 512
N,P = list(map(int,input().split()))
S = input()

S = S[::-1]

if P!=2 and P!=5:

    current = 1

    SP = []

    for i in range(N):
        SP.append((int(S[i])*current)%P)
        current*=10
        current%=P

    SSP = [0]
    s = 0
    for i in range(N):
        s+=SP[i]
        s%=P
        SSP.append(s)

    from collections import Counter

    counter = Counter(SSP)
    ans = 0
    for key in counter:
        ans += (counter[key]*(counter[key]-1))//2

    print(ans)
else:
    ans = 0
    for i in range(N):
        if int(S[i])%P==0:
            ans+=N-i
    print(ans)

Measured memory_bytes: 60076
N = int(input())
a = [int(x) for x in input().split()]

for i in range(N):
    if a[i] == 0:
        print(0)
        exit(0)

ans = 1
for i in range(N):
    ans *= a[i]
    if ans > 1000000000000000000:
        print(-1)
        exit(0)
print(ans)

Measured memory_bytes: 84692
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(void)
{
	char s[101]={0};
	char t[101]={0};
	int slen=0,tlen=0;
	int i=0,j=0;  //循环控制变量 
	char temp; 
	gets(s);
	gets(t);
	slen=strlen(s);
	tlen=strlen(t);
	if(strcmp(s,t)==0)
	{
		printf("Yes");
		return 0;
	 } 
	 
	for(i=0;i<slen;i++)
	{
		temp=s[slen-1];
		for(j=slen-1;j>0;j--)
		{
			s[j]=s[j-1];
		} 
		 s[0]=temp;
		 if(strcmp(s,t)==0)
		 {
		printf("Yes");
		return 0;
	 	 } 
	}
	
	printf("No");
	system("pause");
	return 0;
}

Measured memory_bytes: 376
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
  int n;
  cin >> n;
  int a[2][n];
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < n; j++){
      cin >> a[i][j];
    }
  }
  long cand[n];
  cand[0] = a[0][0];
  for(int i = 0; i < n; i++){
    cand[0] += a[1][i];
  }
  int candmax = cand[0];
  for(int i = 1; i < n; i++){
    cand[i] = cand[i-1] + a[0][i] - a[1][i-1];
    if(cand[i] > candmax){
      candmax = cand[i];
    }
  }
  cout << candmax << endl;
}


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

typedef struct node{
  int key;
  struct node *parent,*left,*right;
}Node;

Node *root,*NIL;

void Insert(int);
void Inorder(Node *);
void Preorder(Node *);
Node * Search(Node *,int);

int main(){
  int m,i,k;
  char com[20];
  Node *r;

  scanf("%d",&m);

  for(i=0; i<m; i++){
    scanf("%s",com);
    if(com[0] == 'i'){
      scanf("%d",&k);
      Insert(k);
    }
    else if(com[0] == 'p'){
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
    else if(com[0] == 'f'){
      scanf("%d",&k);
      r=Search(root,k);
      if(r != NIL)
	printf("yes\n");
      else
	printf("no\n");
    }
  }

    return 0;
}
  
void Insert(int k){
  Node *y = NIL;            
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }

  z->parent = y;

  if(y == NIL)
    root = z;
  else if(z->key < y->key)
    y->left = z;
  else
    y->right = z;
}

void Inorder(Node *r){
  if(r != NIL){
    Inorder(r->left);
    printf(" %d",r->key);
    Inorder(r->right);
  }
}

void Preorder(Node *r){
  if(r != NIL){
    printf(" %d",r->key);
    Preorder(r->left);
    Preorder(r->right);
  }
}
  
Node * Search(Node *r, int k){
  while(r != NIL && k != r->key)
    if(k < r->key)
      r = r->left;
    else
      r = r->right;

  return r;
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  map<string,int>k;
  for(int i=0;i<N;i++){
    string s;
    cin>>s;
    k[s]++;
  }
  int MAX=0;
  for(auto c:k){
    if(c.second>MAX){MAX=c.second;}
  }
  for(auto c:k){
    if(c.second==MAX){cout<<c.first<<endl;}
  }
  return 0;
}

Measured memory_bytes: 19200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=200010,M=1e9+7;
ll hd[N],to[N<<1],nxt[N<<1],siz[N],son[N];
ll in[N],jc[N],jcin[N];
ll tot,n;
ll ans[N],met[N],up[N];
void add(ll x,ll y){
	to[++tot]=y;
	nxt[tot]=hd[x];
	hd[x]=tot;
}
ll dfs(ll x,ll f){
	ll t=1;
	siz[x]=1;
	son[x]=0;
	for(ll i=hd[x];i;i=nxt[i]){
		if(to[i]!=f){
			t*=dfs(to[i],x);
			t%=M;
			siz[x]+=siz[to[i]];
			++son[x];
		}
	}
	t*=jc[siz[x]-1];
	t%=M;
	for(ll i=hd[x];i;i=nxt[i]){
		if(to[i]!=f){
			t*=jcin[siz[to[i]]];
			t%=M;
		}
	}
	met[x]=t;
	return t;
}
void exgcd(ll a,ll b,ll &x,ll &y){
	if(b==0){
		x=1; y=0;
		return;
	}
	exgcd(b,a%b,y,x);
	y-=a/b*x;
}
ll inv(ll p){
	if(p<=n) return in[p];
	ll x=0,y=0;
	exgcd(M,p,x,y);
	if(y>0) return y%M;
	return (M+(y%M));
}
void work(ll x,ll f){
	if(!f){
		for(ll i=hd[x];i;i=nxt[i]){
			ll j=to[i];up[j]=met[1];
			up[j]*=inv(met[j]);up[j]%=M;
			up[j]*=jc[siz[j]];up[j]%=M;
			up[j]*=jcin[n-1];up[j]%=M;
			up[j]*=jc[n-siz[j]-1];up[j]%=M;
			//printf("up[%lld]=%lld\n",j,up[j]);
			work(j,x);
		}
	}
	else{
		ll t=up[x];
		t*=jcin[n-siz[x]];t%=M;
		//printf("1x=%lld,t=%lld\n",x,t);
		for(ll i=hd[x];i;i=nxt[i]){
			if(to[i]!=f){
				t*=jcin[siz[to[i]]];t%=M;
				t*=met[to[i]];t%=M;
			}
		}
		//printf("2x=%lld,t=%lld\n",x,t);
		for(ll i=hd[x];i;i=nxt[i]){
			if(to[i]!=f){
				ll j=to[i];up[j]=t;
				up[j]*=inv(met[j]);up[j]%=M;
				up[j]*=jc[n-siz[j]-1];up[j]%=M;
				up[j]*=jc[siz[j]];up[j]%=M;
				work(j,x);
			}
		}
	}
}
void sol(ll x,ll f){
	if(!f){
		for(ll i=hd[x];i;i=nxt[i]) sol(to[i],x);
		return;
	}
	ans[x]=jc[n-1];
	for(ll i=hd[x];i;i=nxt[i]){
		if(to[i]!=f){
			ll j=to[i];
			sol(j,x);
			ans[x]*=met[j];ans[x]%=M;
			ans[x]*=jcin[siz[j]];ans[x]%=M;
		}
	}
	ans[x]*=up[x];ans[x]%=M;
	ans[x]*=jcin[n-siz[x]];ans[x]%=M;
}
int main(){
	//freopen("F.txt","r",stdin);
	scanf("%lld",&n);
	for(ll i=1;i<n;++i){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		add(x,y);
		add(y,x);
	}
	jc[0]=jcin[0]=1;
	jc[1]=jcin[1]=in[1]=1;
	for(ll i=2;i<=n;++i){
		jc[i]=jc[i-1]*i%M;
		in[i]=in[M%i]*(M-M/i)%M;
		jcin[i]=jcin[i-1]*in[i]%M;
	}
	dfs(1,0);
	up[1]=1;
	work(1,0);
	sol(1,0);
	ans[1]=met[1];
	//for(ll i=1;i<=n;++i) printf("met[%lld]=%lld\n",i,met[i]);
	//for(ll i=1;i<=n;++i) printf("up[%lld]=%lld\n",i,up[i]);
	//for(ll i=1;i<=n;++i) printf("inv(%lld)=%lld,in[%lld]=%lld\n",i+n,inv(i+n),i,in[i]);
	for(ll i=1;i<=n;++i){
		printf("%lld\n",ans[i]);
	}
	return 0;
}

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

int main(){
    long double A,B,H,M,angle,rad,answer;
    long double pi = 3.141592653589793;
    cin >> A >> B >> H >> M;
    angle = abs(30.0 * H - 5.5 * M);
    rad = pi * (angle / 180.0); 
    answer = A * A + B * B - 2.0 * A * B * cos(rad);
    answer = sqrt(answer);
    cout << setprecision(11)<< answer << endl;
}

Measured memory_bytes: 4168
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)

int main () {
	ll H, W; cin >> H >> W;
	ll tmp = H * W;
	if (H == 1 || W == 1) {
		cout << "1" << endl;
	} else if (tmp % 2 == 0) {
		cout << tmp / 2 << endl;
	} else {
		cout << tmp / 2 + 1 << endl;
	}
}

Measured memory_bytes: 3632
#!/usr/bin/env python
from collections import defaultdict, deque
import math
from math import factorial
import re

BIGNUM = 10 ** 9 + 7

def main():
    #L, N = map(int, input().split())
    S = list(input())

    black_index = []
    for index, s in enumerate(S):
        if s == 'B':
            black_index.append(index)

    num = 0
    for i, index in enumerate(black_index):
        right_num = len(S) - (index+1)
        n = right_num - (len(black_index) - i - 1)
        num += n
    print(num)

if __name__ == '__main__':
    main()


Measured memory_bytes: 13344
A, B, C, D = list(map(int, input().split()))

c1 = (C+B-1) // B  # 高橋君が何回攻撃したら青木君のHPが０になるか
c2 = (A+D-1) // D

# print(c2, c2)

if c1 == c2:
    ans = 'Yes'
elif c1 < c2:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

const int vx[] = {-1, 0, 1, -1, 1, -1, 0, 1};
const int vy[] = {-1, -1, -1, 0, 0, 1, 1, 1};

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

  vector<vector<char>> m(h + 2, vector<char>(w + 2, '.'));
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) cin >> m[i][j];
  }

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (m[i][j] == '#') {
        cout << '#';
        continue;
      }

      int count = 0;
      for (int k = 0; k < 8; k++) {
        if (m[i + vy[k]][j + vx[k]] == '#') count++;
      }
      cout << count;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3596
#include <iostream>
#define ll long long
using namespace std;

int main()
{
    ll h;
    while(cin >> h)
    {
        ll sum = 0;
        ll factor = 1;
        while(h >= 1)
        {
            sum += factor;
            h /= 2;
            factor *= 2;
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main() {
  int n, k; cin >> n >> k;
  vi v[n];
  for (int i=0; i<n; i++){
    int t; ll d; cin >> t >> d; t--;
    v[t].pb(d);
  }
  vp p;
  for (int i=0; i<n; i++){
    if (sz(v[i])>0){
      sort(rng(v[i]));
      for (int j=sz(v[i])-1; j>=0; j--){
        if (j==sz(v[i])-1){
          p.pb(P(v[i][j], 1));
        }
        else p.pb(P(v[i][j], 0));
      }
    }
  }
  sort(rng(p));
  
  ll point;
  ll x=0;
  ll y=0;
  stack<ll> st;
  for (int i=n-1; i>=n-k; i--){
    x += p[i].first;
    if (p[i].second ==1){
      y ++;
    }
    else st.push(p[i].first);
  }
  point = x + y*y;
  
  ll ans = point;
  ll point_ch;
  
  for (int i=n-k-1; i>=0; i--){
    if (!st.empty()){
    if (p[i].second == 1){
      y ++;
      x = x + p[i].first -st.top(); st.pop();
      point_ch = x + y*y;
      ans = max(ans, point_ch);
    }
    }
  }
      cout << ans << endl;
      return 0;
}

Measured memory_bytes: 6904
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
//#define at(x,i) get<i>(x);//
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,k;cin >> n >> k;
    deque<ll> que;
    rep(i,n){
        ll a;cin >> a;
        que.push_back(a);
    }
    ll ans=0;
    rep(i,k){
        ll r=i+1;
        ll tmp=0;
        rep(j,r+1){
            deque<ll> deq=que;
            vl score;
            rep(k,j){
                if(deq.empty())break;
                score.pb(deq.front());
                deq.pop_front();
            }
            rep(k,r-j){
                if(deq.empty())break;
                score.pb(deq.back());
                deq.pop_back();
            }
            sort(all(score));
            ll er=0;
            ll ppp=0;
            for(auto p:score){
                if(er<k-r&&p<0){
                    er++;
                    continue;
                }
                ppp+=p;
            }
            chmax(tmp,ppp);
        }
        chmax(ans,tmp);
    }
    cout <<ans <<endl;
}

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

namespace Exhaustive_Search
{
    class Program
    {
        
        static void Main(string[] args)
        {
            int non = int.Parse( Console.ReadLine());
            string[] nums_string = Console.ReadLine().Split(' ').ToArray();
            int[] nums = new int[non];
            for (var i = 0; i < nums.Length; i++)
                nums[i] = int.Parse(nums_string[i]);
            int noc = int.Parse(Console.ReadLine());
            string[] col_string = Console.ReadLine().Split(' ').ToArray();
            int[] col = new int[noc];
            for (var i = 0; i < col.Length; i++)
                col[i] = int.Parse(col_string[i]);
            
            var rs = new resercher(non, nums, noc, col);

            rs.Return_result();

            Console.ReadLine();
        }
    }
    public class resercher
    {
        public int number_of_num;
        public int[] nums;
        public int number_of_col;
        public int[] col;
        public resercher(int non, int[] num, int noc, int[] col)
        {
            this.number_of_num = non;
            this.number_of_col = noc;
            this.nums = num;
            this.col = col;
        }
        public bool sum_up(int result,int sum,int i)
        {
            if (i == number_of_num)
                return sum == result;
            if (sum_up(result, sum, i + 1))
                return true;
            if (sum_up(result, sum + nums[i], i + 1))
                return true;
            return false;
        }
           
        
        public void Return_result()
        {
            foreach(var ln in col)
            {
                Console.WriteLine("{0}", sum_up(ln,0,0) ? "yes" : "no");
            }
        }
    }
}



Measured memory_bytes: 20372
import java.util.*;

public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		int dataset = sc.nextInt();
		while(dataset-- > 0){
			String [] input = sc.next().split(":");
			int h = Integer.parseInt(input[0]);
			int m = Integer.parseInt(input[1]);
			double hdeg = h * 30 + (double)m / 2;
			double mdeg = m * 6;
			double diff = Math.abs(hdeg - mdeg);
			if(diff >= 181){
				diff = 360 - diff;
			}
			if(diff < 30){
				System.out.println("alert");
			}
			else if(90 <= diff && diff <= 180){
				System.out.println("safe");
			}
			else{
				System.out.println("warning");
			}
		}
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 23384
#include<bits/stdc++.h> 
//compiling code: g++ test.cpp(file) -o script(output) -std=c++11(version) -O2(make it 2x faster)
using namespace std;

int N, M;
priority_queue<int> A;
long long total;

int main(){
    cin >> N >> M;
    for (int i=0; i<N; i++){
        int a;
        cin >> a;
        A.push(a);
    }
    for (int i=0; i<M; i++){
        A.push(A.top() / 2);
        A.pop();
    }

    while(!A.empty()){
        total += A.top();
        A.pop();
    }

    cout << total << "\n";
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
  int nums;
  string tmp;
  cin >> nums;
  map<string, int> store;
  for (int i = 0; i < nums; i++) {
    cin >> tmp;
    if (store.count(tmp))
      continue;
    else
      store.insert(pair<string, int>(tmp, 1));
  }
  cout << store.size() << endl;
}

Measured memory_bytes: 19116
a,b,c,x=4.times.map { gets.chomp.to_i  }

count = 0
for i in 0..a do
  for j in 0..b do
    for k in 0..c do
      if 500*i + 100*j + 50*k == x
        count += 1
      end
    end
  end
end

puts count


Measured memory_bytes: 1788
#include <stdio.h>

int main(void)
{
	int bucket[32] = {0};
	int i, b;

	for (i = 0; i < 28; i++){
		scanf("%d", &b);
		bucket[b] = 1;
	}
	for (i = 1; i <= 30; i++){
		if (!bucket[i]) printf("%d\n", i);
	}
	return (0);
}

Measured memory_bytes: 596
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <vector>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> in(m);
  for (auto &x : in) cin >> x.first >> x.second;
  sort(begin(in), end(in));
  int last_split = 0;
  int next_split = numeric_limits<int>::max();
  int res = 0;
  // island 1, bridge 1, island 2, ...
  for (auto &x : in) {
    if (next_split < x.first) {
      ++res;
      next_split = numeric_limits<int>::max();
    }
    next_split = min(next_split, x.second - 1);
  }
  if (next_split < numeric_limits<int>::max()) ++res;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using ll = long long;
int main(int argc, char ** argv)
{
  //
  ll h, w;
  std::cin >> h >> w;

  ll ans = h * w / 2;

  if ((h == 1) || (w == 1)) {
    ans = 1;
  } else if (((h & 0x01) == 1) && ((w & 0x01) == 1)) {
    ans++;
  }
  std::printf("%lld\n", ans);
  return 0;
}


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

int main(void){

  int i,L,M,N,bank=0,min=99;

  while(1){
    min = 99;
    bank = 0;  
    cin >> L;
    if(L == 0) break;

    for(i = 1; i <= 12; i++){
      cin >> M >> N;
      bank += M - N;
      if(bank >= L){
	if(i < min) min = i;
      }
    }
    
    if(bank >= L) cout << min << endl;
    else cout << "NA" << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 1156
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost::multiprecision;  
//using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}


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

    int n, k;
    cin >> n >> k;

    vector<int> a(n);

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

    auto f = [&](auto key){
        int cnt = 0;
        rep(i,n){
            cnt += updiv(a[i], key) - 1;
        }
        return (cnt);
    };

    int ok = 1e9 + 1, ng = 0;
    
    while(ok - ng > 1){
        auto mid = (ok + ng) / 2;
        if(f(mid) <= k){
            ok = mid;
        }else{
            ng = mid;
        }
    }

    cout << ok << '\n';

    return 0;
}



Measured memory_bytes: 4796
package main

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

func solve() {
	x1, y1 := 0, 0
	x2, y2 := getInt(), getInt()
	n := getInt()

	for i := 0; i < n; i++ {
		xi, yi := getInt(), getInt()
		a := getInt()
		switch a {
		case 1:
			x1 = max(x1, xi)
		case 2:
			x2 = min(x2, xi)
		case 3:
			y1 = max(y1, yi)
		case 4:
			y2 = min(y2, yi)
		}
	}

	ans := (max(0, x2-x1)) * (max(0, y2-y1))
	fmt.Fprintln(wr, ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 640