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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

int a[100010];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	REP(i, n) cin >> a[i];
	
	VI ans, yui(100010, 0);
	map<int, int> kyoko;
	int ptr = -1;
	REP(i, n) {
		kyoko[a[i]]++;
		yui[++ptr] = a[n-i-1];
		while(ptr >= 0) {
			if (kyoko[yui[ptr]]) {
				kyoko[yui[ptr]]--;
				ptr--;
			} else {
				break;
			}
		}
		if(ptr == -1) ans.PB(i+1);
	}
	
	REP(i, ans.size()) {
		cout << ans[i];
		if(i != ans.size()-1) cout << " ";
	}
	cout << endl;
  
  return 0;
}


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

namespace ABC_D
{
    class D071
    {
        static int _Mod = 1000000007;

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S1 = Console.ReadLine();
            string S2 = Console.ReadLine();

            long counter = 0;
            int i = 0;
            bool isVertical=false;

            while (i < N)
            {
                if (S1[i] == S2[i]) //縦
                {
                    if (i == 0) counter = 3;
                    else if (isVertical) counter *= 2;
                    isVertical = true;
                    i += 1;
                }
                else //横
                {
                    if (i == 0) counter = 6;
                    else if (isVertical) counter *= 2;
                    else counter *= 3;
                    isVertical = false;
                    i += 2;
                }
                counter %= _Mod;
            }
            Console.WriteLine(counter);
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <string.h>

int main(){
	int a[2][100]={};
	char c[300];
	char *tp;
	int max=0;
	while(scanf("%s",c)!=EOF){
		int i=1;
		tp=strtok(c,",");
		do{
			a[0][i++]=atoi(tp);
			tp=strtok(NULL,",");
		}while(tp!=NULL);
		a[0][i++]=-1;
		int j=i;
		for(;i<100;i++)a[0][i]=0;
		if(max<j){
			max=j;
			i=1;
			do{
				a[0][i]+=a[1][i-1]>a[1][i]?a[1][i-1]:a[1][i];
				i++;
			}while(a[0][i]!=-1);
			a[0][i]+=a[1][i-1];
		}else{
			i=0;
			do{
				a[0][i]+=a[1][i+1]>a[1][i]?a[1][i+1]:a[1][i];
				i++;
			}while(a[0][i]!=-1);
		}
		for(i=0;i<100;i++){
			a[1][i]=a[0][i];
			a[0][i]=0;
			//printf("%d ",a[1][i]);
		}
		//printf("\n");
	}
	max=0;
	int k=0;
	for(k=0;k<100;k++){
		if(max<a[1][k]){
			max=a[1][k];
		}
	}
	printf("%d\n",max);
	return 0;
}

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

#define _ cin.tie(0);ios::sync_with_stdio(false);
using namespace std;

#define rep(n) for(int i = 0; i < n; i++)
#define Sort(a) sort(a.begin(), a.end())
using LL = long long;
const int N = 100000 + 5;

LL tree[N];
LL Query(int pos){
    LL sum = 0;
    while(pos > 0){
        sum += tree[pos];
        pos -= (pos & -pos);
    }
    return sum;
}

void Add(int pos,LL num){
    while(pos <= N){
        tree[pos] += num;
        pos += (pos & -pos);
    }
}
vector<LL> a, b, c;
int main(){ _
    LL  n, m;
    memset(tree, 0, sizeof(tree));
    cin >> n;
    rep(n) { cin >> m; a.push_back(m); }
    rep(n) { cin >> m; b.push_back(m); }
    rep(n) { cin >> m; c.push_back(m); }
    Sort(a), Sort(b), Sort(c);

    /*for(int i = 0; i < n; i++){
        auto tmp = lower_bound(a.begin(), a.end(), b[i]);
        int num = tmp - a.begin();
        Add(i + 1, num);

    }
    LL sum = 0;
    for(auto &i : c){
        auto tmp = lower_bound(b.begin(), b.end(), i);
        int cur = tmp - b.begin();
        LL num = Query(cur);
        sum += num;
    }
    */
    LL sum = 0;
    rep(n){
        LL A = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        LL B = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());
        sum += (A * B);
    }
    cout << sum << endl;
}


Measured memory_bytes: 4212
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>
#include <numeric>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

char str[100005];
LL dp[4][100005];

int main() {
	scanf("%s", str);
	int n = strlen(str);
	dp[0][0] = 1;
	REP(i, n) {
		if (str[i] == '?')
		{
			dp[0][i + 1] = (dp[0][i] * 3) % MOD;
			dp[1][i + 1] = (dp[1][i] * 3 + dp[0][i]) % MOD;
			dp[2][i + 1] = (dp[2][i] * 3 + dp[1][i]) % MOD;
			dp[3][i + 1] = (dp[3][i] * 3 + dp[2][i]) % MOD;
		}
		else {
			dp[0][i + 1] = dp[0][i];
			REP(j, 3) dp[j+1][i + 1] = (dp[j+1][i] + dp[j][i]*((str[i]-'A')==j)) % MOD;
		}
	}
	cout << dp[3][n] << endl;
	return 0;
}

Measured memory_bytes: 3456
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int A, B, K;
    cin >> A >> B >> K;
    vector<int> num;
    for (int i = 1; i <= min(A,B); i++)
    {
        if (A % i == 0 && B % i == 0)
        {
            num.push_back(i);
        }
    }
    sort(num.begin(),num.end());
  	cout << num[num.size()-K];
    return 0;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> res;
  for (ll i = 2; i * i <= n; i++) {
    ll count = 0;
    while (n % i == 0) {
      if (n % i == 0) {
        count++;
        n /= i;
      }
    }

    if (count != 0) {
      res.push_back({i, count});
    }
  }
  if (n != 1) {
    res.push_back({n, 1});
  }
  return res;
}

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

  auto pf = prime_factorize(n);
  ll ans = 0;

  for (auto x : pf) {
    ll now = 1;
    while (x.second >= now) {
      ans++;
      x.second -= now;
      now++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3564
#include <iostream>
#include <cmath>


using namespace std;


int main(){
   int X, Y, N, M,peaceCount;

   cin>>N;
   cin>>M;
   int arrayX[N], arrayY[M];
   cin>>X;
   cin>>Y;

   for(int i=0; i<N; i++){
        cin>>arrayX[i];
   }
   for(int i=0; i<M; i++){
        cin>>arrayY[i];
   }
   for(int i=X+1; i<=Y; i++){
        peaceCount=0;
        for(int j=0; j<N; j++){
                for(int k=0; k<M; k++){
                    if(i>arrayX[j] && i<=arrayY[k]){
                        peaceCount++;
                    }
                }
            }
        if (peaceCount==M*N){
            cout<<"No War"<<endl;
            break;
        }
   }
   if (peaceCount!=M*N){
        cout<<"War"<<endl;
   }
return 0;
   }



Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int n, a[10010], ans = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int x[4096], y[4096], z[4096], n, a[4096];
	for (int i = 0; i < 3600; i++){
		cin >> x[i] >> y[i];
		if (x[i] == 0 && y[i] == 0){
			n=i;
			break;
		}
	}
	for (int i = 0; i < n; i++){
		if (x[i]>y[i]){
			z[i] = x[i]; 
			a[i] = y[i];
			y[i] = z[i];
			x[i] = a[i];
		}
		cout << x[i] <<" "<< y[i] << endl;
	}
	return 0;
}

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

int main() {
  vector<int> R = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << R.at(K-1);
  
      
 
}

// int型の2次元配列(3×4要素の)の宣言
  //vector<vector<int>> data(3, vector<int>(4));
 
  // 入力 (2重ループを用いる)
  //for (int i = 0; i < 3; i++) {
    //for (int j = 0; j < 4; j++) {
      //cin >> data.at(i).at(j);
   // }
  //}


Measured memory_bytes: 256
N = int(input())
s = {}
for i in range(N):
	word = []
	tmp = input()
	for j in range(10):
		word.append(tmp[j])
	word.sort()
	word_add = ""
	for j in range(10):
		word_add += word[j]

	if word_add in s:
		s[word_add] += 1
	else:
		s[word_add] = 1

ans = 0
for i in s.values():
	ans += i * (i-1) // 2
print(ans)

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

using ll = long long;
using pii = pair<int, int>;
constexpr int M = 1e9 + 7;
constexpr int INF = 1e9;

int main() {
    int N;
    cin >> N;
    vector<int> t(N), v(N);
    for(int i = 0; i < N; ++i) {
        cin >> t[i];
    }
    for(int i = 0; i < N; ++i) {
        cin >> v[i];
    }
    v.push_back(0);

    vector<double> dp(201, -1);
    dp[0] = 0;
    for(int i = 0; i < N; ++i) {
        vector<double> nxt(201, -1);
        for(int j = 0; j <= v[i]; ++j) {
            if(dp[j] == -1) {
                continue;
            }
            for(int nv = 0; nv <= min(v[i + 1], v[i]); ++nv) {
                if(abs(nv - j) > t[i]) {
                    continue;
                }
                double ma_v = 0;
                if(abs(v[i] - j) + abs(v[i] - nv) > t[i]) {
                    double tt = (nv - j + t[i]) * 0.5;
                    ma_v = j + tt;
                } else {
                    ma_v = v[i];
                }
                double t1 = (ma_v - j), t2 = (ma_v - nv);
                double move = (j + ma_v) / 2 * t1 + ma_v * (t[i] - t1 - t2) + (ma_v + nv) / 2 * t2;
                nxt[nv] = max(nxt[nv], dp[j] + move);
            }
        }
        dp = move(nxt);
    }
    cout << fixed << setprecision(10) << dp[0] << endl;
}


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

using namespace std;

int main() {
    long long n, k;
    cin >> n >> k;

    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<long long> cnt_a(n, 0), cnt_s(n, 0);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[i] > a[j]) {
                cnt_a[i]++;
                if (i < j) {
                    cnt_s[i]++;
                }
            }
        }
    }

    long long res = 0;
    for (int i = 0; i < n; i++) {
        res += ((k * (k - 1) / 2) % 1000000007) * cnt_a[i];
        res %= 1000000007;
        res += k * cnt_s[i];
        res %= 1000000007;
    }

    cout << res << endl;
}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int h,w;
    cin >> h >> w;
    vector<vector<int>> a(h,vector<int>(w)),b(h,vector<int>(w)),c(h,vector<int>(w));
    for (int i = 0;i < h;++i) for (int j = 0;j < w;++j) cin >> a[i][j];
    for (int i = 0;i < h;++i) for (int j = 0;j < w;++j) cin >> b[i][j];
    for (int i = 0;i < h;++i) for (int j = 0;j < w;++j) c[i][j] = abs(a[i][j]-b[i][j]);
    vector<vector<bitset<30000>>> dp(h+1,vector<bitset<30000>>(w+1));
    for (int i = 0;i < h+1;++i) for (int j = 0;j < w+1;++j) dp[i][j].reset();
    dp[0][1].set(15000);
    dp[1][0].set(15000);
    for (int i = 0;i < h;++i) for (int j = 0;j < w;++j) {
        dp[i+1][j+1] = (((dp[i][j+1]|dp[i+1][j])<<c[i][j])|((dp[i][j+1]|dp[i+1][j])>>c[i][j]));
    }
    int ans = 15000;
    for (int i = 0;i < 30000;++i) if (dp[h][w][i]) ans = min(ans,abs(15000-i));
    cout << ans << endl;
    
}

