akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

template<typename T>
struct rerooting{
    using F=function<T(T,int)>;//集合，頂点番号
    using M=function<T(T,T)>;

    int V;
    vector<vector<int>> G;
    vector<vector<T>> dp;
    vector<T> ans;
    // dp_v = g(merge(f(dp_c1,c1),...,f(dp_ck,ck)),v)
    F f,g;  // TxN->T
    M merge;// TxT->T
    T gen;
    //gen: mergeの元
    rerooting(int V,F f,M merge,T gen,F g=[](T a,int b){return a;})
        :V(V),f(f),merge(merge),gen(gen),g(g),G(V),dp(V),ans(V,gen){}
    
    //bidirectional
    void add_edge(int a,int b){
        G[a].push_back(b);
        G[b].push_back(a);
    }
    T dfs1(int pre,int now){
        T ret=gen;
        for(int i=0;i<G[now].size();i++)if(G[now][i]!=pre){
            dp[now][i]=dfs1(now,G[now][i]);
            ret=merge(ret,f(dp[now][i],G[now][i]));
        }
        return g(ret,now);
    }
    void dfs2(int pre,int now,T frompar){
        for(int i=0;i<G[now].size();i++){
            if(G[now][i]==pre){
                dp[now][i]=frompar;
                break;
            }
        }
        vector<T> lsum(G[now].size()+1),rsum(G[now].size()+1);//親も混ぜて累積
        lsum[0]=gen;rsum[G[now].size()]=gen;
        for(int i=0;i<G[now].size();i++) lsum[i+1]=merge(lsum[i],f(dp[now][i],G[now][i]));
        for(int i=G[now].size();i>0;i--) rsum[i-1]=merge(rsum[i],f(dp[now][i-1],G[now][i-1]));
        for(int i=0;i<G[now].size();i++){
            if(G[now][i]==pre) continue;
            T fromme=merge(lsum[i],rsum[i+1]);
            dfs2(now,G[now][i],g(fromme,now));
        }
    }
    void build(int root=0){
        for(int i=0;i<V;i++) dp[i].resize(G[i].size());
        dfs1(-1,root);
        dfs2(-1,root,gen);
        for(int i=0;i<V;i++){
            for(int j=0;j<G[i].size();j++) ans[i]=merge(ans[i],f(dp[i][j],G[i][j]));
            ans[i]=g(ans[i],i);
        }
    }
};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;ll m;cin>>n>>m;
    auto f=[&](ll dpch,int hoge){return (dpch+1)%m;};
    auto merge=[&](ll lhs,ll rhs){return lhs*rhs%m;};
    rerooting<ll> g(n,f,merge,1);
    rep(i,n-1){
        int u,v;cin>>u>>v;u--,v--;
        g.add_edge(u,v);
    }
    g.build();
    rep(i,n)cout<<g.ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 31104
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        List<Integer> list = new ArrayList<>(N);
        for (int i = 0; i < N; i++) {
        	list.add(sc.nextInt());
        }
        
        System.out.println(list.stream().distinct().count());
    }
    
}

Measured memory_bytes: 29140
import numpy as np
n,m,c=list(map(int,input().split()))
b=np.array(list(map(int,input().split())))
count=0
for i in range(n):
    a = np.array(list(map(int,input().split())))
    if sum(list(a*b))+c>0:
        count+=1
print(count)

Measured memory_bytes: 12420
use std::io::*;
use std::str::FromStr;
use std::cmp::min;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let mut n: u64 = read();
    let k: u64 = read();
    let mut ret = 0;
    while n != 0 {
        n /= k;
        ret += 1;
    }
    println!("{}", ret);
}



Measured memory_bytes: 4352
while True:
    table = input().split()
    a = int(table[0])
    op = table[1]
    b = int(table[2])
    if op == "?":
        break 

    if op == "+":
        print("%d" % (a + b))
    elif op == "-":
        print("%d" % (a - b))
    elif op == "*":
        print("%d" % (a * b))
    else:
        print("%d" % (a / b))


Measured memory_bytes: 5596
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        Console.ReadLine();
        var input = Console.ReadLine();
        var red = input.Count(v => v == 'R');
        var blue = input.Count(v => v == 'B');
        Console.WriteLine(red > blue ? "Yes" : "No");
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int64_t K, N;
  cin >> K >> N;
  vector<int64_t> A(N), B(N);
  for (int64_t i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  B.at(0) = A.at(0) + (K - A.at(N - 1));
  int64_t maxlen = B.at(0);
  for (int64_t i = 1; i < N; i++) {
    B.at(i) = A.at(i) - A.at(i - 1);
    maxlen = max(maxlen, B.at(i));
  }
  cout << K - maxlen << endl;
}

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

