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

#define N   10000
#define NIL -1

typedef struct{
  int p, r, l;
} Node;

Node T[N];
int n, D[N], H[N];

void scan(void){
  int i, u, right, left;
  
  cin >> n;
  for(i=0; i<n; i++) T[i].p = T[i].r = T[i].l = NIL;

  for(i=0; i<n; i++){
    cin >> u >> right >> left;
    T[u].r = right; T[u].l = left;
    if(right != NIL) T[right].p = u;
    if(left != NIL) T[left].p = u;
  } 
}

void Depth(int u, int d){
  D[u]=d;
  if(T[u].r != NIL) Depth(T[u].r, d+1);
  if(T[u].l != NIL) Depth(T[u].l, d+1);
}

int Height(int u){
  int h1=0, h2=0;
 
  if(T[u].r != NIL) h1=Height(T[u].r) + 1;
  if(T[u].l != NIL) h2=Height(T[u].l) + 1;
 
  return H[u] = max(h1,h2);
}

void print(int u){
  
  printf("node %d: parent = %d, ", u, T[u].p);

  if(T[u].p == NIL) printf("sibling = %d, ", NIL); 
  else if(T[T[u].p].l != u) printf("sibling = %d, ", T[T[u].p].l);
  else if(T[T[u].p].r != u) printf("sibling = %d, ", T[T[u].p].r);
  else printf("sibiling = %d, ", NIL);

  if(T[u].r != NIL && T[u].l != NIL) printf("degree = 2, ");
  else if(T[u].r == NIL && T[u].l == NIL) printf("degree = 0, ");
  else printf("degree = 1, ");

  printf("depth = %d, height = %d, ", D[u], H[u]);
  
  if(T[u].p == NIL) printf("root\n");
  else if(T[u].r != NIL || T[u].l != NIL) printf("internal node\n");
  else printf("leaf\n");
}

void Preorder(int u){
  if(u == NIL) return;

  printf(" %d",u);
  Preorder(T[u].r);
  Preorder(T[u].l);
}

void Inorder(int u){
  if(u == NIL) return;

  Inorder(T[u].r);
  printf(" %d",u);
  Inorder(T[u].l);
}

void Postorder(int u){
  if(u == NIL) return;

  Postorder(T[u].r);
  Postorder(T[u].l);
  printf(" %d",u);
}

int main(){

  int i, root;

  scan();

  for(i=0; i<n; i++){
    if(T[i].p == NIL){
      root = i;
      break;
    }
  }

  Depth(root, 0);
  Height(root);
  
  // for(i=0; i<n; i++) print(i);

  printf("Preorder\n");
  Preorder(root);
  printf("\n");

  printf("Inorder\n");
  Inorder(root);
  printf("\n");

  printf("Postorder\n");
  Postorder(root);
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 3240
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
int n,a[101],a1,a2,m,p;
main(){
  cin>>n>>m;
  r(i,n)cin>>a[i];
  r(i,n){
    if(a[i]%2)a1++;
    else a2++;
  }
  p=pow(2,a2);
  if(m){
    if(a1){
      a1--;
      if(a1)p*=pow(2,a1);
    }
    else p=0;
  }
  else{
    if(a1)a1--;
    if(a1)p*=pow(2,a1);
  }
  cout<<p<<endl;
}

Measured memory_bytes: 384
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

s = gc
cp = s.count 'p'
cg = s.count 'g'
puts max (cg - cp)/2,0


Measured memory_bytes: 7676
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse = True)

ans = A[0]
re = [A[1]]
n = 0
for num in A[2:]:
     re.append(num)
     if num < re[0]:
          n += 1
     ans += re[0]
     if n == 2:
         re.pop(0)
         n = 0

print(ans)


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