Measured memory_bytes: 24960
#include<iostream>
using namespace std;
int main(void) {
	int a[4], b[4];
	while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
		int hit = 0;
		int blow = 0;
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (a[i] == b[j]) {
					if (i == j) {
						hit++;
					}
					else {
						blow++;
					}
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import sys
import bisect
N = int(input())
L = list(map(int, input().split()))
LS = sorted(L)
ans = 0
for i in range(N):
  for j in range(N):
    if i < j:
      index = bisect.bisect_left(LS,LS[i]+LS[j])
      ans += index-j-1 

print(ans)

Measured memory_bytes: 74656
package main

import (
	"fmt"
)

func main() {
  var a, b int
  fmt.Scan(&a, &b)
  
  if a + b == 15 {
    fmt.Println("+")
  } else if a * b == 15 {
    fmt.Println("*")
  } else {
    fmt.Println("x")
  }
}

Measured memory_bytes: 1768
import copy
ans=0
h,w,k=map(int,input().split())
cc=[list(input()) for i in range(h)]
for bit in range(1 << h):
  ccc=copy.deepcopy(cc)
  for i in range(h):
    if bit & (1 << i):
       ccc[i]=["!"]*w 
  for bit in range(1 << w):
    cccc=copy.deepcopy(ccc)
    for i in range(w):
      if bit & (1 << i):
        for j in range(h):
          cccc[j][i]="!"
    count0=0
    for i in range(h):
      count0+=cccc[i].count("#")
    if count0==k:
      ans+=1
print(ans)




Measured memory_bytes: 9140
# coding: utf-8
import numpy as np

if __name__ == "__main__":
	n, m = map(int, input().split())

	mat = [[0]*n for _ in range(n)]
	for _ in range(m):
		a, b = map(int, input().split())
		a -= 1; b -= 1
		mat[a][b] += 1
		mat[b][a] += 1

	for i in range(n):
		print(sum(mat[i]))


Measured memory_bytes: 21920
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    ll n;
    cin>>n;
    int p = n%10;
    vector<int> fst = {2,4,5,7,9}, snd = {0,1,6,8};
    if(find(fst.begin(), fst.end(), p) != fst.end())
        cout<<"hon";
    else if(find(snd.begin(), snd.end(), p) != snd.end())
        cout<<"pon";
    else
        cout<<"bon";
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3632
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn exe(n: usize, k: usize, mut h: Vec<u64>) -> u64 {
    h.sort_by(|a, b| b.cmp(a));

    let mut attack_cnt = 0;
    let mut must_kill_attack_cnt = 0;
    for i in 0..n {
        if must_kill_attack_cnt < k {
            must_kill_attack_cnt += 1;
            continue;
        }
        attack_cnt += h[i];
    }

    attack_cnt
}

fn main() {
    input! {
        n: usize,
        k: usize,
        h: [u64; n],
    }
    let ans = exe(n, k, h);
    println!("{}", ans);
}


Measured memory_bytes: 9464
c=[0]*100
while 1:
    try:a,b=map(int,input().split())
    except:break
    c[a-1]+=1;c[b-1]+=1
    if a==0:
        for i in range(2,100):
            if c[i]&1:print('NG');break
        else:print('OK' if c[0]&1 and c[1]&1 else 'NG')
        c=[0]*100

Measured memory_bytes: 7520
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    int h=0,w=0,c=0,d=0,n,m,k,ans=0,y;
    string s,s2;
    cin >> s;
    if(s[0]!='A'){
        cout << "WA" <<endl;
        return 0;
    }
    for(int i=1;i<s.size();i++){
        if(!(s[i]>='a'&&s[i]<='z')){
            if(i>=2 && i<=s.size()-2 && s[i]=='C'){
                c++;
            }
            else {
                cout << "WA" <<endl;
                return 0;
            }
        }
    }
    if(c!=1)cout << "WA" <<endl;
    else
    cout << "AC" <<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	String [] list;
	boolean flg = true;
	boolean [] used;
	int n;
	int [][] pass2;
	

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			if(n == 0) break;
			int [] in = new int[26];
			int [] out = new int[26];
			list = new String[n];
			pass2 = new int[26][26];
			
			for(int i = 0 ; i < n; i++){
				String s = sc.next();
				list[i] = s;
				in[s.charAt(0) - 'a']++;
				out[s.charAt(s.length() - 1) - 'a' ]++;
				int from = s.charAt(0) - 'a';
				int to =  s.charAt(s.length() - 1) - 'a';
				pass2[from][to]++;
				pass2[to][from]++;
			}
			boolean res = isOK(in, out);
			System.out.println(res ? "OK" : "NG");
		}
	}
	
	private boolean isOK(int[] in, int[] out) {
		for(int i = 0 ; i < in.length;i++){
			if(in[i] != out[i]) return false;
		}
		
		flg = false;
		used = new boolean[26];
		int ind = 0;
		for(ind = 0; ind < 26; ind++){
			if(in[ind] > 0){
				break;
			}
		}
		dfs(ind);
		for(int i = 0 ; i < 26; i++){
			for(int j = 0 ; j < 26; j++){
				if(pass2[i][j] > 0){
					return false;
				}				
			}
		}
		
		return true;
	}
	private void dfs(int now) {
		for(int i = 0 ; i < 26; i++){
			if(pass2[now][i] > 0){
				pass2[now][i]--;
				pass2[i][now]--;
				dfs(i);
			}
		}
	}

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

