akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define XX first
#define YY second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N;
int ans[214514];
vector<int> es[214514];
vector<int> mds[3];
vector<int> cls[3];

void Dfs(int v, int p, int col) {
  cls[col].eb(v);
  for (int u : es[v]) {
    if (u == p) continue;
    Dfs(u, v, 3-col);
  }
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> N;
  set<int> cand;
  reps(i, 1, N+1) {
    cand.insert(i);
    mds[i%3].eb(i);
  }

  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    es[a].eb(b);
    es[b].eb(a);
  }

  Dfs(0, 0, 1);
  assert(cls[1].size() + cls[2].size() == N);

  if (cls[1].size() > cls[2].size()) swap(cls[1], cls[2]);
  if (mds[1].size() > mds[2].size()) swap(mds[1], mds[2]);

  if (cls[1].size() <= mds[0].size()) {
    for (int v : cls[1]) {
      int t = mds[0].back(); 
      ans[v] = t;
      cand.erase(t);
      mds[0].pop_back();
    }

  } else {
    assert(mds[1].size() <= cls[2].size());
    assert(cls[2].size() <= mds[0].size() + mds[1].size());

    for (int t : mds[1]) {
      int v = cls[2].back(); 
      ans[v] = t;
      cand.erase(t);
      cls[2].pop_back();
    }
    for (int v : cls[2]) {
      int t = mds[0].back(); 
      ans[v] = t;
      cand.erase(t);
      mds[0].pop_back();
    }
  }

  rep(v, N) {
    if (!ans[v]) {
      assert(!cand.empty());
      int t = *cand.begin();
      ans[v] = t;
      cand.erase(t);
    }
  }

  rep(v, N) {
    if (v) cout << " ";
    cout << ans[v];
  }
  cout << endl;
}


Measured memory_bytes: 29848
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        if(a <= 8 && b <= 8) System.out.println("Yay!");
        else System.out.println(":(");
    }  
}

Measured memory_bytes: 23764
import java.util.ArrayList;
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
//		String s = sc.next();
//		int n = sc.nextInt();

		ArrayList<Integer> bingoCard = new ArrayList<>();

		for(int i=0;i<9;i++) {
			int a = sc.nextInt();
			bingoCard.add(a);
		}

		int n = sc.nextInt();
		for(int i=0;i<n;i++) {
			int b = sc.nextInt();
			for(int j=0;j<bingoCard.size();j++) {
				if(b==bingoCard.get(j)) {
					bingoCard.set(j, 0);
					break;
				}
			}
		}

		if((bingoCard.get(0)==0 && bingoCard.get(1)==0 && bingoCard.get(2)==0)||
			(bingoCard.get(3)==0 && bingoCard.get(4)==0 && bingoCard.get(5)==0)||
			(bingoCard.get(6)==0 && bingoCard.get(7)==0 && bingoCard.get(8)==0)||
			(bingoCard.get(0)==0 && bingoCard.get(3)==0 && bingoCard.get(6)==0)||
			(bingoCard.get(1)==0 && bingoCard.get(4)==0 && bingoCard.get(7)==0)||
			(bingoCard.get(2)==0 && bingoCard.get(5)==0 && bingoCard.get(8)==0)||
			(bingoCard.get(0)==0 && bingoCard.get(4)==0 && bingoCard.get(8)==0)||
			(bingoCard.get(2)==0 && bingoCard.get(4)==0 && bingoCard.get(6)==0)){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}


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

int main()
{
	string a,b,c;
	cin >> a >> b >> c;
	if (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n;
    cin>>n;
    int l=0;
    for(int i=1;i<=n;i++){
        if(i%2!=0){
            int p=0;
            for(int j=1;j<=i;j++){
                if(i%j==0)
                p++;
            }
            if(p==8)
            l++;
        }
    }
    cout<<l;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int k,n,over;
    cin >> k;
    n = min(k,500);
    over = k - n;
    vector<vector<int> > a(n, vector<int>(n, 0));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            int num = (i + j) % n + 1;
            if(num <= over){
                if(i % 2 == 1){
                    num += 500;
                }
            }
            a[i][j] = num;
        }
    }
    cout << n << '\n';
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j > 0) cout << " ";
            cout << a[i][j];
        }
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 2176
/////////////////////////////////////////Info/////////////////////////////////////////////////
//Problem:
//Date:
//Skill:
//Bug:
/////////////////////////////////////////Definations/////////////////////////////////////////////////
//循环控制
#define CLR(a) memset((a),0,sizeof(a))
#define F(i,a,b) for(int i=a;i<=int(b);++i)
#define F2(i,a,b) for(int i=a;i>=int(b);--i)
#define RE(i,n)  for(int i=0;i<int(n);i++)
#define RE2(i,n) for(int i=1;i<=int(n);i++)
//简化敲击
#define PII pair<int,int>
#define PLL pari<long long ,long long>
#define PB push_back
#define ENDL '\n'
#define x first
#define y second
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const long long llinf = 0x3f3f3f3f3f3f3f3f;
////////////////////////////////////////Options//////////////////////////////////////////////////////
#define stdcpph
#define CPP_IO