int main() {
  string o, e;
  cin >> o >> e;
  for (int i = 0; i < e.size(); ++i) {
    cout << o.at(i) << e.at(i);
  }
  if (e.size() < o.size()) {
    cout << o.back();
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
n,a,b,c=map(int,input().split())
if(1):
    r=[]
    ff=0
    r1=[]
    for i in range(n):
        s=input().rstrip("\n")
        r1.append(s)
    for i in range(n):
        s=r1[i]
        if(s=='AB'):
            if(a==b==0):
                ff=1
                break
            if(a==0 and b!=0):
                a+=1
                b-=1
                r.append('A')
            elif(b==0 and a!=0):
                b+=1
                a-=1
                r.append('B')
            elif(a==b==1):
                if(i!=n-1):
                    if('A' in s and 'A' in r1[i+1]):
                        a+=1
                        b-=1
                        r.append('A')
                    else:
                        b+=1
                        a-=1
                        r.append('B')
                else:
                    r.append('B')
            else:
                if(a>b):
                    a-=1
                    b+=1
                    r.append('B')
                else:
                    b-=1
                    a+=1
                    r.append('A')
        elif(s=='BC'):
            if(b==c==0):
                ff=1
                break
            if(b==0 and c!=0):
                b+=1
                c-=1
                r.append('B')
            elif(b!=0 and c==0):
                b-=1
                c+=1
                r.append('C')
            elif(c==b==1):
                if(i!=n-1):
                    if('B' in s and 'B' in r1[i+1]):
                        b+=1
                        c-=1
                        r.append('B')
                    else:
                        c+=1
                        b-=1
                        r.append('C')
                else:
                    r.append('C')
            else:
                if(c>b):
                    c-=1
                    b+=1
                    r.append('B')
                else:
                    b-=1
                    c+=1
                    r.append('C')
        else:
            if(a==c==0):
                ff=1
                break
            if(a==0 and c!=0):
                a+=1
                c-=1
                r.append('A')
            elif(c==0 and a!=0):
                c+=1
                a-=1
                r.append('C')
            elif(a==c==1):
                if(i!=n-1):
                    if('A' in s and 'A' in r1[i+1]):
                        a+=1
                        c-=1
                        r.append('A')
                    else:
                        c+=1
                        a-=1
                        r.append('C')
                else:
                    r.append('C')
            else:
                if(c>a):
                    c-=1
                    a+=1
                    r.append('A')
                else:
                    a-=1
                    c+=1
                    r.append('C')
    if(ff):
        print('No')
    else:
        print('Yes')
        for i in r:
            print(i)



Measured memory_bytes: 89180
import sys

X = int(input())

def prime(x):

    for i in range(1, int(x**0.5)+1, 1):
        if i==1:
            continue
        if x%i==0:
            return False
    return True

while 1:
    if True==prime(X):
        print(X)
        sys.exit()
    X = X + 1

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int[] NM=cin.ArrayInt(2,0);
        int ans=0;
        int lmax=0;
        int rmin=9999999;
        for(int i=0;i<NM[1];i++)
        {
          int[] lr=cin.ArrayInt(2,0);
          if(lr[0]>lmax)lmax=lr[0];
          if(lr[1]<rmin)rmin=lr[1];
        }
        ans=rmin-lmax+1;
        if(ans<0)ans=0;
        Console.WriteLine(ans);
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}


Measured memory_bytes: 17340
n, m = map(int, input().split())

t = [-1] * n
for _ in range(m):
   s, c = map(int, input().split())
   s -= 1

   if (t[s] != -1 and t[s] != c):
      print(-1)
      exit()
   t[s] = c

if (n > 1):
   if (t[0] == 0):
      print(-1)
      exit()

   if (t[0] == -1):
      t[0] = 1

   for i in range(1, n):
      if (t[i] == -1):
         t[i] = 0

else:
   if (t[0] == -1):
      t[0] = 0

print(''.join(map(str, t)))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,number[10001];
    for(int i=1;i<10000;i++)number[i]=i*i;
    while(cin>>n,n){
        vector<int> num;
        for(int i=1;i<n;i++)num.push_back(number[i]%n);
        sort(num.begin(),num.end());
        num.erase(unique(num.begin(),num.end()),num.end());
        int ans[5000]={};
        for(int i=0;i<num.size();i++){
            for(int j=0,k;j<num.size();j++){
                k=num[i]-num[j];
                if(k<0)k+=n;
                if(k>n/2)k=n-k;
                ans[k]++;
            }
        }
        for(int i=1;i<=n/2;i++)cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 1384
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());
        sc.close();

        if (A + B >= C) {
            out.printf("Yes\n");
        }
        else {
            out.printf("No\n");
        }

        out.flush();
    }
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n, c, k;
    cin >> n >> c >> k;
    ll t[n];
    rep(i, n) { cin >> t[i]; }
    sort(t, t + n);
    ll index = 0;
    ll ans = 0;
    ll bus = 1;
    repd(i, 1, n) {
        if (bus == c) {
            ans++;
            index = i;
            bus = 1;
            continue;
        }
        if (t[index] + k < t[i]) {
            ans++;
            index = i;
            bus = 1;
            continue;
        }
        bus++;
    }
    if (bus) {
        ans++;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#define bye return 0
#define speedOne ios::sync_with_stdio(false)
#define speedtwo cin.tie(0)
typedef long long int lli;
typedef long long ll;
using namespace std;
int main()
{   
    speedOne;
    speedtwo;
	int cnt=0, t, m, n, x, y, a, b;
	cin >> m >> n >> x >> y;
	//set<int> s;
	//map<int, int> m;
	vector<int> xn;
	vector<int> yn;
	while(m--){
	    cin >> a;
	    xn.push_back(a);
	}
	while(n--){
	    cin >> b;
	    yn.push_back(b);
	}
	
	int max = *max_element(xn.begin(), xn.end());
	int min = *min_element(yn.begin(), yn.end());
	
	if(min>max && min>x && min<=y) cout << "No War" << endl;
	else cout << "War" << endl;
	
	bye;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
heights = [int(input()) for i in range(N)]
heights.sort()

diff = heights[K-1] - heights[0]
ans = diff

for i in range(N)[1:N-K+1]:
  diff = heights[i+K-1] - heights[i]
  ans = min(ans, diff)
print(ans)
  


Measured memory_bytes: 7384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const ll mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,K;cin>>N>>K;
    int cnt=0;
    while(N){
        N-=N%K;
        N/=K;
        cnt++;
    }
    
    cout<<cnt<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX (ll)(1e3 + 7)
#define INF (ll)(1e18)
#define MOD (ll)(1e9 + 7)

using namespace std;
using ll = long long;
using cd = complex<double>;

int main () {
	int n;
	cin >> n;
	string ar[4] = {"AC", "WA", "TLE", "RE"};
	int cc[4] = {};
	for (int i = 0; i < n; i++) {
		string st;
		cin >> st;
		for (int j = 0; j < 4; j++) {
			cc[j] += st == ar[j];
		}
	}
	for (int j = 0; j < 4; j++) {
		cout << ar[j] << " x " << cc[j] << "\n";
	}
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test1 cout << "test1" << endl;
#define test2 cout << "test2" << endl;
#define fixprecision(n) fixed; cout << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define iikae auto&
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

int main(){
  kyopro;
  ll P, Q, R;
  cin >> P >> Q >> R;
  cout << P + Q + R - max({P, Q, R}) << rt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p) {
    return out << "(" << p.first << ", " << p.second << ")";
}
template<class A> ostream& operator <<(ostream& out, const vector<A> &v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        if(i) out << ", ";
        out << v[i];
    }
    return out << "]";
}

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

    double n;
    cin >> n;
    cout << 2.0 * 3.141592653589 * n << '\n';

    return 0;
}


Measured memory_bytes: 3808
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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

  if(a>=k){
      cout<<a-k<<" "<<b<<endl;
  }else if(a+b>=k){
      cout<<0<<" "<<b-(k-a)<<endl;
  }else{
      cout<<0<<" "<<0<<endl;
  }
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int,int> PI;
typedef long long LL;
const int N=500005;
vector<int> vec[N]; 
int a[N];
int n,k;
struct qq
{
	int l,r;
	int s1,s2;
	PI c;
}tr[N*2];int num;
void upd (int now)
{
	int s1=tr[now].s1,s2=tr[now].s2;
	tr[now].c=max(tr[s1].c,tr[s2].c);
}
void bt (int l,int r)
{
	int now=++num;
	tr[now].l=l;tr[now].r=r;
	tr[now].c={0,0};
	if (l==r) return ;
	int mid=(l+r)>>1;
	tr[now].s1=num+1;bt(l,mid);
	tr[now].s2=num+1;bt(mid+1,r);
}
void change (int now,int x,int c)
{
	if (tr[now].l==tr[now].r)	{tr[now].c={c,x};return ;}
	int mid=(tr[now].l+tr[now].r)>>1;
	int s1=tr[now].s1,s2=tr[now].s2;
	if (x<=mid) change(s1,x,c);
	else change(s2,x,c);
	upd(now);
}
PI query (int now,int l,int r)
{
	if (l>r) return {0,0};
	if (tr[now].l==l&&tr[now].r==r) return tr[now].c;
	int s1=tr[now].s1,s2=tr[now].s2;
	int mid=(tr[now].l+tr[now].r)>>1;
	if (r<=mid) return query(s1,l,r);
	else if (l>mid) return query(s2,l,r);
	else return max(query(s1,l,mid),query(s2,mid+1,r));
}
int du[N];
priority_queue<int> q;
int ans[N];
int main()
{
	scanf("%d%d",&n,&k);
	for (int u=1;u<=n;u++)	{int x;scanf("%d",&x);a[x]=u;}
	bt(1,n);
	for (int u=1;u<=n;u++)
	{
		change(1,a[u],u);PI t;
		//printf("modify:%d %d\n",a[u],u);
		t=query(1,max(1,a[u]-k+1),a[u]-1);if (t.first!=0) {vec[a[u]].push_back(t.second);du[t.second]++;/*printf("%d %d\n",a[u],t.second);*/}
		t=query(1,a[u]+1,min(n,a[u]+k-1));if (t.first!=0) {vec[a[u]].push_back(t.second);du[t.second]++;/*printf("%d %d\n",a[u],t.second);*/}
	}
	for (int u=1;u<=n;u++) if (du[u]==0) q.push(u);
	for (int u=n;u>=1;u--)
	{
		int x=q.top();q.pop();
		ans[x]=u;
		int siz=vec[x].size();
		for (int i=0;i<siz;i++)	
		{
			du[vec[x][i]]--;
			if (du[vec[x][i]]==0)	q.push(vec[x][i]);
		}
	}
	for (int u=1;u<=n;u++) printf("%d\n",ans[u]);
	return 0;
}

Measured memory_bytes: 60288
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = 0,count2 = 0;
		for(int i = 0;i < 3;i++) {
			int a = sc.nextInt();
			if(a == 5) {
				count++;
			}
			if(a == 7) {
				count2++;
			}
		}
		if(count == 2&& count2== 1) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 35600
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


ll f(ll n)
{
	if (n % 2 == 0)
	{
		return n / 2;
	}
	else
	{
		return 3 * n + 1;
	}
}

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

	vector<ll> h(10000);

	h[s] = 1;

	ll old = s;

	for (int i = 1; ; i++)
	{
		ll x = f(old);
		h[x] ++;
		if (h[x] == 2)
		{
			println(i + 1);
			break;
		}

		old = x;
	}
}