Measured memory_bytes: 15000
from collections import Counter
n=int(input())
a=Counter(map(int,input().split()))
a=sorted(a.items(),key=lambda x:x[0])
l=len(a)

a=[1 if a[i][1]%2==1 else 2 for i in range(l)]
id=[i for i in range(l) if a[i]==2]
l=len(id)

cnt=0
for i in range(l-1):
    if id[i]+1==id[i+1]:
        cnt+=1
        
if cnt==1 and l==2:
    ans=sum(a)-4
else:
    if l%2==0:
        ans=sum(a)-l
    else:
        ans=sum(a)-l-1
print(ans)


Measured memory_bytes: 22636
#include <stdio.h>

int main()
{
    int n,i,j,k,tmp,a=1,b=0;
    scanf("%d",&n);
    long long int x[n];
    long long int y[n];
    long long int sax[n*n][3];
    long long int say[n*n][3];
    long long int max=0;
    
    for(i=0;i<n;i++){
        scanf("%lld %lld",&x[i],&y[i]);
 //       printf("A");
    }
    sax[0][0] = 0;
    sax[0][1] = 0;
    sax[0][2] = 0;
    say[0][0] = 0;
    say[0][1] = 1;
    say[0][2] = 0;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            for(k=0;k<a;k++){
          //      printf("B[{%lld %lld}-{%lld %lld}={[%d]%lld %lld}%lld,%lld]",x[i],y[i],x[j],y[j],k,sax[k][0],sax[k][1],x[i] - x[j],y[i] - y[j]);
                if(sax[k][0] == x[i] - x[j] && sax[k][1] == y[i] - y[j]){
                    sax[k][2]++;
                    b=1;
             //       printf("C");
                }
            }
            if(b!=1){
                sax[a][0] = x[i] - x[j];
                sax[a][1] = y[i] - y[j];
                sax[a][2] = 1;
                a++;
             //   printf("D");
            }
            b--;
        }
    }
    
    for(i=1;i<a;i++){
        if(sax[i][2] > max){
            max=sax[i][2];
         //   printf("[x%d %lld]",i,max);
        }
    }
    
    
    if(n==1) max=0;
    printf("%lld",n-max);
    
}



