akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1000000000;
const int MOD = 1000000007;

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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<ll> cumsum(n+1, 0);
  rep(i, n){
    cumsum[i+1] = cumsum[i] + a[i];
  }

  map<ll, ll> mp;
  rep(i, n+1){
    mp[cumsum[i] % m]++;
  }

  ll ans = 0;
  for(auto itr : mp){
    ans += itr.second * (itr.second - 1) / 2;
  }

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


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

long long int h[200000];

int main(void){
    // Your code here!
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h,h+n);
    
    long long int sum=0;
    for(int i=n-1;i>=0;i--){
        if(k>0){k--;continue;}
        sum+=h[i];
    }
    cout<<sum;
    
    return 0;
    
}

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

using namespace std ;

const long long mod = 1e9 + 7ll ;
const int MAX = 100001 + 10  ;

int arr[MAX] ;
int n ;

vector<int>v ;
string s ;

long long dp[MAX][2] ;

long long solve(int idx , bool smaller)
{
	if(idx < 0)
		return 1ll ;
	long long &ret = dp[idx][smaller] ;
	if(ret != -1)
		return ret ;
	ret = 0 ;
	if(smaller == 1)
		ret = (3ll * solve(idx-1 , smaller)) % mod ;
	else
	{
		if(v[idx] == 0)
			ret = solve(idx-1 , smaller) ;
		if(v[idx] == 1)
			ret = (solve(idx-1 , 1) + solve(idx-1 , 0) * 2ll) % mod ;
	}
	return ret ;
}

int main()
{
	memset(dp , -1 , sizeof(dp)) ;
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>s ;
	for(int i = 0 ; i < s.size() ; ++i)
		v.push_back((s[i] - '0')) ;
	reverse(v.begin() , v.end()) ;
	return cout<<solve(v.size()-1 , 0)<<"\n" , 0 ;
}		

Measured memory_bytes: 7112
#include <iostream>

using namespace std;

