akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#define maxint 2147483647;
void dump(int a[],int n)
{
  for (int codeTest = 0; codeTest < n; ++codeTest) {
    if (codeTest!=0)std::cout << " ";
    std::cout << a[codeTest];
  }
  std::cout << '\n';
}
int c=0;
void merge(int *a,int left,int mid,int right) {
  int n1=mid-left,n2=right-mid;
  int i,j=0,k=0;
  int l[300000],r[300000];
  for (i = 0; i < n1; ++i) {
    l[i]=a[left+i];
  }
  for (i = 0; i < n2; ++i) {
    r[i]=a[mid+i];
  }
  l[n1]=maxint;r[n2]=maxint;
  for (i = left; i < right; ++i) {
    if (l[j]<r[k]) {
      a[i]=l[j];
      ++j;
    }else{
      a[i]=r[k];
      ++k;
    }
    ++c;
  }
}

void mergeSort(int *a,int left,int right) {
  int mid;
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(a, left, mid);
    mergeSort(a, mid, right);
    merge(a, left, mid, right);
  }
}
int main() {
  int n;
  int a[500000];
  std::cin >> n;
  for (int i = 0; i < n; ++i) {std::cin >> a[i];}
  mergeSort(a,0,n);
  dump(a,n);
  std::cout << c << '\n';
  return 0;
}



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