int main(){
  int N ; 
  cin >> N ; 
  vector<string> s(N) ; 
  map<string , int> MAP ; 
  for(int i = 0 ; i < N ; i++){
    cin >> s.at(i) ; 
    MAP[s.at(i)]++ ; 
  }
  
  int M ; 
  cin >> M ; 
  vector<string> t(M) ; 
  for(int i = 0 ;i < M ; i++){
    cin >> t.at(i) ; 
    MAP[t.at(i)]--  ;
  }
  
  int cnt = 0 ; 
  for(auto p : MAP){
    cnt = max(cnt , p.second) ; 
  }
  cout << cnt <<  endl ; 
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[6];
int a[6];

int main() {
	while(scanf("%s", s) != EOF) {
		for(int i = 1; i <= 4; i++) a[i] = s[i - 1] - '0';
		int sum = 0;
		for(int i = 1; i <= 4; i++) sum += a[i];
		if(sum == 7) {
			printf("%d+%d+%d+%d=7\n", a[1], a[2], a[3], a[4]);
			continue;
		}
		else {
			if(sum - 2 * a[2] == 7) {
				printf("%d-%d+%d+%d=7\n", a[1], a[2], a[3], a[4]);
				continue;
			}
			else if(sum - 2 * a[3] == 7) {
				printf("%d+%d-%d+%d=7\n", a[1], a[2], a[3], a[4]);
				continue;
			}
			else if(sum - 2 * a[4] == 7) {
				printf("%d+%d+%d-%d=7\n", a[1], a[2], a[3], a[4]);
				continue;
			}
			else {
				if(sum - 2 * a[2] - 2 * a[3] == 7) {
					printf("%d-%d-%d+%d=7\n", a[1], a[2], a[3], a[4]);
					continue;
				}
				else if(sum - 2 * a[3] - 2 * a[4] == 7) {
					printf("%d+%d-%d-%d=7\n", a[1], a[2], a[3], a[4]);
					continue;
				}
				else if(sum - 2 * a[2] - 2 * a[4] == 7) {
					printf("%d-%d+%d-%d=7\n", a[1], a[2], a[3], a[4]);
					continue;
				}
				else if(sum - 2 * a[2] - 2 * a[3] - 2 * a[4] == 7) {
					printf("%d-%d-%d-%d=7\n", a[1], a[2], a[3], a[4]);
					continue;
				}
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long long ans=0;
  int n;
  cin>>n;
  for (int i = 1; i <= n; i++) {
 if(i%3 !=0 && i%5 !=0){
   ans +=i;
 }
}
cout<<ans<<endl;

}


Measured memory_bytes: 3612
#include <stdio.h>

int main(void)
{
char c;
scanf("%c", &c);

switch(c){
    case 'a':
    case 'i':
    case 'u':
    case 'e':
  case 'o':
    printf("vowel\n");
    break;
  default:
    printf("consonant\n");
    break;
}
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
		
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			final int k = sc.nextInt();
			
			if(n == 0 && k == 0){
				break;
			}
			
			int[] array = new int[n];
			
			for(int i = 0; i < n; i++){
				array[i] = sc.nextInt();
			}
			
			int sum = 0;
			for(int i = 0; i < k; i++){
				sum += array[i];
			}
			
			int max = sum;
			for(int i = 0, m = k; m < n; i++, m++){
				sum += array[m] - array[i];
				max = Math.max(sum, max);
			}
			
			System.out.println(max);
		}
		
	}
}

Measured memory_bytes: 13000
#!/usr/bin/env python3
import sys
import math

def solve(H: int):
    n = int(math.log2(H))
    print(pow(2, n+1)-1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    solve(H)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
/*
*Bismillahir Rahmanir Rahmin
* @Author: {{Syed Yasir Shahriar
{
/*//*\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\*/
 
//أعوذ بالله من الشيطان الرجيم
//بسم الله الرحمن الرحيم
 
/*//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\*/
 
/*};/* @Date:   {{create_time}}typedef int MyCustomType;
* @Last Modified by:   mrinm
* @Last Modified time: 2020-07-04 17:09:10
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define v vector<ll>
#define st stack<ll>
#define pq  priority_queue <int>
#define q queue<ll>
#define mod 1000000005
using namespace std;
 
/* int solve(int arr[],int n){

 	   int res=0;
 	   for (int i =0; i<= n - 1; i++) { 
        int val = 0; 
        for (int j =i; j<= n - 1; j++) { 
            val = val + arr[j]; 
            if (val % 2 != 0) 
                res++; 
        } 
    } 
 	   return (res);
 }*/
 
int main(){
 /*    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif*/
     //ios::sync_with_stdio(0);
	  int n;
	  cin>>n;
	  int ans=3*n*n;
	  cout<<ans<<endl;
	 
     return 0;
}

Measured memory_bytes: 3616
n, k ,q = list(map(int, input().split()))
listAns = [input() for i in range(q)]
score = [0] * n
count = 0
for j in listAns:
    score[int(j) - 1] += 1
for h in score:
    if h > q - k:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 61400
// In the name of God //
 
#include <bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(), (x).end()
#define pii pair <int, int>
using namespace std;
const ll mod = 998244353;

void solve() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if(i&1 && x&1) {
            ans++;
        }
    }
    cout << ans << endl;
}

int main()  {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    } 
    // cout << 15*modInverse(6, mod)%mod << " " << 39*modInverse(10, mod)%mod;
}                               

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll n;
ll dp[maxn];
ll a[maxn];
ll k;
int main()
{
    gbtb;
    cin>>n>>k;
    repd(i,1,n)
    {
        cin>>a[i];
    }
    dp[1]=0;
    dp[0]=0;
    repd(i,2,n)
    {
        dp[i]=inf;
    }
    repd(i,2,n)
    {
        for(int j=i-1;j>=max(1ll,i-k);j--)
        {
            dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
        }
    }
    cout<<dp[n];
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}


Measured memory_bytes: 5120
from ctypes import *
import subprocess as sp
from operator import itemgetter
import sys
import os.path

