akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {  
      int n,a;
      cin>>n>>a;
      int x=n*n;
      cout<<x-a;
    }
}
// 🍪 🍪 🍪


Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define  fo(i,n) for(ll i=0;i<n;i++)
#define rfo(i,n) for(ll i=n;i>=0;i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define pb push_back
#define deb(x) cout<< #x << " = "<<x<<endl;
#define F first
#define S second
#define MP make_pair
#define all(x) (x).begin(), (x).end()
void solve()
{
	ll n,c0,c1,c2,c3;
	c0=0;
	c1=0;
	c2=0;
	c3=0;
	cin>>n;
	fo(i,n){
		string s;
		cin>>s;
	
	if(s == "AC"){c0++;
	}
	else if(s == "WA")
	{
		c1++;
	}
	else if(s == "TLE")
	{
		c2++;
	}
	else if(s == "RE")
	{
		c3++;
	}
	}
	cout<<"AC x "<<c0<<endl;
	cout<<"WA x "<<c1<<endl;
	cout<<"TLE x "<<c2<<endl;
	cout<<"RE x "<<c3<<endl;
	
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	solve();
    return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

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

		while (true) {
			int judge = sc.nextInt();
			if (judge == 0)
				break;

			int[] score = new int[judge];
			int max = 0, min = 1000, sum = 0;

			for (int i = 0; i < judge; i++) {
				score[i] = sc.nextInt();
				sum += score[i];
				if (score[i] > max)
					max = score[i];
				if (score[i] < min)
					min = score[i];
			}

			System.out.println((sum - max - min) / (judge - 2));
		}
	}
}

Measured memory_bytes: 29124
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

bool compare_pair(pair<int, int> a, pair<int, int> b){
    return a.second < b.second;
}

int main(){
    int n;
    cin >> n;
    vector<pair<int,int> > v;

    for(int i = 0; i < n; i++){
        int x, l;
        cin >> x >> l;
        v.push_back(make_pair(x-l, x+l));
    }

    sort(v.begin(), v.end(), compare_pair);

    int cur = -(1e9);
    int count = 0;
    
    for(int i = 0; i < n; i++){
        if(cur > v[i].first){
            continue;
        }
        cur = v[i].second;
        count++;
    }

    printf("%d\n", count);

    return 0;

}

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

#define all(s) s.begin(), s.end()
#define vi vector<int>
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second