signed main() {
    string S, T;
    cin >> S >> T;
    const int n = S.length(), m = T.length();
    int ans = 0;
    for (int i = 0; i < n - m + 1; i++) {
        string s = S.substr(i, m);
        int cnt = 0;
        for (int k = 0; k < m; k++) cnt += (s[k] == T[k]);
        ans = max(ans, cnt);
    }

    cout << m - ans << endl;

    return 0;
}



Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int M = int.Parse(input[1]);
        int[] cities = new int[N];
        for(int c = 0;c < N;c++){
            cities[c] = 0;
        }
        
        for(int i = 0;i < M;i++){
            int[] road = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            cities[road[0] - 1]++;
            cities[road[1] - 1]++;
        }
        foreach(int city in cities){
            Console.WriteLine(city);
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<map>

using namespace std;

int main(){
  string S;
  map<string,string> mp;
  mp["Sunny"]="Cloudy";
  mp["Cloudy"]="Rainy";
  mp["Rainy"]="Sunny";
  
  cin>>S;
  
  cout<<mp[S]<<endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>

void print_rectangle(int h, int w){
  int i,j;
  for(i=0; i<h; i++){
    for(j=0; j<w; j++){
      printf("#");
    }
    printf("\n");
  }
}

int main(int argc, char *argv[]){
  int H,W;

  scanf("%d %d", &H, &W);
  while( H!=0 || W!=0 ){
    print_rectangle(H,W);
    printf("\n");
    scanf("%d %d", &H, &W);
  }
  return(0);
}


Measured memory_bytes: 2100
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

#define REP(i, s, n) for (int i = (int)(s); i < (int)(n); ++i)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

int main(void) {
  int n;
  cin >> n;
  VL a(n), b(n);
  ll tot = 0;
  ll mi = 1e10;
  bool all_eq = true;
  REP(i, 0, n) {
    cin >> a[i] >> b[i];
    tot += b[i];
    if (a[i] > b[i]) {
      mi = min(mi, b[i]);
    }
    if (a[i] != b[i]) {
      all_eq = false;
    }
  }
  cout << (all_eq ? 0 : tot - mi) << endl;
}


Measured memory_bytes: 512
import heapq as hq
def main():
    n,m = map(int,input().split(' '))
    w = [list(map(int,input().split(' '))) for i in range(n)]
    w=sorted(w,reverse=True)
    ans = 0
    l = []
    tmp = 0
    for i in range(1,m+1):
        while w and w[-1][0] <= i:
            hq.heappush(l,-w.pop()[1])
        if l:
            ans -=hq.heappop(l)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 28648
#include<iostream>

using namespace std;

int main() {
	int N;
	cin >> N;
	//小数点以下を切り上げる時はfloor、切り捨てceil、四捨五入round
	//int型の切り上げ方法
	//2で割って切り上げる＝＞N+1/2
	//3で割って切り上げる＝＞N+2/3
	//4で割って切り上げる＝＞N+3/4
	printf("%d", (N + 1) / 2);

	return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i,n) cin >> h[i];
	if(n == 2){
		cout << abs(h[0] - h[1]) << endl;
		return 0;
	}
	vector<int> dp(n);
	dp[1] = abs(h[0] - h[1]);
	for(int i(2);i<n;++i){
		int c1 = abs(h[i-2] - h[i]) + dp[i-2];
		int c2 = abs(h[i-1] - h[i]) + dp[i-1];
		dp[i] = min(c1, c2);
	}
	cout << dp[n-1] << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    cout << "ABC" << n << "\n ";

    return 0;
}


Measured memory_bytes: 3664
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

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

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String[] list1 = new String[n];
		
		for (int i = 0; i < list1.length; i++) {
			list1[i] = scan.next();
		}
		
		int m = scan.nextInt();
		String[] list2 = new String[m];
		
		for (int i = 0; i < list2.length; i++) {
			list2[i] = scan.next();
		}
		
		
		int ans = 0;
		for (int i = 0; i < list1.length; i++) {
			int count = 0;
			String target = list1[i];
			
			for (int j = 0; j < list1.length; j++) {
				if (target.equals(list1[j])) {
					count++;
				}
			}
			
			for (int j = 0; j < list2.length; j++) {
				if (target.equals(list2[j])) {
					count--;
				}
			}
			
			ans = Math.max(ans, count);
			
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
row_1 = list(map(int,input().split()))
row_2 = list(map(int,input().split()))
row_3 = list(map(int,input().split()))
row_conc = row_1 + row_2 + row_3
bingo = [0] * 9
n = int(input())
# print(row_conc,n)
for ind in range(n):
  a = int(input())
  #print(ind,a)
  for inner_ind in range(9):
    if row_conc[inner_ind] == a:
      bingo[inner_ind] = 1
if bingo[0] * bingo[3] * bingo[6] == 1:
  print("Yes")
elif bingo[1] * bingo[4] * bingo[7] == 1:
  print("Yes")
elif bingo[2] * bingo[5] * bingo[8] == 1:
  print("Yes")
elif bingo[0] * bingo[1] * bingo[2] == 1:
  print("Yes")
elif bingo[3] * bingo[4] * bingo[5] == 1:
  print("Yes")
elif bingo[6] * bingo[7] * bingo[8] == 1:
  print("Yes")
elif bingo[0] * bingo[4] * bingo[8] == 1:
  print("Yes")
elif bingo[2] * bingo[4] * bingo[6] == 1:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define     bit_1(a)       __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     u              unsigned
#define     pb             push_back
#define     pf             push_front
#define     mpr            make_pair
#define     ins            insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     vstr           vector<string>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))
#define     orderset1      tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define     orderset2      tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>

///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));
/// lcm(a,b)=a/gcd(a,b)*b (handle overflow)

bool sortinrev1(const pair<int,int>&a,const pair<int,int>&b)
{
    //return (a.first > b.first);
    if(a.first==b.first)return (a.second>b.second);
    else return (a.first > b.first);
}
bool sortinrev2(const pair<int,int>&a,const pair<int,int>&b)
{
    //return (a.first > b.first);
    if(a.first==b.first)return (a.second<b.second);
    else return (a.first > b.first);
}



int main()
{
    /*int l,r,d;
    cin>>l>>r>>d;
    int ans=(r/d)-(l/d);
    if(r%d==0 && l%d==0)ans++;
    cout<<ans<<endl;*/
    int n,a,cnt=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a;
        if(i&1 && a&1)cnt++;
    }
    cout<<cnt<<endl;
}



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

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

using namespace std;

int main(){
	int n,k; cin>>n>>k;
	int ans=0;
	rep(i,n){
		int a; cin>>a;
		if(a>=k) ans++;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;

int hako[222][222];
int h,w;
int c[11][11];
int c2[11];

int main(){
  cin>>h>>w;
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      cin>>c[i][j];
    }
  }

  
  for(int k=0;k<10;k++){
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++){
        if(c[i][j]>c[i][k]+c[k][j]) c[i][j]=c[i][k]+c[k][j];
      }
    }
  }
  
  
  int t,res=0;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>t;
      if(t==-1) continue;
      res+=c[t][1];
    }
  }
  cout<<res<<endl;
  
  return 0;
}



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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,A,B,C; cin >> N >> A >> B >> C;
    vector<int> s(N);
    for (int i=0;i<N;++i){
        string S; cin >> S;
        if (S=="AB") s[i]=0;
        if (S=="BC") s[i]=1;
        if (S=="AC") s[i]=2;
    }
    vector<int> cnt(3);
    cnt[0]=-A,cnt[1]=-B,cnt[2]=-C;
    vector<vector<int>> minwin(3,vector<int>(N+1,0));
    for (int i=0;i<N;++i){
        ++cnt[s[i]],++cnt[(s[i]+1)%3];
        int sum=0;
        for (int j=0;j<3;++j){
            minwin[j][i+1]=(0<cnt[j]?(cnt[j]+1)/2:0);
            sum+=minwin[j][i+1];
        }
        if (i+1<sum){cout << "No" << '\n'; return 0;}
    }
    cout << "Yes" << '\n';
    cnt[0]=cnt[1]=cnt[2]=0;
    vector<int> nxt(3);
    for (int i=0;i<N;++i){
        char ans; bool ok=false;
        for (int j=0;j<3;++j){
            if (cnt[j]<minwin[j][i+1]){
                ans=(char)('A'+j); ++cnt[j];
                ok=true; break;
            }
        }
        if (!ok){
            for (int j=0;j<3;++j) if (s[i]==j){
                for (int k=0;k<2;++k){
                    nxt[(j+k)%3]=upper_bound(minwin[(j+k)%3].begin(),minwin[(j+k)%3].end(),cnt[(j+k)%3])-minwin[(j+k)%3].begin();
                }
                if (nxt[j]<nxt[(j+1)%3]) ans=(char)('A'+j),++cnt[j];
                else ans=(char)('A'+(j+1)%3),++cnt[(j+1)%3];
            }
        }
        cout << ans << '\n';
    }
}

