akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

signed main(){
    int n,m; cin >> n >> m;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int sum=accumulate(all(a),0);
    double std=(double)sum/(double)4/(double)m;
    int cnt=0;
    rep(i,n){
        if(a[i]>=std) cnt++;
    }
    if(cnt>=m) cout<< "Yes"<<endl;
    else cout<< "No"<<endl;
}

Measured memory_bytes: 764
#include<iostream>  
#include<cstdio>
#include<stdio.h>
#include<cstring>  
#include<cstdio>  
#include<climits>  
#include<cmath> 
#include<vector>
#include <bitset>
#include<algorithm>  
#include <queue>
#include<map>
using namespace std;
int a, b;
int main() {
	cin >> a >> b;
	if (a == 1)
	{
		a = 15;
	}
	if (b == 1)
	{
		b = 15;
	}
	if (a == b)
	{
		cout << "Draw" << endl;
	}
	else if (a < b)
	{
		cout << "Bob" << endl;
	}
	else
	{
		cout << "Alice" << endl;

	}
}

Measured memory_bytes: 256
from itertools import combinations
import math
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for v in combinations(range(N), 2):
  a = sum([(i - j) ** 2 for i, j in zip(X[v[0]], X[v[1]])])
  if math.ceil(a ** 0.5) == a ** 0.5:
    ans += 1
    
print(ans)

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