Measured memory_bytes: 384
def resolve():
    N, M, X = map(int, input().split())
    A = list(map(int, input().split()))
    big = 0
    small = 0
    for i in A:
        if i>X:
            big += 1
        elif i<X:
            small += 1
    if big >= small:
        print(small)
    else:
        print(big)
resolve()

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

typedef long long ll;

int main()
{
    ll i,n;
    cin>>n;
    ll ar[n];
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    ll dp[n];
    dp[1] = 0;
    dp[2] = abs(ar[1]-ar[2]);
    for(i=3;i<=n;i++)
    {
        dp[i] = min((abs(ar[i]-ar[i-1])+dp[i-1]),(abs(ar[i]-ar[i-2])+dp[i-2]));
    }
    cout<<dp[n];
    // for(i=1;i<=n;i++)
    // cout<<dp[i]<<" "<<ar[i]<<"\n";
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int d, b, c, e, f;
	
	while (scanf("%d", &d) != EOF){
		b = 0;
		c = 2;
		e = d;
		f = d;
		while (f <= 600 - e) {
			b = b + (f * f * e);
			f = d * c;
			c++;
		}
		printf("%d\n", b);
	}
	
	return (0);
}	

Measured memory_bytes: 596
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e2 + 7;
const int mod = 1e9+7;
int a[N];
int n,ans;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    int sum=0;
    for(int i=1;i<=n;i++){
        sum+=a[i];
    }
    int x=sum/n;
    int y=(sum+n-1)/n;

    for(int j=1;j<=n;j++){
        ans+= (a[j]-x)*(a[j]-x);
    }
    int ans2=0;
    for(int j=1;j<=n;j++){
        ans2+= (a[j]-y)*(a[j]-y);
    }
    cout<<min(ans,ans2)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int w;
    int i;
    int f;

    while (scanf("%d", &w) != EOF) {
        f = 0;
        for (i = 0; i < 10; i++) {
            if ((w & 1 << i) == 1 << i) {
                if (f) printf(" ");
                printf("%d", 1 << i);
                f = 1;
            }
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 596
# coding: utf-8
# Your code here!
num,total = map(int,input().split())

for i in range(num + 1):
    for j in range(num - i + 1):
        k = num - i - j
        if (i * 10000 + j * 5000 + k * 1000 == total) and (i + j + k == num):
            print(i,j,k)
            exit()
print(-1,-1,-1)

            

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
#define PI  3.14159265358979323846264338327950
 
 
int main () {
    int A,B,C;
    cin >> A >> B >> C;

    if(A <= C && C <= B)cout <<"Yes" << endl;
    else cout << "No" << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> v(n), used(2020, 0);
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
        used[v[i]] = 1;
    }
    int m; cin >> m;
    for(int i = 0; i < m; i++)
    {
        int x; cin >> x;
        x--;
        if(used[v[x] + 1] || v[x] + 1 >= 2020) continue;
        swap(used[v[x]], used[v[x] + 1]);
        v[x]++;
    }
    for(int i = 0; i < n; i++) cout << v[i] << endl;
    return 0;
}




Measured memory_bytes: 3184
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<cstdlib>
#define range(i,a,b) for(int i = (a); i <= (b); i++)
#define rrange(i,a,b) for(int i = (a); i >= (b); i--)
#define rep(i,b) for(int i = 1; i <= (b); i++)
#define rrep(i,b) for(int i = (b); i >= 1; i--)
#define all(a) (a).begin(), (a).end()
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long ll;
const int N=1e5+11;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001LL;
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
priority_queue<int> Q1;
priority_queue<int,vector<int>,greater<int> > Q2;
int n;
ll a[N<<2],ans=-LLINF,h[N],t[N];
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
ll ll_read(){
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int main(){
//	freopen("ex.in","r",stdin);
	n=read();
	rep(i,3*n) a[i]=read();
	rep(i,n) Q2.push(a[i]),h[0]+=a[i];
	range(i,n+1,2*n){
		ll tmp=Q2.top();
		if(tmp<a[i]) Q2.pop(),Q2.push(a[i]),h[i-n]+=a[i]-tmp;
		h[i-n]+=h[i-n-1];
	}
	range(i,2*n+1,3*n) Q1.push(a[i]),t[n]+=a[i];
	rrange(i,2*n,n+1){
		ll tmp=Q1.top();
		if(tmp>a[i]) Q1.pop(),Q1.push(a[i]),t[i-n-1]+=a[i]-tmp;
		t[i-n-1]+=t[i-n];
	}
	range(i,0,n) ans=max(ans,h[i]-t[i]);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 5240
#include<iostream>
using namespace std;
int main(){
long long N, K;
cin >> N;
cin >> K;
long long s = 0;
for (long long i = K ; i <= N +1; ++i){
s += i*(N -i +1) +1;
  s = s % 1000000007;
}
  cout << s << endl;
}


Measured memory_bytes: 3188
import math


def kaibun_check(texts):
    n = len(texts)
    if texts == texts[::-1]:
        return True
    return False


def main():
    S = list(input())
    N = len(S)
    if not kaibun_check(S):
        print("No")
        return
    if not kaibun_check(S[0:(N - 1) // 2]):
        print("No")
        return
    if not kaibun_check(S[math.ceil((N + 3) / 2) - 1:]):
        print("No")
        return
    print("Yes")
    return


main()


Measured memory_bytes: 38384
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
using namespace std;

#define ll long long
#define MP make_pair

int main(void) {
  int a,b,h;
  cin>>a>>b>>h;
  cout<<((a+b)*h)/2<<"\n"; 

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll a,b,c;
    cin >> a >> b >> c;
    if (c<a){
        cout << a-c << " " << b << endl;
    }
    else {
        cout << 0 << " " << max(0ll,a+b-c) << endl;
    }
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;

int longest_increasing_subsequence(const vector<int> &v) {
	int n = v.size();
	vector<int> dp(n, INF);
	for (int i = 0; i < n; i++)
		*lower_bound(dp.begin(), dp.end(), v[i]) = v[i];
	return find(dp.begin(), dp.end(), INF) - dp.begin();
}


bool b[200005];
VI a;

VI ans(200005, 0);

VI g[200005];

VI dp;

void dfs(int i,int sz) {
	//v.push_back(a[i]);
	int it = lower_bound(ALL(dp), a[i]) - dp.begin();
	int tmp = dp[it];
	dp[it] = a[i];
	sz = max(sz, it + 1);
	ans[i] = sz;
	b[i] = true;
	for (int j : g[i]) {
		if (b[j])continue;
		dfs(j, sz);
	}
	dp[it] = tmp;
}

int main() {
	
	int n;
	cin >> n;
	a.resize(n);
	dp.resize(n);
	REP(i, n)dp[i] = INF;
	REP(i, n)cin >> a[i];

	REP(i, n - 1) {
		int c, d;
		cin >> c >> d;
		c--; d--;
		g[c].push_back(d);
		g[d].push_back(c);
	}
	dfs(0, 0);
	

	REP(i, n)cout << ans[i] << endl;

}



Measured memory_bytes: 28080
#include"bits/stdc++.h"
using namespace std;

int main() {

	double N;
	cin >> N;

	double a[100],dis[100];
	double sum = 0.;
	double samune = 1000.;
	int ans = 1000;

	for (int i = 0; i < N; i++) {

		cin >> a[i];
		sum += a[i];

	}

	for (int i = 0; i < N; i++) {

		dis[i] = fabs((sum / N) - a[i]);

		if (dis[i] < samune) {
			samune = dis[i];
			ans = i;

		}
	}

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
#include <functional>

using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 9901 //1000000007LL
#define rep(i,a,n) for (int i=a ; i<n ; i++)
#define per(i,a,n) for (int i=n-1 ; i>=a ; i--)
#define LLINF 100000000000000005LL
#define INF (int)1e9+1
#define endl '\n'
#define pb push_back

// debug 도구

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto& x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}\n";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)

// debug 도구 end

using llong = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VPII = vector<pair<int, int>>;
using VLL = vector<long long>;
using PII = pair<int, int>;

int main()
{
    IOS;

    char a, b;
    cin >> a >> b;
    if (a == b) cout << "H" << endl;
    else cout << "D" << endl;

    return 0;
}

Measured memory_bytes: 3624
a = input()
t = 1
b =["q","a","z","w","s","x","e","d","c","r","f","v","t","g","b","y","h","n","u","j","m","i","k","p","o","l"]
for i in range(26):
  if a == b[i]:
    print("a")
    t = 0
    break
if t == 1:
  print("A")

Measured memory_bytes: 8996
#include <cstdio>

int main(int argc, const char * argv[]) {
    
    int n,d,x;
    
    scanf("%d %d %d",&n,&d,&x);
    int ans = 0;
    for(int i=0,tmp;i<n;i++){
        scanf("%d",&tmp);
        ans += (d-1)/tmp;

    }
    
    printf("%d\n",ans+x+n);
    return 0;
}

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

template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 998244353;
using mint = ModInt<MOD>;

int main() {
    int n;
    std::string s;
    std::cin >> n >> s;

    mint ans = 1;
    std::vector<mint> cnt(8, 0);
    cnt[0] = n;

    for (char c : s) {
        int i;
        for (i = 0; i < 3; ++i) {
            if (c == "RGB"[i]) break;
        }

        int nb = 0;
        for (int b = 0; b < 8; ++b) {
            if ((b & (1 << i)) || cnt[b] == 0) continue;
            nb = b;
        }

        ans *= cnt[nb];
        cnt[nb] -= 1;
        cnt[nb | (1 << i)] += 1;
    }

    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 900
S = input()
N = len(S)
s_set = set(S)
if len(s_set) == 1:
  print(0)
  quit()

ans = 100

def change_to_s(s):
  flag = True
  T = S
  while flag:
    _T = ''
    flag = False
    for i in range(len(T)-1):
      if s in [T[i], T[i+1]]:
        _T += s
      else:
        _T += T[i]
        flag = True
    T = _T
  return N - len(_T), _T

for s in s_set:
  n, t = change_to_s(s)
  ans = min(ans, n)

print(ans)

Measured memory_bytes: 3188
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define maxn 4005
#define inf 1e9
using namespace std;

inline int read()
{
	int x = 0, w = 1;char ch = getchar();
	while (ch > '9' || ch < '0') { if (ch == '-')w = -1;ch = getchar(); }
	while (ch >= '0' && ch <= '9')x = x * 10 + ch - '0', ch = getchar();
	return x * w;
}

int n, m, ans, maxans, pos, tmp;
int a[maxn][maxn], f[maxn], num[maxn], vis[maxn];

inline int max(int x, int y) { return x > y ? x : y; }
inline int min(int x, int y) { return x < y ? x : y; }

int main(void)
{
	n = read(), m = read();ans = inf;
	for (int i = 1;i <= n;i++)
		for (int j = 1;j <= m;j++)
			a[i][j] = read();
	for (int i = 1;i <= n;i++)
		num[i] = 1;
	for (int i = 1;i <= m;i++)
	{
		memset(f, 0, sizeof(f));
		maxans = 0;
		for (int j = 1;j <= n;j++)
		{
			f[a[j][num[j]]]++;
			if (f[a[j][num[j]]] > maxans)
			{
				maxans = f[a[j][num[j]]];
				pos = a[j][num[j]];
			}
		}
		vis[pos] = 1, ans = min(ans, maxans);
		for (int j = 1;j <= n;j++)
			while (vis[a[j][num[j]]]) num[j]++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5276
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001

int main(void) {
	string s; cin >> s;
	int n = s.size();
	vi a(n); rep(i,n) a[i] = s[i]-'0';
	int ans = INF;
	rep(m,2){
		int cnt = 0;
		rep(i,n){
			int c = (i+m)%2;
			if(a[i]!=c) cnt++;
		}
		ans = min(ans,cnt);
	}
	cout << ans << endl;
}




Measured memory_bytes: 896
# Aizu Problem NTL_1_A: Prime Factorize
#
import itertools
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input2.txt", "rt")


def factors(n):
    f = 2
    increments = itertools.chain([1,2,2], itertools.cycle([4,2,4,2,4,6,2,6]))
    for incr in increments:
        if f*f > n:
            break
        while n % f == 0:
            yield f
            n //= f
        f += incr
    if n > 1:
        yield n

N = int(input())
print("%d: %s" % (N, ' '.join([str(_) for _ in list(factors(N))])))

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


using namespace std;

int main(void)
{
	string s,t;
	bool jud=false;

	cin>>s>>t;

	for(int i=0;i<s.size();i++){
		if(s==t){
			jud=true;
			break;
		}
		string temp=s.substr(s.size()-1,1);
		s.insert(0,temp);
		s.erase(s.size()-1);
	}

	if(jud) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int a[50],b[50],c[50],ans=0;
signed main(){
    int n;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
    rep(i,n){
        cin>>b[i];
        ans+=b[i];
    }
    rep(i,n-1)cin>>c[i];
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]+1)ans+=c[a[i-1]];
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i=0;i<n;++i) cin >> l[i];
  
  int ans=0;
  int res=0;
  for (int i=0;i<n;++i){
    ans=max(ans,l[i]);
    res+=l[i];
  }
  res-=ans;
  if (ans<res) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scanf("%s", &s)
	fmt.Scanf("%s", &t)
	var out int

	out = 0
	for ii := 0; ii < len(s); ii++ {
		if s[ii:ii+1] != t[ii:ii+1] {
			out++
		}
	}
	fmt.Println(out)

}


Measured memory_bytes: 4580
using System;
 
namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            var height = new int[10];
            for(int i=0; i < 10; ++i) {
                height[i] = int.Parse(Console.ReadLine());
            }
            Array.Sort(height);
            for(int i = 1; i <= 3; ++i) {
                Console.WriteLine(height[10 - i]);
            }
        }
    }
}

Measured memory_bytes: 5728
while True:
    try:
        c1, c2, c3 = map(int, input().split())
    except:
        break
    nums = list(set([i + 1 for i in range(10)]) ^ set([c1, c2, c3]))
    hit = 0
    for n in nums:
        if c1 + c2 + n <= 20: hit += 1

    if hit / 7 >= 0.5:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 6748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
int n,a[100005];
int main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	int ans = 0;
	for(int i=0;i<n;){
		bool x = 0,y = 0;
		for(int j=i+1;j<n;j++){
			if(a[j-1] < a[j]) x=1;
			if(a[j-1] > a[j]) y=1;
			if(x&&y){
				i=j; ans++; goto fail;
			}
		}
		ans++; break; fail:;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
import math
N = int(input())
v = list(map(int,input().split()))
v_new = 0
#新しい具材の価値をv_newとした
a = 0
k = []
#kで
p = N
for i in range(N-1):
    #全ての要素が同じ場合は終了する
    if v.count(v[0]) == p:
        break
    else:
       x = min(v)
       v.remove(x)
       #xをvのリストから除外
       y = min(v)
       v_new = (x+y)/2
       #価値を(x+y)/2とした
       v.append(v_new)
       #v_newをvのリストに挿入
       v.remove(y)
       #yをvのリストから除外
       v_new = 0
       #v_newを初期化
       p = p-1
       a = 0
       x = 0
       y = 0
print(v[0])

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    string s;
    cin >> s;
    REP(i, s.size()) {
        if (i%2==0) cout << s[i];
    }
    cout << "\n";
}


Measured memory_bytes: 592
#include <iostream>
using namespace std;
int main()
{
  int num[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k,i;
  cin>>k;
 
  cout<<num[k-1]<<endl;
  return 0;
}

Measured memory_bytes: 888
// https://atcoder.jp/contests/abc149/tasks/abc149_c

#include <bits/stdc++.h>
using namespace std;

int main()
{
    long MAX_ = 1000001;

    long x;
    cin >> x;

    vector<bool> prime(MAX_, true);
    prime[0] = false;
    prime[1] = false;

    for (long p = 2; p < MAX_; p++)
    {
        if (not prime[p])
            continue;
        for (long j = p * p; j < MAX_; j += p)
        {
            prime[j] = false;
        }
    }
    for (long j = x; j < MAX_; j++)
        if (prime[j])
        {
            cout << j << endl;
            return 0;
        }
    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())
#define MOD 998244353 
#define mx 200003

string ss;
int n;



int main(){
	cin >> n;
	cin >> ss;
	set<int> R, G, B;
	for(int i = 0; i < n * 3; i++){
		if(ss[i] == 'G')
			G.insert(i);
		else if(ss[i] == 'R')
			R.insert(i);
		else B.insert(i);
	}
	vector<int> tipe(n * 3, -1);
	for(int i = 0; i < n * 3; i++){
		if(tipe[i] != -1)
			continue;
		tipe[i] = 0;
		if(ss[i] == 'R'){
			auto it1 = G.lower_bound(i);
			auto it2 = B.lower_bound(i);
			tipe[min(*it1, *it2)] = 1;
			tipe[max(*it1, *it2)] = 2;
			G.erase(it1);
			B.erase(it2);
		}
		else if(ss[i] == 'G'){
			auto it1 = R.lower_bound(i);
			auto it2 = B.lower_bound(i);
			tipe[min(*it1, *it2)] = 1;
			tipe[max(*it1, *it2)] = 2;
			R.erase(it1);
			B.erase(it2);
		}
		else{
			auto it1 = G.lower_bound(i);
			auto it2 = R.lower_bound(i);
			tipe[min(*it1, *it2)] = 1;
			tipe[max(*it1, *it2)] = 2;
			G.erase(it1);
			R.erase(it2);
		}
	}
	long long nolR = 0, satuR = 0;
	long long nolG = 0, satuG = 0;
	long long nolB = 0, satuB = 0;
	long long jaw = 1;
	for(int i = 0; i < n * 3; i++){
		// debug(i);
		if(tipe[i] == 0){
			if(ss[i] == 'R')
				nolR += 1;
			if(ss[i] == 'G')
				nolG += 1;
			if(ss[i] == 'B')
				nolB += 1;
		}
		else if(tipe[i] == 1){
			if(ss[i] == 'R'){
				// assert((nolG > 0) ^ (nolB > 0));
				if(nolG > 0){
					jaw = jaw * nolG % MOD;
					nolG -= 1;
				}
				else if(nolB > 0){
					jaw = jaw * nolB % MOD;
					nolB -= 1;
				}
				// else assert(false);
				satuR += 1;
			}
			else if(ss[i] == 'G'){
				// assert((nolR > 0) ^ (nolB > 0));
				if(nolR > 0){
					jaw = jaw * (nolR + nolB) % MOD;
					nolR -= 1;
				}
				else if(nolB > 0){
					jaw = jaw * nolB % MOD;
					nolB -= 1;
				}
				// else assert(false);
				satuG += 1;
			}
			else{
				// assert((nolG > 0) ^ (nolR > 0));
				if(nolG > 0){
					jaw = jaw * (nolG + nolR) % MOD;
					nolG -= 1;
				}
				else if(nolR > 0){
					jaw = jaw * nolR % MOD;
					nolR -= 1;
				}
				// else assert(false);
				satuB += 1;
			}
		}
		else{
			if(ss[i] == 'R'){
				// assert((satuG > 0) ^ (satuB > 0));
				if(satuG > 0){
					jaw = jaw * (satuG + satuB) % MOD;
					satuG -= 1;
				}
				else if(satuB > 0){
					jaw = jaw * satuB % MOD;
					satuB -= 1;
				}
				// else assert(false);
			}
			else if(ss[i] == 'G'){
				// assert((satuR > 0) ^ (satuB > 0));
				if(satuR > 0){
					jaw = jaw * (satuR + satuB) % MOD;
					satuR -= 1;
				}
				else if(satuB > 0){
					jaw = jaw * satuB % MOD;
					satuB -= 1;
				}
				// else assert(false);
			}
			else{
				// assert((satuG > 0) ^ (satuR > 0));
				if(satuG > 0){
					jaw = jaw * (satuG + satuR) % MOD;
					satuG -= 1;
				}
				else if(satuR > 0){
					jaw = jaw * satuR % MOD;
					satuR -= 1;
				}
				// else assert(false);
			}
		}
	}
	for(int i = 1; i <= n; i++)
		jaw = jaw * i % MOD;
	cout << jaw << '\n';
}

Measured memory_bytes: 15748
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    string s;
    cin >> s;
    if(s=="ABC")cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3596