Measured memory_bytes: 256
import Data.Char(toLower, ord)
import Text.Printf
import Data.List
import Data.Function
import qualified Data.Map as Map

main = interact $ show' . solve
  where
    show' = unlines . map fmt
    solve = addEmpty . count
    fmt (s, d) = printf "%s : %d" s d
    addEmpty xs = [tuple [c] |c <- ['a'..'z']]
      where
        tuple s = case m of
                    Just val -> (s, val)
                    Nothing -> (s, 0)
          where m = Map.lookup s map
        map = Map.fromList xs
    count cs = map length' . group . sort $ [toLower' c| c <- cs, isAlpha c]
    length' str = ([head str], length str)
    toLower' c | isUpper c = toLower c
               | otherwise = c
    isUpper c = a <= o && o <= z
      where o = ord c
    isAlpha c = a <= o && o <= z'
      where o = ord c
    a = ord 'A'
    z = ord 'Z'
    z' = ord 'z'



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

const int N=2e5+100;
int mod=1e9+7;
typedef long long ll;
int a[N];
map<int,int>mp;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n;cin>>n;
    int s=0;
    for(int i=1;i<=n;i++) cin>>a[i],s^=a[i];
    for(int i=1;i<=n;i++){
        cout<<(s^a[i])<<" ";
    }
    return 0;
}
/*
1e15
*/