int main() {
  int N,ans=0;
  cin >> N;

  if(N%10==7){
    ans=1;
  }
  if(N/10%10==7){
    ans=1;
  }
  if(N/100==7){
    ans=1;
  }
  if(ans==1) {
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3620
from collections import deque
from itertools import product


def bfs(x, y):
    dist = [[10 ** 9] * w for _ in range(h)]
    dist[y][x] = 0
    que = deque([(x, y)])
    near = product(range(-2, 3), repeat=2)

    while len(que) > 0:
        x, y = que.popleft()
        if (x, y) == (Dw - 1, Dh - 1):
            return dist[y][x]

        for dx, dy in product(range(-2, 3), repeat=2):
            cnt = (abs(dx) + abs(dy) >= 2)
            i, j = x + dx, y + dy
            if (0 <= i < w and 0 <= j < h and
                    dist[j][i] > dist[y][x] + cnt and s[j][i] == '.'):
                dist[j][i] = dist[y][x] + cnt
                if cnt == 0:
                    que.appendleft((i, j))
                elif cnt == 1:
                    que.append((i, j))
    else:
        return -1


h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
s = [input() for _ in range(h)]

print(bfs(Cw - 1, Ch - 1))


Measured memory_bytes: 97260
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int y,m,d;
   char c1,c2;
   cin >> y >> c1 >> m >> c2 >> d;
   cout << (m <= 4? "Heisei" : "TBD") << endl;


   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <numeric>
typedef long long int ll;
using namespace std;
int main(){ 
	ll N,M,a,ans=0,ans1=0;
	string s;
	cin>>N>>M;
	vector<ll> p(N,0);
	vector<ll> S(N,0);
	for(ll i=0;i<M;i++){
		cin>>a>>s;
		if(S[a-1]==0){
			if(s=="AC"){
				S[a-1]=1;
				ans++;
				ans1=ans1+p[a-1];
			}else{
				p[a-1]++;
			}
		}
	}
	cout<<ans<<" "<<ans1<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int a,b;
		Scanner in=new Scanner(System.in);
		a=in.nextInt();
		b=in.nextInt();
		if(a+b>=10) System.out.println("error");
		else System.out.println(a+b);
   
	}

}


Measured memory_bytes: 20820
#include<bits/stdc++.h>
using namespace std;
template <typename T> T Abs(T num){return num<0?-num:num;}
template <typename T> T Min(T x,T y){return x<y?x:y;}
typedef long long ll;
ll X,K,D,t1,t2,d1,d2,res;
int main()
{
	cin>>X>>K>>D;
	X=Abs(X);
	t1=X/(D+D);
	t2=t1+1;
	if(t1+t1>K)
	{
		cout<<X-K*D<<endl;
		return 0;
	}
	d1=X-t1*(D+D);
	d2=X-t2*(D+D);
	if(t2+t2>K) res=d1;
	else res=Abs(d1)<Abs(d2)?d1:d2; 
	if(K%2==1) cout<<Min(Abs(res+D),Abs(res-D))<<endl;
	else cout<<Abs(res)<<endl;
	return 0;
}

Measured memory_bytes: 3592
import copy
N, M = map(int, input().split())
LR = []
LR2 = []
count = 0
min = 1
max = N
for i in range(M):
    l, r = map(int, input().split())
    LR2.append(l)
    LR2.append(r)
    LR3 = copy.copy(LR2)
    LR.append(LR3)
    LR2.clear()
#print(M, N, LR)

for i in LR:
    if min < i[0]:
        min = i[0]
    if max > i[1]:
        max = i[1]
    #print(min, max)
if max - min >= 0:
    ans = max - min + 1
else:
    ans = 0
print(ans)



Measured memory_bytes: 21652
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;//ハッシュテーブル用
using System.Linq;

class Program
{
    //Hashtable ht = new Hashtable();
    static List<int> s = new List<int>();
    static List<int>[] sl;
    static decimal result;
    static int N,K;
    //StringBuilder strresult= new StringBuilder("");//Append(str ○○)関数で文字を追加していく



    static void Main()
    {
        //Modular mo = new Modular(0);//素数で割った余りを出せで使う。()内が初期値。★使い方：Modular型で宣言すると、その時点でのその素数で割った余りを保持する変数になる（powべき乗、Fac累乗、nCr組み合わせも関数として存在）
        //Node<> no = new Node<>();//UnionFind★Find関数で根っこの値を返す（根っこの値が一緒なら同グループ）、Unite関数で二つの木をくっつける
        //Permutation<> pe = new Permutation<>();//配列＆リストを並べ替えた場合の全ケースを出力★All関数でリスト形式で返す。
        //Treap<> tr = new Treap<>();//平衡二分木★Insert()関数で挿入、FindIndex()関数で該当する大きさの物が入るべき配列番号を返す。
        PriorityQueue<int,int> pr = new PriorityQueue<int,int>();//優先度付キュー★Add(key,value)で格納、Dequeue()で取りだし。keyが小さいものから取り出す。
Read1();
      Read2();
for(int i=0;i<N;i++){pr.Add(s[i],i);}
        
for(int i=0;i<N;i++){
  result=pr.Dequeue().Value;result++;
        Console.WriteLine(result.ToString());
}
    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }

    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
        N = int.Parse(tmp[0]);
        K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {
        sl = new List<int>[N];
        for (int i = 0; i < N; i++) {
            sl[i] = new List<int>();
            string[] tmp = Console.ReadLine().Split(' ');
            for (int j = 0; j < K; j++) {
                sl[i].Add(int.Parse(tmp[j]));
            }
        }

    }
}



class PriorityQueue<TKey, TValue>
{
    SortedDictionary<TKey, Queue<TValue>> dict = new SortedDictionary<TKey, Queue<TValue>>();
    int count = 0;

    public int Count
    {
        get
        {
            return count;
        }
    }

    public void Add(TKey key, TValue value)
    {
        if (!dict.ContainsKey(key))
        {
            dict[key] = new Queue<TValue>();
        }

        dict[key].Enqueue(value);
        count++;
    }

    public KeyValuePair<TKey, TValue> Dequeue()
    {
        var queue = dict.First();
        if (queue.Value.Count <= 1)
        {
            dict.Remove(queue.Key);
        }
        count--;
        return new KeyValuePair<TKey, TValue>(queue.Key, queue.Value.Dequeue());
    }
}

Measured memory_bytes: 38708
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int V, Mod;
	List<int>[] es;
	int[] par;
	long[] dp0, dp1;
	void Solve()
	{
		var I = G;
		V = I[0];
		Mod = I[1];
		es = new List<int>[V];
		par = new int[V];
		dp0 = new long[V];
		dp1 = new long[V];
		for (var u = 0; u < V; u++) es[u] = new List<int>();
		for (var e = 0; e < V - 1; e++)
		{
			I = G;
			es[I[0] - 1].Add(I[1] - 1);
			es[I[1] - 1].Add(I[0] - 1);
		}
		DFS1(0, -1);
		DFS2(0);
		DFS3(0);
		for (var u = 0; u < V; u++) WriteLine(dp0[u] * (dp1[u] + 1) % Mod);
	}
	long DFS2(int u)
	{
		dp0[u] = 1L;
		foreach (var v in es[u]) dp0[u] = dp0[u] * (DFS2(v) + 1) % Mod;
		return dp0[u];
	}
	void DFS3(int u)
	{
		var W = es[u].Count;
		var x = new long[W + 1];
		var y = new long[W + 1];
		x[0] = y[W] = 1;
		for (var i = 0; i < W; i++) x[i + 1] = x[i] * (dp0[es[u][i]] + 1) % Mod;
		for (var i = W - 1; i >= 0; i--) y[i] = y[i + 1] * (dp0[es[u][i]] + 1) % Mod;
		for (var i = 0; i < W; i++) dp1[es[u][i]] = (dp1[u] + 1) * x[i] % Mod * y[i + 1] % Mod;
		x = y = null;
		foreach (var v in es[u]) DFS3(v);
	}
	void DFS1(int u, int p)
	{
		par[u] = p;
		es[u].Remove(p);
		foreach (var v in es[u]) DFS1(v, u);
	}
}


Measured memory_bytes: 41460
def main():
  import math
  N = int(input())
  gcd={}
  ans=0
  for i in range(1,N+1):
    for j in range(1, N+1):
      key=i*N+j
      gcd[key]=math.gcd(i,j)
  
  for k, i in gcd.items():
    for j in range(1, N+1):
      key=j*N+i
      ans+=gcd[key]
        
  print(ans)

if __name__=='__main__':
  main()


Measured memory_bytes: 11668
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
using namespace std;

