akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

int main(void){
	while(1){
		int n,i;
		double breakup={0},Ave={0},Score[1000];
		scanf("%d",&n);
		if(n==0) return 0;
		for(i=0;i<n;i++){
			scanf("%lf",&Score[i]);
			Ave+=Score[i];
		}
		Ave=Ave/n;
		for(i=0;i<n;i++){
			breakup+=(Ave-Score[i])*(Ave-Score[i]);
		}
		breakup=breakup/n;
		breakup=sqrt(breakup);
		printf("%f\n",breakup);
	}
	return 0;
}

Measured memory_bytes: 660
class UnionFind:
  def __init__(self, n):
    self.par = [i for i in range(n)]
    self.size = [1]*n
    self.rank = [0]*n
  def find(self, x):
    if self.par[x]==x:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]
  def unit(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x==y:
      return
    elif self.rank[x]<self.rank[y]:
      self.par[x] = y
      self.size[y] += self.size[x]
      return
    elif self.rank[y]<self.rank[x]:
      self.par[y] = x
      self.size[x] += self.size[y]
    else:
      self.par[y] = x
      self.size[x] += self.size[y]
      self.rank[x] += 1
      
  def same(self, x, y):
    return self.find(x)==self.find(y)
  
  def count(self, x):
    return self.size[x]

N, M, *L = map(int, open(0).read().split())
u = UnionFind(N+1)
m = N*(N-1)//2
ans = []
for a, b in zip(*[iter(L[::-1])]*2):
  ans += [m]
  A = u.find(a)
  B = u.find(b)
  if A!=B:
    na = u.count(A)
    nb = u.count(B)
    u.unit(a,b)
    m -= na*nb

print('\n'.join(map(str,ans[::-1])))

Measured memory_bytes: 26128
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int maxn=2e5+100;
long long int prearr[maxn];
long long int sufarr[maxn];
int main()
{
    long long int n,k;
    long long int ans=0;
    cin>>n>>k;
    ++n;
    long long int sum=0;
    for(int i=0;i<=n;++i)
    {
        sum+=i;
        prearr[i]=i;
        if(i)
            prearr[i]+=prearr[i-1];
    }
    for(int j=n,i=1;j>=0;--j,++i)
    {
        sufarr[i]=j;
        sufarr[i]+=sufarr[i-1];
        //cout<<sufarr[i]<<" ";
    }
    //cout<<endl;
    for(int i=k;i<=n;++i)
    {
        ans+=(sum-prearr[i])-(sum-sufarr[i])+1;
        //cout<<prearr[i]<<" "<<sufarr[i]<<endl;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6760
#include<bits/stdc++.h>
#define int  long long 
#define loop(i,a,b) for(i=a;i<b;i++)
#define mod 1000000007
#define INF 1000000000000
#define pb push_back
#define lim 1000001
using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,d,ans=0,i;
    cin>>n>>d;

    loop(i,0,n) {
    	int a,b;
    	cin>>a>>b;

    	if((a*a+b*b)<=d*d)
    		ans++;
    }

    cout<<ans<<endl;

    return 0;}

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

int main() {
	ll X;
	cin >> X;
	if (X >= 30) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return(0);
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
  int n;
  cin>>n;
  
  int num[n+1];
  rep(i, n){
    cin>>num[i+1];}
  
  int max1=0;
  int max2=0;
  
  int num2[n+1];
  
  rep(i, n){
    num2[0]=0;
    num2[i+1]=0;}
    
    
  rep(i, n){
    num2[i+1]=num[i+1];}
  
  sort(num2, num2+n+1);
    max1=num2[n];
     max2=num2[n-1];  

 
  
  
 for(int i=1;i<=n;i++){
   if(num[i]==max1){
     cout<<max2<<endl;}
   else{
     cout<<max1<<endl;}
 }
 
  
}



Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <list>
#define INF 0x3f3f3f3f
#define maxn 105000
#define maxnn 6000
#define juzheng 300
#define line cout << "-------------------------" << endl;
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define fill_(a,b,n) fill(a,a + n,b)
#define esp 1e-9
 
#define ri(n) scanf("%d",&n)
#define ri2(a,b) scanf("%d %d",&a,&b)
#define ri3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define rd(n) scanf("%lf",&n)
#define rd2(a,b) scanf("%lf %lf",&a,&b)
#define rd3(a,b,c) scanf("%lf %lf %lf",&a,&b,&c)
#define rl(n) scanf("%lld",&n)
#define rl2(a,b) scanf("%lld %lld",&a,&b)
#define rl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define rs(str) scanf("%s",str)
#define pr(n) cout << n << endl
#define ll long long
#define int64 __int64

using namespace std;

const ll mod = 1e9 + 7;

//Date:2018-8-5
//Author：HarryBlackCat

int n;

int main() {
	//cin.sync_with_stdio(false);//降低cin，cout时间
	while(~ri(n)){
		if(n < 1200)
			puts("ABC");
		else if(n < 2800)
			puts("ARC");
		else
			puts("AGC"); 
	}
	return 0;
}

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

const ll INF = 1e18;

int main()
{
	ios_base::sync_with_stdio(false);

	int N, W;
	cin >> N >> W;
	vector<int> w(N + 1), v(N + 1);
	for (int i = 1; i <= N; i++)
		cin >> w[i] >> v[i];
	const int V = 1000 * N;
	vector<vector<ll>> dp(N + 1, vector<ll> (V + 1, INF));
	dp[1][0] = 0;
	dp[1][v[1]] = w[1];
	for (int i = 2; i <= N; i++)
	{
		for (int j = 0; j <= V; j++)
		{
			dp[i][j] = dp[i - 1][j];
			if (j < v[i])
				continue;
			dp[i][j] = min(dp[i][j], w[i] + dp[i - 1][j - v[i]]);
		}
	}
	int answer = 0;
	for (int i = 0; i <= V; i++)
	{
		if (dp[N][i] <= W)
			answer = i;
	}
	cout << answer;

	return 0;
}

Measured memory_bytes: 83236
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var c1 = IO.RSInt;
            var c2 = IO.RSInt;
            var c3 = IO.RSInt;

            if (!((c2[0] - c1[0]) == (c2[1] - c1[1]) && (c2[1] - c1[1]) == (c2[2] - c1[2])))
            {
                WriteLine("No");
                return;
            }
            if (!((c2[0] - c3[0]) == (c2[1] - c3[1]) && (c2[1] - c3[1]) == (c2[2] - c3[2])))
            {
                WriteLine("No");
                return;
            }
            WriteLine("Yes");
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 13396
#define LOCAL
#include <bits/stdc++.h>
 
using namespace std;
 
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 += "}";
    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...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
//Auther: Arin Roday
#define vec vector
#define i64 long long
#define endl '\n'
#define sz(x) (x).size()
#define times(n) for(int i = 0; i < (n); ++i)
#define bits(x) __builtin_popcount(x)
 
void solve(){
    int h ,n;
    cin >> h >> n;
    int a[n];
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    i64 sum = 0;
    for(int i = 0; i < n; ++i){
        sum += a[i];
        if(sum - h >= 0){
            break;
        }
    }
    if(sum - h >= 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
 
int main(){
    solve();
}

Measured memory_bytes: 640
N,K  = map(int,input().split())
p = list(map(int,input().split()))

dice = []
for i in range(N):
  temp = (1+p[i])/2
  dice.append(temp)

#print(dice)
ans = 0
prev = sum(dice[:K])
ans = prev
for i in range(K,N):
  temp = prev-dice[i-K]+dice[i]
  ans = max(ans,temp)
  prev = temp
print(ans)


Measured memory_bytes: 100556
import java.util.*;

public class Main{
	static class Move{
		int fy,fx,ty,tx;
		public Move(int fy,int fx,int ty,int tx){
			this.fy=fy+1;
			this.fx=fx+1;
			this.ty=ty+1;
			this.tx=tx+1;
		}
		@Override
		public String toString(){
			return fy+" "+fx+" "+ty+" "+tx;
		}
	}

	static Scanner s=new Scanner(System.in);
	static int h=s.nextInt(),w=s.nextInt();
	static int[][] f=new int[h][w];
	
	static ArrayList<Move>r=new ArrayList<>();
	
	public static void main(String[] $){
		for(int i=0;i<h;++i)
			Arrays.setAll(f[i],o->s.nextInt());
		
		for(int i=0;i<h;++i) {
			for(int j=0;j<w-1;++j) {
				if(f[i][j]%2==1)
					f(i,j,i,j+1);
			}
		}
		for(int i=0;i<h-1;++i) {
			if(f[i][w-1]%2==1)
				f(i,w-1,i+1,w-1);
		}
		
		System.out.println(r.size());
		r.forEach(System.out::println);
	}
	static void f(int i,int j,int I,int J){
		r.add(new Move(i,j,I,J));
		++f[I][J];
	}
}


Measured memory_bytes: 98776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(abs(a - c) <= d)
		cout << "Yes";
	else {
		if(abs(a - b) <= d && abs(b - c) <= d)
			cout << "Yes";
		else
			cout << "No";
	}
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  ll N,K;
  cin >> N >> K;
  vector<ll> A(N);
  for(ll i=0;i<N;i++){
    cin >> A.at(i);
    A.at(i)--;
  }

  ll now=0;
  bool flag=false;
  vector<ll> visited(N,-1);
  for(ll i=0;i<K;i++){
    if(visited.at(now)>=0){
      flag=true;
      K=(K-i)%(i-visited.at(now));
      break;
    }
    visited.at(now)=i;
    now=A.at(now);
  }
  if(flag){
    for(ll i=0;i<K;i++){
      now=A.at(now);
    }
  }
  cout << now+1 << endl;

  return 0;
}

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

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

	int c0 = 0;
	int c1 = 0;

	for(char c: s){
		if(c=='0') c0++;
		else c1++;
	}

	cout << 2 * min(c0, c1) << endl;

	return 0;
}

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

using namespace std;

int main()
{
    int m,d;
    cin>>m>>d;
    int d1=0;
    int d10=0;
    int k=0;
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=d;j++)
        {
            d1=j%10;
            d10=j/10;
            if(i==d1*d10 && d1>1 && d10>1)
            {
                k++;
               // cout<<i<<" "<<d1<<" "<<d10<<endl;
            }
        }
    }
    cout<<k<<endl;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else
    cout << "Balanced" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
	
		int ans = b;

		if(n*a < b){
		ans = n*a;
		}
		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
dp = [[0]*(w+1) for _ in range(n+1)]
for i in range(n):
    w_, v_ = wv[i]
    for j in range(w+1):
        if j < w_:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j-w_]+v_, dp[i][j])