Measured memory_bytes: 5292
N,K = map(int, input().split())
l = list(map(int,input().split()))
l.sort()
i  = 0

if(K >= N):
  ans = 0
else:
  while(i<K):
    l[N-i-1] = 0
    i += 1
  ans = sum(l)
print(ans)

Measured memory_bytes: 26180
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 205
using namespace std;

typedef long long ll;
ll n, m, r, s, mn = 1e18, a[15], d[N][N], num[N], b[15];
bool v[15];
//void f(int p) {
//	int i;
//	if (p == r) {
//		s = 0;
//		for (i = 1; i < r; i++) {
//			s += d[num[i - 1]][num[i]];
//		}
//		mn = min(mn, s);
//		return;
//	}
//	for (i = 0; i < r; i++) {
//		if (v[i]) continue;
//		num[p] = a[i];
//		v[i] = true;
//		f(p + 1);
//		v[i] = false;
//	}
//}
//
int main()
{
	ll i, j, k, t1, t2, t3;
	cin >> n >> m >> r;
	for (i = 0; i <= n; i++) for (j = 0; j <= n; j++) d[i][j] = 1e9;
	for (i = 0; i <= n; i++) d[i][i] = 0;
	for (i = 0; i < r; i++) scanf("%lld", &a[i]);
	for (i = 0; i < m; i++) scanf("%lld %lld %lld", &t1, &t2, &t3), d[t1][t2] = d[t2][t1] = t3;
	for (k = 1; k <= n; k++) {
		for (i = 1; i <= n; i++) {
			for (j = 1; j <= n; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	//f(0);
	for (i = 0; i < r; i++) b[i] = i;
	do {
		s = 0;
		for (i = 1; i < r; i++) {
			s += d[a[b[i - 1]]][a[b[i]]];
		}
		mn = min(mn, s);
	} while (next_permutation(b, b + r));
    cout << mn << endl;
    return 0;
}


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

using namespace std;

int main() {
    int n;
    cin>>n;
    int x=n%10;
    if(x==2||x==4||x==5||x==7||x==9)
    cout<<"hon"<<endl;
    else if(x==0||x==1||x==6||x==8)
    cout<<"pon"<<endl;
    else cout<<"bon"<<endl;
}

Measured memory_bytes: 3632
def dfs(cnt, s, now):
    if cnt == n:
        ans.append(s)
        return
    for i in range(now+1):
        dfs(cnt+1, s+al[i], max(i+1, now))

n = int(input())
ans = []
al = [chr(i) for i in range(97, 97+26)]
dfs(0, "", 0)
for i in ans:
    print(i)

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


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

int main(){
    int s,w; cin >> s >> w;
    if(w>=s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    }

Measured memory_bytes: 3632
#include <stdio.h>

int main() {
	char a[4];
	
	scanf("%s", &a);
	
	if (a[1] == 'R') {
		a[1] = 'B';
		printf("%s\n", a);
		return 0;
	}
	if(a[1] == 'B') {
		a[1] = 'R';
		printf("%s\n", a);
	}
	return 0;
}

Measured memory_bytes: 1640
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
#define nl '\n'
typedef long long ll;
typedef long double ld;
//////////////////////////////////////////////////////////////////////



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

  ll ans = 0 , a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;

  ll foo[1+f]={0};
  for(ll i=0;100*a*i<=f;i++)
    for(ll j=0;100*a*i+100*b*j<=f;j++){
      ll temp = 100*a*i+100*b*j;
      foo[temp]=temp;
    }

  foo[f] = 9e18;
  for(int i=f-1;i>=0;i--)
    if(foo[i] == 0)foo[i] = foo[i+1];
  //else cerr << foo[i] << endl;
  
  ll water=0 , sugar=0;
  for(ll i=0;c*i<=f;i++)
    for(ll j=0;c*i+d*j<=f;j++){
      ll tot = c*i+d*j;
      if(tot*e > 100*f)continue;
      ll cut = (tot + e - 1)/e;
      cut *= 100;
      if(cut > f)continue;
      ll wata = foo[cut];
      if(wata+tot > f)continue;//
      //cerr << "#" << i << ',' << j << endl;
      //cerr << "~" << water << " : " << sugar << endl;
      //cerr << i << "," << j << ": " << tot << " : " << wata << endl;
      //cerr << "~" << wata << ": " << cut << " : " << tot << endl;
      // tot / wata >= sugar / water
      if( (water==0 or sugar==0) or (water * tot > sugar * wata) ){
	water = wata , sugar = tot;
	//cerr << "$" << water << ',' << sugar << endl;
      }
    }
  cout << water+sugar << ' ' << sugar << endl;
  
  return 0;
};


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

static const int N = 52;
static const int MOD = 1e9+7;
int n;
char s[2][N];

void init(){

    for(int i=0; i<2; i++){
        for(int j=0; j<n; j++){
            cin>>s[i][j];
        }
    }
}

int main(){
    int ast,i=0;
    ll ans;

    cin>>n;

    vector<int> v;

    init();

    for(int j=0; j<n; j++){
        if(s[i][j] == s[i+1][j]){
            v.push_back(1);
        }

        else if( s[i][j] == s[i][j-1]){
            v.push_back(0);
        }
    }


    if(v[0] == 1){
        ans = 3;
    }else {
        ans = 6;
    }

    for(int j=1; j<v.size(); j++){
        if(v[j] == 1 && v[j-1] == 0){
            ans *= 1;  ans %= MOD;
        }

        else if(v[j] == 1 && v[j-1] ==1){
            ans *= 2; ans %= MOD;
        }

        else if(v[j] == 0 && v[j-1] == 1){
            ans *= 2; ans %= MOD;
        }

        else if(v[j] == 0 && v[j-1] == 0){
            ans *= 3; ans %= MOD;
        }
    }

    cout<<ans<<endl;

    return 0;
}


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

int main(){
    string S;
    cin >> S;
    int L = S.size();
    string ans = "AC";
    if(S[0] != 'A'){
        ans = "WA";
    }
    int cnt = 0;
    for(int i = 1; i < L; ++i){
        if(isupper(S[i])){
            if(i == 1 || i == L - 1 || S[i] != 'C'){
            ans = "WA";
            }
            ++cnt;
        }
    }
    if(cnt != 1){
        ans = "WA";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N, cnt, X[100], MIN_N = 0x3f3f3f3f;
int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> X[i];
	}
	for (int i = 1; i <= 100; i++)
	{
		cnt = 0;
		for (int j = 0; j < N; j++)
		{
			cnt += (X[j] - i) * (X[j] - i);
		}
		MIN_N = min(cnt, MIN_N);
	}
	cout << MIN_N << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int a[maxn],n;
int dp[maxn];		//dp[i]´ú±í´ÓiÏÂ±êÊ¯Í·µ½ÖÕµã×î¶Ì¾àÀë 

int main() {
	cin>>n;
	for(int i =0 ;i< n;i++) cin>>a[i];
	
	dp[n-1] = 0;
	dp[n-2] = abs(a[n-2] - a[n-1]);
	for(int i = n-3;i >= 0;i--) {
		dp[i] = min(dp[i+1]+abs(a[i] - a[i+1]),
				dp[i+2] + abs(a[i] - a[i+2]));
	}
	cout<<dp[0];
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> vec(7);
    vec = {0, 105, 135, 165, 189, 195, 201};
    for (int i = 0; i < 6; i++){
        if (vec[i] <= N && N < vec[i + 1])
            cout << i << endl;
    }
}

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

const ll MAX = 1e18;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<ll> a(n);
	for (ll& x : a) {
		cin >> x;
		if (x == 0) {
			cout << 0;
			return 0;
		}
	}
	ll ans = 1;
	for (int i=0; i<n; i++) {
		ll tmp = MAX/a[i];
		if (ans > tmp) {
			cout << -1; return 0;
		}
		ans *= a[i];
	}
	cout << ans;
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
#define Endl '\n'
typedef long long int lli;
typedef pair<int, int> ii;
void solve();
int main(int argc, char const *argv[]){
 	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  solve();
}
void solve(){
  lli N;
  cin>>N;
  string s;
  cin>>s;
  lli ans = 0;

  lli r[N+1] ={0};
  lli g[N+1] = {0};
  lli b[N+1] = {0};
  if(s[0] == 'R')r[1] = 1;
  if(s[0] == 'G') g[1] = 1;
  if(s[0] == 'B') b[1] = 1;

  for(int i=2;i<=N;i++){
    if(s[i-1] == 'R')r[i] = 1;
    if(s[i-1] == 'G')g[i] = 1;
    if(s[i-1] == 'B')b[i] = 1;
    r[i]+=r[i-1];
    g[i]+=g[i-1];
    b[i]+=b[i-1];
  }

    for(int i=0;i<N;i++){
      for(int k=i+2;k<N;k++){
        if(s[i] == s[k])
          continue;

        set<char> st;
        st.insert(s[i]);  st.insert(s[k]);
        if(st.find('R') == st.end()){
          if(r[k] -r[i] > 0){
            ans+= r[k] - r[i];
            if(s[(i+k)/2] == 'R' && (i+k)%2 == 0)
            ans--;
          }
        }

        if(st.find('G') == st.end()){
          if(g[k] - g[i]>0){
            ans+= g[k] - g[i];
            if(s[(i+k)/2] == 'G' && (i+k)%2 == 0){
              ans--;
            }
          }
        }
        if(st.find('B') == st.end()){
          if(b[k] - b[i]>0){
            ans+= b[k] - b[i];
            if(s[(i+k)/2] == 'B' && (i+k)%2 == 0)
              ans--;
          }
        }
      }
    }

  cout<<ans<<endl;
}


Measured memory_bytes: 3736
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#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 rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
const string YES = "Yes";
const string NO = "No";
// clang-format on

void solve(long long N, long long M) {
  ANS((N == M ? YES : NO));
}

// clang-format off
int main() {
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  solve(N, M);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int x, a, b;
  
  scanf("%d %d %d", &x, &a, &b);
  
  if((-1)*a + b <= 0){
    printf("delicious\n");
  } else if((-1)*a + b <= x){
    printf("safe\n");
  } else {
    printf("dangerous\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

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

		int n = scan.nextInt();
		int k = scan.nextInt();
		int q = scan.nextInt();
		int[] a = new int[n];
		Arrays.fill(a, (k - q));
		int ai;

		for (int i = 0; i < q; i++) {
			ai = scan.nextInt();
			a[ai - 1]++;
		}

		for (int t : a) {
			out.println(t > 0 ? "Yes" : "No");
		}

		out.flush();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 24636
A, B, H, M = list(map(int, input().split()))

m = 360/60 * M
h = 360/12 * (H + M/60)
deg = abs(h-m)
if deg>180: deg = 360-deg

import math

Csq = A**2 + B**2 - 2*A*B*math.cos(math.radians(deg))
print('{:.10f}'.format(math.sqrt(Csq)))



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

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int x, y;
	cin >> x >> y;
	if ((y - 2 * x) % 2 == 0 && y - 2 * x >= 0 && 4 * x - y >= 0) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}



Measured memory_bytes: 3648
<?php

fscanf(STDIN, "%d", $n);

$a = $n % 10;
if (in_array($a, [2, 4, 5, 7, 9])) {
    echo "hon";
} elseif (in_array($a, [0, 1, 6, 8])) {
    echo "pon";
} else {
    echo "bon";
}

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

using namespace std;

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

  if(h%a == 0){
    std::cout << h/a;
  }else{
    std::cout << h/a + 1;
  }

}

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

using namespace std;

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

  string s;
  cin >> s;
  const string k{"keyence"};
  for (int i = 0; i < 8; i++) {
    const string prefix = k.substr(0, i);
    const string suffix = k.substr(i);
    const auto j = s.size() - suffix.size();
    if (prefix == s.substr(0, i) && suffix == s.substr(j)) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N,Q;
    cin >> N >> Q;
    string s;
    cin >> s;
    string t[Q],d[Q];
    ll i;
    for(i=0;i<Q;i++){
      cin >> t[i] >>d[i];
    }
    ll l=-1,r=N;
    ll tmp,j;
    bool death;
    ll ans=N;
    while(r-l>1){
      tmp=(r+l)/2;
      j=tmp;
      death=false;
      for(i=0;i<Q;i++){
        if(j>=0&&j<=N-1&&s[j]==t[i][0]){
            if(d[i][0]=='L')j--;else j++;
        }
        if(j<0)death=true;
      }
      if(death)l=tmp;else r=tmp;
    }
    ans-=l+1;
    l=-1;r=N;
    while(r-l>1){
      tmp=(r+l)/2;
      j=tmp;
      death=false;
      for(i=0;i<Q;i++){
        if(j>=0&&j<=N-1&&s[j]==t[i][0]){
            if(d[i][0]=='L')j--;else j++;
        }
        if(j>N-1)death=true;
      }
      if(death)r=tmp;else l=tmp;
    }
      ans-=N-r;
    if(ans<0)cout << 0;else cout << ans;
    return 0;
}


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

int main(){
    int R;
    cin >> R;
    if(R < 1200){
        cout << "ABC" << endl;
    }else if(R >= 1200 && R < 2800){
        cout << "ARC" << endl;
    }else if(R >= 1200 && R >= 2800 && R <= 4208){
        cout << "AGC" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ; 
#define inf (1LL<<60)
long long int dp[3001][3001] ; 
long long int solve(int i,int j,vector<long long int>& arr){
    if(i>j){
        return 0 ; 
    }
  if(i==j){
      return dp[i][j] = 0 ; 
  }
  if(dp[i][j]!=-1){
      return dp[i][j] ; 
  }
   long long int sum = 0; 
  for(int p = i ; p<=j; p++){
      sum+=arr[p] ; 
  }
  long long int ans =inf; 
  for(int k = 0 ; k<=j-1-i;k++){
      ans= min(ans,solve(i,i+k,arr)+solve(i+k+1,j,arr)) ; 
  }
 
  return dp[i][j] = sum+ans ; 
}
int main(){
    int n ; cin>>n ; 
    vector<long long int> arr(n+1) ; 
    for(int i = 1; i<=n ; i++){
        cin>>arr[i] ; 
    }
     memset(dp,-1,sizeof(dp)); 
    cout<<solve(1,n,arr) ; 
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define endl        '\n'
#define db          double
#define ld          long double
#define ll          long long
#define ull         unsigned long long
#define sqr(x)      (x) * (x)
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)   ((a/gcd(a,b)) * b)
#define pf(x) 		push_front(x)
#define pb(x)       push_back(x)
#define eb(x)		emplace_back(x)
#define all(x)      (x).begin(), (x).end()
#define rall(x) 	(x).rbegin(), (x).rend()
#define sz(x) 		(int)x.size()
#define debug(x) 	cerr << #x << " = " << (x) <<endl
#define unsyncIO    ios_base::sync_with_stdio(0); cin.tie(0)

const ld PI = acos((ld)-1);
const int MOD = 1e9+7;
const ll INF = 1e18; 

using namespace std;

int main()
{
    //freopen("/home/taalpatar_shepai/Documents/my_codes/out.txt", "w", stdout);
    unsyncIO;
    ll a, b, c, d;
    vector<ll> t(4);
    cin >> a >> b >> c >> d;
    t[0] = a * c; 
    t[1] = a * d; 
    t[2] = b * c; 
    t[3] = b * d; 
    cout << *max_element(all(t)) << endl;

    return 0;
}

Measured memory_bytes: 3648
while True:
    num_str = input().split()
    H, W = [int(i) for i in num_str]
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if i % 2 == 0:
                if j % 2 == 0:
                    print("#", end="")
                else:
                    print(".", end="")
            else:
                if j % 2 == 0:
                    print(".", end="")
                else:
                    print("#", end="")
        print()
    print()



Measured memory_bytes: 7008
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>

using namespace std;
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        printf("%d\n",(n-1)*(m-1));
    }
    return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int main(){
	int a;scanf("%d",&a);
	if(a%10==3)printf("bon\n");
	else if(a%10==0||a%10==1||a%10==6||a%10==8)printf("pon\n");
	else printf("hon\n");
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     

int32_t main()
{
     IOS;
     
     int n,a,b;
     cin>>n>>a>>b;
     
     cout<<min(a,b)<<" "<<max(0LL,a+b-n);
     
     return 0;     
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[][] m = new int[10][10];
    for (int i = 1; i <= N; i++ ) {
      int l = i;
      while (l/10 > 0) {
        l /= 10;
      }
      int r = i%10;
      m[l][r]++;
    }
    
    long ans = 0;
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        ans += (long)m[i][j]*m[j][i];
      }
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 22612
n, y = map(int, input().split())
def main():
  for m in range(n+1):
    s = y - 10000 * m
    if s < 0: break
    if s > 5000 * (n-m):
      continue
    for g in range(n - m + 1):
      s2 = s -5000 * g
      if s2 < 0: break
      if s2 == 1000 * (n -m -g):
        return m, g, n-m-g
  return -1, -1, -1

print(*main())

Measured memory_bytes: 3064
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define pb push_back
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define endl "\n" // interactive problem
#define int long long

const int N = 55;
const int inf = (int)(1e9) + 123;
const int mod = (int)(1e9) + 7;
const double EPS = 1e-9;

vector <int> v[N];
int par[N];
int lvl[N];
int n;
int m;
bool painted[N];
int X[N];
int Y[N];

void dfs(int x, int p = 0, int level = 0) {
    lvl[x] = level;
    par[x] = p;
    for(auto to : v[x]) {
        if (to == p) continue;
        dfs(to, x, level + 1);
    }
}

void paint(int x, int y) {
    while (lvl[x] > lvl[y]) {
        painted[x] = true;
        x = par[x];
    }
    while (lvl[x] < lvl[y]) {
        painted[y] = true;
        y = par[y];
    }
    while (x != y) {
        painted[x] = true;
        painted[y] = true;
        x = par[x];
        y = par[y];
    }
}

int getPainted() {
    int cnt = 0;
    for(int i = 1; i <= n; ++i) {
        cnt += painted[i];
        painted[i] = false;
    }
    return cnt;
}

signed main() {
    cin.tie(0);
    ios_base :: sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i < n; ++i) {
        int x, y; cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs(1);
    cin >> m;
    for(int i = 0; i < m; ++i) {
        cin >> X[i] >> Y[i];
    }
    int answer = 0;
    for(int mask = 0; mask < (1 << m); ++mask) {
        for(int j = 0; j < m; ++j) {
            if ((mask >> j) & 1) {
                paint(X[j], Y[j]);
            }
        }
        int curpainted = (1ll << (n - 1 - getPainted()));
        //cout << mask << ' ' << curpainted << endl;
        if (__builtin_popcount(mask) & 1ll) {
            curpainted *= -1;
        }
        answer += curpainted;
    }
    cout << answer;
    return 0;
}

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

using namespace std;

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

    int n;
    cin >> n;
    char c[n];
    for(int i = 0; i < n; i++)
        cin >> c[i];
    bool ok = false;
    for(int i = 0; i < n; i++)
    {
        if(c[i] == 'Y')
        {
            ok = true;
            break;
        }
    }
    cout << (ok ? "Four" : "Three");

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  string S; cin >> S;
  if(S[0]==S[1] && S[1]==S[2]){
    cout << "No" << endl;
  }
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sf sacnf
#define pf printf
#define ll long long
#define ull unsigned long long
#define ii pair <int,int>
#define iii pair <int,ii>
#define pll pair <ll,ll>
#define plll pair <ll,pll>
#define Ziru 0
using namespace std;

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

    if(a>b) cout<<"a > b"<<endl;
    else if(b>a) cout<<"a < b"<<endl;
    else cout<<"a == b"<<endl;
    return Ziru;
}




Measured memory_bytes: 3084
#include <cstdio>
#include <iostream>

using namespace std;

namespace {

void Print(const int* a, int n) {
  for (int i = 0; i < n; ++i) {
    if (i > 0) printf(" ");
    printf("%d", a[i]);
  }
  printf("\n");
}

void InsertionSort(int* a, int n) {
  Print(a, n);
  for (int i = 1; i < n; ++i) {
    const int v = a[i];
    int j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      --j;
    }
    a[j + 1] = v;
    Print(a, n);
  }
}
} // namespace

int main() {
  int n;
  int a[100];

  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  InsertionSort(a, n);
  return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	ll N=in();
	auto V=vecin<ll>(N);
	sort(ALL(V),greater<ll>());
	vector<ll> C(N);
	if(N%2){
		int even = N/2;
		int odd = N-even;
		REP(i,odd-2){
			C[i] = 2;
		}
		C[odd-2]=C[odd-1]=1;
		for(int i=odd;i<N;i++){
			C[i] = -2;
		}
	}
	else{
		int even = N/2;
		int odd = N-even;
		REP(i,odd-1){
			C[i] = 2;
		}
		C[odd-1]=1;
		C[odd]=-1;
		for(int i=odd+1;i<N;i++){
			C[i] = -2;
		}
	}
	int left=0,right=N-1;
	ll sum1=0;
	while(C[left]>0){
		sum1 += C[left]*V[left];
		left++;
	}
	while(C[right]<0){
		sum1 += C[right]*V[right];
		right--;
	}
	ll sum2=0;
	left=0,right=N-1;
	while(C[left]>0){
		sum2 -= C[left]*V[N-1-left];
		left++;
	}
	while(C[right]<0){
		sum2 -= C[right]*V[N-1-right];
		right--;
	}

	out(max(sum1,sum2));
	return 0;
}


Measured memory_bytes: 1792
main(){double a,l,x,s,t;
for(;~scanf("%lf%lf%lf",&a,&l,&x);)
s=(l+l+a)/2,t=(l+x+l)/2,printf("%lf\n",sqrt((a/2)*(a/2)*(s-a)*s)+2*sqrt((l/2)*(l/2)*(t-l)*t));exit(0);}

Measured memory_bytes: 652
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

int main() {
	string S;
	cin >> S;
	if (S.size() >= 4) {
		if (S[0] == 'Y'&&S[1] == 'A'&&S[2] == 'K'&&S[3] == 'I') {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
from collections import deque
l=deque()
for _ in range(input()):
    a=raw_input().split()
    c=a[0][-4]
    if c=="i":   l.popleft()
    elif c=="L": l.pop()
    elif c=="s": l.appendleft(a[1])
    else:
        try:     l.remove(a[1])
        except:  pass

print " ".join(l)

Measured memory_bytes: 125016
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>

using namespace std;

typedef pair<int,int> pii;

pii numToPlc[101];
int plcToNum[10][10];
int res;
map<vector<vector<int> >,int > m;
vector<vector<int> > g;

bool moveNum(int a){
  pii cur=numToPlc[a];
  if(a%10==1){
    numToPlc[a].first=(a/10)-1;
    numToPlc[a].second=0;
    plcToNum[(a/10)-1][0]=a;
    plcToNum[cur.first][cur.second]=-1;
    return true;
  }
  pii nxtPos=numToPlc[a-1];nxtPos.second++;
  if(plcToNum[nxtPos.first][nxtPos.second]!=-1
     ||nxtPos.second>=8)
    return false;
  else{
    numToPlc[a]=nxtPos;
    plcToNum[nxtPos.first][nxtPos.second]=a;
    plcToNum[cur.first][cur.second]=-1;
    return true;
  }
}
void backNum(int a,pii &p){
  pii cur=numToPlc[a];
  plcToNum[cur.first][cur.second]=-1;
  numToPlc[a]=p;
  plcToNum[p.first][p.second]=a;
}
vector<vector<int> > trans(){
  vector<vector<int> > res(4,vector<int>(8,-1));
  for(int i=1;i<=4;i++){
    for(int j=1;j<=7;j++){
      pii &p=numToPlc[i*10+j];
      res[p.first][p.second]=i*10+j;
    }
  }
  return res;
}
void dfs(int hand){
  vector<vector<int> > tmp=trans();
  if(g==tmp){
    res=min(res,hand);
    return;
  }
  else if(m.find(tmp)!=m.end()&&m[tmp]<=hand)return;
  m[tmp]=hand;
  for(int i=1;i<=4;i++){
    for(int j=2;j<=7;j++){
      pii cur=numToPlc[i*10+j];
      bool ok=moveNum(i*10+j);
      if(ok){
	dfs(hand+1);
	backNum(i*10+j,cur);
      }
    }
  }
}

int main(){
  const int INF=1000000000;
  for(int i=0;i<4;i++)g.push_back(vector<int>(8,-1));
  for(int i=0;i<4;i++)
    for(int j=0;j<7;j++)
      g[i][j]=(i+1)*10+(j+1);
  int t;
  cin>>t;
  while(t--){
    m.clear();
    res=INF;
    memset(plcToNum,-1,sizeof(plcToNum));
    for(int i=0;i<4;i++){
      for(int j=0;j<7;j++){
	int a;
	cin>>a;
	numToPlc[a].first=i;
	numToPlc[a].second=j+1;
	plcToNum[i][j+1]=a;
      }
    }
    for(int i=1;i<=4;i++)moveNum(i*10+1);
    dfs(0);
    if(res==INF)cout<<-1<<endl;
    else cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
#define WA cout<<"char134217728";exit(0)
#define RE throw
#define TLE sleep(1000)
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, g;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    int a;
    cin >> a;
    g = gcd(g, a);
  }
  cout << g << endl;
}

Measured memory_bytes: 256
function Main(input) {
    input = input.split("\n");
    S = input[1].split(" ");
    o = {};
    for (i of S) o[i] = true;
    console.log(Object.keys(o).length == 3 ? "Three" : "Four");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#ABC069C
N=int(input())
A=list(map(int,input().split()))
four=0
two=0
other=0
for a in A:
	if a%4==0:
		four+=1
	elif a%2==0:
		two+=1
	else:
		other+=1
print('Yes') if other+(two>0)-(four+1)<=0 else print('No')

Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

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

    if(N == 1)
        cout << "Hello World" << endl;
    else if(N == 2)
    {
        int  A, B;
        cin >> A >> B;
        cout << A + B <<endl;
    }
        

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define hell  1000000007
using namespace std;
map<int,long long> mp;
vector<long long int> v;
int main(){
	
	long long int n,k;
	cin >> n >> k;
    
    long long int a[n], b[n];
    
	for(int i=0;i<n;i++){
		
		cin >> a[i] >> b[i];
		
		v.push_back(a[i]);
		
		mp[a[i]] += b[i];
		
	}
	
	sort(v.begin(),v.end());
	
	v.resize(distance(v.begin(),unique(v.begin(),v.end())));
	
	for(int i=0;i<v.size();i++){
		
		k -= mp[v[i]];
		
		if(k <= 0){
			cout << v[i] << endl;
			break;
		} 
		
	}
	
	return 0;
}

Measured memory_bytes: 6516