int main(){
  string s;
  cin >> s;

  int index = 0;
  int count = 0;
  while (index < s.length() - 1 && s.length() > 0){
    if (s[index] != s[index + 1]){
      count += 2;
      s.erase(index, 2);
      index = max(0, index - 1);
    }
    else{
      index++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 512
import java.io.*;
import java.util.*;
 
public class Main {
 
	void submit() {
	    String S = nextString();
	    char[] C = S.toCharArray();
	    if((C[2]==C[3]) && (C[4]==C[5])){
            out.println("Yes");	        
	    }else{
            out.println("No");	        
	    }
	}

	void preCalc() {
 
	}
 
	void stress() {
 
	}
 
	void test() {
 
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}
 
	static final Random rng = new Random();
 
	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

long long int myc(long long int a, long long int b) {
    if (b == 0) return 1;
    if (b == 1) return a;
    if (a <= b) return 1;
    return myc(a - 1, b) + myc(a - 1, b - 1);
}

int main() {
    int n, p;
    cin >> n >> p;
    int one = 0, zero = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a % 2 == 1) {
            one++;
        } else {
            zero++;
        }
    }
    long long int res = 0;
    for (int i = 0; i <= one; i += 2) {
        res += myc(one, i) * ((long long int)1 << zero);
    }
    if (p == 1) {
        res = ((long long int)1 << n) - res;
    }
    cout << res << endl;
}


Measured memory_bytes: 3608
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef vector<int>vi;
typedef vector<vi>vii;
void debug(const vi &V){
    for(int i=0;i<V.size();i++)cout<<V[i]<<" ";cout<<endl;
}
int main(){
    int n,k,m;
    while(cin>>n>>k>>m,n||k||m){
        vector<int>V(n);
        rep(i,n)V[i]=i;
        int pos=m-1;
        while(V.size()>1){
            V.erase(V.begin()+pos);
            pos=(pos+k-1)%V.size();
            //debug(V);
        }
        cout<<V[0]+1<<endl;

    }
    return 0;
}

Measured memory_bytes: 1252
n = int(input())
t, a = map(int, input().split())
t *= 1000
a *= 1000
lst = list(map(int, input().split()))
tmp = abs(t - 6 * lst[0] - a)
tmpa = 0
for i in range(1, n):
    temp = abs(t - 6 * lst[i] - a)
    if temp < tmp:
        tmp = temp
        tmpa = i
print(tmpa + 1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define ar array
#define pb push_back


int main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("outputc.txt","w",stdout);
	// #endif
	
	//int t;
	//cin>>t;
	//while(t--)
	{
		int n,w;
		cin>>n>>w;
		ll a[n][2];
		for(int i=0;i<n;i++)
		{
			cin>>a[i][0]>>a[i][1];
		}
		ll dp[w+1];
		memset(dp,0,sizeof(dp));
		//for(int i=0;i<n;i++)
		//{
			//dp[0][a[i][0]]=a[i][1];
		//}
		for(int i=0;i<n;i++)
		{
			for(int j=w;j>=0;j--)
			{
				if(j-a[i][0]>=0)
				{
					dp[j]=max(dp[j],dp[j-a[i][0]]+a[i][1]);
				}
			}
		}
		ll ans=0;
		//for(int i=0;i<n;i++)
		{
			for(int j=0;j<=w;j++)
			{
				ans=max(ans,dp[j]);
			}
		}
		cout<<ans<<'\n';
	}
		
}


Measured memory_bytes: 4408
#include<iostream>
#include<string>
using namespace std;
int main(){
  int k[4][3];
  int n;
  int count;
  int tmp;
  string hou;
  while(1){
    count=1;
    k[0][1]=1;
    k[1][0]=4;
    k[1][1]=2;
    k[1][2]=3;
    k[2][1]=6;
    k[3][1]=5;

    cin>>n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin>>hou;
      if(hou=="North"){
	tmp=k[3][1];
	k[3][1]=k[0][1];
	k[0][1]=k[1][1];
	k[1][1]=k[2][1];
	k[2][1]=tmp;
      }
      else if(hou=="West"){
	tmp=k[1][0];
	k[1][0]=k[0][1];
	k[0][1]=k[1][2];
	k[1][2]=k[2][1];
	k[2][1]=tmp;
      }
      else if(hou=="East"){
	tmp=k[1][2];
	k[1][2]=k[0][1];
	k[0][1]=k[1][0];
	k[1][0]=k[2][1];
	k[2][1]=tmp;
      }
      else if(hou=="South"){
	tmp=k[1][1];
	k[1][1]=k[0][1];
	k[0][1]=k[3][1];
	k[3][1]=k[2][1];
	k[2][1]=tmp;
      }
      else if(hou=="Right"){
	tmp=k[1][1];
	k[1][1]=k[1][2];
	k[1][2]=k[3][1];
	k[3][1]=k[1][0];
	k[1][0]=tmp;
      }
      else if(hou=="Left"){
	tmp=k[1][1];
	k[1][1]=k[1][0];
	k[1][0]=k[3][1];
	k[3][1]=k[1][2];
	k[1][2]=tmp;
      }
      count+=k[0][1];
    }
    cout<<count<<endl;
  }
}

Measured memory_bytes: 1208
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll A, B, C;
	cin >> A >> B >> C;
	rep(i, B) {
		if ((i * A) % B == C) {
			cout << "YES" << endl; return 0;
		}
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 256
from  itertools import combinations
N=int(input())
L=list(map(int,input().split()))
A=list(combinations(L,3))
ans=0
for i in A:
    i=sorted(list(i))
    #print(i)
    if i[0]!=i[1] and i[1]!=i[2] and i[2]!=i[0] and i[2]<i[0]+i[1]:
        ans+=1
print(ans)

Measured memory_bytes: 20208
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}

auto factor(int n){
  map<int,int>res;
  for(int i=2;i*i<=n;i++){
      for(; n%i==0;n/=i) res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
////////////////////////////////////////////////////////////
  vector<vector<int>>v(100001,vector<int>(0));
void dfs(vector<int>&dis,int start){
  for(int i:v[start]){
    if(dis[i]==-1){
      dis[i]=dis[start]+1;
       dfs(dis,i);
    }
  }
}
signed main() {
  int n;
  cin>>n;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }

vector<int>dg(n,-1),ds(n,-1);
  dg[n-1]=0;
  ds[0]=0;
dfs(dg,n-1);
dfs(ds,0);

  int sunuke=0,fennec=0;
rep(i,n){
  if(dg[i]>=ds[i]) fennec++;
  else sunuke++;
}
if(sunuke>=fennec)cout<<"Snuke"<<endl;
else cout<<"Fennec"<<endl;
}


Measured memory_bytes: 14812
#include <algorithm>
#include <iostream>
#include <map>
#include <string>

using namespace std;

void check(map<long long, long long> mp) {
  cout << "-----------------------------" << endl;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    cout << it->first << "," << it->second << endl;
  }
}

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

  map<long long, long long> res;
  long long num = 0;
  long long tmp = p;
  if (p == 1) {
    res[1] = 1;
    num++;
  }
  for (long long i = 2; i * i <= p; i++) {
    while (tmp % i == 0) {
      res[i]++;
      num++;
      tmp /= i;
    }
  }
  if (tmp != 1) {
    res[tmp] = 1;
    num++;
  }
  long long ans = 1;
  for (auto it = res.begin(); it != res.end(); it++) {
    for (int i = 0; i < it->second / n; i++) {
      ans *= it->first;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	if h == 1 || w == 1 {
		fmt.Println(1)
		return
	}

	r := h * w
	if r%2 == 0 {
		fmt.Println(r / 2)
	} else {
		fmt.Println(r/2 + 1)
	}
}


Measured memory_bytes: 512
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    N = int(input())
    D = []
    for _ in range(N):
        D.append(int(input()))

    ans = 0
    pre = INF
    for d in sorted(D, reverse=True):
        if d < pre:
            ans += 1
            pre = d
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
#include <iostream>

using namespace std;

int main()
{
    string S;
    cin >> S;
    int size = S.size();
    string result;
    for(int i = 0; i < size; i++)
    {
        if(S.at(i) == '0')
            result.push_back('0');
        else if (S.at(i) == '1')
            result.push_back('1');
        else
        {
           if(!result.empty())
               result.pop_back();
        }
    }
    cout << result << endl;

}


Measured memory_bytes: 760
S = input()
T = input()

import re

regxp = '^' + S + '.'

repattern = re.compile(regxp)
result = repattern.search(T)

# print(result.group())

try:
	if result.group() == T:
		print('Yes')
	else:
		print('No')
except:
	print('No')

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

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

	ll n;
	cin >> n;

	ll	digit;
	ll	count;
	digit = 1;
	count = -1;
	while (n / digit)
	{
		digit *= 10;
		count++;
	}
	ll nine;
	nine = n / (digit / 10) - 1 + 9 * count;
	ll temp;
	temp = n;
	ll original;
	original = 0;
	while (temp)
	{
		original += temp % 10;
		temp /= 10;
	}
	cout << max({original, nine}) << endl;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	cout << a[n / 2] - a[n / 2 - 1];
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = 0;
		for(int i=0;i<n;i++)a+=sc.nextLong();
		System.out.println(a/n);
	}
}

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