int main()
{
	int score_a[4];
	int score_b[4];
	int sum_a, sum_b;
	
	cin >> score_a[0] >> score_a[1] >> score_a[2] >> score_a[3];
	cin >> score_b[0] >> score_b[1] >> score_b[2] >> score_b[3];
	sum_a = score_a[0] + score_a[1] + score_a[2] + score_a[3];
	sum_b = score_b[0] + score_b[1] + score_b[2] + score_b[3];
	
	if (sum_a > sum_b) cout << sum_a << "\n";
	else cout << sum_b << "\n";
	
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;   cin >> s;
    int tmp = 0;
    for (int i = 0; i < s.length(); i++) 
        tmp = (tmp + (s[i]-'0'))%9;
    if (tmp==0)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    return 0;
}   

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n, m;
    cin >> n >> m;
    ll a[m], sum = 0;
    for (ll i = 0; i < m; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    if (n >= sum)
        cout << n - sum << endl;
    else
        cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define ind(a) scanf("%d", &a)
#define inlld(a) scanf("%lld", &a)
#define ind2(a, b) scanf("%d%d", &a, &b)
#define inlld2(a, b) scanf("%lld%lld", &a, &b)
#define ind3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define inlld3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

using namespace std;

const int N=1e4+5;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

ll d, dp[N][100][2][2];
string s;
vector<ll>digs;

ll solve(ll i, ll mod, ll islesser, ll hasstarted)
{
    if(i==digs.size())
        return (mod==0 && hasstarted==1);
    if(dp[i][mod][islesser][hasstarted]!=-1)
        return dp[i][mod][islesser][hasstarted];
    if(islesser && hasstarted)
    {
        ll ret=0;
        for(ll a=0; a<=9; a++)
            ret=(ret+solve(i+1, (mod+a)%d, islesser, hasstarted))%MOD;
        // printf("%lld %lld %lld %lld %lld\n", i, mod, islesser, hasstarted, ret);
        return dp[i][mod][islesser][hasstarted]=ret;
    }
    if(islesser)
    {
        ll ret=0;
        ret+=solve(i+1, 0, 1, 0);
        for(ll a=1; a<=9; a++)
            ret=(ret+solve(i+1, (mod+a)%d, 1, 1))%MOD;
        // printf("%lld %lld %lld %lld %lld\n", i, mod, islesser, hasstarted, ret);
        return dp[i][mod][islesser][hasstarted]=ret;
    }
    ll ret=0;
    ret=solve(i+1, (mod+digs[i])%d, 0, 1);
    for(ll a=0; a<digs[i]; a++)
        ret=(ret+solve(i+1, (mod+a)%d, 1, 1))%MOD;
    // printf("%lld %lld %lld %lld %lld\n", i, mod, islesser, hasstarted, ret);
    return dp[i][mod][islesser][hasstarted]=ret;
}

int main() 
{
    cin>>s;
    cin>>d;
    ll x=s.length();
    for(ll a=0; a<x; a++)
        digs.pb((s[a]-'0'+0));
    memset(dp, -1, sizeof(dp));
    ll ans=0;
    ans=solve(1, 0, 1, 0);
    ans=(ans+solve(1, digs[0]%d, 0, 1))%MOD;
    for(ll a=1; a<digs[0]; a++)
        ans=(ans+solve(1, a%d, 1, 1))%MOD;
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 32512
n, m = [int(i) for i in input().split()]
dat = [[int(i) for i in input().split()] for i in range(n)]
dat.sort()
sum = 0
_m = 0
for i in dat:
    if _m + i[1] >= m:
        print(sum + i[0]*(m - _m))
        break
    _m += i[1]
    sum += i[0] * i[1]

Measured memory_bytes: 21604
class Heap
  def initialize(n, &block)
    @que = []
    @size = 0
    @cmp = block || lambda{ |a,b| a < b }
    (0...n).each do |x| push(x) end
  end

  def top
    @que[0]
  end

  def push(x)
    i = @size
    while i > 0 do
      j = (i - 1) / 2
      break unless @cmp.call(x, @que[j])
      @que[i] = @que[j]
      i = j
    end
    @que[i] = x
    @size += 1
  end

  def trim1
    x = @que[0]
    @update.call(x)
    i = 0
    while (ii = i * 2 + 1) < @size do
      j1 = ii
      j2 = ii + 1
      j1 = j2 if j2 < @size && @cmp.call(@que[j2], @que[j1])
      break unless @cmp.call(@que[j1], x)
      @que[i] = @que[j1]
      i = j1
    end
    @que[i] = x
  end

  def trim(l, &block)
    @update = block
    l.times do trim1 end
  end
end

n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
fs = gets.split.map(&:to_i)
 
l = as.inject(:+) - k

if (l <= 0)
  p 0
  exit
end

# O(n * log(n))
as.sort!
fs.sort_by! {|f| -f}

max_f = fs[0]

# O(n * log(n))
afs = as.zip(fs).sort_by do |a,f| a*f end

h = l * max_f * max_f
a_acc = 0
r_acc = 0

# O(n)
fs = afs.map do |a,f| f end
a_sums = afs.map do |a,f| a_acc += a end
rs = (n-1).downto(0).map do |i| r_acc += h / fs[i] end

t = nil
lm = 0

# O(log(n))
m = (0...n).bsearch do |i|
  next true if (i == n - 1)

  a_i, f_i = afs[i]
  af = a_i * f_i

  nn = n - i - 1
  ub = a_sums[i] + af * (rs[nn-1] + nn) / h
  lb = ub - nn

  next true if (lb >= l)

  if (ub < l)
    lm = i + 1
  else
    t = af
  end
  false
end

# O(n)
if (t)
  s = a_sums[m-1]
  (m...n).each do |i| s += t / fs[i] end
  t = nil if (s < l)
end

unless (t)
  nn = n - m
  ll = (m == 0) ? l: l - a_sums[m-1]
  t = [(ll + nn) * h / rs[nn-1], afs[m][0] * afs[m][1]].min
end

# O(n)
if (lm > 0)
  l -= a_sums[lm-1]
  n -= lm
  m -= lm
  fs = fs.drop(lm)
  afs = afs.drop(lm)
end

gs = []
# O(n)
(0...m).each do |i|
  a,f = afs[i]
  l -= a
  gs.push(a*f)
end
# O(n)
(m...n).each do |i|
  f = fs[i]
  a = t / f
  l -= a
  gs.push(a*f)
end

raise unless (l <= 0 && -l <= n)

if (l == 0)
  p gs.max
else
  # O(n * log(n))
  q = Heap.new(n) do |i,j| gs[i] > gs[j] end
  # O(n * log(n))
  q.trim(-l) do |i| gs[i] -= fs[i] end
  p gs[q.top]
end

Measured memory_bytes: 58272
#!/usr/bin/env python3

from itertools import combinations

def main():
    march = list("MARCH")
    di = {c: 0 for c in march}
    n = int(input())
    for i in range(n):
        s = input()
        c = s[0]
        if c in march:
            di[c] += 1
    res = 0
    for com in combinations(march, 3):
        x, y, z = com
        res += di[x] * di[y] * di[z]
    print(res)

main()


Measured memory_bytes: 3064
import sys

def cnt(n):
    m = str(n)
    l = len(m)
    if l == 1: return n + 1
    tot = 0
    tot += pow(10, (l - 1) // 2) * (int(m[0]) - 1)
    tot += pow(10, l // 2) - 1 - 9 * pow(10, l // 2 - 1) * (l & 1 ^ 1)
    while l >= 2:
        l -= 2
        if l == 0: tot += m[1] >= m[0]
        elif l == 1: tot += int(m[1]) + 1 - (m[-1] < m[0])
        else:
            m = str(int(m[1:-1]) - (m[-1] < m[0]))
            m = '0' * (l - len(m)) + m
            tot += int(m[0]) * pow(10, (l - 1) // 2)
    return tot

a, b = map(int, sys.stdin.readline().split())

def main():
    print(cnt(b) - cnt(a-1))

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include<algorithm>

using namespace std;

int main(){
    int a,b,c;cin>>a>>b>>c;
    int sum[3];
    sum[0]=10*a+b+c;
    sum[1]=a+10*b+c;
    sum[2]=a+b+10*c;
    int ans=sum[0];
    if(ans<sum[1])ans=sum[1];
    else if(ans<sum[2])ans=sum[2];
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

l = [0] * (n + 1)

for i in range(n, 0, -1):
    count = 0
    for j in range(n // i - 1):
        if l[i * (j + 2)] == 1:
            count += 1
    count %= 2
    if a[i - 1] != count:
        l[i] = 1

m = 0
b = []
for i in range(1, n + 1):
    if l[i] == 1:
        m += 1
        b.append(i)

print(m)
print(*b)

Measured memory_bytes: 71772
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;


// 68 11 55

int gcd(int a, int b) {
    while (b != 0) {
        auto na = a % b;
        a = b;
        b = na;
    }
    return a;
}


void oneCase() {
    int n;
    cin >> n;
    cout << "ABC" << n << '\n';
}


int main() {
    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}

ll fact(ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        res = (res * n) % mod;
        --n;
    }
    return res;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = [0] + list(map(int, input().split()))
C = [0] + list(map(int, input().split()))

ans=0
bk=-1
for a in A:
    if a-1==bk:
        ans+=C[bk]
    ans+=B[a]
    bk=a
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()



int main(){
    int n;
    cin>>n;
    map<string,vector<P>> mp;
    rep(i,n){
        string s;
        cin>>s;
        int a;
        cin>>a;
        mp[s].push_back({a,i+1});
    }
    for(auto x: mp){
        sort(etob(x.second));
        for(auto v: x.second){
            cout<<v.second<<endl;
        }
    }
}

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

using int64 = int64_t;

int main() {
  vector<int64> cap(5);
  int64 n;
  cin >> n;
  for (int i = 0; i < 5; ++i)
    cin >> cap[i];
  int64 m = *min_element(cap.begin(), cap.end());
  cout << (n / m) + (n % m > 0) + 4 << "\n";
  return 0;
}


Measured memory_bytes: 256
import sys
from itertools import combinations
from math import sqrt

read = sys.stdin.read
readline = sys.stdin.readline


def main():
    N, K, *xyc = map(int, read().split())
    x = xyc[::3]
    y = xyc[1::3]
    xy = list(zip(x, y))
    c = xyc[2::3]
    left = 0
    right = 10 ** 6
    delta = 0.1 ** 7
    while right - left > delta:
        mid = (left + right) / 2
        intersections = []
        r = [(mid / i) ** 2 for i in c]
        for i, j in combinations(range(N), 2):
            x1, y1 = xy[i]
            x2, y2 = xy[j]
            X = x2 - x1
            Y = y2 - y1
            XY = X ** 2 + Y ** 2
            r1 = r[i]
            r2 = r[j]

            a = (XY + r1 - r2) / 2
            b = XY * r1 - a ** 2
            if b < delta:
                continue
            b = sqrt(b)
            xi1 = (a * X + Y * b) / XY + x1
            yi1 = (a * Y - X * b) / XY + y1
            xi2 = (a * X - Y * b) / XY + x1
            yi2 = (a * Y + X * b) / XY + y1
            intersections.append((xi1, yi1))
            intersections.append((xi2, yi2))

        intersections.extend(xy)
        cnt = 0
        for X, Y in intersections:
            tmp = 0
            for (i, j), k in zip(xy, r):
                XY = (X - i) ** 2 + (Y - j) ** 2
                if XY < k + delta:
                    tmp += 1
            cnt = max(tmp, cnt)
            if cnt >= K:
                break
        if cnt >= K:
            right = mid
        else:
            left = mid

    print(right)


if __name__ == '__main__':
    main()

Measured memory_bytes: 44892
#include<bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0;i<n;i++)
typedef long long int ll;
int main(){
    ll n;
    cin>>n;
  	ll A[200000],p,q,r,s=0,i,j,k,ans=1e15;
    forn(i,n) cin>>A[i];
    p=A[0],q=0,r=A[1]+A[2],j=0,k=2;
    forn(i,n-3) s+=A[i+3];
    for(i=1;i<n-2;i++){
        q+=A[i],r-=A[i];
        while(abs(p-q)>abs(p-q+2*A[j+1])) p+=A[j+1],q-=A[j+1],j++;
        while(abs(r-s)>abs(r-s+2*A[k+1])) r+=A[k+1],s-=A[k+1],k++;
        ans=min(ans,max({p,q,r,s})-min({p,q,r,s}));
    }
    cout<<ans;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <ctype.h>

int main(void)
{
  char s1[10],s2[10],s3[10];

  scanf("%s %s %s",s1,s2,s3);

  printf("%c%c%c\n",toupper(s1[0]),toupper(s2[0]),toupper(s3[0]));

  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	map<int, int> ac, cnt;
	int n, m;
	cin >> n >> m;
	int ans = 0, pen = 0;
	rep(i, m){
		int a;
		string b;
		cin >> a >> b;
		if(b == "WA"){
			if(!ac[a]) cnt[a]++;
		}
		else{
			if(!ac[a]){
				ac[a] = 1;
				pen += cnt[a];
				ans++;
			}
		}
	}
	cout << ans << " " << pen << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 9600
s,*A=$<.read.split
C=(0..M=18).map{[s=0]*19}
A.map{|a|a=(a.to_r*10**9).to_i
i=j=0
i+=1until a[i]>0
i>M&&i=M
(j+=1;a/=5)until 0<a%5
j>M&&j=M
s+=C[M-i,19].sum{_1[M-j,19].sum}
C[i][j]+=1}
p s

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#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 << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	ll x, y, z, k; 
	cin >> x >> y >> z >> k;
	vector<ll> a(x), b(y), c(z);
	rep(i,x) cin >> a[i];
	rep(i,y) cin >> b[i];
	rep(i,z) cin >> c[i];

	// aとbの組なら全列挙出来る
	vector<ll> ab(0);
	rep(i,x){
		rep(j,y){
			ab.push_back(a[i]+b[j]);
		}
	}
	sort(ab.begin(),ab.end());
	int n = ab.size();

	// abにaとbの和が昇順に入っているがそこからどうしたらいいんだ
	// 各種族の最大値
	priority_queue<tuple<ll, int, int>> pque;
	rep(i,z){
		pque.push({ab[n-1]+c[i], n-1, i});
	}

	while(k--){
		auto X = pque.top();
		pque.pop();
		ll sum, ind_ab, ind_c;
		tie(sum, ind_ab, ind_c) = X;
		cout << sum << endl;
		sum -= ab[ind_ab];
		// ind_cは使わなそう
		if(ind_ab!=0){
			ind_ab--;
			sum += ab[ind_ab];
			pque.push({sum, ind_ab, ind_c});
		}
	}
}


Measured memory_bytes: 11624
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
/*
    vec1.size();
    str1.length();
    vec1.pop_back;
*/
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<pll> vplll;
#define rep(i,l,r) for (ll i = l; i < r; ++i)
#define reprev(i,l,r) for (ll i = r; i >= l; --i)
ll mod = 1e9+7;
ll expo_mod(ll x, ll y, ll p) 
{ 
    ll res = 1;
    x = x % p; 
    if (x == 0) 
        return 0; 
    while (y > 0) 
    {
        if (y%2==1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    double prob[n+1];
    rep(i,1,n+1)
    {
        cin>>prob[i];
        // prob[i]*=100;
    }
    double dp[n+1][n+1];
    rep(i,0,n+1)
    {
        rep(j,0,n+1)
        {
            if(i==0 && j==0)
            {
                dp[i][j]=1;
            }
            else if(j>i)
            {
                dp[i][j]=0;
            }
            else if(j==0)
            {
                dp[i][j]=dp[i-1][j]*(1-prob[i]);
            }
            else
            {
                dp[i][j]=dp[i-1][j]*(1-prob[i]) + dp[i-1][j-1]*prob[i];
            }
        }
    }
    double ans=0;
    rep(i,0,n+1)
    {
        if(i>n-i)
        {
            ans+=dp[n][i];
        }
    }
    // rep(i,0,n)
    // {
    //     ans/=100;
    // }
    cout << fixed << setprecision(10) <<ans<<endl; 
    // cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 70656
#include <stdio.h>
#include <string.h>
#define MAXL 10

int capitalA(char S[MAXL + 1]);

int checkC(char S[MAXL + 1]);

int checkSmall(char S[MAXL + 1]);

int main(void){
    char S[MAXL + 1];
    scanf("%s", S);

    if(capitalA(S) == 0){
        printf("WA\n");
    }else{
        if(checkC(S) == 0){
            printf("WA\n");
        }else{
            if(checkSmall(S) == 0){
                printf("WA\n");
            }else{
                printf("AC\n");
            }
        }
    }

    return 0;
}

int capitalA(char S[MAXL + 1]){
    return (S[0] == 'A')? 1 : 0;
}

int checkC(char S[MAXL + 1]){
    int numC = 0;
    for(int i = 2; i < strlen(S) - 1; i++){
        if(S[i] == 'C') numC++;
    }
    return (numC == 1)? 1 : 0;
}

int checkSmall(char S[MAXL + 1]){
    for(int i = 1; i < strlen(S); i++){
        if(S[i] == 'C') continue;
        
        if(!(S[i] >= 'a' && S[i] <= 'z')) return 0;
    }
    return 1;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
    class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' ').ToArray();
            Console.WriteLine(new Calu().calu(input1));
        }
        public class Calu{
            public string calu(string[] input1){
                string ss="";
                foreach(var s in input1){
                    ss+=s.Substring(0, 1);
                }
                ss = ss.ToUpper();
                return ss;
            }
        }
    }

Measured memory_bytes: 13268
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <sstream>
using namespace std;

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

int main() {
    string s;
    while(getline(cin,s) && s != "END OF INPUT") {
        int res = 0;
        rep(i,s.size()){
            if(s[i] == ' ') {
                cout << res;
                res = 0;
            } else {
                res ++;
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 1188
#include <stdio.h>
#include <stdlib.h>
int main(){
  int *s,n,i,j,tmp,ave;
  while(1){
    ave=0;
    scanf("%d",&n);
    if(n==0)break;
    s=malloc(n*sizeof(int));
    for(i=0;i<n;i++)
      scanf("%d",&s[i]);
    for(i=0;i<n;i++){
      for(j=n-1;j>i;j--){
	if(s[j]<s[j-1]){
	  tmp=s[j];
	  s[j]=s[j-1];
	  s[j-1]=tmp;
	}
      }
    }
    for(i=1;i<n-1;i++)   ave+=s[i];
    printf("%d\n",ave/(i-1));
    free(s);
  }
  return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define foru(i, a, b) for(int i = a; i <= b; i++) 
#define ford(i, a, b) for(int i = a; i >= b; i--) 
#define endl "\n"
#define scv(a, b, c) #a#b#c
#define com(a,b) a ## b

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef vector<pll> v2l;
typedef pair<char, int> pci;
typedef vector<pci> vci;

const int N = 1e6 + 1;
const int NN = 3e3 + 1;
const ll MOD = 998244353;
const ll oo = 1e18 + 7;
const int BASE = 10000;

class solve {
public: 
    solve() {
        int n;
        cin >> n;
        vector<ld> a(n + 1);
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
        }
        sort(a.begin() + 1, a.end());
        ld res = a[1];
        for (int i = 2; i <= n; i++) {
            res = (res + a[i]) / 2;
        }
        cout << res;
    }
};

int main() {
    #ifdef DEBUG
        com(fre, open) (scv(solve, ., inp), "r", stdin);
        com(fre, open) (scv(solve, ., out), "w", stdout);
    #endif
    ios_base::sync_with_stdio(1);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    solve kAN;
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <math.h>
using namespace std;

int main() {


  int x,a,b;

  cin >> x;

  for (int i=-130;i<130;i++){
    for (int j=-130;j<130;j++){
      long long tmp;
      tmp=pow(i,5)-pow(j,5);
      if (tmp==x){
        a=i;
        b=j;
      }
    }
  }
  
  cout << a << " " << b<<endl;
  
  return 0;


}

Measured memory_bytes: 4096
import scala.io.StdIn.{readLine, readInt}

object Main {
  def gcd(x:Long, y:Long):Long = if(y==0) x else gcd(y, x%y)
  def lcm(x:Long, y:Long) = (x/gcd(x,y))*y

  def main(args:Array[String]) = {
    val n = readInt
    val l = readLine.split(" ").map(_.toLong)
    var r = l(0)
    for(i<- 1 until n) {
      r = lcm(r,l(i))
    }
    println(r)
  }
}

Measured memory_bytes: 43984
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> 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: 3596
n = input()

keta_num = len(n)
keta1 = 9
keta2 = 900
keta3 = 90000


if keta_num == 6:
    print(keta1+keta2+keta3)
elif keta_num == 5:
    print(int(n) - 10000+1+keta1+keta2)
elif keta_num == 4:
    print(keta1+keta2)
elif keta_num == 3:
    print(int(n)-100+1+keta1)
elif keta_num == 2:
    print(keta1)
elif keta_num == 1:
    print(int(n)-1+1)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        System.out.println(solve(N, a));
    }
    public static String solve(int N, int[] a) {
        if (a[0] > 0) {
            return "-1";
        }
        BigInteger answer = BigInteger.ZERO;
        for (int i = 1; i < N; i++) {
            if (a[i-1]+1 < a[i]) {
                return "-1";
            }
            if (a[i-1]+1 == a[i]) {
                answer = answer.add(BigInteger.ONE);
                continue;
            }
            answer = answer.add(new BigInteger(Integer.toString(a[i])));
        }
        return answer.toString(10);
    }
}


Measured memory_bytes: 95612
from scipy.sparse import*
f=csgraph.johnson
t=map(int,open('/dev/fd/0').read().split())
n,m,l=t[:3]
m=m*3+3
for i in f(f(csr_matrix((t[5:m:3],(t[3:m:3],t[4:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]].clip(0,n)%n-1:print i

Measured memory_bytes: 31020
n = int(input())
s = input()
e = [0] * n
w = [0] * (n + 1)
e[0] = 1 if s[0] == 'E' else 0
w[0] = 0
w[1] = 1 if s[0] == 'W' else 0
for i in range(1, n):
    if s[i] == 'E':
        e[i] = e[i - 1] + 1
        w[i + 1] = w[i]
    else:
        e[i] = e[i - 1]
        w[i + 1] = w[i] + 1
min = float("inf")
for i in range(n):
    if min > e[-1] - e[i] + w[i]:
        min = e[-1] - e[i] + w[i]
print(min)

Measured memory_bytes: 73552
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<ctime>
#include<algorithm>
using namespace std;
const int MR=2000000;


int main(){
	char s[3][110];
	cin.getline(s[0],101);
	cin.getline(s[1],101);
	cin.getline(s[2],101);
	int index[3]={0},turn=0;
	while(s[turn][index[turn]]!=0){
		int t=index[turn];
		index[turn]++;
		turn=s[turn][t]-'a';
	}
	printf("%c\n",'A'+turn);
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=1e5+5;

int ara[MX];

int main(){
     int i, j, k;
     int n, l;
     cin >> n >> l;
     for(i=0; i<n; ++i){
          cin >> ara[i];
     }
     for(i=0; i+1<n; ++i){
          if(ara[i]+ara[i+1]>=l) break;
     }
     if(i>=n-1){
          cout << "Impossible" << endl;
          return 0;
     }
     cout << "Possible" << endl;
     for(j=0; j<i; ++j) cout << j+1 << " ";
     for(j=n-2; j>i; --j) cout << j+1 << " ";
     cout << i+1 << endl;
}


Measured memory_bytes: 4032
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def main():
    N = in_n()
    yaku = make_divisors(N)

    ans = 0
    for n in yaku:
        if n < N // n - 1:
            ans += N // n - 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9276
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n;
ll a[200005];
int main() {
  scanf("%lld", &n);
  for (ll i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  ll ans = 0, j = 2, k = a[1];
  for (ll i = 1; i <= n; i++) {
    while ((j <= n) && (k & a[j]) == 0)
      k ^= a[j++];
    k ^= a[i];
    ans += j - i;
  }
  printf("%lld\n", ans);
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<string> str(N);
	string str1, str2;
	int count = 0;

	for (int i = 0; i < N; i++) {
		cin >> str.at(i);

		if (i != 0) {
			str2 = str.at(i-1);
			str1 = str.at(i);
			if (str1.at(0) != str2.at(str2.size() - 1)) {
				cout << "No" << endl;
				count++;
              	break;
			}
		}
	}
	if (count == 0) {
		sort(str.begin(), str.end());
		for (int i = 1; i < N; i++) {
			if (str.at(i) == str.at(i - 1)) {
				cout << "No" << endl;
              	count++;
              	break;
			}
		}
	}
	if (count == 0)
		cout << "Yes" << endl;
}

Measured memory_bytes: 256
def call(n):
    """
    n: int
    output numbers that is multiple of 3 or include '3' (1 <= number <= n)
    
    >>> call(30)
     3 6 9 12 13 15 18 21 23 24 27 30
    """

    line = ''
    for i in range(1, n+1):
        x = i
        if x % 3 == 0:
            line += ' ' + str(i)
            continue
        while x > 0:
            if x % 10 == 3:
                line += ' ' + str(i)
                break
            x //= 10

    print(line)

if __name__ == '__main__':

    i = int(input())
    call(i)

Measured memory_bytes: 7708
#include <iostream>
#include <vector>
#include <iostream>
#include <cstdio>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
 
#define ll long long
#define pb push_back
#define vi vector<int>
#define sz(a) (int((a).size()))
#define mp make_pair
#define f first
#define s second
#define pii pair<int, int>
 
using namespace std;
 
const int mod = 998244353;
const int inf = (int)2e9;
const ll INF = (ll)2e18;
const int N = 100100;

int cnt[30];
string w;
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> w;
	for (int i = 0; i < sz(w); i++) {
		cnt[w[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		if (cnt[i] % 2) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = null;

		char answer = 'A';
		try {
			while ((line = br.readLine()) != null) {
				line = line.trim();
				if(line.indexOf(answer) != -1){
					if(line.indexOf(answer) == 0) answer = line.charAt(2);
					else answer = line.charAt(0);
				}
			}
			System.out.println(answer);
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

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

const long long INF = 1LL << 60;

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

    vector<pair<long long, long long>> p(N);
    long long max_dist = 0;
    set<pair<long long, long long>> candidates;

    //中心を真ん中にずらす
    for(int i=0; i<N; ++i){
        long long x, y;
        cin >> x >> y;
        p[i] = {x, y};

        long long dist = abs(x-5e8) + abs(y-5e8);

        if( max_dist < dist ){
            max_dist = dist;
            candidates.clear();
            candidates.insert({x, y});
        }else if( dist == max_dist){
            candidates.insert({x, y});
        }else{
            continue;
        }
    }

    unordered_map<long long, long long> hightest_y;
    unordered_map<long long, long long> lowest_y;

    for(int i=0; i<N; ++i){
        long long x = p[i].first;
        long long y = p[i].second;
        if( hightest_y.count(x) > 0 && y < hightest_y[x] ) continue;
        hightest_y[x] = y;

        if( lowest_y.count(x) > 0 && y > lowest_y[x] ) continue;
        lowest_y[x] = y;
    }


    long long ans = 0;
    for(auto p : candidates){
        long long cx = p.first;
        long long cy = p.second;
        for(auto hmp: hightest_y){
            long long x = hmp.first;
            long long y = hmp.second;
            ans = max( ans, abs(cx - x) + abs(cy - y) );
        }

        for(auto lmp: lowest_y){
            long long x = lmp.first;
            long long y = lmp.second;
            ans = max( ans, abs(cx - x) + abs(cy - y) );
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 22832
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        n: usize,
    }

    let mut res = 0;
    for i in 1..n + 1 {
        let mut j = i;
        while j <= n {
            res += j;
            j += i;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 2092
n, k = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7

s = input()		# 文字列の入力  abcdefg...

ans=0
for i in range(n-1):
	if s[i]==s[i+1]: ans+=1

ans = min(ans + (k*2), n-1)

print(ans)



Measured memory_bytes: 3316
A = [0, 0, 0, 0]
for i in range(3):
  x, y = map(int, input().split())
  A[x-1] += 1
  A[y-1] += 1
f = 0
for i in range(4):
  if A[i] == 3:
    print("NO")
    f = 1
    break
if f == 0:
  print("YES")

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int>E(n);
  vector<int>W(n);
  if(s[0] == 'W') W[0] = 1;
  else W[0] = 0;
  for(int i = 1;i < n;i++){
    W[i] = W[i-1];
    if(s[i] == 'W') W[i]++;
  }
  if(s[n-1] == 'E') E[n-1] = 1;
  else E[n-1] = 0;
  for(int i = n-2;i >= 0;i--){
    E[i] = E[i+1];
    if(s[i] == 'E') E[i]++;
  }
  int ans = 1e9;
  rep(i,n){
    if(i == 0) ans = min(ans,E[1]);
    else if(i == n-1) ans = min(ans,W[n-2]);
    else ans = min(ans,W[i-1]+E[i+1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    for (int i=0; i<n; i++) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}


Measured memory_bytes: 3232
import sys
input = sys.stdin.readline


Q = int(input())
Query = []
for _ in range(Q):
    N = int(input())
    A = list(map(int, input().split()))
    S = input().rstrip()
    Query.append((N, A, S))



def solve(N, A, S):
    Base = []
    for i in reversed(range(N)):
        s = S[i]
        a = A[i]
        if s == "0":
            for b in Base:
                a = min(a, a^b)
            if a:
                Base.append(a)
        else:
            for b in Base:
                a = min(a, a^b)
            if a:
                return False
                
    return True

for N, A, S in Query:
    print(0 if solve(N, A, S) else 1)

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

int main(){
  string s; cin >> s;
  vector<char> buf;
  for(char x : s){
    if(buf.size() != 0 && buf.back() == x){
      if(buf.back() == x) continue;
    }
    buf.push_back(x);
  }
  cout << buf.size() - 1 << endl;
  return 0;
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  long long ans = 0;
  bool ok = true;
  if(a == b && b == c && c == a && a%2 == 0) ok = false, ans = -1;
  if(a%2 || b%2 || c%2) ok = false;
  while(ok){
    int na = (b+c) / 2, nb = (c+a) / 2, nc = (a+b) / 2;
    a = na, b = nb, c = nc;
    if(a%2 || b%2 || c%2) ok = false;
    ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<bool> c(n+1,false);
    c.at(1)=true;
    int check=0;
for(int i=2;i<=sqrt(n);i++){
check=i*i;
while(check<=n){
    c.at(check)=true;
    check*=i;
}
}
for(int i=n;i>=1;i--){
    if(c.at(i)){
        cout<<i<<endl;
        return 0;
    }
}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		
		int x3 = y1 - y2 + x2;
		int y3 = x2 - x1 + y2;
		int x4 = y1 - y2 + x1;
		int y4 = x2 - x1 + y1;
		
		System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);
		
	}
}


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

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MAX_V=114514LL;
const ll MAX = 100010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

//const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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 COM(ll n, ll 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(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n;cin>>n;
  vl a(n+1);
  rep(i,n+1)cin>>a[i];
  COMinit();
  map<ll,ll>M;
  ll key=-1;
  rep(i,n+1){
    M[a[i]]++;
  }
  for(auto p:M){
    if(p.second==2)key=p.first;
  }
  ll id1=-1,id2=-1;
  rep(i,n+1){
    if(a[i]==key&&id1==-1){
      id1=i;
    }
    else if(a[i]==key){
      id2=i;
    }
  }
  ll point=id1-0+n-id2;
  for(ll i=1;i<=n+1;i++){
    if(point+1<i){
      cout<<COM(n+1,i)<<'\n';
    }
    else {
      ll ans=COM(n+1,i);
      ll d=COM(point,i-1);
      ans=ans+MOD-d;
      ans%=MOD;
      cout<<ans<<'\n';
    }
  }
}



Measured memory_bytes: 10624
#include<iostream>
	int n, count = 0;

	void f(int, int, int, int);
	int main()
	{
		while (std::cin >> n){
			count = 0;
			for (int a = 0; a <= 9; a++)
				for (int b = 0; b <= 9; b++)
					for (int c = 0; c <= 9; c++)
						for (int d = 0; d <= 9; d++)
							f(a, b, c, d);

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

	void f(int a, int b, int c, int d)
	{
		if (a + b + c + d == n)
		{
			count++;
		}
	}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int A, B, K;
  string S;
  cin >> A >> B >> S;
  K=0;
  for (int i=0; i<A; i++) {
    if (S.at(i)!='-') {
      K=K+1;
    }
  }
  if (S.at(A)=='-') {
    K=K+1;
  }
  for (int j=A+1; j<A+B+1; j++) {
    if (S.at(j)!='-') {
      K=K+1;
    }
  }
  if (K==A+B+1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main(){
  int N;
  cin>>N;
  int a[N];
  for(int i=0;i<N;++i){
    cin>>a[i];
  }
  sort(a,a+N,greater<int>());
  int alice=0;
  int bob=0;
  for(int i=0;i<N;++i){
    if(i%2==0){
      alice+=a[i];
    }
    else{
      bob+=a[i];
    }
  }
  cout<<alice-bob<<endl;
}
    


Measured memory_bytes: 3192
I=lambda:map(int,input().split())
N=0xfffff
n,q=I()
c=list(I())
Q=[]
R=range
for i in R(q):l,r=I();Q.append(l<<40|r<<20|i)
Q.sort()
A=[[]for i in R(N)]
for i in R(n):A[c[i]].append(i)
B=[0]*N
def P(i,x):
	i+=1
	while i<=n:B[i]+=x;i+=i&-i
for i in A:
	if i:P(i[0],1);i.reverse()
t=0
o=[0]*q
for x in Q:
	l=(x>>40)-1
	r=x>>20&N
	i=x&N
	while t<l:
		b=A[c[t]]
		P(b[-1],-1)
		b.pop()
		if b:P(b[-1],1)
		t+=1
	while r:o[i]+=B[r];r-=r&-r
	while l:o[i]-=B[l];l-=l&-l
for i in o:print(i)

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

def numal(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return numal(num//26-1)+chr(90)
    else:
        return numal(num//26)+chr(64+num%26)
      
ans = numal(N).lower()

print(ans)

Measured memory_bytes: 9176
#!/usr/bin/env python3

def dividors(n):
    res = []
    for i in range(1, n + 1):
        if n % i == 0:
            res.append(i)
    return res

def main():
    n = int(input())
    res = 0
    for i in range(1, n + 1):
        if i % 2 == 1 and len(dividors(i)) == 8:
            res += 1
    print(res)

main()


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

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

int main() {
  deque<char> ans;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    ans.push_back(s[i]);
  }

  int q;
  cin >> q;
  bool han = false;
  for (int que = 0; que < q; que++) {
    int mode;
    cin >> mode;
    if (mode == 1)
      han = !han;
    else {
      int f;
      char c;
      cin >> f >> c;
      if (f == 1 && !han || f == 2 && han) {
        ans.push_front(c);
      } else {
        ans.push_back(c);
      }
    }
  }

  while (!ans.empty()) {
    char res;
    if (!han) {
      res = ans.front();
      ans.pop_front();
    } else {
      res = ans.back();
      ans.pop_back();
    }
    cout << res;
  }
  cout << endl;
}


Measured memory_bytes: 896
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N;
    cin >> N;
    int time[N];
    int xy[N];
    int prex = 0,prey = 0,pretime = 0;
    for(int i = 0; i < N; i++){
        int t;
        cin >> t;
        time[i] = t - pretime;
        pretime = t;
        int a,b;
        cin >> a >> b;
        xy[i] = abs(prex - a) + abs(prey - b);
        prex = a;
        prey = b;
    }
    for(int i = 0; i < N; i++){
        if(time[i] < xy[i]){
            cout << "No" << endl;
            return 0;
        }
        else if(time[i] == xy[i]) continue;
        else if((time[i] - xy[i]) % 2 == 0) continue;
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<algorithm>
using namespace std;
int c[30];
int n;
int dp[11000][21];
int solve(int a,int b){
	if(a<=0)return 1;
	if(~dp[a][b])return dp[a][b];
	for(int i=1;i<=c[b];i++){
		if(!solve(a-i,(b+1)%(n*2)))return dp[a][b]=1;
	}
	return dp[a][b]=0;
}
int main(){
	int a;
	int b;
	while(scanf("%d",&a),a){
		n=a;
		scanf("%d",&b);
		for(int i=0;i<a*2;i++)scanf("%d",c+i);
		for(int i=0;i<=b;i++)for(int j=0;j<a*2;j++)dp[i][j]=-1;
		printf("%d\n",solve(b,0));
	}
}

Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <queue>

#define fori(x) for(int i=0;i<x;++i)

// cout << fixed << setprecision(10) << num << endl;

using namespace std;

int main(){
  long long h;
  cin>>h;
  
  if(h==1){
    cout<<1;
    return 0;
  }
  
  long long i=1,a=0;
  while(h>1){
    h/=2;
    a+=i;
    i*=2;
    if(h==1){
      a+=i;
    }
  }
  cout<<a;
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();

    let mut b = vec![Vec::new(); n];
    for i in 0..n {
        let a: usize = itr.next().unwrap().parse().unwrap();
        for _ in 0..a {
            let x: usize = itr.next().unwrap().parse().unwrap();
            let y: usize = itr.next().unwrap().parse().unwrap();
            b[i].push((x - 1, y));
        }
    }

    let mut ans = 0;
    for bit in 0..1 << n {
        let mut stat: Vec<usize> = vec![2; n];
        let mut ok = true;
        // たってる人
        for i in 0..n {
            if bit >> i & 1 == 1 {
                if stat[i] == 0 {
                    ok = false;
                }
                stat[i] = 1;
                for &(x, y) in b[i].iter() {
                    if (y == 0 && stat[x] == 1) || (y == 1 && stat[x] == 0) {
                        ok = false;
                    } else {
                        stat[x] = y;
                    }
                }
            }
        }
        for i in 0..n {
            if (bit >> i & 1 == 0) && stat[i] == 1 {
                ok = false;
            }
        }

        if ok {
            ans = std::cmp::max(ans, (bit as u32).count_ones());
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();

    let (n, m) = (line[0], line[1]);

    let mut wars: Vec<(i32, i32)> = Vec::new();

    for _ in 0..m{
        let line = read_as_vec::<i32>();
        wars.push((line[0], line[1]));
    }


    wars.sort_by_key(|x| (x.1, x.0));

    let mut ans: i32 = 1;
    let mut prev_cut = wars[0].1;
    for i in 1..m{
        if prev_cut <= wars[i].0{
            ans += 1;
            prev_cut = wars[i].1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 300005
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

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

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	//  WF("output.txt");
	DF("err.txt");

	int N;
	scanf("%d", &N);
	vector <int> w(N);
	for (int i = 0; i < N; i++) scanf("%d", &w[i]);
	int sum = accumulate(ALL(w), 0);
	int res = sum;
	int psum = 0;
	for (int i = 0; i < N; i++) {
		psum += w[i];
		res = min(res, abs(psum - (sum - psum)));
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256