int n, m;
int a[100005];
int v[100005];

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        int u = a[i];
        while (u % 2 == 0) {
            v[i]++;
            u /= 2;
        }
    }

    long long lcm = a[1];
    for (int i = 2; i <= n; i++) {
        lcm = 1LL * lcm * a[i] / __gcd(lcm, (long long) a[i]);
        if (lcm > 2 * m) return cout << 0, 0;
    }
    int u = lcm;
    int p = 0;
    while (u % 2 == 0) {
        p++;
        u /= 2;
    } 
    for (int i = 1; i <= n; i++) {
        if (v[i] != p) {
            return cout << 0, 0;
        }
    }
    if (p == 0) return cout << 0, 0;
    //ans / lcm
    int ans = (2 * m / lcm + 1) / 2;
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int n, k;
int h[200001];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		cin >> h[i];
	}
	sort(h + 1, h + 1 + n);
	long long ans = 0;
	/*for (int i = n; i >= max(0,n-k+1); i--)
		h[i] = 0;*/
	for (int i = 1; i <= max(n-k,0); i++)
	{
		ans += h[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

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

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int n, m;

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	cin >> n >> m;
	if (n >= 10) cout << m << endl;
	else cout << m + 100 * (10 - n) << endl;
	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    m/=2;
    ll mn=min(n,m);
    ll ans=mn;
    n-=mn;
    m-=mn;
    m*=2;
    if(m>=4)
    ans+=m/4;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	char ch;cin>>ch;switch(ch){case('A'):{cout<<'T';break;}
	case('T'):{cout<<'A';break;}case('G'):{cout<<'C';break;}
	case('C'):{cout<<'G';break;}}
	return 0;
}

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

namespace io {
char buf[1<<21], *p1 = buf, *p2 = buf;
inline char gc() {
    if(p1 != p2) return *p1++;
    p1 = buf;
    p2 = p1 + fread(buf, 1, 1 << 21, stdin);
    return p1 == p2 ? EOF : *p1++;
}
#define G gc

#ifndef ONLINE_JUDGE
#undef G
#define G getchar
#endif

template<class I>
inline void read(I &x) {
    x = 0; I f = 1; char c = G();
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = G(); }
    while(c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = G(); }
    x *= f;
}

template<class I>
inline void write(I x) {
    if(x == 0) {putchar('0'); return;}
    I tmp = x > 0 ? x : -x;
    if(x < 0) putchar('-');
    int cnt = 0;
    while(tmp > 0) {
        buf[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while(cnt > 0) putchar(buf[--cnt]);
}

#define in(x) read(x)
#define outn(x) write(x), putchar('\n')
#define out(x) write(x), putchar(' ')

} using namespace io;

#define ll long long
const int N = 100010;

ll a;

int main() {
	read(a);
	outn(3LL * a * a);
}

Measured memory_bytes: 256
// written by : soumya_27
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define mod ((int)1e9+7)//998244353//((int)1e18+7)
#define M_PI 3.14159265358979323846
// #define maxx ((int)1e7+7)
#define pb push_back
#define ins insert
#define F first
#define S second
#define ins insert
#define pii pair <int , int>
#define lb lower_bound
#define ub upper_bound
#define usefile freopen("input.txt","r",stdin); freopen("ou(tp)ut.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test int t; cin >> t; while(t--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
int exp(int x,int y,int p){ int res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int add(int a, int b) {return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)     
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
using namespace std;
int fact[1000006];
// void facto() {fact[0] = 1; for(i=1 ; i<1000006 ; i++) fact[i] = mul(fact[i-1], i);}
// int ncr(int n, int r) { int res = fact[n]; res = mul(res, inv(fact[r])); res = mul(res, inv(fact[n-r])); return res;}
void solve()
{
    fast
    // test
    {
        int n, i, j, k, c = 0;
        cin >> n >> k;
        int a[n];
        for(i=0 ; i<n ; i++)
        	cin >> a[i];
        int st=1, en=(int)1e9, mid, ans = 0;
        while(st <= en)
        {
        	mid = (st+en)/2;
        	int c = 0;
        	for(i=0 ; i<n ; i++)
        	{
        		c += (a[i]/mid);
        		if(a[i]%mid == 0)
        			c--;
        	}
        	if(c <= k)
        	{
        		ans = mid;
        		en = mid-1;
        	}
        	else st = mid+1;
        }
        cout << ans << "\n";
    }
}

signed main()
{
    // time__("solve")
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5220
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MAX 10000001

static bool gosei[MAX];

void a() {
	for (int i = 2; i <= sqrt(MAX); i++)
		if (gosei[i] == false) {
			for (int j = 2, k = 0; (k = i*j) <= MAX; j++)
				gosei[k] = true;
		}
}

int c(int a) {
	if (a == 2)return 1;
	if (a % 2 == 0)return 0;
	for (int i = 3; i <= sqrt(a); i += 2)
		if (a%i == 0)
			return 0;
	return 1;
}

int main() {
	a();
	int b = 0;
	for (int a; cin >> a;) {
		//if (a < MAX) {
		//	if (!gosei[a])b++;
		//}
		//else
		b += c(a);
	}
	cout << b << endl;
	return 0;
}

Measured memory_bytes: 10924
import java.util.Scanner;


public class Main{

	static int[] memo;
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		memo = new int[n+1];
		System.out.println(function(n));
	}

	public static int function(int n) {
		if(n==0 || n==1) {
			memo[n] = 1;
			return 1;
		}

		if(memo[n]!=0) {
			return memo[n];
		}else {
			memo[n] = function(n-1) + function(n-2);
		}
		return memo[n];
	}

}

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


int main(){
	string input;
	cin >> input;
	int wins = 0;
	int loses = 0;
	for(int i=0;i<input.size();i++){
		if(i % 2 == 0){
			if(input[i] == 'g'){
			}else{
				loses ++;
			}
		}else{
			if(input[i] == 'g'){
				wins++;
			}else{
				
			}
		}
			
	}
	
	cout << wins - loses << endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
//#define for(i,n) for(int i=0;i<n;i++)
using namespace std;


const int M = 200005; 
const int INF = 0x3f3f3f3f;


int main()
{
	string s;
	cin >> s;
	string t,tt;
	int sum=1;
	t=s[0];
	int len=s.size();
	for(int i=1;i<len;i++) {
		tt="";
		tt+=s[i];
		if(tt!=t) {
			t=tt;
			sum++;
			//cout <<i<<" "<<t<<endl;
		}
		else {
			i++;
			if(i<len) {
				tt+=s[i] ;
				t=tt;
				sum++;
			}
			
			//cout <<i<<" "<<t<<endl;
		}	
	}
	cout << sum<<endl;
	return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    print(A - B * 2 if A - B * 2 >= 0 else 0)
    return



# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import itertools
n = int(input())
A = [int(i) for i in input().split()]
A_sum = [0]+list(itertools.accumulate(A))
"""累積和は単調増加
4パートに分ければいいので別ける箇所3点left,mid,rightを探す．
全探索はTLEなのでmidに関するループ探索を行うと，条件式からl,rは決まる．
今回の問題では差をなくすことが目的なので，0~l,l~iとi~r,r~nの差が小さい時がベスト
この条件のもと，lとrを決める．for文で書く場合break入れないとTLE

"""
ans = 10**9
P,Q,R,S = 0,0,0,0
l = 0
r = 2
for i in range(1,n):
    while(l<i and abs(A_sum[l]-(A_sum[i]-A_sum[l])) >= abs(A_sum[l+1]-(A_sum[i]-A_sum[l+1]))):
        #単調増加だから超えるような時はp,qの差が大きくなる時だよね
        l += 1
    while(r<n and abs((A_sum[n]-A_sum[r]) -(A_sum[r]-A_sum[i])) >= abs((A_sum[n]-A_sum[r+1])-(A_sum[r+1]-A_sum[i]))):
        r += 1
    P = A_sum[l]
    Q = A_sum[i]-P
    R = A_sum[r]-A_sum[i]
    S = A_sum[n]-A_sum[r]
    ans =min(ans,abs(max(P,Q,R,S)-min(P,Q,R,S)))
    

print(ans)

Measured memory_bytes: 24308
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
typedef long long int lli;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define JUGAD freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pb push_back
#define pf push_front
#define mp make_pair
#define ff first
#define ss second
#define N 1000001
using namespace std;

int main(){
    FAST;
    lli n;cin>>n;
    lli ans=0;
    for(lli i=1;i<n;i++){
        for(lli j=1;j<=n/i;j++){
            lli k=n-i*j;
            if(k>0){ans++;}
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3644
# python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
A = iln()

# dp[N][2]とする。
# dp[x]はA[x]までの合計の最大値
# dp(x,0)はA[x]で反転しなかった場合、dp(x,1)はA[x]反転した結果を格納
dp = [[0 for _ in range(2)] for _ in range(N+1)]
# dp[0][1]は無効とする(反転結果が格納されるのはdp[1][1]から)。
dp[0][1] = -1*INF
for i in range(N):
    # A[i]を反転しなかった場合の最大値をdp[i+1][0]に格納
    dp[i+1][0] = max(dp[i][0]+A[i], dp[i][1]-A[i])
    # A[i]を反転した場合の最大値をdp[i+1][1]に格納
    dp[i+1][1] = max(dp[i][0]-A[i], dp[i][1]+A[i])

# 最後の数字は反転できないため、dp[N][0]を出力する
print(dp[N][0])


Measured memory_bytes: 29092
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    string s;
    cin >> s;
    
    if (s[0] == 'S') {
        cout << "Cloudy" << endl;
    } else if (s[0] == 'R') {
        cout << "Sunny" << endl;
    } else {
        cout << "Rainy" << endl;
        
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int[] x = sc.nextIntArray(n);
    long min = Long.MAX_VALUE;
    for (int xc = 1; xc <= 100; xc++) {
      long sum = 0L;
      for (int xi : x) {
        sum += Math.pow(xi - xc, 2);
      }
      min = Math.min(min, sum);
    }
    System.out.println(min);
  }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int price, oneCoins;
  cin >> price >> oneCoins;

  if (price < oneCoins || price%500 == 0 || price%500 < oneCoins) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int>data(m);
    rep(i,n){
        int k ;
        cin >>  k;
        rep(j,k){
            int a;
            cin >> a;
            a--;
            data[a]++;
        }
    }
    int cnt = 0;
    rep(i,m){
        if(data[i] == n)cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
n = int(sys.stdin.readline())
a = [int(s) for s in sys.stdin.readline().split()]
a.sort(reverse=True)
a_sum = 0
b_sum = 0
for i in range(n):
    if i % 2 == 0:
        a_sum += a[i]
    else:
        b_sum += a[i]
print(a_sum - b_sum)

Measured memory_bytes: 38256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;
int main(){
  int N,Z,W;
  cin >> N >> Z >> W;
  int a[2000] = {};
  REP(i,N) cin >> a[i];
  if(N == 1) cout << abs(a[0] - W) << endl;
  else cout << max(abs(a[N-2]-a[N-1]),abs(a[N-1]-W)) << endl;
  return 0;
}


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

#ifdef DEBUG
#define debug(...) __VA_ARGS__
#else
#define endl '\n'
#define debug(...)
#endif
#define debugf(...) debug(printf(__VA_ARGS__))

const int N = 1e5 + 5;

int msd(int x) {
    int ans = 0;
    while (x > 0) {
        ans = x % 10;
        x /= 10;
    }
    return ans;
}

int lsd(int x) {
    return x % 10;
}

using ii = pair<int, int>;
using ll = long long;
map<ii, int> f;

int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n; cin >> n;

    ll ans = 0;
    for (int x = 1; x <= n; x++) {
        int m = msd(x);
        int l = lsd(x);
        ans += 2 * f[ii{m, l}];
        if (m == l) ans++;
        f[ii{l, m}]++;
    }

    cout << ans << endl;

    return 0;
%>

Measured memory_bytes: 3676
#include<bits/stdc++.h> 
using namespace std;
const int N = 10101;
char s[10];
int main() {
	int ans = 0;
	s[0] = s[1] = s[2] = 0;
	scanf("%s",s);
	for (int i = 0;i < strlen(s); i++) {
		if (s[i] == 'R'){
			int j = 0;
			while (s[i+j] == 'R')
				j++;
			ans = j;
			break;
		}
	}
	printf("%d",ans);
	return 0;
}

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

int main(){
  int L;
  cin >> L;
  double V;
  V = L*L*L;

  V /= 27.0;
  printf("%.12f\n", V);
  return 0;
}

Measured memory_bytes: 384
#template
from collections import Counter
def inputlist(): return [int(j) for j in input().split()]
#template
N = int(input())
ans = 0
li = ['0']*N
for i in range(N):
    s = list(input())
    s.sort()
    li[i] = ''.join(s)
c = Counter(li)
key = c.keys()
for i in key:
    if c[i] >= 2:
        ans += c[i]*(c[i]-1)//2
print(ans)

Measured memory_bytes: 19848
#include <iostream>
#include <limits>

using namespace std;

int main(int argc, char *argv[]) {
	int N, T;
	cin >> N >> T;

	int m = std::numeric_limits<int>::max();
	int benefit = 0;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int Ai;
		cin >> Ai;

		if (m > Ai) m = Ai;
		if (Ai - m == benefit) cnt++;
		else if (Ai - m > benefit) {
			benefit = Ai - m;
			cnt = 1;
		}
	}

	cout << cnt << endl;

	return 0;
}

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

using namespace std;

int main() {
    int a = 0, b = 0, c = 0, d = 0, e = 0, k = 0;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    cin >> k;
    if (a < b && b < c && c < d && d < e) {
        if (k < e - a || k < e - b || k < e - c || k < e - d) {
            cout << ":(" << endl;
        } else {
            cout << "Yay!" << endl;
        }
    } else {
        cout << ":(" << endl;
    }

}

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

const int N = 1e5 + 5;

int v[N];

int main() {
#ifdef HOME
	freopen("arc.in", "r", stdin);
	freopen("arc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n, x, l(0), ant(0);

	cin >> n;
	for (int i = 1; i <= n + 1; ++i) {
		cin >> x;
		if (x == i)
			++l;
		else 
			ant+= (l + 1) / 2,
			l = 0; }

	cout << ant << endl;

	return 0; }

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define repU(i,s,t) for(int i = (s); i <= (t); ++i)
#define repD(i,t,s) for(int i = (t); i >= (s); --i)
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) (((a)^(b)) & 1 ^ 1)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = 1e9 + 7;

ull nxt_sbset(ull s){
	ull tem = s + (s & -s);
	ull btm = (~tem & s) / (s & -s) >> 1;
	return btm | tem;
}

int n,a[305][305];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll s = 0;
	cin>>n;
	rep(i,n)rep(j,n){ cin>>a[i][j],s += a[i][j]; }
	s /= 2;
	rep(i,n)repU(j,i + 1,n - 1){
		bool f = 0;
		rep(k,n){
			if(a[i][j] > a[i][k] + a[k][j]){ cout<<-1<<'\n'; return 0; }
			if(!f && k != i && k != j && a[i][j] == a[i][k] + a[k][j]) s -= a[i][j],f = 1;
		}
	}
	cout<<s<<'\n';
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
	int K;
    cin >> N >> K;
	vector<int> ki(K);
	vector<int> num(10-K);
	for(int i=0; i<K; i++){
    	cin >> ki.at(i);
    }
	int count = 0;
	for(int i=0; i<10; i++){
    	int f = 0;
        for(int j=0; j<K; j++){
            if(i == ki.at(j)){
            	f = 1;
            }
        }
    	if(f == 0){
        	num.at(count) = i;
        	count++;
        }
    }
	int anser = 0;
	int ati5 = 0;
	int ati4 = 0;
	int ati3 = 0;
	int ati2 = 0;
	for(int i5=-1; i5<count; i5++){
      for(int i4=-1; i4<count; i4++){
        for(int i3=-1; i3<count; i3++){
          for(int i2=-1; i2<count; i2++){
            for(int i1=0; i1<count; i1++){
              	if(i5 == -1){
                	ati5 = 0;
                }else{
                	ati5 = num.at(i5);
                }
              	if(i4 == -1){
                	if(i5 == -1){
                		ati4 = 0;
                    }else{
                    	ati4 = num.at(0);
                    }
                }else{
                	ati4 = num.at(i4);
                }
              	if(i3 == -1){
                	if(i4 == -1 && i5 == -1){
                		ati3 = 0;
                    }else{
                    	ati3 = num.at(0);
                    }
                }else{
                	ati3 = num.at(i3);
                }
              	if(i2 == -1){
                	if(i3 == -1 && i4 == -1 && i5 == -1){
                		ati2 = 0;
                    }else{
                    	ati2 = num.at(0);
                    }
                }else{
                	ati2 = num.at(i2);
                }
				if(10000*ati5+1000*ati4+100*ati3+10*ati2+num.at(i1) >= N){
                	anser = 10000*ati5+1000*ati4+100*ati3+10*ati2+num.at(i1);
                	i1 = count;
                	i2 = count;
                	i3 = count;
                	i4 = count;
                	i5 = count;
                }
            }
          }
        }
      }
    }
	cout << anser << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> t(n);
  int sum=0; //元のかかる時間
  for(int i=0;i<n;i++){
    cin >> t.at(i);
    sum += t.at(i);
  }
  //cout << sum << endl;
  int m;
  cin >> m;
  vector<pair<int,int>> dr(m);
  for(int i=0;i<m;i++){
    cin >> dr.at(i).first >> dr.at(i).second;
  }
  
  for(int i=0;i<m;i++){
    cout << sum - t.at(dr.at(i).first-1) + dr.at(i).second << endl;
  }
  
  return 0;
}

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

int main() {
    int n; cin >>n;
    vector<int> A(100003,0); // -1 to 100001
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t; ++t; // t = 0 の場合を考慮する
        A[t-1]++;
        A[t]++;
        A[t+1]++;
    }
    int ret = 0;
    for (int i = 0; i < 100003; i++) ret = max(ret, A[i]);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 640
import os
import sys

import numpy as np


def solve(inp):
    FENWICK_TREE = []
    FENWICK_LOGN = []

    def fenwick_init(n):
        log_n = 0
        m = n
        while m:
            log_n += 1
            m >>= 1
        FENWICK_TREE.append(np.zeros(n + 1, dtype=np.int64))
        FENWICK_LOGN.append(log_n)
        return len(FENWICK_TREE) - 1

    def fenwick_add(ins, i, x):
        arr = FENWICK_TREE[ins]
        n = arr.size - 1
        while i <= n:
            arr[i] += x
            i += i & -i

    def fenwick_sum(ins, i):
        arr = FENWICK_TREE[ins]
        result = 0
        while i > 0:
            result += arr[i]
            i ^= i & -i
        return result

    def fenwick_lower_bound(ins, x):
        arr = FENWICK_TREE[ins]
        log_n = FENWICK_LOGN[ins]
        n = arr.size - 1
        sum_ = 0
        pos = 0
        for i in range(log_n, -1, -1):
            k = pos + (1 << i)
            if k < n and sum_ + arr[k] < x:
                sum_ += arr[k]
                pos += 1 << i
        return pos + 1

    n = inp[0]
    q = inp[1]
    aaa = inp[2:2 + n]
    ooo = inp[2 + n::3]
    lll = inp[3 + n::3]
    rrr = inp[4 + n::3]
    buf = []

    bid = fenwick_init(n)
    for i in range(n):
        fenwick_add(bid, i + 1, aaa[i])
    for i in range(q):
        if ooo[i] == 0:
            fenwick_add(bid, lll[i] + 1, rrr[i])
        else:
            buf.append(fenwick_sum(bid, rrr[i]) - fenwick_sum(bid, lll[i]))
    return buf


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8[:],)', cache=True)(solve)
    print('compiled', file=sys.stderr)

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(inp)
print('\n'.join(map(str, ans)))


Measured memory_bytes: 74428
#include <stdio.h>
#include <algorithm>
long long p = 1000000000;
long long l, r, m, t, k;
long long n, x, y, z, w;
long long a[200000];
int main() {
	l = p * p * (-1);
	r = p * p + 1;
	scanf("%lld%lld", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
		if (a[i] < 0)x++;
		if (a[i] == 0)y++;
		if (a[i] > 0)z++;
	}
	std::sort(a, a + n);
	while (r - l > 1) {
		m = (r + l) / 2;
		t = 0;
		if (m == 0) {
			t = x * z;
		}
		if (m > 0) {
			t = x * z + (x + z) * y + y * (y - 1) / 2;
			w = n - 1;
			for (long long i = x + y; i < n; i++) {
				while (a[w] * a[i] >= m)w--;
				if (w > i)t += w - i;
				else break;
			}
			w = 0;
			for (long long i = x - 1; i >= 0; i--) {
				while (a[w] * a[i] >= m)w++;
				if (w < i)t += i - w;
				else break;
			}
		}
		if (m < 0) {
			w = x - 1;
			for (long long i = n - 1; i >= x + y; i--) {
				while (w >= 0 && a[w] * a[i] >= m)w--;
				if (w >= 0)t += w + 1;
			}
		}
		if (t < k)l = m;
		else r = m;
	}
	printf("%lld\n", l);
}

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

int main() {
    long long int A[200];
    int i, X, N, count = 0;
    cin>>N;
    for (int j = 0; j < N; j++)
        cin>>A[j];
    X = 1;
    while (X != 0)
    {
        for (i = 0; i < N; i++)
        {
            if (A[i] % 2 != 0)
            {
                X = 0; break;
            }
            else
                A[i] /= 2;
        }
        if (X)
            count++;
    }
    cout<<count;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int l[m],r[m];
	for(int i=0;i<m;i++)
	{
		cin>>l[i]>>r[i];
	}
	int L=l[0],R=r[0];
	for(int i=1;i<m;i++)
	{
		if(l[i]>L)
		{
			L=l[i];
		}
		if(r[i]<R)
		{
			R=r[i];
		}
		if(L>R)
		{
			cout<<0;
			return 0;
		}
	}
	cout<<R-L+1; 
	return 0;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
P = list(map(int, input().split()))
memo = sum(P[:K])
ans = memo

for i in range(K, N):
    memo = memo - P[i-K] + P[i]
    ans = max(ans, memo)

print(K-1+((ans-K+1) - 0.5*((ans-K+1)-1)))


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

#define MAX_H 50
#define MAX_W 50
int h, w;
char s[MAX_H][MAX_W];

inline bool is_in_range(const int y, const int x) {
    return 0 <= y && y < h && 0 <= x && x < w;
}

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

int bfs() {
    queue<pair<int, pii>> que;
    que.push(make_pair(0, make_pair(0, 0)));
    s[0][0] = '#';
    while(!que.empty()) {
        int cost = que.front().first;
        pii now = que.front().second;
        que.pop();
        if(now.first == h - 1 && now.second == w - 1) return cost;
        cost++;
        REP(i, 4) {
            int ny = now.first + dy[i], nx = now.second + dx[i];
            if(is_in_range(ny, nx) && s[ny][nx] == '.') {
                s[ny][nx] = '#';
                que.push(make_pair(cost, make_pair(ny, nx)));
            }
        }
    }
    return -1;
}

int main() {
    cin >> h >> w;
    int ans = h * w;
    REP(j, h) {
        REP(i, w) {
            cin >> s[j][i];
            if(s[j][i] == '#') {
                ans--;
            }
        }
    }
    int cst = bfs();
    cout << (cst == -1 ? -1 : ans - cst - 1) << "\n";

    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 n = sc.nextInt();
        int k = sc.nextInt();
        char[] s = sc.next().toCharArray();

        s[k-1] = Character.toLowerCase(s[k-1]);

        for (char c : s)
            System.out.print(c);

        System.out.println();
    }
}

Measured memory_bytes: 23764
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>
#include <bitset>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

template<class T>
inline bool chmin(T &a, const T b) { return a > b && (a = b, true); }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int H, W;
	cin >> H >> W;

	vector<vector<int>> A(H, vector<int>(W));
	vector<vector<int>> B(H, vector<int>(W));
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> A[i][j];
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> B[i][j];

	const int offset = 6500;
	vector<bitset<offset * 2 + 1>> dp(W + 1);
	dp[0][offset] = 1;
	for (int i = 0; i < H; i++) {

		for (int j = 0; j < W; j++) {

			for (int k = 0; k <= 2 * offset; k++) {

				if (0 <= k + A[i][j] - B[i][j] && k + A[i][j] - B[i][j] <= 2 * offset) {
					dp[j + 1][k] = dp[j + 1][k] | dp[j][k + A[i][j] - B[i][j]];
				}
				if (0 <= k - A[i][j] + B[i][j] && k - A[i][j] + B[i][j] <= 2 * offset) {
					dp[j + 1][k] = dp[j + 1][k] | dp[j][k - A[i][j] + B[i][j]];
				}

			}

		}
		DMP(dp);

		if (i == H - 1) break;
		vector<bitset<offset * 2 + 1>> tmp(W + 1);
		for (int j = 1; j <= W; j++) {
			for (int k = 0; k <= 2 * offset; k++) {
				if (0 <= k + A[i + 1][j - 1] - B[i + 1][j - 1] && k + A[i + 1][j - 1] - B[i + 1][j - 1] <= 2 * offset) {
					tmp[j][k] = tmp[j][k] | dp[j][k + A[i + 1][j - 1] - B[i + 1][j - 1]];
				}
				if (0 <= k - A[i + 1][j - 1] + B[i + 1][j - 1] && k - A[i + 1][j - 1] + B[i + 1][j - 1] <= 2 * offset) {
					tmp[j][k] = tmp[j][k] | dp[j][k - A[i + 1][j - 1] + B[i + 1][j - 1]];
				}
			}
		}
		swap(tmp, dp);
		DMP(dp);

	}

	int ans = INF;
	for (int i = 0; i <= 2 * offset; i++) {
		if (dp[W][i]) chmin(ans, abs(i - offset));
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a += b;
    c += d;
    if(a < c) cout << "Right" << endl;
    else if(a > c) cout << "Left" << endl;
    else cout << "Balanced" << endl;
    
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int k=1;
    vector <ll> a(n);
    rep(i,n){
        cin >> a[i];
        if(a[i]==0){
            k=0;
        }
    }

    ll ans;
    ans=1;
    if(k!=0){
    rep(i,n){
        //cout << ans << endl;
        if(ans>1000000000000000000/a[i]){
            ans=-1;
            break;
        
        
        
        }
        ans*=a[i];
        
    }
    }
    if(k==0){
        ans=0;
    }

    cout << ans << endl;
    

    return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n, m;
    cin >> n >> m;
    priority_queue <int> q;
    FOR(i, 1, n)
    {
        int x;
        cin >> x;
        q.push(x);
    }
    FOR(i, 1, m)
    {
        int t = q.top();
        q.pop();
        q.push(t / 2);
    }
    ll res = 0;
    while(!q.empty())
    {
        res += q.top();
        q.pop();
    }
    cout << res;
    return 0;
}


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

int main() {
    int n,k;
    int num = 1;
    cin >> n >> k;
   
    for (int i = 0; i < n; i++) {
        if (num < k) {
            num *= 2;
        }
        else {
            num += k;
        }
    }
    cout << num << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void solve()
{
  int n,k;
  cin>>n>>k;
  int arr[n];
  
  for(int i=0;i<n;i++)
    cin>>arr[i];
  
  sort(arr,arr+n);
  long long ans=0;
  for(int i=0;i<k;i++)
    ans+=arr[i];
  
  cout<<ans<<endl;
}

int main()
{
solve();
}

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

int main(){
    string S;
    cin >> S;
    map<char,int> mp;

    long long ans = 0;
    for(int i=0;i<S.size();i++){
        ans += i - mp[S[i]];
        mp[S[i]]++;
    }

    cout << ans + 1 << endl;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename V>
class BIT {
public:
  // 1-origin
  vector<V> bit;
  int n;
  BIT (int n_)
  {
    n = n_;
    bit.resize(n + 1);
  }
  V sum(int i)
  {
    ++i;
    V s = 0;
    while (i > 0) {
      s += bit[i];
      i -= i & -i;
    }
    return s;
  }
  void add(int i, V x)
  {
    ++i;
    while (i <= n)
    {
      bit[i] += x;
      i += i & -i;
    }
    return ;
  }
  void set(int i, V x)
  {
    return add(i, x - bit[i]);
  }
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  const lli inf = 1LL << 60;
  lli n, k;
  while (cin >> n >> k) {
    vector<lli> a(n);
    each (i, a) cin >> i;
    each (i, a) i-= k;

    vector<lli> acc(n);
    acc[0] = a[0];
    for (int i = 1; i < n; ++i) {
      acc[i] = acc[i - 1] + a[i];
    }

    vector<pair<lli, int>> v;
    v.push_back(make_pair(0, 0));
    for (int i = 0; i < acc.size(); ++i) {
      v.push_back(make_pair(acc[i], i + 1));
    }
    stable_sort(v.begin(), v.end());

    lli sum = 0;
    BIT<lli> bit(v.size());
    each (i, v) {
      sum += bit.sum(i.second);
      // cout << i << ": " << bit.sum(i.second) << endl;
      bit.add(i.second, 1);
    }
    cout << sum << endl;
  }
  
  return 0;
}


Measured memory_bytes: 10604
A , B = map(int , input().split())

# A**2 - 2AK + K**2 = B**2 - 2BK + K**2
# 2(B - A)K = B**2 - A**2
# K = (A + B) / 2

K = (A + B) / 2

#下記で整数かどうかを判定
if K % 1 == 0:
    print(int(K))
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 2940
//Author : Siriuslight
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0),cout<<setprecision(10)<<fixed;
#define int long long
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const ll inf = 1e9+100, N = 1e3+5;
const ll INF = 1e18+100, MOD = 1e9+7;

ll powmod(ll a,ll b,ll m=MOD){ll r=1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}
ll power(ll a,ll b){ll r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
ll gcd(ll a,ll b){if(!b)return a;return gcd(b,a%b);}
ll inv(ll a, ll m = MOD){return powmod(a,m-2,m);}
ll lcm(ll a,ll b){return(a*b)/gcd(a,b);}

//ordered_set X;
//X.insert(3);
//X.order_of_key(3) no of elements less than 3
//*X.find_by_order(n) nth greatest element(0-indexed)

int h, w, dp[N][N];
char g[N][N];

int solve(int x, int y){
    if(x < 1 || x > h || y < 1 || y > w || g[x][y] == '#') return 0;
    if(x == h && y == w) return 1;
    int &res = dp[x][y];
    if(res != -1) return res;
    res = 0;
    res += solve(x + 1, y);
    res %= MOD;
    res += solve(x, y + 1);
    res %= MOD;
    return res;
}

int32_t main(){
    FIO;
    cin >> h >> w;
    for(int i = 1; i <= h; ++i){
        for(int j = 1; j <= w; ++j){
            cin >> g[i][j];
        }
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(1, 1);
}


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

int main(){
    string s;
    cin >> s;
    int n = s.length();

    vector<int> ans;
    ans.push_back(n);

    for(int i=1; i<n; i++){
        if(s[i-1] != s[i]){
            ans.push_back(
                max(i, n-i)
            );
        }
    }
    sort(ans.begin(),ans.end());
    //for(auto a : ans) cout << a << " ";
    //cout << endl;
    cout << ans[0] << endl;
    return 0;
}

Measured memory_bytes: 768
#include<stdio.h>

int main(void)
{
  char s[5],u,v,w,x;
  int a,b,c,d;
  scanf("%s",s);
  u = s[0];
  v = s[1];
  w = s[2];
  x = s[3];
  a = (int)u - 48;
  b = (int)v - 48;
  c = (int)w - 48;
  d = (int)x - 48;
  if(a+b+c+d==7)
    {
      printf("%d+%d+%d+%d=7\n",a,b,c,d);
      return 0;
    }
  else if(a+b+c-d==7)
    {
      printf("%d+%d+%d-%d=7\n",a,b,c,d);
      return 0;
    }
  else if(a+b-c+d==7)
    {
      printf("%d+%d-%d+%d=7\n",a,b,c,d);
      return 0;
    }
  else if(a-b+c+d==7)
    {
      printf("%d-%d+%d+%d=7\n",a,b,c,d);
      return 0;
    }
  else if(a+b-c-d==7)
    {
      printf("%d+%d-%d-%d=7\n",a,b,c,d);
      return 0;
    }
  else if(a-b+c-d==7)
    {
      printf("%d-%d+%d-%d=7\n",a,b,c,d);
      return 0;
    }
  else if(a-b-c+d==7)
    {
      printf("%d-%d-%d+%d=7\n",a,b,c,d);
      return 0;
    }
  else if(a-b-c-d==7)
    {
      printf("%d-%d-%d-%d=7\n",a,b,c,d);
      return 0;
    }
}


Measured memory_bytes: 128