#ifdef stdcpph
#include<bits/stdc++.h>
#else
#include<ctype.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<map>
#include<algorithm>
#include<functional>
#ifdef CPP_IO
#include<iostream>
#include<iomanip>
#include<string>
#else
#include<stdio.h>
#endif
#endif
////////////////////////////////////////Basic Functions//////////////////////////////////////////////
template<typename INint> inline void IN(INint &x)
{
	x = 0; int f = 1; char c; cin.get(c);
	while (c<'0' || c>'9') { if (c == '-')f = -1; cin.get(c); }
	while (c >= '0'&&c <= '9') { x = x * 10 + c - '0'; cin.get(c); }
	x *= f;
}
template<typename INint> inline void OUT(INint x)
{
	if (x > 9)OUT(x / 10); cout.put(x % 10 + '0');
}
////////////////////////////////////////Added Functions//////////////////////////////////////////////
const int maxn = int(1e5+8);
vector<int>G[maxn],D[maxn];
int ans[maxn];
void dfs(int u, int p,int dis)
{
	ans[u] = dis;
	RE(i,G[u].size())if(p!=G[u][i])
		dfs(G[u][i], u, (dis + D[u][i])%2);
}
////////////////////////////////////////////Code/////////////////////////////////////////////////////
int main()
{
	//freopen("C:\\Users\\VULCAN\\Desktop\\data.in", "r", stdin);
	int T(1), times(0);
#ifdef CPP_IO// CPP_IO
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//cin >> T;
#else
	//IN(T);
#endif 
	/////////////////////////////////////////////////////////////////////////////////////////////////
	while (++times, T--)
	{
		int n; cin >> n;
		RE2(i, n-1)
		{
			int a, b; cin >> a >> b; int v; cin >> v;
			G[a].PB(b); G[b].PB(a); D[a].PB(v); D[b].PB(v);
		}
		dfs(1, 0,0);
		RE2(i, n)
			cout << (ans[i] & 1) << ENDL;
	}
	///////////////////////////////////////////////////////////////////////////////////////////////////
	return 0;
}

Measured memory_bytes: 15232
n=input()
n_=n
l=[]
for i in range(1,len(str(n))+1):
            w_i=int(n)%10
            if int(n)<10:
                        l.append(int(n))
                        break
            l.append(w_i)
            n=int(n)//10
            

s=sum(l)                        

if int(n_)%s==0:
            print('Yes')
else:
            print('No')




Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, A, B;
    cin >> N >> A >> B;
    if((B - A) % 2 == 0){
        cout << "Alice" << endl;
    }
    else{
        cout << "Borys" << endl;
    }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 45;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    ll K;
    cin >> N >> K;
    vector<ll> a(N); for (int i = 0; i < N; i++) cin >> a[i];

    vector<vector<ll> > dp(2, vector<ll>(MAX + 5));

    for (int i = 0; i <= MAX; i++) {
        ll d = MAX - i, flagNum = 0;
        ll p = pow(2, d);
        for (ll ai : a) {if ((ai & p) > 0) flagNum++;}
        ll nonFlagNum = N - flagNum;
        int curBit = (K & p) > 0;
        if (dp[0][i] != 0) {
            dp[0][i+1] = max(dp[0][i+1], dp[0][i] + p * flagNum);
            dp[0][i+1] = max(dp[0][i+1], dp[0][i] + p * nonFlagNum);
        }
        if (curBit) dp[0][i+1] = max(dp[0][i+1], dp[1][i] + p * flagNum);
        dp[1][i+1] = max(dp[1][i+1], dp[1][i] + p * (curBit ? nonFlagNum : flagNum));
    }

    cout << max(dp[0][MAX+1], dp[1][MAX+1]) << '\n';
}


Measured memory_bytes: 1024
import sys

input = sys.stdin.readline
N, K = map(int, input().split())

MOD = 10 ** 9 + 7

edges = [[] for _ in range(N)]
for _ in range(N -1):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

def P(n, r, MOD):
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret %= MOD
    return ret