print(dp[n][w])

Measured memory_bytes: 119916
#include<bits/stdc++.h>
#define ll long long
#define N 200010
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
int n,a[N];
bool pa(int x){
	priority_queue<int> b;
	unordered_map<int,int> c;c.clear();
	while (!b.empty()) b.pop();
	for (int i=1;i<=n;i++){
		if (a[i]<=a[i-1]){
			if (x==1) return false;
			while (!b.empty()&&b.top()>a[i]){c[b.top()]=0;b.pop();}
			c[a[i]]++;if (c[a[i]]==1) b.push(a[i]);
			int y=a[i];
			while (c[y]>=x){
				b.pop();c[y]=0;
				if (y==1) return false;
				y--;c[y]++;if (c[y]==1) b.push(y);
			}
		}
	}
	return true;
}
int main(){
	read(n);
	for (int i=1;i<=n;i++)read(a[i]);
	int l=1,r=n,mid;
	while (l<r){
		mid=(l+r)/2;
		if (pa(mid)) r=mid;else l=mid+1;
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 8948
import math 
N = int(input())
A = list(map(int, input().split()))
m = [0] * int(1e6+1)
for i in range(N):
    m[A[i]] += 1
pw = True
for p in range(2, len(m)):
    c = 0
    for i in range(p, len(m), p):
        c += m[i]
    if c > 1:
        pw = False
        break
if pw:
    print('pairwise coprime')
    exit()
d = A[0]
for i in range(N):
    d = math.gcd(d, A[i])
if d == 1:
    print('setwise coprime')
else:
    print('not coprime')

Measured memory_bytes: 189256
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        400005
#define mod         1000000007 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,sum=0,count=0,flag=0;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
        if(a[i]<0){
            count++;
            a[i]=(-1)*a[i];
        }
        if(a[i]==0){
            flag=1;
        }
    }
    ll mi=1000000000000000;
    for(i=0;i<n;i++){
        sum+=a[i];
        mi=min(mi,a[i]);
    }
    if(count%2==0 || flag==1){
        cout<<sum;
    }
    else{
        sum=sum-2*mi;
        cout<<sum;
    }
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
    int n;
    while(cin >> n)
    {
        if(n==-1)break;
        double x=1.0,y = 0.0;
        double vx=0,vy=1;
        double idox = -1;
        double idoy = 0;
        while(--n)
        {
            //turn
            idox = -x / fabs(sqrt((x*x) + (y*y)));
            idoy = -y / fabs(sqrt((x*x) + (y*y)));
            vx = idoy;
            vy = -idox;

            //cout << vx << ","<<vy << endl;
            //move
            x += vx;
            y += vy;
        }
        printf("%.2f\n%.2f\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

#define REP(i,n) for (int i=0;i<(n);i++)
#define PII pair<int,int>
#define LL long long
#define vi vector<int>

int c[10][10];

void findMin() {
	LL newC;
	bool changed = false;
	do {
		changed = false;
		REP(i, 10) {
			REP(j, 10) {
				if (i == j) continue;
				REP(k, 10) {
					if (k == i || k == j) continue;
					newC = c[i][k] + c[k][j];
					if (c[i][j] > newC) {
 						c[i][j] = newC;
						changed = true;
					}
				}
			}
		}
	} while (changed);

	return;
}

int main(){
	int h, w;
	int A[200][200];
	int sum=0;
	cin >> h >> w;
	REP(i, 10) {
		REP(j, 10) {
			cin >> c[i][j];
		}
	}
	REP(i, h) {
		REP(j, w) {
			cin >> A[i][j];
		}
	}

	findMin();


	REP(i, h) {
		REP(j, w) {
			if (A[i][j] == -1 || A[i][j] == 1) continue;
			sum += c[A[i][j]][1];
		}
	}

	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define ll long long
#define ldb long double
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(i,a,b) for (int i = (a); i < (b); ++i)
#define rrof(i,a,b) for (int i = (b)-1; i >= (a); --i)


const int MOD = 1e9+7;
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n){
	ll res=1;

	while(n){
		if(n%2)
		res*=a;
		a*=a;
		n/=2;
	}
	
	return res;
}

int main(){
	fast;
	
	int h,a;
	cin>>h>>a;
	
	if(h%a==0)
	cout<<h/a;
	
	else
	cout<<(h/a)+1;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
//26

string str = "aiueo";
signed main(){
	char c;
	int f = 0;
	scanf("%c", &c);
	rep(i,5)if(str[i] == c)f = 1;
	if(f)printf("vowel\n");
	else printf("consonant\n");
	return 0;
}





Measured memory_bytes: 256
#include <iostream>

int main(int argc, char *argv[])
{
    int n;
    std::cin >> n;
    int max = 0;
    int res = 0;
    for(int i= 0; i < n; i++){
        int t;
        std::cin >> t;
        max = std::max(max, t);
        res += t;
    }
    res -= (max/2);
    std::cout << res << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

int fact(int N){
	if(N == 0){
		return 1;
	}
	else{
		return MOD(N * fact(N - 1));
	}
}

signed main(){
	int N, M, i, j, k;
	scanf("%lld%lld", &N, &M);
	vector<vector<vector<int>>> dp(M + 1, vector<vector<int>>(N, vector<int>(N, 0)));
	dp[0][0][0] = 1;
	for(i = 0; i < M; i++){
		for(j = 0; j < N; j++){
			for(k = 0; k < N; k++){
//				printf("dp[%lld, %lld, %lld] = %lld\n", i, j, k, dp[i][j][k]);
				dp[i + 1][j][j] = MOD(dp[i + 1][j][j] + (k + 1) * dp[i][j][k]);
				if(k < j){
					dp[i + 1][j][k] = MOD(dp[i + 1][j][k] + (j - k) * dp[i][j][k]);
				}
				if(j < N - 1){
					dp[i + 1][j + 1][k] = MOD(dp[i + 1][j + 1][k] + dp[i][j][k]);
				}
			}
		}
	}
	printf("%lld\n", MOD(dp[M][N - 1][N - 1] * fact(N - 1)));
	return 0;
}

Measured memory_bytes: 216192
from math import sqrt
n = int(input())
cnt = [0]*1000000
ans = 0
for i in range(2,int(sqrt(n))):
    if(n==1): break
    j = 1
    while n%i==0:
        n = n//i
        cnt[i-1]+=1
        if cnt[i-1]==j:
            ans+=1
            j+=1
            cnt[i-1]=0
if n!=1: ans+=1
print(ans)

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

#include <atcoder/all>

using namespace std;
using namespace atcoder;

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const int maxn = 200010;
using Mint = modint998244353;

Mint ten[maxn];

struct S {
    Mint sum;
    int cnt;
};

S op(S l, S r) { return S{l.sum * ten[r.cnt] + r.sum, l.cnt + r.cnt}; }

S e() { return S{0, 0}; }

struct F {
    int x;
};

S mapping(F l, S r) {
    if (!l.x)
        return r;
    else
        return S{(ten[r.cnt] - 1) / 9 * l.x, r.cnt};
}

F composition(F l, F r) { return F{l.x ? l.x : r.x}; }
F id() { return {0}; }

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

    ten[0] = 1;
    rep(i, maxn - 1) ten[i + 1] = ten[i] * 10;

    int N, Q;
    cin >> N >> Q;
    V<S> vec;

    rep(i, N) { vec.pb(S{1, 1}); }

    lazy_segtree<S, op, e, F, mapping, composition, id> seg(vec);

    while (Q--) {
        int l, r, x;
        cin >> l >> r >> x;
        --l;
        seg.apply(l, r, F{x});
        auto ans = seg.all_prod();
        cout << ans.sum.val() << endl;
    }
    return 0;
}

Measured memory_bytes: 10620
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  int n;
  int a[200005];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  vector<int> b;
  for(int i=0;i<n;i+=2){
    b.push_back(a[i]);
  }
  reverse(b.begin(),b.end());
  for(int i=1;i<n;i+=2){
    b.push_back(a[i]);
  }
  if(n%2==0)reverse(b.begin(),b.end());
  for(int i=0;i<n-1;i++){
    cout<<b[i]<<" ";
  }
  cout<<b[n-1]<<"\n";
  return 0;
}


Measured memory_bytes: 3828
def main():
    from collections import deque
    N, M = (int(i) for i in input().split())
    edge = [[] for _ in range(N)]
    for i in range(M):
        a, b = (int(i) for i in input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)

    def bfs(G, s):
        dist = [-1 for _ in range(N)]
        que = deque()
        dist[s] = 0
        que.append(s)
        while que:
            u = que.popleft()
            for v in G[u]:
                if dist[v] != -1:
                    continue
                dist[v] = dist[u] + 1
                que.append(v)
        return dist

    d = bfs(edge, 0)
    if 0 <= d[N-1] <= 2:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    main()


Measured memory_bytes: 96844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;


int main()
{
    int n, i;
    int count[4] = {0};
    cin >> n;
    string st;
    for (i = 0; i < n; i++) {
        cin >> st;
        if (st == "AC") count[0]++;
        else if(st == "WA") count[1]++;
        else if (st == "TLE") count[2]++;
        else count[3]++;
    }

    cout << "AC x " << count[0] << endl;
    cout << "WA x " << count[1] << endl;
    cout << "TLE x " << count[2] << endl;
    cout << "RE x " << count[3] << endl;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;
long long n,q,h,s,d;

int main()
{cin>>q>>h>>s>>d;
cin>>n;
    if(2*q<h)
        h=2*q;
    if(2*h<s)
        s=2*h;
    if(2*s<d)
        d=2*s;
    cout<<(n/2)*d+(n%2)*s;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    while (in.hasNext()) {
      int N = in.nextInt();
      int currMax = 0;
      int view = 0;

      for (int i = 0; i < N; ++i) {
        int Hi = in.nextInt();

        if (Hi >= currMax) {
           ++view;
        }

        currMax = Math.max(currMax, Hi);
      }
 
      System.out.println(view);
    }
  }
}

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

int main(){
	int n,k,temp;
	cin >> n >> k;
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin >> temp;
		v[i] = temp;
	}
	sort(v.begin(),v.end());
	int current_min = 1e9;
	for(int i=0;i<n-k+1;i++){
		int j=i+k-1;
		current_min = min(current_min,v[j]-v[i]);
	}
	cout << current_min;
	
	
 }


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>

#define max(X, Y) ((X)>(Y)?(X):(Y))
#define min(X, Y) ((X)<(Y)?(X):(Y))

int x[100010], y[100010];
int main()
{
    int n, w, h;
    while (~scanf("%d%d%d", &n, &w, &h)) {
        memset(x, 0, sizeof(x));
        memset(y, 0, sizeof(y));
        while (n--) {
            int a, b, c;
            scanf("%d%d%d", &a, &b, &c);
            x[max(0, a-c)]++;
            x[min(w+1, a+c)]--;
            y[max(0, b-c)]++;
            y[min(h+1, b+c)]--;
        }
        bool okx=true;
        for(int i=0;i<w;++i) {
            if (i) x[i]+=x[i-1];
            if (!x[i]) okx=false;
        }
        bool oky=true;
        for(int i=0;i<h;++i) {
            if (i) y[i]+=y[i-1];
            if (!y[i]) oky=false;
        }
        puts((okx||oky) ? "Yes" : "No");
    }
}

Measured memory_bytes: 1784
package main

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

const (
	maxN = 51
)

var N, K int

type Points []Point

type Point struct {
	y, x int
}

func (p Points) Len() int {
	return len(p)
}
func (p Points) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}
func (p Points) Less(i, j int) bool {
	if p[i].x > p[j].x {
		return true
	}
	return p[i].y < p[j].y
}

var points Points

func main() {
	fsc := NewFastScanner()
	N, K = fsc.NextInt(), fsc.NextInt()
	X := make([]int, 0)
	Y := make([]int, 0)
	for i := 0; i < N; i++ {
		x, y := fsc.NextInt(), fsc.NextInt()
		points = append(points, Point{y: y, x: x})
		X = append(X, x)
		Y = append(Y, y)
	}
	sort.Sort(points)
	sort.Ints(X)
	sort.Ints(Y)
	// fmt.Println(points)
	var result int64
	result = 1 << 62
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			for k := 0; k < N; k++ {
				for l := k + 1; l < N; l++ {
					lx := X[i]
					rx := X[j]

					by := Y[k]
					uy := Y[l]

					cnt := 0
					for m := 0; m < N; m++ {
						y, x := points[m].y, points[m].x
						if lx <= x && x <= rx && by <= y && y <= uy {
							cnt++
						}
					}

					if cnt >= K {
						result = Int64Min(result, int64(rx-lx)*int64(uy-by))
					}
				}
			}
		}
	}
	fmt.Println(result)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;

  vector<int> c(n);
  c[0] = 0;
  int cnt = 0;
  FOR(i, 1, n) {
    if (s[i - 1] == 'A' && s[i] == 'C') cnt++;
    c[i] = cnt;
  }

  int l, r;
  rep(i, q) {
    cin >> l >> r;
    cout << c[r - 1] - c[l - 1] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <vector>

#define int long long
#define dotimes(i, n) for (int i : range(n))

using namespace std;

class range {
  class iterator {
    int i, s;
  public:
    iterator(int i, int s): i(i), s(s) {}
    int& operator*() {
      return i;
    }
    void operator++() {
      i += s;
    }
    bool operator!=(iterator const& that) {
      return i < that.i;
    }
  };
  iterator b, e;
public:
  range(int e): b({0, 1}), e({e, 1}) {}
  range(int b, int e): b({b, 1}), e({e, 1}) {}
  range(int b, int e, int s): b({b, s}), e({e, s}) {}
  iterator begin() {
    return b;
  }
  iterator end() {
    return e;
  }
};

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

template<typename T>
inline int size(T container) {
  return static_cast<int>(container.size());
}

template<typename T>
inline bool maxs(T& a, T const& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
inline bool mins(T& a, T const& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

const int N = static_cast<int>(1e6);
int dp[N][2];

signed main() {
  vector<int> pollock;
  // skip n = 1
  for (int n = 2;; n++) {
    int p = n*(n+1)*(n+2)/6;
    if (p >= N)
      break;
    pollock.emplace_back(p);
  }
  dotimes(i, N) dotimes(j, 2)
    dp[i][j] = i;
  for (int p : pollock) {
    if (p % 2)
      dotimes(i, N - p) {
        mins(dp[p+i][0], dp[i][0] + 1);
        mins(dp[p+i][1], dp[i][1] + 1);
      }
    else
      dotimes(i, N - p)
        mins(dp[p+i][0], dp[i][0] + 1);
  }
  for (;;) {
    int x = rint();
    if (!x)
      break;
    printf("%lld %lld\n", dp[x][0], dp[x][1]);
  }
  return 0;
}



Measured memory_bytes: 18188
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

s = input()

if s[2]==s[3] and s[4]==s[5]:
    print("Yes")
else:
    print("No")



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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int n,count=0;
    cin>>n;
    Vi a(n),b(n);
    REP(i,0,n){
        cin>>a[i]>>b[i];
    }
    reverse(ALL(a));
    reverse(ALL(b));
    REP(i,0,n){
        if((a[i]+count)%b[i]!=0) count += b[i]-((a[i]+count)%b[i]);
    }
    cout<<count<<endl;
    return 0;
}


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

int n,m;
int ans[10];

int main(){
	memset(ans,-1,sizeof(ans));
	scanf("%d%d",&n,&m);
	while(m--){
		int s,c;
		scanf("%d%d",&s,&c);
		if(ans[s] == -1){
			ans[s] = c;
		} else if(ans[s] != c){
			printf("-1\n");
			return 0;
		}
	}
	if(ans[1] == 0 && n > 1){
		printf("-1\n");
		return 0;
	}
	if(ans[1] == -1) {
		if(n == 1) ans[1] = 0;
		else ans[1] = 1;
	}
	for(int i=1;i<=n;i++){
		if(ans[i] == -1) ans[i] = 0;
		printf("%d",ans[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint cal(string s){
	lint ret=0;
	rep(i,s.size()){
		ret*=10;
		ret+=(s[i]-'0');
	}
	return ret;
}
int main()
{
	int n;string s;lint out=0;
	cin>>s;n=s.size();
	rep(i,(1<<(n-1))){
		vector<int> v;v.pb(0);
		rep(j,n-1){
			if((i&(1<<j))) v.pb(j+1);
		}
		v.pb(n);
		rep(j,v.size()-1){
			out+=cal(s.substr(v[j],v[j+1]-v[j]));
		}
	}
	cout<<out<<endl;
}


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

int main(){
    string s; cin >> s;
    if(s == "RRR"){ cout << 3 << endl; return 0; }
    if((s[0] == s[1] or s[1] == s[2]) and s[1] == 'R'){ cout << 2 << endl; return 0; }
    if(s[0] == 'R' or s[1] == 'R' or s[2] == 'R') { cout << 1 << endl; return 0; }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
    int key;
    Node *r,*l,*p;
};

Node *root,*NIL;


Node *find(Node *u,int k){
    while(u!=NIL&&k!=u->key){
        if(k<u->key)
            u=u->l;
        else 
            u=u->r;
    }
    return u;
}

void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;

    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->l=NIL;
    z->r=NIL;
    
    while(x!=NIL){
        y=x;
        if(z->key<x->key){
            x=x->l;
        }
        else {
            x=x->r;
        }
    }
    z->p=y;
    if(y==NIL){
        root=z;
    }
    else {
        if(z->key<y->key){
            y->l=z;
        } 
        else{
            y->r=z;
        }
    }
}
void inorder(Node *u){
     if(u==NIL)return;
     inorder(u->l);
     printf(" %d",u->key);
     inorder(u->r);
}
 void preorder(Node *u){
     if(u==NIL)return;
     printf(" %d",u->key);
     preorder(u->l);
     preorder(u->r);
}

int main(){
    int n,i,x;
    string com;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        cin>>com;
        if(com[0]=='f'){
            scanf("%d",&x);
            Node *t=find(root,x);
            if(t!=NIL)
                printf("yes\n");
            else
                printf("no\n");
        }
        else if(com=="insert"){
            scanf("%d",&x);          
            insert(x);
        }
     else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 21940
n = map( int, input())
a = list(map( int, input().split() ))
A_point = 0
B_point = 0
flag = 1

a.sort(reverse=True)

for point in a:
    if flag%2 == 1:
        A_point += point
        flag += 1
    elif flag%2 == 0:
        B_point += point
        flag += 1

print("{}".format(A_point-B_point))

Measured memory_bytes: 9076
#include <stdio.h>
int main(void)
{
	int t[4];
	int n[4];
	int i;
	
	for(i=0;i<4;i++)
	scanf("%d %d",&t[i],&n[i]);
	
	for(i=0;i<4;i++){
		switch(t[i]){
			case 1:t[i]=6000; break;
			case 2:t[i]=4000; break;
			case 3:t[i]=3000; break;
			case 4:t[i]=2000; break;
		}
	}
	
	for(i=0;i<4;i++)
	printf("%d\n",t[i]*n[i]);
	
	return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s[n];
    for (int i = 0; i < n; i++) cin >> s[i];
    int m;
    cin >> m;
    string t[m];
    for (int i = 0; i < m; i++) cin >> t[i];
    int res = 0;
    for (int i = 0; i < n; i++) {
        int tmp = 0;
        for (int j = 0; j < n; j++) {
            if (s[i] == s[j]) tmp++;
        }
        for (int j = 0; j < m; j++) {
            if (s[i] == t[j]) tmp--;
        }
        res = max(res, tmp);
    }
    cout << res << "\n";
    return 0;
}

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

void chmin(int& a, int b){
    a = min(a, b);
}

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int main(){
    int N, Ma, Mb, a[40], b[40], c[40];
    cin >> N >> Ma >> Mb;
    for(int i=0; i<N; i++) cin >> a[i] >> b[i] >> c[i];

    // C[g][s] = グループgの選び方（1つ以上）で Mb*sumA - Ma*sumB = s となるときの最小コスト
    // sが負の値になり得るのでmap
    map<int, int> C[2];
    
    // グループgに属するのはインデックス [start[g], term[g]) の範囲のものとする
    int start[2] = {0, N/2}, term[2] = {N/2, N};
    
    for(int g=0; g<2; g++){
        int sz = term[g] - start[g];
        // 全列挙。1つ以上選ぶのでbits=0を見ない
        for(int bits=1; bits<(1<<sz); bits++){
            int s = 0, cost = 0;
            for(int i=0; i<sz; i++) if(nth_bit(bits, i)){
                s += Mb * a[i+start[g]] - Ma * b[i+start[g]];
                cost += c[i+start[g]];
            }
            if(C[g].count(s)){
                chmin(C[g][s], cost);
            }else{
                C[g][s] = cost;
            }
        }
    }

    // C[0][0], C[1][0], C[0][s] + C[1][-s] をそれぞれ調べる
    const int INF = 1e9;
    int ans = INF;
    for(int g=0; g<2; g++) if(C[g].count(0)) chmin(ans, C[g][0]);
    for(auto& p : C[0]){
        int s = p.first, c0 = p.second;
        if(C[1].count(-s)) chmin(ans, c0 + C[1][-s]);
    }
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use text_io::*;
use std::str::FromStr;

pub struct Scanner {
    buf: std::collections::VecDeque<String>,
}
impl Scanner {
    pub fn new() -> Self {
        Self {
            buf: std::collections::VecDeque::new(),
        }
    }
    fn scan_line(&mut self) {
        let mut flag = 0;
        while self.buf.is_empty() {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let mut iter = s.split_whitespace().peekable();
            if iter.peek().is_none() {
                if flag >= 5 {
                    panic!("There is no input!");
                }
                flag += 1;
                continue;
            }
            for si in iter {
                self.buf.push_back(si.to_string());
            }
        }
    }
    pub fn next<T: FromStr>(&mut self) -> T {
        self.scan_line();
        self.buf
            .pop_front()
            .unwrap()
            .parse()
            .unwrap_or_else(|_| panic!("Couldn't parse!"))
    }
    pub fn next_usize(&mut self) -> usize {
        self.next()
    }
    pub fn next_isize(&mut self) -> isize {
        self.next()
    }
    pub fn next_chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect()
    }
    pub fn next_string(&mut self) -> String {
        self.next()
    }
    pub fn next_char(&mut self) -> char {
        self.next()
    }
    pub fn next_float(&mut self) -> f64 {
        self.next()
    }
}
fn main() {
    let mut sc = Scanner::new();
    let h = sc.next_usize();
    let w = sc.next_usize();
    let k = sc.next_usize();

    let mut m = Vec::with_capacity(h);

    for _ in 0..h {
        let s = sc.next_chars();
        m.push(s);
    }

    let mut ans = 0;
    for hbit in 0..1 << h {
        for wbit in 0..1 << w {
            let mut black = 0;
            for i in 0..h {
                for j in 0..w {
                    if hbit & 1 << i == 0 && wbit & 1 << j == 0 && m[i][j] == '#' {
                        black += 1;
                    }
                }
            }

            if black == k {
                ans += 1;
            }
        }
    }

    println!("{}", ans);
}


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

int main() {
    long long n; cin >>n;
    long long ans = n + 1;
    for (long long i = 1; i*i <= n; i++) {
        if (i * (long long)(n/i) == n) ans = min(ans, i + (long long)(n/i) - 2);
    }
    cout << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import sys

sys.setrecursionlimit(10**6)
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def slv(N, A, UV):
    A.insert(0, -1)
    g = [list() for _ in range(0, N+1)]
    for u, v in UV:
        g[u].append(v)
        g[v].append(u)

    ans = [-1] * (N+1)
    ans[1] = 1
    dp = [INF] * (N+1)
    dp[0] = A[1]

    def dfs(u, p):
        for v in g[u]:
            if v == p:
                continue

            i = bisect.bisect_left(dp, A[v])
            b = dp[i]
            dp[i] = A[v]
            ans[v] = bisect.bisect_left(dp, INF)
            dfs(v, u)
            dp[i] = b

    dfs(1, 0)
    for i in range(1, N+1):
        print(ans[i])


def main():
    N = read_int()
    A = read_int_n()
    UV = [read_int_n() for _ in range(N-1)]
    slv(N, A, UV)


if __name__ == '__main__':
    main()


Measured memory_bytes: 381736
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


void solve(){
	char c;
	cin >> c;
	if(c>='A' && c<='Z')
		cout << "A" << endl;
	else{
		cout << "a" << endl;
	}
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 3640
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define mkp make_pair
//# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

using namespace std;

ll q , w , e , z ;


int main()
{
	speed;

    int n ;
    cin >> n ;
    int a[n];
    for(int i = 0 ; i < n ; i ++ ){
        cin >> a[i] ;
    }
    z+=1;
    for(int i = 1 ; i < n ; i ++ ){
            q = 0;
        for(int j = i ; j > -1 ; j -- ){
            if(a[j]>a[i]){
                q=1;
            }
        }
        if(q == 0 ){
            z++;
        }
    }

    cout<< z ;

	time;
}


Measured memory_bytes: 256