# C++のstd::setのラッパー。こいつを呼び出す。
set_code = r"""
#include <set>

std::set<int> s;

void add(int x) {
    s.insert(x);
}

bool find(int x) {
    return s.find(x) != s.end();
}

void remove(int x) {
    s.erase(x);
}

bool empty() {
	return s.empty();
}

int getMin() {
	return *s.begin();
}
"""

class CppSet:
	# オブジェクトが作られた数
	# オブジェクトごとに共有ライブラリを作成する必要があるので、counterで共有ライブラリにIDを割り振る
	counter = 0

	def __init__(self):
		# 共有ライブラリを作成して、それを呼び出す
		lib_name = './hoge{}.so'.format(CppSet.counter)

		# C++のソースを書き出します
		code_file_name = "tmp.cpp"
		with open(code_file_name, "w") as f:
			f.write(set_code)

		CppSet.counter += 1 

		# 共有ライブラリを作成。-std=c++14とかにすると動かなくなる
		sp.Popen(['g++', '-fPIC', '-shared', '-std=c++11', '-O2', code_file_name, '-o', lib_name]).communicate()

		# Pythonから共有ライブラリを召喚します
		# 召喚方法は https://over80.hatenadiary.jp/entry/20150816/pure_python_inotify を参照
		# 上で書いたコードのgetMinとかの関数が、共有ライブラリではシンボルに変換される(マングリング)らしい
		# なので、シンボルから関数名を得るためにデマングルとかいうやつをやります
		# 最終的にシンボルと関数の対応関係を使って、各関数を召喚します
		# マングリング: https://albel06.hatenablog.com/entry/2016/03/17/180000
		# デマングル: http://0xcc.net/blog/archives/000095.html
		lib = CDLL(lib_name)
		self.add = getattr(lib, "_Z3addi")
		self.find = CFUNCTYPE(c_bool, c_int)(
						("_Z4findi", lib),
						((1, "x"), )
					)
		self.remove = getattr(lib, "_Z6removei")
		self.empty = CFUNCTYPE(c_bool)(
						("_Z5emptyv", lib),
						()
					)

		self.getMin = CFUNCTYPE(c_int)(
						("_Z6getMinv", lib),
						()
					)

def main():
	N, Q = map(int, sys.stdin.readline().split())
	tmp = [tuple(map(int, sys.stdin.readline().split())) for _ in range(N)]
	stx = [(s - x, 1, x) for s, t, x in tmp] + [(t - x, -1, x) for s, t, x in tmp]
	stx.sort()
	
	D = [int(sys.stdin.readline()) for _ in range(Q)] 
	ans = [-1]*Q

	idx = 0
	stx_len = len(stx)
	se = CppSet()
	for i, d in enumerate(D):
		while idx < stx_len:
			t, com, x = stx[idx]
			if t > d:
				break
			if com == 1:
				se.add(x)
			else:
				se.remove(x)
			idx += 1
		ans[i] = (-1 if se.empty() else se.getMin())

	print(*ans, sep='\n')

if __name__ == "__main__":
	main()


Measured memory_bytes: 126336
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	string s; cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return;
}

int main() {
	solve();
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define N (110)

int n, t[N];
int lst[N * N];
int v[N], in[N];
int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i){
        scanf("%d", t  + i);
    }
    for (int i = 1; i <= n; ++i){
        scanf("%d", v + i);
    }
    for (int i = 1; i <= n; ++i){
        in[i] = min(v[i], v[i-1]);
    }
    in[1] = in[n+1] = 0;
    for (int i = 1; i <= n+1; ++i){
        lst[i-1] = i;
    }
    for (int op = 0, cl = n+1; op < cl; ++op){
        int x= lst[op];
        if (x + 1 <= n){
            int y = x + 1;
            if (in[x] + t[x] < in[y]){
                in[y] = in[x] + t[x];
                lst[cl++] = y;
            }
        }
        if (x - 1 >= 1){
            int y = x - 1;
            if (in[x] + t[y] < in[y]){
                in[y] = in[x] + t[y];
                lst[cl++] = y;
            }
        }
    }
    double ans  = 0;
    for (int i = 1; i <= n; ++i){
        int t1 = v[i] - in[i];
        int t2 = v[i] - in[i+1];
        if (t1 + t2 <= t[i]){
            ans += (in[i] + v[i]) / 2.0 * t1 + (in[i+1] + v[i]) / 2.0 * t2 + (t[i] - t1 - t2) * v[i];
        }
        else {
            double t1 = (in[i+1] - in[i] + t[i]) / 2.0;
            double t2 = (t[i] - in[i+1] + in[i]) / 2.0;
            ans += in[i] * t1 + 0.5 * t1 * t1 + in[i+1] * t2 + 0.5 * t2 * t2;
        }
    }
    printf("%0.15lf\n", ans);
}

Measured memory_bytes: 128
# 解法 全探索をする，上から読んでる冊数をi,jとしてKを超えない範囲で最大のものを週つ力すれば良い
# 全探索だったらだめだったN^2になるから
# まずAを最大限選ぶ，次にその時選べる最大のBを選ぶ
N,M,K = map(int,input().split())

A = list(map(int,input().split()))
B = list(map(int,input().split()))
# 累積和
suma = 0
sumb = 0

As = [0]*N
for i,a in enumerate(A):
    suma += A[i]
    As[i] = suma

Bs = [0]*M
for i,b in enumerate(B):
    sumb += B[i]
    Bs[i] = sumb