// infty
#define ULLINF (ULLONG_MAX)
#define LLINF  (LLONG_MAX)
#define IINF   (INT_MAX)
#define INF    (1<<29)

// math
#define Sq(x) ((x)*(x))

// container utility
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair
#define PB push_back
#define EACH(it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();it++)

// rep
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;

typedef long long ll;

// pair util
#define FST first
#define SND second

// range validator
#define CK(n,a,b) (a<=n && n<b)

// conversion
template<class T> inline string toStr(T a) { ostringstream oss_; oss_ << a; return oss_.str(); }
inline int toInt(string s) { return atoi(s.c_str()); }

// prime
bool isPrime(int a) { for(int i=2; i*i <=a; i++) if(a%i == 0) return false; return true; }

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

//////////////////////////////////////////////////////////////


int main() {
  
  string s;
  while(cin >> s) {
    
    int const N = s.size();
    
    if(N%2) {
      cout << "NA" << endl;
      continue;
    }
    
    string output;
    
    for(int i=0; i<N; i+=2) {
      int a = s[i]-'0'-1; if(!CK(a, 0, 6)) { cout << "NA" << endl; goto EXIT; }
      int b = s[i+1]-'0'-1; if(!CK(b, 0, 5)) { cout << "NA" << endl; goto EXIT; }
      
      char ch = (char)('a' + a*5+b);
      if(!CK(ch,'a','z'+1)) {
	if(b == 1 && a == 5) ch = '.';
	else if(b == 2 && a == 5) ch = '?';
	else if(b == 3 && a == 5) ch = '!';
	else if(b == 4 && a == 5) ch = ' ';
	else { cout << "NA" << endl; goto EXIT; }
      }
      output += ch;
    }
    cout << output << endl;
    
  EXIT:;
  }
  
  return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
#include<string>
#include<cmath>
#include<tuple>
#include<algorithm>
#define INF 1111111111
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> tup;
typedef long long ll;
vector<int> vec(100100);
vector<int> passed(100100);
vector<int> dx = {-1,1};
int n,k;

int main() {
  string s,ans;
  cin >> s;
  if(s.size() == 2)
    cout << s << endl;
  else if(s.size() == 3){
    ans += s.at(2);
    ans += s.at(1);
    ans += s.at(0);
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 1024
from collections import Counter

s = input()

s = list(s)

res = float("inf")
for c in s:
	l = s[:]
	n = 0
	while 1:
		if len(set(l)) == 1:
			break
		else:
			n+=1
			for i in range(len(l)-1):
				if l[i]==c or l[i+1]==c:
					l[i] = c
			l.pop()
	res = min(res, n)

print(res)

Measured memory_bytes: 3444
#include <set>
#include <deque>
#include <algorithm>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;

#define MP make_pair
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

set<int> vsi;
int n;

inline int getx(int a){return (a>>25 & 7);}
inline int gety(int a){return (a>>28 & 7);}
inline int getidx(int x, int y){return y*n+x;}
inline int getstate(int a, int x, int y){return ((a>>getidx(x,y))&1);}
inline int setstate(int a, int x, int y, int state){
	if(state){
		return a|(1<<getidx(x,y));
	}else{
		int p=1<<getidx(x,y);
		p = ~p;
		return a&p;
	}
}
inline int setpos(int a, int x, int y){
	int ret=a;
	ret &= ((1<<25)-1);
	ret |= x<<25;
	ret |= y<<28;
	return ret;
}

inline int count(int b){
	int ret = 0;
	REP(i,n)REP(j,n)if(getstate(b,i,j))ret++;
	return ret-1;
}

inline int step(int &b){
	int tb = b;
	int ret = 0;
	int x=getx(b);
	int y=gety(b);
	REP(i,n){
		REP(j,n){
			if(y==i&&x==j)continue;
			int cnt = 0;
			REP(k,8){
				int ny=i+dy[k];
				int nx=j+dx[k];
				if(nx<0 || ny<0 || nx>=n || ny>=n)continue;
				if(getstate(tb,nx,ny))cnt++;
			}
			if(getstate(tb,j,i)){
				if(cnt!=2&&cnt!=3)b=setstate(b,j,i,0);
			}else if(!getstate(tb,j,i)){
				if(cnt==3)b=setstate(b,j,i,1);
			}
		}
	}
	return ret;
}

int main(){
	while(cin>>n, n){
		vsi.clear();
		string b;
		REP(i,n){
			string tmp;
			cin>>tmp;
			b+=tmp;
		}
		int is=0;
		REP(i,n){
			REP(j,n){
				switch(b[i*n+j]){
				case '@':
					is = setpos(is, j, i);
				case '#':
					is |= (1LL<<i*n+j);
					break;
				}
			}
		}
		queue<pair<int, int> > q;
		q.push(MP(0,is));
		int ans=-1;
		while(!q.empty()){
			int x,y;
			pair<int, int> tmp=q.front();
			q.pop();
			if(EXIST(vsi,tmp.second))continue;
			vsi.insert(tmp.second);
			if(count(tmp.second)==0){
				ans=tmp.first;
				break;
			}
			x = getx(tmp.second);
			y = gety(tmp.second);
			REP(i,8){
				int nx=x+dx[i];
				int ny=y+dy[i];
				if(nx<0 || ny<0 || nx>=n || ny>=n || getstate(tmp.second, nx, ny)==1)continue;
				int tb = tmp.second;
				tb=setstate(tb,x,y,0);
				tb=setstate(tb,nx,ny,1);
				tb=setpos(tb,nx,ny);
				step(tb);
				if(EXIST(vsi,tb))continue;
				q.push(MP(tmp.first+1, tb));
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1644
#include<stdio.h>
#include<string.h>
#include<math.h>

#define distance(a, b) (pow(pow((a), 2) + pow((b), 2), 0.5))

typedef struct {
    int x;
    int y;
} point;

point array[200000];

int main()
{
    int n, d;
    double target_distance;
    int answer = 0;

    scanf("%d %d", &n, &d);

    for (int i = 0; i<n; i++)
    {
        scanf("%d %d", &(array[i].x), &(array[i].y));
    }

    for (int i = 0; i<n; i++)
    {
        target_distance = distance(array[i].x, array[i].y);
        if (target_distance <= d)
            answer ++;
    }

    printf("%d", answer);

    return 0;
}

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

int main() {

    ll A, B;
    cin >> A >> B;

    if (A * B <= 0)
        cout << "Zero";
    else {
        if (A > 0 && B > 0)
            cout << "Positive";
        else {
            if ((B - A) % 2 == 0)
                cout << "Negative";
            else
                cout << "Positive";
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	w := map[string]string{"Sunny": "Cloudy", "Cloudy": "Rainy", "Rainy": "Sunny"}
	s := readString()
	fmt.Println(w[s])
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
using System;

namespace AtCoder
{
    class Program
    {
        static IO io = new IO();

        static void Main(string[] args)
        {
            //入力
            io.ReadSplit();
            long X = io.Long();
            long Y = io.Long();

            //計算
            string output = Winner(X, Y);

            //出力
            io.WriteLine(output);
        }
        static string Winner(long X, long Y)
        {
            if (X + Y < 2) { return "Brown"; }
            else if (Math.Abs(X - Y) < 2) { return "Brown"; }
            else { return "Alice"; }
        }
    }
    class IO
    {
        private string[] _Inputs;
        private int _Index;
        public void Read()
        {
            _Inputs = new string[1];
            _Inputs[0] = Console.ReadLine();
            _Index = 0;
        }
        public void ReadSplit()
        {
            _Inputs = Console.ReadLine().Split(' ');
            _Index = 0;
        }
        public string String()
        {
            return _Inputs[_Index++];
        }
        public string[] String(int xCount)
        {
            string[] rv = new string[xCount];
            Array.Copy(_Inputs, _Index, rv, 0, xCount);
            _Index += xCount;
            return rv;
        }
        public int Int()
        {
            return int.Parse(_Inputs[_Index++]);
        }
        public int[] Int(int xCount)
        {
            int[] rv = new int[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = int.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public long Long()
        {
            return long.Parse(_Inputs[_Index++]);
        }
        public long[] Long(int xCount)
        {
            long[] rv = new long[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = long.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public void Write(string xStr)
        {
            Console.Write(xStr);
        }
        public void WriteLine(string xStr)
        {
            Console.WriteLine(xStr);
        }
    }
}

Measured memory_bytes: 13140
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s[] = new String[n];
    String tmp = "";
    long same = 1;
    long answer =0;
    for(int i=0;i<n;i++){
      tmp = sc.next();
      char[] chars = tmp.toCharArray();
      Arrays.sort(chars);
      s[i] = String.valueOf(chars);
    }
    Arrays.sort(s);
    for(int i=0;i<n-1;i++){
      if((s[i]).equals(s[i+1])){
        same+=1;
      }else{
        answer = answer+((same*(same-1))/2);
        same=1;
      }
    }
    if(same!=1){
      answer +=((same*(same-1))/2);
    }
        System.out.println(answer);
//    for(int i=0;i<n;i++){ 
//    System.out.println(s[i]);
//    }
  }
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int a, b, c;
    string s;
    cin >> a >> b >> c;
    //cin >> s;
    cout << max(0, c + b - a) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int A, B;
  cin >> A >> B;
  if(A >=1 && A<= 9 && B >= 1 && B <=9){
    cout << A*B << endl;
  }else cout << "-1" << endl; 

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vvl v(m+1);  // v[i] : i日後に報酬がもらえるアルバイトの報酬を要素とするvector
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        if(a <= m) {
            v[a].pb(b);
        }
    }
    exrep(i, 1, m) {
        sort(rall(v[i]));
    }
    
    priority_queue<ll> prQ;
    ll ans = 0;
    for(ll x = 1; x <= m; x++) {  // a <= x の中でbが最大のものを選ぶ
        for(auto p1 : v[x]) {
            prQ.push(p1);
        }
        if(prQ.empty()) {
            continue;
        }
        auto p2 = prQ.top();
        prQ.pop();
        ans += p2;
    }

    out(ans);
    re0;
}

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

int main() {
  string s;
  cin >> s;
  vector<string> ss = {"Sunny","Cloudy","Rainy"};
  for(int i = 0; i < 3; i++){
    if(ss.at(i) == s)
      cout << ss.at((i+1)%3) << endl;
  }
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		String numberArray1 = "";  //1～n-1の数字が順に格納された数列リスト
		String numberArray2 = "";  //比較する数列リスト

		for(int i = 1; i <= n; i++) {
			numberArray1 += String.valueOf(i);
			numberArray2 += String.valueOf(sc.nextInt());
		}

		List<String> numberList = new ArrayList<String>();
		permutation(numberArray1, "", numberList);

		for(int i = 0; i < numberList.size(); i++) {
			if(numberList.get(i).equals(numberArray2)) {
				if(i != 0) display(numberList.get(i-1));
				display(numberArray2);
				if(i != numberList.size() - 1) display(numberList.get(i+1));
				break;
			}
		}
	}

	public static List<String> permutation(String s, String ans, List<String> list) {
		if(s.length() <= 1) {
			list.add(ans + s);
		}
		else {
			for(int i = 0; i < s.length(); i++) {
				permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i), list);
			}
		}

		return list;
	}

	//String型を引数としそれを空白を開けて表示するメソッド
	public static void display(String s) {
		for(int i = 0; i < s.length(); i++) {
			if(i != 0) System.out.print(" ");
			System.out.print(s.charAt(i));
		}
		System.out.println();
	}

}



Measured memory_bytes: 130600
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector <int> cost(n);
  for(int i = 0;i<n;i++)
    cin>>cost[i];
  vector<int> dp(n);
  dp[0] = 0;
  dp[1] = abs(cost[1]-cost[0]);
  int cst = 0;
  for(int i = 2;i<n;i++)
  { 
    dp[i] = min(dp[i-1]+abs(cost[i]-cost[i-1]),dp[i-2]+abs(cost[i]-cost[i-2]));
     
  }
  cout<<dp[n-1]<<'\n';
  return 0;
}
  	


Measured memory_bytes: 1024
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/6/20 20:00:35
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	int x=read(),i=1;
	while(1){
		++i;
		if(x*i%360==0) break;
	}
		printf("%d",i);
	return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      string str;
      cin >> str;
     
      if (str.size() == 1 ) {
        
        if (str.at(0) == '2' || str.at(0) == '4' || str.at(0) == '5' || str.at(0) == '7' || str.at(0) == '9' ) {
          cout << "hon" << endl;
        }
        
        else if (str.at(0) == '0' || str.at(0) == '1' || str.at(0) == '6' || str.at(0) == '8' ) {
          cout << "pon" << endl;
        }
        else if (str.at(0) == '3' ) {
          cout << "bon" << endl;
        }
      }
        
        
      else if (str.size() == 2 ) {
        
        if (str.at(1) == '2' || str.at(1) == '4' || str.at(1) == '5' || str.at(1) == '7' || str.at(1) == '9' ) {
          cout << "hon" << endl;
        }
        
        else if (str.at(1) == '0' || str.at(1) == '1' || str.at(1) == '6' || str.at(1) == '8' ) {
          cout << "pon" << endl;
        }
        else if (str.at(1) == '3' ) {
          cout << "bon" << endl;
        }
      }
       
      else if (str.size() == 3 ) {
        
        if (str.at(2) == '2' || str.at(2) == '4' || str.at(2) == '5' || str.at(2) == '7' || str.at(2) == '9' ) {
          cout << "hon" << endl;
        }
        
        else if (str.at(2) == '0' || str.at(2) == '1' || str.at(2) == '6' || str.at(2) == '8' ) {
          cout << "pon" << endl;
        }
        else if (str.at(2) == '3' ) {
          cout << "bon" << endl;
        }
      }

    }

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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int N;
vector<int> d;

signed main()
{
    cin >> N;
    d.resize(N);
    rep(i, N)
    {
        cin >> d[i];
    }

    sort(all(d));

    cout << d[N / 2] - d[N / 2 - 1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

class unionfind
{
public:
    vector<ll> parent;
    vector<ll> ranks;

    void init(ll n)
    {
        REP(i, n)
        {
            parent.push_back(i);
            ranks.push_back(0);
        }
    }

    ll find(ll x)
    {
        return parent[x] == x ? x : parent[x] = find(parent[x]);
    }

    void unite(ll x, ll y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (ranks[x] < ranks[y])
        {
            parent[x] = y;
        }
        else
        {
            parent[y] = x;
            if (ranks[x] == ranks[y])
                ranks[x]++;
        }
    }
    bool same(ll x, ll y)
    {
        return find(x) == find(y);
    }
};

int main(void)
{
    unionfind road;
    unionfind rail;

    int n, k, l;
    int p, q;
    cin >> n >> k >> l;

    road.init(n);
    rail.init(n);

    REP(i, k)
    {
        cin >> p >> q;
        p--;
        q--;
        road.unite(p, q);
    }
    REP(i, l)
    {
        cin >> p >> q;
        p--;
        q--;
        rail.unite(p, q);
    }

    map<pair<ll, ll>, ll> mp;
    REP(i, n)
    {
        mp[{road.find(i), rail.find(i)}]++;
    }
    REP(i, n)
    {
        cout << mp[{road.find(i), rail.find(i)}] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 18660
def primelist(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def factorization(n):
    plist = primelist(int(n**0.5))
    factor = []
    for p in plist:
        k = 0
        while n%p==0:
            k+=1
            n//=p
        if k>0:
            factor.append((p,k))
        if n==1:
            break
    if n!=1:
        factor.append((n,1))

    return factor

def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def main():
    n = int(input())
    
    factors = factorization(n)

    ans = 0
    for _,e in factors:
        a_e = int(((1+8*e)**0.5-1)/2)
        ans += a_e

    print(ans)


if __name__ == "__main__":
    main()

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

int n, k;
int m;
long long a[1010];
vector<long long> v;
long long ans;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> k;
	m = n * (n + 1) / 2;
	for(int i=1; i<=n; ++i) cin >> a[i];
	for(int i=1; i<=n; ++i) a[i] += a[i-1];
	for(int i=1; i<=n; ++i)
		for(int j=i; j<=n; ++j)
			v.push_back(a[j] - a[i-1]);
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for(int i=42; i>=0; --i){
		int t = 0;
		vector<long long> w;
		for(int j=0; j<v.size(); ++j)
			if((v[j] >> i) % 2 == 1){
				++t;
				w.push_back(v[j]);
			}
		if(t >= k){
			ans += (long long)1 << i;
			for(int j=0; j<w.size(); ++j)
				w[j] -= (long long)1 << i;
			v = w;
		}else{
			for(int j=0; j<v.size(); ++j)
				if((v[j] >> i) % 2 == 1)
					v[j] -= (long long)1 << i;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 6256
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
vector<int> coins;
int dp[100010];

void init_coins()
{
    coins.push_back(1);
    int k = 6;
    for (int i = 0; i < 6; i++)
    {
        coins.push_back(k);
        k *= 6;
    }
    k = 9;
    for (int i = 0; i < 5; i++)
    {
        coins.push_back(k);
        k *= 9;
    }
}

int solve(int n)
{
    if (dp[n] == -1)
    {
        if (n == 0)
        {
            dp[n] = 0;
        }
        else
        {
            int ans = INF;
            for (int i = 0; i < coins.size(); i++)
            {
                if (n - coins[i] >= 0)
                {
                    ans = min(ans, 1 + solve(n - coins[i]));
                }
            }
            dp[n] = ans;
        }
    }
    return dp[n];
}

int main()
{
    int n, x, y;
    cin >> n;
    init_coins();

    for (int i = 0; i < 100010; i++)
    {
        dp[i] = -1;
    }

    cout << solve(n) << endl;
    return 0;
}

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

int main() {
    int N; cin >> N;
    vector<pair<int,int>> v(N);
    ll cnt = 0;
    double diff = 0;
    for (int i = 0; i < N; i++) cin >> v[i].first >> v[i].second;
    sort(v.begin(), v.end());

    do{
        cnt++;
        for (int i = 1, n = v.size(); i < n; i++)
        {
            diff += sqrt((v[i-1].first-v[i].first)*(v[i-1].first-v[i].first) + (v[i-1].second-v[i].second)*(v[i-1].second-v[i].second));
        }
        
    } while(next_permutation(v.begin(), v.end())); 
    cout << setprecision(10) <<  diff/cnt << endl;
}

Measured memory_bytes: 256
while True:
    try:
        p,q=map(int,raw_input().split())
    except EOFError:
	break
    S,L=[],[]
    while True:
        L.append(p/q)
        amari=p%q
        if amari in S:
            S.append(amari)
            break
        S.append(amari)
        p=amari*10
    if S[-1]==S[-2]==0:
        print "".join(map(str,L[1:-1]))
    else:
        t=S.index(S[-1])
        s=" "*t+"^"*(len(S)-t-1)
        print "".join(map(str,L[1:]))
        print s

Measured memory_bytes: 4240
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG



//桁数の計算
bool kaibun(string S){
  ll len = S.size();
  ll loop = len / 2 - 1;
  bool ans = true;

  for (ll i = 0; i <= loop ; i++){
    if(S.at(i) != S.at(len - 1 -i)){
      ans = false;
      break;
    }
  }
  return ans;
}



int main() {
  string S;
  cin >> S;

  ll N = S.size();
  string S1 = S.substr(0,(N-1)/2);
  string S2 = S.substr((N+3)/2 - 1);
  


  if (kaibun(S) && kaibun (S1) && kaibun (S2)) {
    cout << "Yes" << endl;
    return 0; 
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3604
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

module Util =
    let strRev s =
        s
        |> Seq.rev
        |> Seq.map string
        |> String.concat ""

[<EntryPoint>]
let main _ =
    let [| A; B; K |] = reada int

    let ab = [| A; B |]
    for i in 0 .. K - 1 do
        let j = i % 2
        let k = (i + 1) % 2

        let c =
            if ab.[j] % 2 = 0 then ab.[j]
            else ab.[j] - 1

        let c = c / 2
        ab.[j] <- c
        ab.[k] <- ab.[k] + c

    printfn "%d %d" ab.[0] ab.[1]
    0 // return an integer exit code


Measured memory_bytes: 14044
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.container;
import std.bigint;
import std.math;

void main()
{
	auto s = readln.chomp.to!int;
	writeln(s/3600, ":", s%3600/60, ":", s%60);
}

Measured memory_bytes: 1072
MOD = 10 ** 9 + 7

N = int(input())

ans = pow(10, N, MOD)
ans -= 2 * pow(9, N, MOD)
ans += pow(8, N, MOD)
ans %= MOD # 最後にMODを取り忘れないように気をつけましょう

print(ans)

Measured memory_bytes: 9172