def dfs():
    used = [0] * N
    ret = K
    stuck = [0]
    while stuck:
        v = stuck.pop()
        child_number = sum(not used[i] for i in edges[v])
        if not child_number:
            used[v] = True
            continue
        ret *= P(K - 2 + (v == 0), child_number, MOD)
        ret %= MOD
        used[v] = True
        for u in edges[v]:
            if used[u]:
                continue
            stuck.append(u)
    return ret

print(dfs())

Measured memory_bytes: 23596
from bisect import bisect_left

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = []
for _ in range(m):
	bc.append(list(map(int,input().split())))

a.sort()
bc = sorted(bc, key=lambda x:x[1])

l = [0 for _ in range(n+1)]
for i in range(1,n+1):
	l[i] = a[i-1]
for i in range(n):
	l[i+1] += l[i]

ans = l[-1]
num = 0
loop = 0

while True:
	if len(bc) == 0:
		break
	tmp = bc.pop()
	b = tmp[0]
	c = tmp[1]
	index = bisect_left(a,c) - num
	if index <= 0:
		break
	if b >= index:
		ans -= l[index+num] - l[num]
		ans += index * c
		num += index
		loop = index
	else:
		ans -= l[b+num] - l[num]
		ans += b * c
		num += b
		loop = b

print(ans)


Measured memory_bytes: 37716
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;
static const int N =1000;

int lcs(string X,string Y){
  int c[N+1][N+1];
  int m=X.size();
  int n=Y.size();
  int maxl=0;
  X=' '+X;
  Y=' '+Y;
  for(int i=0;i<=m;i++)c[i][0]=0;
  for(int j=1;j<=n;j++)c[0][j]=0;

  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(X[i]==Y[j]){
        c[i][j]=c[i-1][j-1]+1;
      }else{
        c[i][j]=max(c[i-1][j],c[i][j-1]);
      }
      maxl=max(maxl,c[i][j]);
    }
  }
  return maxl;
}

int main(){
  string s1,s2;
  int n;cin>>n;
  for(int i=0;i<n;i++){
    cin>>s1>>s2;
    cout<<lcs(s1,s2)<<endl;
  }
  return 0;
}



Measured memory_bytes: 7028
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort(reverse=True)

ans = h[0]

for i, j in zip(h[:-K + 1], h[K - 1:]):
    div = i - j
    if div == 0:
        ans = 0
        break
    if div < ans:
        ans = div

print(ans)


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

int main(){
	while(true){
		char S[101];
		cin >> S;
		if(S[0]=='0')
			break;
		int countA=0;
		int countB=0;
		
		for(int i=1;S[i]!='\0';i++){
			if(S[i]=='A')
				countA++;
			else if(S[i]=='B')
				countB++;
		}
		if(countA > countB)
			countA++;
		else if(countA < countB)
			countB++;

		cout << countA <<' '<< countB<<endl;
	}
	return 0;
}

Measured memory_bytes: 1144
n,m=map(int,input().split())
student=[]
for _ in range(n):
    a,b=map(int,input().split())
    student.append([a,b])

checkpoint =[]
for _ in range(m):
    c,d = map(int,input().split())
    checkpoint.append([c,d])