Measured memory_bytes: 4400
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] NX = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long sorce = NX[1];
            long min = 1001;
            int cnt = 0;
            for(int j = 0; j < NX[0]; j++)
            {
                long m = long.Parse(Console.ReadLine());
                sorce -= m;
                min = Math.Min(min, m);
                cnt++;
            }
            if (sorce != 0)
            {
                while (true)
                {
                    if (sorce - min < 0)
                    {
                        break;
                    }
                    sorce -= min;
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


Measured memory_bytes: 28192
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Set;
import java.util.HashSet;

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter writer = new PrintWriter(System.out);
        Set<String> riceCakeSize = new HashSet<>(); 
        
        int num = Integer.parseInt(br.readLine());
        
        for(int i = 0; i < num; i++){  riceCakeSize.add(br.readLine());  }
        writer.println(riceCakeSize.size());
        
        br.close();
        writer.close();
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define drep(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

ll gcd(ll a,ll b){
    if(a<b){
        int t=a;a=b;b=t;
    }
    int c=a%b;
    while(c!=0){
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}

ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

bool isPrime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0)return false;
    }
    return true;
}

int main() {
    
   int n;
    while(cin>>n){
   int ans=0;
   for(int i=n;i<=600-n;i+=n){
       ans+=n*(i*i);
   }
   cout<<ans<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3048
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

ll llmax(ll a, ll b){
  return a > b ? a : b;
}

ll log2(ll n){
  ll l = 1;
  while(n /= 2) l++;
  return l;
}

int main(){
  ll N, K;
  cin >> N >> K;
  ll a[N];
  rep(i, N) cin >> a[i];
  // rep(i, N) a[i] = 1;

  vector<ll> subarray;
  ll summax;
  rep(l, N){
    ll sum = 0;
    repi(r, l, N){
      sum += a[r];
      subarray.push_back(sum);
      if(l == 0 && r == N-1) summax = sum;
    }
  }

  ll ans = 0;
  rrep(b, log2(summax)){
    ll mask = 1;
    mask <<= b;
    vector<ll> candidates;
    ll arrsize = subarray.size();
    rep(i, arrsize)
      if(subarray[i] & mask) candidates.push_back(subarray[i]);
    if((ll) candidates.size() >= K){
      subarray = candidates;
      ans += mask;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6384
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
#define fil(x) memset(x, 0, sizeof(x))
#define fillb(x) memset(x,false,sizeof(x))
#define fillm(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define pll pair<int, int>
#define pf printf
#define sf scanf
#define all(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define fo(i,n) for(int i=0;i<n;i++)
#define of(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define nl endl

typedef unsigned long long lll;
typedef long long ll;
int knigtx8[] = {2, 2, -2, -2, 1, 1, -1, -1}; ///knight move in chess
int knigty8[] = {1, -1, 1, -1, 2, -2, 2, -2}; ///knight move in chess
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; ///for 8 directions
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1}; ///for 8 directions
int dx4[] = {0, 0, 1, -1}; ///for 4 directions
int dy4[] = {1, -1, 0, 0}; ///for 4 directions
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

int atoz(){
    int frnt,bck,nibo,present,i;string s;
        frnt = abs(s[i]-present);
        bck = 26-frnt;
        nibo = min(frnt,bck);
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

int main()
{
    IOS;
    ll n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0 and i%5!=0)
        {
            sum+=i;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3636
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
a = inpl()
su = sum(a)
if n >= su:
    print(n-su)
else:
    print(-1)

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

int main(){
	int k,x;
	cin >> k >> x;
	int s,e;
	s = x-k+1;
	e = x+k-1;
	if(s<-1000000) s=-1000000;
	if(e>1000000) e=1000000;
	for(int i=s;i<=e;i++) cout << i << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long int
vector<int> num;
int k, len;
int dp[1005][5][2];
int calc(int pos, int cnt, int edge)
{
    if (pos == len)
    {
        if (cnt == k)
            return 1;
        return 0;
    }
    else if (dp[pos][cnt][edge] != -1)
        return dp[pos][cnt][edge];
    int maxdigit = 9;
    if (edge)
        maxdigit = num[pos];
    int res = 0;
    for (int i = 0; i <= maxdigit; i++)
    {
        int newedge = (edge & (i == maxdigit));
        int newcount = (cnt + (i > 0));
        if (newcount <= k)
            res += calc(pos + 1, newcount, newedge);
    }
    return (dp[pos][cnt][edge] = res);
}
signed main()
{
    string s;
    cin >> s >> k;
    len = s.length();
    memset(dp, -1, sizeof(dp));
    for (int i = 0; i < len; i++)
    {
        num.pb(s[i] - '0');
    }
    int ans = calc(0, 0, 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner in = new Scanner(System.in);

		double r = in.nextDouble();

		//System.out.println((r*r*Math.PI) + " " + (2*r*Math.PI));
		System.out.printf("%f %f",(r*r*Math.PI),(2*r*Math.PI));

		//System.out.printf("%.10f %.10f\n",r*r*Math.PI,(2*r)*Math.PI)

	}

}



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

int main() {
	int n;
	char a[110], b[110], c[110];
	cin >> n;
	cin >> a >> b >> c;
	int count[30];
	int ans = 0;
	int answer = 0;
	for (int j = 0; j < 30; j++) {
		count[j] = 0;
	}
	int all = 0;
	for (int i = 0; i < n; i++) {
		count[a[i]-97]++;
		count[b[i]-97]++;
		count[c[i]-97]++;
		for (int j = 0; j < 30; j++) {
			all += count[j];
			ans = max(ans, count[j]);
		}
		answer += all - ans;
		for (int j = 0; j < 30; j++) {
			count[j] = 0;
		}
		ans = 0;
		all = 0;
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    if(a > b){
        cout << "a > b" << endl;
    }
    else if(a < b){
        cout << "a < b" << endl;
    }
    else cout << "a == b" << endl;
    return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

string str, ans;

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

	cin >> str;
	for(int i = 0; i < str.size()-8; i++){
		ans += str[i];
	}
	cout << ans;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

using Graph = vector<vector<int>>;

vector<int> ans(10010), c(10010); int cnt = 0;
void dfs(const Graph &G, int v, int p) { 
    ans[v] = c[cnt];
    cnt++;
	for (auto nv : G[v]) {
		if (nv == p)continue;
		dfs(G, nv, v);
	}
}

int main() {
    int n;
    cin >> n;
    Graph G(n);
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i, n)cin >> c[i];
    c.resize(n); sort(rall(c));
    dfs(G, 0, -1);
    cout << accumulate(all(c), 0) - c[0] << endl;
    rep(i, n)cout << ans[i] << " ";
    cout << endl;
}

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

int main(){
	map<string, int> points;
	for(int i=0; i<2; i++){
		int n;
		cin >> n;
		for(int j=0; j<n; j++){
			string s;
			cin >> s;
			if(i==0) points[s]++;
			else points[s]--;
		}
	}
	int ans = 0;
	for(auto p : points){
		ans = max(ans, p.second);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N,M = gets.split.map(&:to_i)

prefs = []
states = []

(N+1).times do
  states << []
end

M.times do
  p, y = gets.split.map(&:to_i)
  states[p].push(y)
  prefs << [p,y]
end

order = Hash.new

#年から順序を導出
states.each_with_index do |y, p|
  states[p].sort.each_with_index do |year, i|
    order[year] = i+1
  end
end

#答え出力
prefs.each do |(pref,year)|
  str = "%#06d" % pref + "%#06d" % order[year]
  puts str
end


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

int main(void){
    long n, m;
    cin >> n >> m;
    array<vector<long>,8> value;
    for(long i=0; i<8; i++){
        value[i].resize(n);
    }
    for(long i=0; i<n; i++){
        long x, y, z;
        cin >> x >> y >> z;
        value[0][i] = + x + y + z;
        value[1][i] = + x + y - z;
        value[2][i] = + x - y + z;
        value[3][i] = + x - y - z;
        value[4][i] = - x + y + z;
        value[5][i] = - x + y - z;
        value[6][i] = - x - y + z;
        value[7][i] = - x - y - z;
    }
    long v_max=0;
    for(long i=0; i<8; i++){
        long sum = 0;
        sort(value[i].begin(), value[i].end(), greater<long>());
        for(long j=0; j<m; j++){
            sum += value[i][j];
        }
        v_max = max(sum, v_max);
    }
    cout << v_max << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>

using namespace std;


int main(){
  int a,b,c,s;
  s = 0;
  cin >> a >> b >> c;
  for(int i = a; i < b+1;i++){
    if(c % i == 0) s++;
  }
  printf("%d\n",s);

  return 0;
}


Measured memory_bytes: 3212
#include<iostream>
#include<string>
#include<vector>

using namespace std;

#define MOD 1000000007LL


typedef uint64_t ullint;

string s;

int main() {
	cin >> s;
	vector<vector<ullint> > dp((int)s.size() + 1, vector<ullint> (13, 0));

	dp[0][0] = 1;
	for (unsigned int i = 0; i < s.size(); i++) {
		int c;
		if (s[i] == '?') { c = -1; }
		else { c = s[i] - '0'; }

		for (int j = 0; j < 10; j++) {
			if (c != -1 && c != j) { continue; }
			for (int k = 0; k < 13; k++) {
				dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
			}
		}
		for (int j = 0; j < 13; j++) {
			dp[i + 1][j] %= MOD;
		}
	}
	cout << dp[(int)s.size()][5] << endl;
}

Measured memory_bytes: 13696
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())

sys.setrecursionlimit(10 ** 9)


def main():
    A, B = MAP()
      
    print(A*2 if A == B else max(A, B)*2 - 1)
    

if __name__ == '__main__':    
    main()                       

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];


void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  COMinit();
  int n;
  cin>>n;
  int a,b;
  int val[n+1];
    rep(i, n+1){
    cin>>val[i];}
  
  int pl[n+1];
  rep(i, n+1){
    pl[i]=-1;}
  
  rep(i, n+1){
    if(pl[val[i]]==-1)
    pl[val[i]]=i;
    else{a=min(pl[val[i]],i);
         b=max(pl[val[i]],i);
        break;}
  }

  
  for(int k=1;k<=n+1;k++){
    if(k==1){cout<<n<<endl;
            continue;}
    ll gans=0;
    
    if(k-1>a+n-b){
      cout<<COM(n+1, k)<<endl;}
    else{
   gans=COM(a+n-b, k-1);
          gans%=MOD;
         ll ans=COM(n+1, k)-gans;
      ans+=MOD;
      ans%=MOD;
      
      cout<<ans<<endl;
    }
  }
          
return 0;
  
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
#define pii pair<ll,ll>
#define ff first
#define ss second
#define sfi(a) scanf("%d",&a)
#define sfi2(a,b) scanf("%d %d",&a,&b)
#define sfi3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(a) scanf("%lld",&a)
#define all(a) a.begin(),a.end()
#define keepu(a) a.erase(unique(all(a)),a.end())
#define inf 1e7
#define m_p make_pair
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))

typedef long long ll;
const ll mod = 1e9+7;
const int sz = 500;


int main(){

    int n,m;
    cin >> n >> m;

    double arr[n];
    ll tot = 0;

    for(int i=0;i<n;i++){
        cin >> arr[i];
        tot += (int)arr[i];
    }

    long double x = tot/((4.0)*m);

    int cnt = 0;
    for(int i=0;i<n;i++){
        if(arr[i]-x>=0.000000001 || arr[i]-x==0) cnt++;
    }

    if(cnt>=m) puts("Yes");
    else puts("No");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
	if(b&1)
		r=(r*a)%m;
	b=b/2;
	a=(a*a)%m;
	}
	return r%m;
}

int main() {
    ll n; cin>>n;
    ll mn = 100000000000000;
    for(ll i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            mn = min(mn,i+n/i-2);
        }
    }
    cout<<mn<<endl;
    return 0;
}
/*
1
5 1
1 2
2 3
3 4
3 5
2 2 5 2
*/


Measured memory_bytes: 256
import heapq
N,M=list(map(int,input().split()))
Xs = list(map(int,input().split()))
Xs.sort()

if N >= M:
    print(0)
    exit()

pq = []
for i in range(M-1):
    heapq.heappush(pq, Xs[i] - Xs[i+1])

for i in range(N-1):
    heapq.heappop(pq)

res = 0
while pq:
    res -= heapq.heappop(pq)

print(res)


Measured memory_bytes: 13960
#include <stdio.h>
#include <string.h>
typedef long long ll;

char str[200005];
ll len;
ll ans;
ll add;

int main()
{
    scanf("%s", str);

    len = strlen(str);

    for (ll i = len - 1; i >= 0; i--) {
        if (str[i] == 'B' &&
            str[i + 1] == 'C') {
            add++;

            i--;
            while (str[i] == 'A') {
                ans += add;
                i--;
            }
        }
        else {
            add = 0;
        }
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

char s[maxn],t[maxn];

int main()
{
	scanf("%s",s+1); scanf("%s",t+1);
	int len=strlen(s+1),ans=0;
	rep(i,1,len) ans+=(s[i]!=t[i]); cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4152
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(){
	string str;
	while(getline(cin,str)){
		for(int num=0;num<26;num++){
			for(int i=0;i<str.length();i++){
				if(97<=str[i] && str[i]<=122){
					str[i]+=1;
					if(str[i]>122) str[i] -=26;
				}
			}
			string::size_type index1 = str.find("the");
			string::size_type index2 = str.find("this");
			string::size_type index3 = str.find("that");
		
			if( index1 == string::npos && index2 == string::npos &&
				index3 == string::npos){
				continue;
			}else{
				cout << str <<endl;
				break;
			}
		}
	}
	return 0;

}

Measured memory_bytes: 1176
oo=input().strip()
ee=input().strip()

ol=[]
el=[]
for o in oo:
  ol.append(o)

for e in ee:
  el.append(e)

if len(ol)!=len(el):
  el.append("")

ans=""
for i in range(len(ol)):
  ans+=ol[i]
  ans+=el[i]
print(ans)
  

Measured memory_bytes: 3060
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var s = Number(lines[0]);
 var info = [];
 info.push(s);
 var num = s;
 var i = 1;
 while(true){
 if(num%2 == 0){
   num = num / 2;
 }else if(num % 2 == 1){
   num = 3*num + 1;
 }
 
 if(info.indexOf(num) != -1){
   console.log(i+1);
   break;
 }else{
   info.push(num);
   i++;
   continue;
 }
}
});

Measured memory_bytes: 7628
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    L = [LI() for i in range(N)]
    
    for x in range(101):
        for y in range(101):
            max_num = float('inf')
            ans = 0
            res = True
            for xn, yn, hn in L:
                if hn == 0:
                    max_num = min(max_num, abs(x-xn)+abs(y-yn))
                    if max_num == 0:
                        res = False
                        break
                else:
                    temp = abs(x-xn)+abs(y-yn)+hn
                    if ans != 0 and ans != temp:
                        res = False
                        break
                    else:
                        ans = temp
            if (max_num >= 2 and ans == 0) or ans > max_num:
                res = False

            if res:
                if ans != 0:
                    print(x,y,ans)
                else:
                    print(x,y,1)
                exit()
    
    
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9568
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<int> a;
  while (n > 0) {
    ll d = (n-1)%26;
    a.push_back(d);
    n = (n-1)/26;
  }
  // Here, a has all values.
  reverse(all(a));
  string ans;
  for (int i : a) {
    ans += (char)('a'+i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3652