sum_time=0
max_count = 0
count = 0
# i,jは実際に読んでいる数とする
import bisect
for i in range(N+1):
    count = 0
    if i ==0:
        sum_time=0
    else:
        sum_time=As[i-1]
        count += i
    if sum_time>K:
        continue
    ind = bisect.bisect_right(Bs,K-sum_time)
    count += ind
    max_count = max(max_count,count)

print(max_count)

Measured memory_bytes: 48944
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}


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

	if (n % 2 == 0) {
		if (k <= n / 2) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	else {
		if (k <= (n+1) / 2) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}

	return 0;
	
}




Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

char in[1<<21];
char const*o;

inline void init_in() { 
  o = in;
  in[fread(in,1,sizeof(in)-4,stdin)] = 0;
}

int readInt(){ 
  unsigned u = 0, s = 0;
  while(*o && *o <= 32){
    ++o;
  }
   
  while(*o>='0' && *o<='9'){
    u = (u<<3) + (u << 1) + (*o++ - '0');
  }

  return static_cast<int>((u^s)) ;
}

int cnt[202020];
template<typename T> void fastout(T &n) {
  T N = n, rev, count = 0;
  rev = N;
  if (N == 0) {
    putchar_unlocked('0');
    putchar_unlocked('\n');
    return;
  }
  while ((rev % 10) == 0) { 
    ++count; rev /= 10;
  }
  rev = 0;
  while (N != 0) { 
    rev = (rev << 3) + (rev << 1) + N % 10;
    N /= 10;
  }
  while (rev != 0) { 
    putchar_unlocked(rev % 10 + '0');
    rev /= 10;
  }
  while (count--) putchar_unlocked('0');
  putchar_unlocked('\n');
}
int main(){
  init_in();
  int n = readInt(); int k = readInt();
  
  for (int i = 0; i < n; ++i) {
    int x = readInt();
    ++cnt[x];
  }
  
  sort(cnt, cnt + n + 1 , greater<int>());

  n -= accumulate(cnt, cnt + k, int());

  fastout(n);

  return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>
int main(void){
char s[20];
  int count;
  int kazoe=0;
  int max=0;
  scanf("%s",&s);
  for(count=0;s[count+1]!='\0';count++){
  if(s[count]=='A'&&s[count+1]=='C'){printf("Yes");return 0;}
  }
  printf("No");
return 0;
}

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

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

int N,L;

int main() {

	cin >> N >> L;
	
	if(L<=0&&0<=L+N-1)cout << (L + L + N - 1) * N/ 2 << endl;
	else if(0<L)cout << (int)((L + 1 + L + N - 1) * (N - 1) / 2.0) << endl;
	else cout << (int)((L + L + N - 2) * (N - 1) / 2.0) << endl;
		
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string S; cin >> S;
    int N = S.size();
    vector<pair<char,int>> R;
    int i = 0;
    while(i < N) {
        char c = S[i];
        int cnt = 1;
        while(S[i+cnt] == c) cnt++;
        R.push_back(make_pair(c,cnt));
        i += cnt;
    }
    int ans = N;
    int rest_S = 0;
    REP(i,R.size()-1) {
        if(R[i].first == 'S' && R[i+1].first == 'T') {
            R[i].second += rest_S;
            int ret = min(R[i].second,R[i+1].second);
            R[i].second -= ret;
            R[i+1].second -= ret;
            rest_S = R[i].second;
            ans -= 2*ret;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4460
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;
ll N = 1000000;

bool hantei(int p){
	if (p == 1) return false;
	REP(i, 2, p) {
		if (p%i == 0) return false;
	}
	return true;
}

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr); 
	cout.setf(ios::fixed); 
	cout.precision(20);

	int n;
	cin >> n;
	for (int i = 31; i < 55555; i += 30) {
		if (hantei(i)) {
			if (i != 31) cout << " ";
			cout << i;
			n--;
		}
		if (n == 0)break;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  G[a - 1].append(b - 1)
  G[b - 1].append(a - 1)
def dfs(V, v):
  _V = [v for v in V]
  _V[v] = 1
  cnt = 0
  if sum(_V) == N:
    return 1
  else:
    for adj in G[v]:
      if _V[adj] == 0:
        cnt += dfs(_V, adj)
    return cnt
print(dfs([0] * N, 0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
using ll = long long;

int main() {
    int count = 0;
    ll x, y;
    cin >> x >> y;
    while(y >= x){
        x *= 2;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<cmath>
#include<vector>
#include<stack>
#include<map>
#include<set>
#define Run(i,l,r) for(int i=l;i<=r;i++)
#define Don(i,l,r) for(int i=l;i>=r;i--)
#define ll long long
#define ld long double
#define inf 0x3f3f3f3f
#define mk make_pair
#define fir first
#define sec second
using namespace std;
const int N=510;
int n,k;
int cal(int x,int y){
	int re=0;
	re = (x + y) %n;
	if(x&1)re+=n;
	if(re>=k)re-=n;
	return re;
}
int main(){
	scanf("%d",&k);
	if(k==1){
		puts("1\n1\n");
		return 0;
	}
	n = ((k-1)/4+1)*2;
	printf("%d\n",n);
	for(int i=0;i<n;i++,puts(""))
	for(int j=0;j<n;j++){
		int col = cal(i,j);
		cout<<col+1<<" ";
	}
	return 0;
}//by tkys_Austin;


Measured memory_bytes: 1152
#include<iostream>

int main(){
	
	int a,b,c,k=0;
	std::cin >>a>>b>>c;
	
	for (int i=a; i<=b; i++){
		
		if (c%i==0)k++; 
		
	}
	
	std::cout <<k <<"\n";
	
	return 0;
	
}

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

using namespace std;

int main() {

	double a,b;
	cin >> a >> b;

	if ((a + b) / 2 != int((a + b) / 2)) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		cout << (int)((a + b) / 2) << endl;
	}

}

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



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,K;cin>>N>>K;
  if(K==0){cout<<N*N;return 0;}
  long ans=0;
  for(long b=K+1;b<=N;b++){
    long Q=N/b;
    long x=Q*(b-K);
    long y=max(0L,N-(b*Q+K)+1);
    ans+=x+y;
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // input
    ll n;
    cin >> n;
    vector<ll> p(n);
    rep(i, n) { cin >> p[i]; }
    // output
    vector<ll> sub = p;
    sort(ALL(sub));
    int cnt = 0;
    rep(i, sub.size()){
        if (sub[i] != p[i]) {
            cnt++;
        }
    }
    if (cnt <= 2) {
        puts("YES");
    } else {
        puts("NO");
    }
    return 0;
}

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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

// ========================================================================= //

const int N = 200179;
int n, a[N];

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

    ll ans = 0;
    int i = n - 1;
    while (i >= 0) {
        if (a[i] > i) {
            cout << "-1\n";
            return 0;
        }
        ans += a[i];
        while (i > 0 && a[i - 1] == a[i] - 1)
            --i;
        if (i > 0 && a[i - 1] < a[i]) {
            cout << "-1\n";
            return 0;
        }
        --i;
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 1024
use strict;
use warnings;
package Dsu;
sub new{
	return bless[(-1)x$_[1]],$_[0];
}
sub merge{
	my$self=shift;
	my$x=$self->leader($_[0]);
	my$y=$self->leader($_[1]);
	return$x if$x==$y;
	($x,$y)=($y,$x)if-$self->[$x]<-$self->[$y];
	$self->[$x]+=$self->[$y];
	return$self->[$y]=$x;
}
sub same{
	my$self=shift;
	return$self->leader($_[0])==$self->leader($_[1]);
}
sub leader{
	my$self=shift;
	my$a=shift;
	return$a if$self->[$a]<0;
	return$self->[$a]=$self->leader($self->[$a]);
}
sub size{
	return-$_[0]->[$_[1]];
}
sub groups{
	#TODO
}
package main;
my($N,$Q)=split$",<>;
my$dsu=Dsu->new($N);
for(1..$Q){
	my($t,$u,$v)=split$",<>;
	if($t==0){
		$dsu->merge($u,$v);
	}
	else{
		print $dsu->same($u,$v)?1:0,$/;
	}
}


Measured memory_bytes: 15388
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

typedef long long ll;

const int MAXN = 200000;

ll a[26], b[26], c[150][26], d[150];

char S[MAXN + 5]; int f[MAXN + 5];
int main() {
	int n, m; ll l, r;
	scanf("%s%lld%lld", S + 1, &l, &r);
	n = strlen(S + 1), m = n / 2;
	
	f[0] = -1, f[1] = 0;
	for(int i=2;i<=m;i++) {
		int j = f[i - 1];
		while( j != -1 && S[i] != S[j + 1] )
			j = f[j];
		f[i] = j + 1;
	}
	
	int p = m - f[m];
	if( f[m] && m % (m - f[m]) == 0 ) {
		ll q1 = r / p, r1 = r % p, q2 = (l - 1) / p, r2 = (l - 1) % p;
		for(int i=1;i<=p;i++) b[S[i] - 'a']++;
		for(int i=0;i<26;i++) a[i] += q1 * b[i];
		for(int i=1;i<=r1;i++) a[S[i] - 'a']++;
		for(int i=0;i<26;i++) a[i] -= q2 * b[i];
		for(int i=1;i<=r2;i++) a[S[i] - 'a']--;
	}
	else {
		for(int i=1;i<=p;i++) c[0][S[i] - 'a']++;
		for(int i=1;i<=m;i++) c[1][S[i] - 'a']++;
		int k; d[0] = p, d[1] = m;
		for(k=1;d[k]<=r;k++) {
			for(int j=0;j<26;j++)
				c[k + 1][j] = c[k][j] + c[k - 1][j];
			d[k + 1] = d[k] + d[k - 1];
		}
		
		ll t = r;
		for(int i=k;i>=0;i--) {
			if( t >= d[i] ) {
				for(int j=0;j<26;j++)
					a[j] += c[i][j];
				t -= d[i];
			}
		}
		for(int i=1;i<=t;i++)
			a[S[i] - 'a']++;
		
		t = l - 1;
		for(int i=k;i>=0;i--) {
			if( t >= d[i] ) {
				for(int j=0;j<26;j++)
					a[j] -= c[i][j];
				t -= d[i];
			}
		}
		for(int i=1;i<=t;i++)
			a[S[i] - 'a']--;
	}
	
	for(int i=0;i<26;i++) printf("%lld ", a[i]);
}

Measured memory_bytes: 2244
#include <stdio.h>

int main()
{
	int input;

	scanf("%d", &input);

	bool YYMM = false;
	bool MMYY = false;

	if (input % 100 >= 1 && input % 100 <= 12) YYMM = true;
	if (input / 100 >= 1 && input / 100 <= 12) MMYY = true;

	if (YYMM && MMYY) printf("AMBIGUOUS\n");
	else if (YYMM) printf("YYMM\n");
	else if (MMYY) printf("MMYY\n");
	else printf("NA\n");

	return 0;
}

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

int main(){
 
  int N, D;
  cin >> N >> D;
  
  if (N % (2 * D + 1) == 0){
    cout << N / (2 * D + 1);
  }else{
    cout << N / (2 * D + 1) + 1;
  }
  return 0;
}


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

using namespace std;

int main()
{
    long long a,b,c,d;
    scanf("%lld%lld",&a,&b);
    c=a>b?a:b,d=a>b?b:a;
    if((c-d)%2==0) printf("%lld\n",(c+d)/2);
    else printf("IMPOSSIBLE\n");
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
	static void Main()
	{
		var source = Console.ReadLine();
		var destination = Console.ReadLine();

		var sourceTable = new Dictionary<char, char>();
		var destinationTable = new Dictionary<char, char>();

		var isDifference = false;
		for (var i = 0; i < source.Length && !isDifference; ++i) {
			var sourceCharactor = source[i];
			var destinationCharactor = destination[i];
			if (sourceTable.ContainsKey(sourceCharactor)) {
				if (sourceTable[sourceCharactor] != destinationCharactor) {
					isDifference = true;
				}
			}
			
			if (destinationTable.ContainsKey(destinationCharactor)) {
				if (destinationTable[destinationCharactor] != sourceCharactor) {
					isDifference = true;
				}
			}

			sourceTable[sourceCharactor] = destinationCharactor;
			destinationTable[destinationCharactor] = sourceCharactor;
		}

		Console.WriteLine(isDifference ? "No" : "Yes");
	}
}

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

const int MAXN = 105;

int a[MAXN], n;

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int ans = 0;
	for (int i = 1; i <= n; ) {
		int j = i;
		while (j+1 <= n && a[j+1] == a[i]) j++;
		ans += (j-i+1)/2;
		i = j+1;
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    string S;

    cin >> S;

    S[3] = '8';

    cout << S << endl;

    return 0;
}

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

int main(void)
{
	int a, b, sum;
	cin >> a >> b;
	sum = a + b;

	if (a % 3 == 0 || b % 3 == 0 || sum % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}

	

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF  numeric_limits<int_fast64_t>::max();
#define intf int_fast64_t
int main(){
    intf n,cnt=0;
    cin >>n;
    vector<intf> a(n),b(n);
    for(auto &e:a) cin >>e;
    for(auto &f:b) cin >>f;
    // sort(a.begin(),a.end());
    // sort(b.begin(),b.end());

    rep(i,n){
        if(a[i]>b[i]){
            cnt -= (a[i]-b[i]);
           // cout << cnt <<"\t"<<a[i]<<"\t"<<b[i]<<endl;
        }else{
            cnt += ((b[i]-a[i])/2);
            //cout << cnt <<"\t"<<a[i]<<"\t"<<b[i]<<endl;
        }
    }

    if(cnt>=0){
        cout << "Yes" <<endl;
        //cout << cnt <<endl;
    }else{
        cout << "No"<<endl;
    }

}

Measured memory_bytes: 384
/* - - - - - - - - - - - - - - -
	User : 		VanishD
	problem :
	Points : 	
- - - - - - - - - - - - - - - */
# include <bits/stdc++.h>
# define 	ll 		long long
using namespace std;
const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
int read(){
	int tmp = 0, fh = 1; char ch = getchar();
	while (ch < '0' || ch > '9'){ if (ch == '-') fh = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9'){ tmp = tmp * 10 + ch - '0'; ch = getchar(); }
	return tmp * fh;
}
const int N = 110;
char s[N], t[N];
bool cmp(char x, char y){
	return x > y;
}
int main(){
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	scanf("\n%s\n%s", s + 1, t + 1);
	int la = strlen(s + 1), lb = strlen(t + 1);
	sort(s + 1, s + la + 1);
	sort(t + 1, t + lb + 1, cmp); 
	for (int i = 1; i <= min(la, lb); i++){
		if (s[i] < t[i]){
			printf("Yes\n");
			return 0;
		}
		if (s[i] > t[i]){
			printf("No\n");
			return 0;
		}
	}
	if (la >= lb)
		printf("No\n");
		else printf("Yes\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define vll vector<ll>
ll power(ll a, ll b, ll mod){ ll c = 1; while(b>0){ if(b%2) c*=a, c%=mod; b/=2; a*=a; a%=mod; } return c; }
#define MAX 1000000007
int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   ll n;
   cin>>n;ll ans=0;
   for(ll i=1;i*i<=n;i++)
   {
       if(n%i==0)
       {
           if((i)<(n/i -1))
           { ans+=n/i-1;}
       }
   }
   cout<<ans;   
}

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

int main() {

    int N,max=0;
    long long count=0;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++)cin>>A[i];

    for(int i=0;i<N;i++){
        if(max<A[i]){
            max=A[i];
        }
        else {
            count+=max-A[i];
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 4032
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);

  vector<int> A(n);

  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    A[i] = a;
  }

  unordered_set<int> set;
  for (int i = 0; i < n; i++) {
    set.insert(A[i]);
  }

  cout << ((A.size() == set.size()) ? "YES" : "NO") << endl;
  
  return 0;
}


Measured memory_bytes: 9288
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			if(a == 0 && b == 0){
				break;
			}
			
			if(a < b){
				int tmp = a;
				a = b;
				b = tmp;
			}
			
			int count = 0;
			
			while(b != 0){
				a = a % b;
				
				int tmp = a;
				a = b;
				b = tmp;
				count++;
			}
			
			System.out.println(a + " " + count);
		}
	}
}



Measured memory_bytes: 33500
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;cin>>a>>b;
int ans=0;
for(int i=0;i<2;i++){
  if(a>b) {
      ans+=a;
      a--;
  }
  else{
      ans+=b;
      b--;
  }
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import deque
n, m = map(int, input().split())
A = deque([int(input()) for _ in range(m)])
memo = [1, 2] + [0] * (n - 2)
if len(A) > 0:
    if A[0] == 1:
        memo[0] = 0
        memo[1] = 1
        A.popleft()
if len(A) > 0:
    if A[0] == 2:
        memo[1] = 0
        A.popleft()
for i in range(2, n):
    if len(A) > 0:
        if A[0] == i + 1:
            A.popleft()
        else:
            memo[i] = (memo[i - 1] + memo[i - 2]) % 1000000007
    else:
        memo[i] = (memo[i - 1] + memo[i - 2]) % 1000000007
print(memo[n-1])

Measured memory_bytes: 8832
<?php
// 問題URL
// https://atcoder.jp/contests/abc043/tasks/abc043_b
$n = fgets(STDIN);

$a = str_split($n);
$b = array();

for ($i = 0; $i < count($a); $i++) {
	if ($a[$i] == 'B') {
		if (count($b) > 0) {
			array_splice($b, count($b) - 1, 1);
		}
	} else {
		$b[] = $a[$i];
	}
}
$out = implode($b);

print $out;

Measured memory_bytes: 3828
using System;
namespace atcorderpractice
{
    class Mainclass
    {
        public static void Main(string[] args)
        {

            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int[] x = new int[n];
            int ans = 0;
            int min = 1000000;
            for (int i = 0; i < n; i++)
            {
                x[i] = int.Parse(input[i]);
            }

            for (int p = 1; p <= 1000; p++)
            {
                for (int i = 0; i < n; i++)
                {
                    ans += (x[i] - p) * (x[i] - p);

                    if (ans >= min)
                    {
                        break;
                    }
                }

                if (ans <= min)
                {
                    min = ans;
                }
                ans = 0;
            }

            Console.WriteLine(min);

        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <cxxabi.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()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

char *demangle(const char *demangle)
{
    int status;
    return abi::__cxa_demangle(demangle, 0, 0, &status);
}

int main()
{
    int N;
    string S;
    cin >> N;
    vector<int> vec(N);
    int s = 0,t=0;
    rep(i, N)
    {
        cin >> vec[i];
        
    }

    rep(i,N){
        s += vec[i];
        t += vec[i] * vec[i];
    }

    s *= s;
    cout << (s - t) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long[] a = new long[5];
        for(int i = 0 ; i < 5 ; i++){
            a[i] = sc.nextLong();
            if(i != 0){
                a[0] = Math.min(a[0] , a[i]);
            }
        }
        long yono = n / a[0];
        if(n % a[0] != 0) yono++;
        System.out.println(yono + 4);
    }
}

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

struct RMQ{
	int n;
	vector<long long> rangeGcd;
	RMQ(const vector<long long>& array){
		n=array.size();
		rangeGcd.resize(4*n);
		init(array,1,0,n-1);
	}
	long long init(const vector<long long>& array,int node, int left, int right){
		if(left==right)	return rangeGcd[node]=array[left];
		int mid = (left+right)/2;
		return rangeGcd[node]=__gcd(init(array,2*node,left,mid),init(array,2*node+1,mid+1,right));
	}
	long long update(int index,int newValue,int node, int nodeLeft, int nodeRight){
		if(index<nodeLeft || nodeRight<index)	return rangeGcd[node];
		if(nodeLeft == nodeRight)	return rangeGcd[node]=newValue;
		int mid = (nodeLeft + nodeRight) / 2;
        return rangeGcd[node] = __gcd(update(index, newValue, node*2, nodeLeft, mid),
                update(index, newValue, node*2+1, mid+1, nodeRight));
	}
	long long update(int index, int newValue) { return update(index, newValue, 1, 0, n-1); }
	long long query(int left, int right, int node, int nodeLeft, int nodeRight) {
        if(right < nodeLeft || nodeRight < left) return 0;
        if(left <= nodeLeft && nodeRight <= right) return rangeGcd[node];
        int mid = (nodeLeft + nodeRight) / 2;
        return __gcd(query(left, right, node*2, nodeLeft, mid),
                   query(left, right, node*2+1, mid+1, nodeRight));
    }
    long long query(int left, int right){
    	return query(left,right,1,0,n-1);
    }
};

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	vector<long long> arr(n);
	for (int i = 0 ; i<n;i++)	cin>>arr[i];
	RMQ seg(arr);
	long long m = -1;
	for (int i = 1;i<n-1;i++)
		m = max(m,__gcd(seg.query(0,i-1),seg.query(i+1,n-1)));
	m = max(m,seg.query(1,n-1));
	m = max(m,seg.query(0,n-2));
	cout<<m;
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


ll n, m, q, ans = INF;
vector<ll> s, list;
int main() {
	cin >> n >> m >> q;
	REP(i, n) {
		ll a;
		cin >> a;
		s.push_back(a);
		list.push_back(a);
	}
	s.push_back(MINF);
	REP(i, n) {
		ll lev = list[i], st = -1, now = 0;
		vector<ll> v;
		REP(j, n + 1) {
			if (s[j] >= lev) {
				if (st == -1) st = j;
				now++;
			}
			else {
				if (now >= m) {
					vector<ll> ss;
					FOR(k, st, j) ss.push_back(s[k]);
					sort(ALL(ss));
					REP(k, now - m + 1)v.push_back(ss[k]);
				}
				now = 0;
				st = -1;
			}
		}
		sort(ALL(v));
		if (v.size() >= q) ans = min(ans, v[q - 1] - lev);
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner scanner=new Scanner(System.in);
        int N=scanner.nextInt();
        int ints[]=new int[N];
        for(int i=0;i<N;i++){
            ints[i]=scanner.nextInt();
        }
        Arrays.sort(ints);
        int max=ints[N-1];
        double lenToMid[] = new double[N-1];
        for(int i=0;i<N-1;i++){
            lenToMid[i]=Math.abs(ints[i]-max/2.0);
        }
        double minLenToMid=Double.MAX_VALUE;
        for(int i=0;i<N-1;i++){
            if(minLenToMid>lenToMid[i])minLenToMid=lenToMid[i];
        }
        for(int i=0;i<N-1;i++){
            if(minLenToMid==lenToMid[i]){
                System.out.println(max+" "+ints[i]);
                return ;
            }
        }
    }
}


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

int main (){
  string s,s1,s2;
  int n;
  cin>>n>>s;
  s1=s.substr(0,n/2);
  s2=s.substr(n/2,n/2);
  if(s1==s2&&n%2==0)
cout<<"Yes";
  else
    cout<<"No";
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*; 
class Main 
{
public static void main(String args[]) 
{
Scanner sc = new Scanner(System.in); 
int n = sc.nextInt(); 
int k = sc.nextInt(); 
int arr[] = new int[n]; 
  
for(int i=0;i<n;i++) 
{
arr[i]=sc.nextInt();
} 
Arrays.sort(arr); 
int sum=0; 
for(int i=0;i<k;i++) 
{
   sum=sum+arr[i];
} 
System.out.print(sum);
  
}  
}  

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

const double rad = 180 / M_PI;

int main() {
    cout<< fixed << setprecision(100);
    double a, b, x;
    cin >> a >> b >> x;
    x /= a;
    if (x < a * b / 2) {
        double p = x * 2 / b;
        cout << atan(b / p) * rad << endl;
    } else {
        x = a * b - x;
        double p = x * 2 / a;
        cout << atan(p / a) * rad << endl;
    }
}


Measured memory_bytes: 512
N = int(input())
Ss=[input() for s in range(N)]
inside_count = [s.count("AB") for s in Ss]
start_count = len([s for s in Ss if s[0]=="B" and s[-1]!="A"])
end_count = len([s for s in Ss if s[-1]=="A" and s[0]!="B"])
multi_count = len([s for s in Ss if s[0]=="B" and s[-1]=="A"])
if end_count==0 and start_count==0:
    if multi_count<=0:
        print(sum(inside_count))
    else:
        print(sum(inside_count)+multi_count-1)
else:
    print(sum(inside_count)+min(start_count,end_count)+multi_count)

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

struct data{
    int i, u, a, p;
    data(int _i, int _u, int _a, int _p) : i(_i), u(_u), a(_a), p(_p) {}
    bool operator<(const data other) const{
        if(a != other.a)      return a > other.a;
        else if(p != other.p) return p < other.p;
        else                  return i < other.i;               
    }
};

int main(){
    int n;
    while(cin >> n, n){
        int i, u, a, p;
        vector<data> v;
        
        for(int t = 0; t < n; t++){
            cin >> i >> u >> a >> p;
            v.push_back(data(i,u,a,p));
        }
        
        sort(v.begin(), v.end());
        
        int uni[1001] = {};
        int passed = 0;

        for(data x : v){
            bool rulea = passed < 10 && uni[x.u] < 3;
            bool ruleb = passed < 20 && uni[x.u] < 2;
            bool rulec = passed < 26 && uni[x.u] < 1;
            if(rulea || ruleb || rulec){
                cout << x.i << endl;
                uni[x.u]++;
                passed++;
            }
        }

    }
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define N 3005

using namespace std;

const int mod = 998244353;

int n, S;
int a[N], f[N];

inline int read() {
	int x = 0; bool neg = false; char ch = getchar();
	while(!isdigit(ch)) (ch == '-') && (neg = true), ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return neg ? -x : x;
}

int main() {
	scanf("%d %d", &n, &S);
	for(int i = 1; i <= n; ++i)
		a[i] = read();
	
	int ans = 0;
	for(int i = 1; i <= n; ++i) {
		if(a[i] > S) continue;
		else if(a[i] == S) {
			ans = (ans + 1LL * i * (n - i + 1)) % mod;
		} else {
			ans = (ans + 1LL * f[S - a[i]] * (n - i + 1)) % mod;
			for(int j = S; j > a[i]; --j)
				(f[j] += f[j - a[i]]) %= mod;
			f[a[i]] = (f[a[i]] + i) % mod;
		}
	}
	
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256