for i in range(n):
    s = student[i]
    dist = float('inf')

    num=0
    for j in range(m):
        c=checkpoint[j]
        tmp = abs(s[0]-c[0]) + abs(s[1]-c[1])

        if tmp < dist:
            dist = tmp
            num=j+1

    print(num)
        


Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
int main(){   
    string s;
    cin>>s;
    int n=s.size();
    for(int i=0;i<n;i++){
        if(s[i]=='A'&&s[i+1]=='C'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  DPT4
// 累積和を使う方法
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod = 1e9+7;
// mint
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
//istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
mint dp[3010][3010]={};
mint cum[3010]={};
int main(int argc, const char * argv[]) {
    int n;
    cin>>n;
    string s;
    cin>>s;
    rep(j,n){
        dp[1][j]=1;
    }
    cum[0]=0;
    for (int i=2; i<=n; i++) {
        for (int j=1; j<n-i+3; j++) cum[j]=cum[j-1]+dp[i-1][j-1];
        if(s.at(i-2)=='<'){
            rep(j,n-i+1) {
                dp[i][j]=cum[n-i+2]-cum[j+1];
            }
        }else{
            rep(j,n-i+1) {
                dp[i][j]=cum[j+1];
            }
        }
    }
    cout << dp[n][0]<<endl;
    return 0;
}


Measured memory_bytes: 49236
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N;
	cin >> N;
	int a[N];
	int sum = 0;
	rep(i, 0, N) {
		cin >> a[i];
		sum += a[i];
	}
	int mean = sum / N;

	int min_v = 1e9;
	for(int i = mean - 1; i <= mean + 1; i++) {
		int tmp_v = 0;
		rep(j, 0, N) {
			tmp_v += pow(a[j] - i, 2);
		}
		min_v = min(min_v, tmp_v);
	}

	cout << min_v << endl;


}


Measured memory_bytes: 256
N = int(input())

if N % 2 > 0 or N < 10:
  print(0)
  exit(0)
else:
  #S = str(N)[::-1]
  ans = 0
  N = N // 10
  for i in range(50):
    ans += N
    N = N // 5
    
print(ans)

Measured memory_bytes: 2940
#include <cstdio>
using namespace std;
int n,m,k,f[100010],fn[100010],cnt[100010],sum[100010],ans[100010];

int find(int x){return f[x]==x?x:f[x]=find(f[x]);}

void merge(int u,int v){
	int f1=find(u),f2=find(v);
	if(f1!=f2)f[f2]=f1;
}

int main(){
	int i,j,a,b;
	scanf("%d%d%d",&n,&m,&k);
	for(i=1;i<=n;i++)f[i]=i;
	for(i=1;i<=m;i++){
		scanf("%d%d",&a,&b);
		cnt[a]++,cnt[b]++,merge(a,b);
	}
	for(i=1;i<=n;i++)f[i]=find(i);
	for(i=1;i<=n;i++)fn[f[i]]++;
	for(i=1;i<=k;i++){
		scanf("%d%d",&a,&b);
		if(f[a]==f[b])sum[a]++,sum[b]++;
	}
	for(i=1;i<=n;i++)ans[i]=fn[f[i]]-cnt[i]-sum[i]-1;
	for(i=1;i<n;i++)printf("%d ",ans[i]);
	printf("%d\n",ans[n]);
	return 0;
}


Measured memory_bytes: 2944
#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 SORT(v, n) std::sort(v, v+n);
#define VSORT(v) std::sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };


int main(void)
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll n;
	vector<ll> a;
	cin >> n;
	REP(i, n) {
		ll tmp;
		cin >> tmp;
		a.pb(tmp);
	}

	int count = 0;
	while (true) {
		REP(i, n) {
			if (a[i] % 2 == 0) {
				a[i] /= 2;
			}
			else {
				cout << count << endl;
				return 0;
			}
		}
		count++;
	}

}

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

const int MAX = 510000;
const int MOD = 1000000007;

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

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

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  init_ncr();

  ll n,k;cin>>n>>k;
  vector<ll> A(n);
  for(ll i=0;i<n;i++)cin>>A[i];
  sort(A.begin(), A.end());

  ll ans =0;
  for(ll i=0;i<n;i++){
    if (n-i-1 < k-1)break;
    ans -= A[i] * ncr(n-i-1, k-1) % MOD;
    ans %= MOD;

    ans += A[n-i-1] * ncr(n-i-1, k-1) % MOD;
    ans %= MOD;
  }

  if(ans < 0) ans += MOD;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 13056
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    x = int(readline())

    if x < 600:
        print(8)
    elif x < 800:
        print(7)
    elif x < 1000:
        print(6)
    elif x < 1200:
        print(5)
    elif x < 1400:
        print(4)
    elif x < 1600:
        print(3)
    elif x < 1800:
        print(2)
    else:
        print(1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;



int main()
{
  ll f,N,H,x[101],y[101],h[101],kh;
  cin >> N;
  REP(i,N){
    cin >> x[i] >> y[i] >> h[i];
  }
  REP(Cx,101){
    REP(Cy,101){
      f = 1;
      kh = -1;
      vector<int> lis(0);
      REP(i,N){
        if(h[i] == 0){
          if(kh != -1){
            if((kh-abs(x[i]-Cx)-abs(y[i]-Cy) ) <= 0)
              continue;
            else{
              f = 0;
              break;
            }
          }else{
            lis.push_back(i);
            continue;
          }
        }
        else if(kh == -1)
          kh = abs(x[i]-Cx)+abs(y[i]-Cy) + h[i];
        else{
          if((abs(x[i]-Cx)+abs(y[i]-Cy) + h[i])!=kh){
            f = 0;
            break;
          }
        }
      }
      REP(i,lis.size()){
            if((kh-abs(x[lis[i]]-Cx)-abs(y[lis[i]]-Cy) ) <= 0)
              continue;
            else{
              f = 0;
              break;
            }
        }
      if(f && (kh>0)){
        cout << Cx << " " << Cy << " " << kh << endl;
        return 0;
      }
    }
  }
  return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <cmath>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define step(i, f, n, a) for(int (i) = (f); (i) < (n); (i)+=a)
#define rstep(i, f, n, a) for(int (i) = (f); (i) >= (n); (i)-=a)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

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

int main(){
	int n, count = 0;
	gets(n)
	int input[n];
	rep(i, n){
		gets(input[i])
	}
	sort(input, input+n);

	rep(i, n-1){
		if (input[i] == input[i+1]){
			count ++;
			// i ++;
		}
	}
	count = count%2 == 0 ? count:count+1;
	puts(n - count);
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(),m = sc.nextInt();
		if(m == 1) {
			System.out.println(0);
			return;
		}
		int[] x = new int[m];
		int[] xdif = new int[m-1]; //差
		int[] xidx = new int[2000001]; //どの差がどのインデックスか
		for(int i = 0;i < m;i ++) {
			x[i] = sc.nextInt();
		}
		Arrays.sort(x);
		for(int i = 0;i < m - 1;i ++) {
			xdif[i] = Math.abs(x[i+1] - x[i]);
			xidx[xdif[i]] = i;
		}
		Arrays.sort(xdif);
		int sum = 0;
		for(int i = 0;i < xdif.length - n + 1;i ++) {
			sum += xdif[i];
		}
		/*int len = xdif.length;
		int[] groupidx = new int[n-1];
		for(int i = 0;i < n - 1;i ++) {
			groupidx[i] = xidx[xdif[len - 1 - i]];
		}
		int sum = 0;
		for(int i = 0;i < n - 1;i ++) {
			int  g = groupidx[i];
			if(n == 2) {
				if(groupidx[i] == 0) {
					sum += x[x.length - 1] - x[g+1];
				}else {
					sum += x[g] - x[0];
					sum += x[x.length - 1] - x[g+1];
				}
			}else {
				if(i == 0){
					if(groupidx[i] != 0) {
						sum += x[g] - x[0];
					}
				}else if(i == n - 2) {
					sum += x[g] - x[groupidx[i-1]+1];
					sum += x[x.length - 1] - x[g+1];
				}else {
					if(groupidx[i - 1] != groupidx[i]) { //グループの要素数が１じゃないとき
						sum += x[g] - x[groupidx[i-1]+1];
					}
				}
			}
		}*/
		System.out.println(sum);
	}
}

Measured memory_bytes: 67528
#include<bits/stdc++.h>
using namespace std;
#define N 1000005
#define eps 1e-10
#define Pi acos(-1.0)
int n,m,len;
int a[N];
bool f[N];
char s[N];
int main()
{
	int T=1;
	//scanf("%d",&T);
	while(T--)
	{
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		n=a*a*b;
		if(n>=2*c)
		{
			double c1=c*2.0/b/a;
			double l=-eps,r=90.0+eps;
			while(l+eps<r)
			{
				double mid=(l+r)/2;
				if(b*cos((90-mid)/180*Pi)<=c1*cos(mid/180*Pi))
					l=mid;
				else
					r=mid;
			}
			printf("%.10f",90-l);
		}
		else
		{
			double c1=c*2.0/a/a-b;
			c1=b-c1;
			double l=-eps,r=90.0+eps;
			while(l+eps<r)
			{
				double mid=(l+r)/2;
				if(c1*cos((90-mid)/180*Pi)<=a*cos(mid/180*Pi))
					l=mid;
				else
					r=mid;
			}
			printf("%.10f",90-l);
		}
	}
}

Measured memory_bytes: 384
#include <stdio.h>

int main(){
    int i;
    long long n = 0;
    int d, e =0;
    double a, b, c  =0;
    scanf("%lld",&n);
    for(i = 0; i < n; i++){
        scanf("%d:%d",&d ,&e);
        a = (double)d * 30 + (double)e * 0.5;
        b = (double)e * 6;
        if ((b - a) >= 0 && 180 >= (b - a)){
            c = b - a;
        }
        else if ((a - b) >= 0 && 180 >= (a - b)){
            c = a - b;
        }
        else if ((b - a) > 180){
            b = 360 - b;
            c = a + b;
        }
        else if ((b - a) < 0){
            a = 360 - a;
            c = a + b;
        }
        if(c >= 0 && c < 30){
            printf("alert\n");
        }
        else if(90 <= c && c <= 180){
            printf("safe\n");
        }
        else{
            printf("warning\n");
        }
    }
    return (0);
}

Measured memory_bytes: 584
#include <iostream>

using namespace std;

const double EPS = 1e-10;

bool ok(double val) {
	return (val >= 0.0 ? val : -val) < EPS;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		double x[4], y[4];
		for (int j = 0; j < 4; j++)
			cin >> x[j] >> y[j];
		double xx1 = x[0]-x[1], xx2 = x[2]-x[3];
		double yy1 = y[0]-y[1], yy2 = y[2]-y[3];
		if (ok(xx1*yy2 - xx2*yy1))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNextInt()){
			int a=sc.nextInt();
			int b=sc.nextInt();
			if(a<0||b<0) break;
			System.out.println(Integer.toString(a+b).length());
		}
		sc.close();
	}
}

Measured memory_bytes: 20500
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    S = input()

    if N % 2 == 1:
        print('No')
    else:
        half = N // 2
        if S[0:half] == S[half:N]:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    solve()


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

#define INF_LL (int64)1e18
#define INF (int64)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

bool isPrime(::std::int64_t x){
  for (::std::int64_t i = 2; i*i <= x; ++i) {
    if (x % i == 0) return false;
  }
  return true;
}
int main(void) {
  int64 N, K;
  int64 R, S, P;
  string s;
  cin >> N >> K >> R >> S >> P >> s;
  int64 res = 0;
  REP(i, K) {
    int64 last = i;
    for (int64 j = i; j < N; j += K) {
      if (last == j-K && s[j-K] == s[j]) {
        continue;
      } else {
        last = j;
        switch (s[j]) {
          case 'r': res += P; break;
          case 'p': res += S; break;
          case 's': res += R; break;
        }
      }
    }
  }
  cout << res << endl;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
vector<int> x(10), y(10);
double dist(int i, int j){
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return sqrt(dx*dx+dy*dy);
}
int main() {
  int n;
  cin >> n;
  rep(i,n) cin >> x[i] >> y[i];
  double len = 0;
  rep(i,n)rep(j,i) len += dist(i,j);
 
  int num = 2;
  for(int i=n-1; i>=1; i--) num *= i;
  int fact = 1;
  for(int i=n; i>=1; i--) fact *= i;
  double ans = (len*num) / fact;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
int n;
int x[102],cnt=0;

int main(){
    
    ll n,m;
    cin>>n>>m;
    ll ans;
    if(n==1&&m==1)ans = 1;
    else if(n==1||m==1)ans = n*m-2;
    else ans = n*m-2*(n+m-2);
    cout<< ans <<endl;
return 0;
}

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

long long int N, a[114514], m, c, i;

int main(){
    scanf("%lld", &N);
    for(; i < N; ++i){
        scanf("%lld", a + i);
        m = max(m, a[i]);
    }
    for(i = 0; i < N; ++i){
        if(a[i] < m)++c;
        if(a[i] < m - 1)return puts("No") & 0;
    }
    if((c == 0) && (m == N - 1))return puts("Yes") & 0;
    puts(((c > m - 1) || (c < m * 2 - N)) ? "No" : "Yes");
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import static java.lang.System.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		long x = sc.nextInt();
		long GCD = Math.abs(x - sc.nextLong());
		for(int i = 1; i < n; i++) {
			long dist = Math.abs(x - sc.nextLong());
			GCD = gcd(GCD, dist);
		}
		out.println(GCD);
		
		out.close();
	}
	  private static long gcd(long m, long n) {
		    if(m < n) return gcd(n, m);
		    if(n == 0) return m;
		    return gcd(n, m % n);
		}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}

Measured memory_bytes: 21960
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
//int NUMOFDIV(int n) 素因数分解して+1してかける奴
int NUMOFDIV2(int n) {
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
	int a[5], min = 9, mini, sum = 0;
	rep(i, 5) {
		cin >> a[i];
		if ((a[i] % 10 != 0) &&(a[i] % 10 < min)) {
			min = a[i] % 10;
			mini = i;
		}
	}
	rep(i, 5) {
		if (i == mini)
			sum += a[i];
		else
			sum += ((a[i] + 9) / 10) * 10;
	}
	cout << sum;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=1;i<=n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
int n,ans=0;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for (int i=1;i<=n;i++){
    	int x,y;
    	cin>>x>>y;
    	ans+=y-x+1;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define bug cout<<"--------------"<<endl
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=1e9;
const ll llf=1e18;
const int mod=1e9+7;
const int maxn=1e5+10;
int n,m;
bool ck(int x){
	int k=m/x;
	if(k>=n) return 1;
	return 0;
}
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	int n,a,b;
	cin>>n;
	if(n==1){
		puts("Hello World");
	}else{
		cin>>a>>b;
		cout<<a+b<<endl;
	}
	return 0;
}


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

/*alias*/
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using ll=long long;

using namespace std;

/*input*/
int n;
int c[3];
/*funcs*/


/*main*/
int main(){
    cin>>c[0]>>c[1]>>c[2]>>n;
    sort(c,c+3);
    int sup1=n/c[2];
    int ans=0;
    for(int i=0;i<sup1+1;i++){
        int neon=n-i*c[2];
        int sup2=neon/c[1];
        for(int j=0;j<sup2+1;j++){
            int neoneon=neon-j*c[1];
            if(neoneon%c[0]==0){
                ans++;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

char data[1000000];

int solve(const char *S, int N) {
  vector<int> A(N);
  A[0] = N;
  int i = 1, j = 0;
  while (i < N) {
    while (i+j < N && S[j] == S[i+j]) ++j;
    A[i] = j;
    if (j == 0) { ++i; continue;}
    int k = 1;
    while (i+k < N && k+A[k] < j) A[i+k] = A[k], ++k;
    i += k; j -= k;
  }
  int ret = 0;
  REP(i,N ) {
    if(A[i] <= i) chmax(ret, A[i]);
  }
  return ret;
}
int main() {
  int N; scanf("%d", &N);
  scanf("%s", data);
  int ans = 0;
  REP(i,N) {
    int tmp = solve(data+i, N-i);
    chmax(ans, tmp);
    //    cout << i << " " << N-i << " " << tmp << " " << ans << endl;                           
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  double cost[22][22];
  double ans;
  cin>>n>>m;
  double l[22],a[22],b[22];
  for(int i=0;i<n;i++)
    cin>>l[i]>>a[i]>>b[i];

  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++){
      double x=l[i]-l[j];
      double y=a[i]-a[j];
      double z=b[i]-b[j];
      cost[i][j]=cost[j][i]=x*x+y*y+z*z;
    }

  
  for(int i=0;i<(1<<n);i++){
    int sum=0;
    double tmp=0;
    for(int j=0;j<n;j++)
      if(i>>j&1)sum++;
    if(sum!=m)continue;
    for(int j=0;j<n;j++){
      for(int k=j+1;k<n;k++){
	if(i>>k&1&&i>>j&1)tmp+=cost[j][k];
      }
    }
    ans=max(ans,tmp);
  }
  
  printf("%.10lf\n",ans);
  return 0;
}



Measured memory_bytes: 3292
#include<iostream>
#include <stdio.h>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include <cmath>
#include <limits>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

int main(){
double a,b,x;
cin>>a>>b>>x;
double ans;
double pi=acos(-1);
if(x>=(a*a*b/2)){
ans=atan((a*a*a)/(2*(a*a*b-x)));
ans=180*ans/pi;
ans=90-ans; 
}
else{
ans=atan((2*x)/(a*b*b));
ans=180*ans/pi; 
ans=90-ans;  
}

printf("%2.10f\n",ans);

 return 0;
}
/*
2 2 4

45.0000000000

12 21 10

89.7834636934

3 1 8

4.2363947991

*/

Measured memory_bytes: 256
#include<stdio.h>

/*
//Q4 time
int main(void){
    
    int data;
    int a,b,c;
    
    scanf("%d",&data);
    
    a = data / 3600;
    
    b = (data % 3600) / 60;
    
    c = (data % 3600) % 60;
    
    printf("%d:%d:%d",a,b,c);
    
    return 0;
}

*/


int main(void){
    
    int a,b;
    
    scanf("%d%d",&a,&b);
    
    if(a < b){
        printf("a < b\n");
    }else if(b < a){
        printf("a > b\n");
    }else{
         printf("a == b\n");
    }
}


Measured memory_bytes: 2072
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int64, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt64(scanner)
	}
	sort.SliceStable(aa, func(i, j int) bool {
		return aa[j] < aa[i]
	})
	var ans int64
	ans = aa[0]
	j := 1
	for i := 2; i < n; i++ {
		ans += aa[j]
		if i&1 == 1 {
			j++
		}
	}
	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 6340
n, q = map(int, input().split())
s = input()

ac = [0] * n

for i in range(1, n):
        if s[i-1:i+1]=="AC": ac[i] = 1
        ac[i] += ac[i-1]

for i in range(q):
        l, r = map(int, input().split())
        print(ac[r-1] - ac[l-1])

Measured memory_bytes: 9412
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  cin >> N;
  N = N%10;
  if(N==3)cout << "bon" << endl;
  else if(N==0||N==1||N==6||N==8)cout << "pon" << endl;
  else cout << "hon" << endl;
  
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
      
      
int main(){
   char a[3];
   int q=0;
   cin >> a[0] >> a[1] >> a[2];
   if(a[0] == '7'){q=1;}
  if(a[1] == '7'){q=1;}
  if(a[2] == '7'){q=1;}
  if(q==1){cout << "Yes" << endl;}else{cout << "No" << endl;}
}

Measured memory_bytes: 3584
#include <algorithm>
#include <iostream>
#include <numeric>

using namespace std;
using ll = long long;

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

int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];

  int ave = accumulate(a, a + n, 0) / n;

  int c1 = 0;
  rep(i, n) { c1 += (ave - a[i]) * (ave - a[i]); }
  int c2 = 0;
  rep(i, n) { c2 += (ave + 1 - a[i]) * (ave + 1 - a[i]); }

  cout << min(c1, c2) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll H, W;
  cin >> H >> W;
  vector<vector<char>> MAP(H + 2, vector<char>(W + 2, '#'));
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      cin >> MAP[i][j];
    }
  }
  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      cout << MAP[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>

int main(){
    int x,y,z;
    int max;
    scanf("%d",&z);
    while(z){
        max = 0;
        z *= z*z;
        for(x=1;x*x*x<z;x++){
            for(y=1;x*x*x+y*y*y<=z;y++){
                if(max<x*x*x+y*y*y)max=x*x*x+y*y*y;
            }
        }
        printf("%d\n",z-max);
        scanf("%d",&z);
    }
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long

void test_case()
{
    long n,k,i,j;
    cin>>n>>k;
    long h[n];
    for(long i=0;i<n;i++)
        cin>>h[i];
    vector<long> dp(n,INT_MAX);
    dp[0]=0;
    for(i=0;i<n;i++)
    {
        for(j=1;j<=k && (i+j)<n;j++)
        {
            dp[i+j]=min(dp[i+j] , dp[i]+abs(h[i+j]-h[i]));
        }
    }
    cout<<dp[n-1];
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


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

class Program {
    static void Main(string[] args) {
        int n = Cin.Ni();
        int m = Cin.Ni();
        int[] roadCount = new int[n];
        for (int i = 0; i < m; i++) {
            roadCount[Cin.Ni() - 1]++;
            roadCount[Cin.Ni() - 1]++;
        }
        foreach (var item in roadCount) {
            Console.WriteLine(item);
        }
    }
}


public class Cin {
    private static string[] s = new string[0];
    private static int i = 0;

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

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

    public static int Ni() {
        return int.Parse(Next());
    }

    public static long NextLong() {
        return long.Parse(Next());
    }

    public static double NextDouble() {
        return double.Parse(Next());
    }

}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define jam(t) cout<<"Case #"<<t<<": "
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 1000000007ll
#define sz 400005
#define bitcnt(x) __builtin_popcountll(x)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}


ll arr[sz];
void solve(){
    ll n,k;
    cin >> n >> k;
    for(ll i=1;i<=n;i++)
        arr[i] = i;
    for(ll i=1;i<=n;i++)
        arr[i]+=arr[i-1];
    ll an = 0;
    for(ll i=k;i<=n+1;i++){
        ll diff = ((arr[n]-arr[max(0ll,n-i)]-(arr[i-1]))+1ll);
      //  trace(arr[max(0ll,n-k)]);

        an+=diff;
        an%=mod;
    }
    g(an);

}
int main()
{
#ifndef ONLINE_JUDGE
input_from_file
#endif
 
    FASTIO
    cin.tie(NULL);
    fflush(stdout);
    ll t = 1;
   // cin >> t;
    for(ll tcase = 1;tcase <= t;tcase++){
        solve();
        
    }
return 0;
}

Measured memory_bytes: 5112
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'

//DP法
template <class T>
inline bool chmin(T &a, T b) //change minimum
{
        if (a > b)
        {
                a = b;
                return true;
        }
        return false;
}
template <class T>
inline bool chmax(T &a, T b) //change max
{
        if (a < b)
        {
                a = b;
                return true;
        }
        return false;
}

typedef long long ll; //64bit型
using namespace std;

// const long long INF = 1LL << 60; //無限大の値
int INF = 1000000;

int main()
{
        int N, L;
        cin >> N >> L;

        int ans = 0;

        if (L >= 0)
        {
                for (int i = 2; i <= N; i++)
                {
                        ans += L + i - 1;
                }
        }
        else if (L < 0 && N - 1 > -1 * L)
        {
                for (int i = 1; i <= N; i++)
                {
                        ans += L + i - 1;
                }
        }
        else
        {
                for (int i = 1; i < N; i++)
                {
                        ans += L + i - 1;
                }
        }

        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 256