akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
  bool is_prime[1000000];

  is_prime[0] = is_prime[1] = false;
  for(int i=2; i<1000000; i++){
    is_prime[i] = true;
  }

  for(int i=2; i*i<1000000; i++){
    if(is_prime[i]){
      for(int j=i*i; j<1000000; j+=i){
        is_prime[j] = false;
      }
    }
  }

  while(1){
    int n,count;
    cin >> n;
    if(n==0)
      break;

    while(1){
      count = 0;
      for(int i=0; i<=n/2; i++){
        if(is_prime[i]&&is_prime[n-i])
          count++;
      }
      cout << count << endl;
      break;
    }

  }
  return 0;
}



Measured memory_bytes: 4040
if __name__=="__main__":
        l1 = list(map(int,input().split(" ")))
        l2 = list(map(int,input().split(" ")))
        l = {i:0 for i in range(200001)}
        N = l1[0]
        K = l1[1]
        for i in range(N):
            l[l2[i]]+=1
        dict = sorted(l.values())
        condition = lambda t:t!=0
        fliter_dict = list(filter(condition,dict))
        if len(fliter_dict)<=K:
            print(0)
        else:
            print(sum(fliter_dict[0:(len(fliter_dict)-K)]))

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

using namespace std;

int main()
{string S; long long K;
 cin >> S >> K;
 char c = '1';
 for(int i = 0; i < min((long long)S.size(),K); i++)
 {if(S[i] != '1'){c = S[i]; break;}}
 
 cout << c <<endl;
 return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
typedef long long llong;

#define MAX 100001
const llong mod = 1000000000 + 7;

int main()
{
  int N, M;
  llong H[MAX];
  int a, b;
  vector<int> A[MAX];
  int ans = 0;

  scanf("%d%d", &N, &M);

  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &H[i]);
  }

  for (int i = 0; i < M; i++)
  {
    scanf("%d%d", &a, &b);
    A[a].push_back(b);
    A[b].push_back(a);
  }

  for (int i = 1; i <= N; i++)
  {
    vector<int> X = A[i];
    int flag = 1;
    for (int x : X)
    {
      if (H[x - 1] >= H[i - 1])
      {
        flag = 0;
        break;
      }
    }
    if (flag)
    {
      ans++;
    }
  }

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

  return 0;
}

Measured memory_bytes: 9668
#include <bits/stdc++.h>
using namespace std;
 
 
int main()
{
 
    int64_t x;
    cin>>x;

    int64_t cnt=0;
    int64_t money=100;
    while(money<x){
        money = money*1.01;
        cnt++;
    }

    cout<<cnt<<endl;

    return 0;
}   

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

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

    int n;
    cin >> n;
    vector<int> a(n);
    int maxa = 0;
    rep(i, n) {
        cin >> a[i];
        chmax(maxa, a[i]);
    }

    int d = maxa / 2;
    int diff = INF;
    int idx = 0;
    rep(i, n) {
        if (a[i] == maxa) continue;
        if (abs(d - a[i]) < diff) {
            idx = i;
            diff = abs(d - a[i]);
        }
    }

    cout << maxa << " " << a[idx] << endl;



    return 0;
}

Measured memory_bytes: 640
N = int(input())
l = []
m=0
a=0
r=0
c=0
h=0
for i in range(N):
    l.append(input()) 

for i in l:
    if i.startswith('M'):
        m+=1
    if i.startswith('A'):
        a+=1
    if i.startswith('R'):
        r+=1
    if i.startswith('C'):
        c+=1
    if i.startswith('H'):
        h+=1

print(m*a*r+m*a*c+m*a*h+a*r*c+a*r*h+r*c*h+m*r*c+m*r*h+m*c*h+a*c*h)
        

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

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		double a=in.nextDouble(),b=in.nextDouble(),c=Math.toRadians(in.nextDouble());
		double S=a*b*Math.sin(c)/2,L=a+b+Math.sqrt(Math.pow(a, 2)+Math.pow(b, 2)-(2*a*b*Math.cos(c))),H=2*S/a;
		out.printf("%f\n%f\n%f\n", S,L,H);
		out.flush();
	}
}



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

mt19937_64 llrand((int) chrono::steady_clock::now().time_since_epoch().count());

#define st first
#define nd second
#define pb push_back

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;

const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 2e5+5;

int n, ans[N], a[N];
vector<int> dp;
vector<int> adj[N];

void dfs(int u, int p, vector<int> &dp) {
 int l = lower_bound(dp.begin(), dp.end(), a[u]) - dp.begin();
 int cond1 = 0, cond2 = 0, place;

 if(l == dp.size()) cond1 = 1, dp.push_back(a[u]);
 else cond2 = 1, place = dp[l], dp[l] = a[u];

  ans[u] = dp.size();

 for(auto v : adj[u]) if(v != p) dfs(v, u, dp);

  if(cond1) dp.pop_back();
  if(cond2) dp[l] = place;

}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for(int i = 1; i <= n; i++) cin >> a[i];
  
  int u, v;
  for(int i = 0; i < n-1; i++) {
    cin >> u >> v;
    adj[u].pb(v);
    adj[v].pb(u);
  }
  dfs(1, -1, dp);
  for(int i = 1; i <= n; i++) cout << ans[i] << "\n";
}

Measured memory_bytes: 30436
def b_balanced_neighbors(N):
    """
    整数Nに対し、N頂点の無向グラフで、以下の条件を満たすものを1つ構成せよ。
    1. 単純かつ連結
    2. ∀S∈Z, ∀k, 頂点kに隣接する頂点の番号の値の和がS
    """

    # 非連結で、∀S∈Z, ∀k, 頂点kとそれに隣接する頂点の番号の値の和がS
    # を満たすグラフを考えると、この条件は補グラフが
    # 与えられた条件を満たすための十分条件となる。
    # この条件を考えると、{1, ..., N} を2つ以上のグループに分割する方法であって、
    # グループに含まれる辺の和がグループによらず一定となる方法を1つ見つければいい。
    # そのような方法が存在すれば、同じグループに属するような頂点間に辺を張った
    # グラフが上の条件を満たす。分割の方法例は以下のものがある。
    # Nが奇数: {1, N-1}, {2, N-2}, ..., {N} (和がN)
    # Nが偶数: {1, N}, {2, N-1}, ..., {N, 1} (和がN+1) (*)
    # 上の方法で構成されるグラフの補グラフはO(N**2)で構成可能である。
    pair_sum = N + 1 - (N % 2)
    ans_tmp = []
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            if i + j != pair_sum:
                # (*)で表された辺を除いたグラフを構成する
                ans_tmp.append((i, j))
    return '\n'.join([str(len(ans_tmp))] + [' '.join(map(str, a)) for a in ans_tmp])

N = int(input())
print(b_balanced_neighbors(N))

Measured memory_bytes: 3700
#include <stdio.h>
#include <stdlib.h>


struct node{
  struct node *R,*L,*oya;
  int s;
};
typedef struct node *tree;

tree run;


tree treeMinimum(tree x){
  while(x->L!=NULL) x =x->L;
  return x;
}

void make(int x){
  tree b=NULL;
  tree a=run;
  tree c;
  
  c=malloc(sizeof(struct node));
  c->s=x;
  c->L=NULL;
  c->R=NULL;

  while(a!=NULL){
    b=a;
    if(c->s < a->s){
      a=a->L;
    }
    else a=a->R;
  }

  c->oya=b;
  if(b==NULL) run=c;
  else{
    if(c->s < b->s){
      b->L=c;
    }
    else b->R=c;
  }
}

tree serch(int z){
  tree x=run;
  
  while(x!=NULL){
    if(x->s==z) return x;
    else if(z < x->s) x=x->L;
    else x=x->R;
  }
  return NULL;
}


tree treeSuccessor(tree x){
  tree y;
  
  if(x->R!=NULL) return treeMinimum(x->R);
  y=x->oya;
  while(y!=NULL&&x==y->R){
    x=y;
    y=y->oya;
  }
  return y;
}

void treeDelete(int x){
  tree a;
  tree b;
  tree z;

  z=serch(x);

  if(z->L==NULL || z->R==NULL) b=z;
  else b=treeSuccessor(z);

  if(b->L!=NULL) a=b->L;
  else a=b->R;

  if(a!=NULL) a->oya=b->oya;

  if(b->oya==NULL) run=a;
  else if(b==b->oya->L) b->oya->L=a;
  else b->oya->R=a;

  if(b!=z) z->s=b->s;
}



void in(tree x){
  if(x==NULL) return;
  in(x->L);
  printf(" %d",x->s);
  in(x->R);
}

void pred(tree x){
  if(x==NULL) return;
  printf(" %d",x->s);
  pred(x->L);
  pred(x->R);
}

int main(){
  int  i, data,x,find;
  char order[20];

  scanf("%d",&data);

  for(i=0;i<data;i++){
    scanf("%s",order);

    if(order[0]=='f'){
      scanf("%d",&x);
      if(serch(x)!=NULL) printf("yes\n");
      else printf("no\n");
    }
    
    else if(order[0]=='i'){
      scanf("%d",&x);
      make(x);
    }
    else if(order[0]=='p'){
      in(run);
      printf("\n");
      pred(run);
      printf("\n");
    }
    else if(order[0]=='d'){
      scanf("%d",&x);
      treeDelete(x);
    }
  }
  return 0;
}



Measured memory_bytes: 25228
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Gosu_Hiroo
 */

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin,  i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define readint ({int t;cin >> t;t;})
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}

template <typename T>
ostream& operator << (ostream& os, const vector<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

template <typename T>
ostream& operator << (ostream& os, const set<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

//#define int ll

class AAirportBus {
public:
    int T[101010];
void solve(std::istream& cin, std::ostream& cout) {
    int N, C, K;
    cin >> N >> C >> K;
    _for(i,N)cin >> T[i];
    sort(T, T+N);
    auto beg = 0;
    int c = C, curr = 0, ans =0;
    while(curr < N){
        c = C, beg = curr, ans ++;
        while(T[curr] <= T[beg] + K && c -- && curr < N){
            curr ++;
        }
    }
    cout << ans << endl;


}


};


#undef int
int main() {


	AAirportBus solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(0); ios::sync_with_stdio(0); out<<fixed<<setprecision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
string arr;
int d;
long long getsum(int ind,int sum,int flag,vector<vector<vector<long long> > >&dp){
	if(ind==arr.size()) {
		if(sum!=0&&sum==d) return 1;
		return 0;
	}
	if(dp[ind][sum][flag]!=-1) return dp[ind][sum][flag];
	int limit=9;
	if(!flag) limit=arr[ind]-'0';
	long long res=0;
	for(int i=0;i<=limit;i++){
		int a=i!=0?sum+1:sum;
		if(flag||i<limit){
			
			
			res+=getsum(ind+1,a,1,dp);
		}
		else res+=getsum(ind+1,a,0,dp);
	}
	dp[ind][sum][flag]=res;
	return res;
	
	
}
int main() {
	
		
		cin>>arr;
	    cin>>d;
	
		
		
		
			vector<vector<vector<long long> > >dp(arr.size()+1,vector<vector<long long> >(102,vector<long long>(2,-1)));
		long long u=getsum(0,0,0,dp);
		
		
		cout<<u<<endl;
		
		
	
	
	return 0;
}

Measured memory_bytes: 4188
#include <stdio.h>
int main(){
  int x;
  scanf("%d", &x);
  long long int arr[x], max = 1e18, prod = 1, flag = 0, zero = 0;
  
  for (int i = 0; i < x; i++) {
    scanf("%lld", &arr[i]);
    flag = (arr[i] > max) ? 1 : flag;
    prod *= arr[i];
    (arr[i]) ? max /= arr[i] : zero = 1;
  }
  (zero) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));
  return 0;
}

Measured memory_bytes: 3872
def triangle?(a, b, c)
    return false if a + b <= c
    true
end

sankaku = 0
eikaku = 0
chokaku = 0
donkaku = 0
end_flg = false

loop do
    line = gets
    if line == "\n"
        break;
    end
    next if end_flg
    a, b, c = line.split.map(&:to_i).sort

    if !triangle?(a, b, c)
        puts "#{sankaku} #{chokaku} #{eikaku} #{donkaku}"
        end_flg = true
        break;
    end

    sankaku += 1
    if a**2 + b**2 > c **2
        eikaku += 1
    elsif a**2 + b**2 == c **2
        chokaku += 1
    else
        donkaku += 1
    end
end




Measured memory_bytes: 6872
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto S = sread();
    auto K = "keyence";
    foreach (i; 0 .. S.length + 1)
        foreach (j; i .. S.length + 1)
        {
            if (K == S[0 .. i] ~ S[j .. $])
            {
                writeln("YES");
                return;
            }
        }
    writeln("NO");
}


Measured memory_bytes: 636
#include<stdio.h>

int main(void){
    int W, H, x, y, r;
    scanf("%d", &W);
    scanf("%d", &H);
    scanf("%d", &x);
    scanf("%d", &y);
    scanf("%d", &r);

    if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){printf("Yes\n");}
    else{printf("No\n");}

    return 0;

}


Measured memory_bytes: 2148
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//  
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

template<class T> inline bool chmin(T& a, T b){ if(a>b){a=b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b){ if(a<b){a=b; return 1;} return 0;}

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;

//#define __DBG__


void solve(void){
  
  string S;
  
  cin >> S;
    
  vector<string> A={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  
  int ans;
  
  REP(i,7){
    if(S==A[i]){
      ans = 7-i;
      cout << ans << endl;
    }
  }
  return;
   
}


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

    solve();
 
    return 0;
}


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

int main() {
	int N,K,x = 1;
  cin >> N >> K;
  for(int i;i < N;i++){
    if(x >= K){
      x += K;
    }else{
      x *= 2;
    }
  }
  cout << x << endl;
}

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

int main() {
	int N;
	string S;
	string T;
    cin>>N;
	cin>>S;
	cin>>T;
	
	for(int i=0;i<N;i++){
		cout<<S.at(i);
		cout<<T.at(i);
	}
	cout<<endl;

	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a>b){
    printf("a > b\n");
  }else if(a<b){
    printf("a < b\n");
  }else if(a == b){
    printf("a == b\n");
  }
  return 0;
}



Measured memory_bytes: 2044
#include <algorithm>
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;
using ll = long long;

ll big( ll base, ll b ){
    ll ans = 1;
    while( b ){
        if( b%2 ){
            ans = (ans*base)%MOD;
        }
        base = (base*base)%MOD;
        b >>= 1;
    }
    return ans%MOD;
}


int main(){
    ll n, a, b;
    while( cin >> n >> a >> b ){
        ll ans = big( 2 , n );
        ans = (ans-1);
        ///cout << ans << " ans\n";
        if( ans < 0 ){
            ans = (ans+MOD);
        }
        ans = ans%MOD;
        ll N = n, K = a;
        ll res = 1;
        for( ll i = 1; i <= K; i++ ){
            res = (res*N)%MOD;
            N--;
            res = (res*big( i , MOD-2 ))%MOD;
        }
        res += MOD;
        ///cout << res%MOD << endl;
        ///cout << "res " << res << "\n";
        N = n;
        K = b;
        ll res1 = 1;
        for( ll i = 1; i <= K; i++ ){
            res1 = (res1*N)%MOD;
            N--;
            res1 = (res1*big( i, MOD-2 ))%MOD;
        }
        ///cout << res1 << endl;
        res = (res+res1)%MOD;
        cout << (ans-res+MOD)%MOD << endl;
    }
}


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

using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
vector<int>v[maxn];
int n,m;
int main()
{
	cin>>n>>m;
	int a,b;
	priority_queue<int>que;
	for(int i=1;i<=n;i++)
	{
		cin>>a>>b;
		if(a>m)
			continue;
		v[m-a+1].push_back(b);//m-a+1天之后不能在做这份工作了	
	}
	ll mon = 0;
	for(int i=m;i>=1;i--)
	{
		for(int M:v[i])
		{
			que.push(M);	
		} 
		if(!que.empty())
		{
			mon+=que.top();
			que.pop();
		}
	}
	cout<<mon<<endl;
	return 0;
 } 

Measured memory_bytes: 5632
// D - Candy Distribution

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

ll A[100000];
ll cum_A[100001];
unordered_map<int, ll> mod_cnt;

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

	for (int i=0; i<N; i++) {
		cin >> A[i];
		cum_A[i+1] = cum_A[i] + A[i];
	}

	for (int i=0; i<=N; i++) {
		mod_cnt[cum_A[i] % M]++;
	}

	ll ans = 0;

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

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8048
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<62;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	ll x;double p;cin>>x>>p;
	double ans;
	if(x%2==0){
		ans=(100.0/p)*(double)(x/2.0);
	}else{
		ans=(p/100.0)*((100.0/p)*(double)((x-1.0)/2.0)+1)+((100.0-p)/100.0)*((100.0/p)*(double)(x+1.0)/2.0+1);
	}
	printf("%.10f\n",ans);
}

Measured memory_bytes: 256
use itertools::Itertools;
use proconio::input;

fn main() {
    input!(n: usize, k: usize, a: [i64; n]);

    let ans = solve(n, k, a)
        .iter()
        .fold(1, |acc, &a| (acc * a).rem_euclid(1_000_000_007));

    println!("{}", ans)
}

fn solve(n: usize, k: usize, a: Vec<i64>) -> Vec<i64> {
    if n == k {
        return a;
    }
    let (pos, neg) = a
        .iter()
        .sorted_by(|a, b| b.abs().cmp(&a.abs()))
        .partition::<Vec<i64>, _>(|&&a| a >= 0);
    let (pl, nl) = (pos.len(), neg.len());

    if pl == 0 && k % 2 == 1 {
        return neg.into_iter().skip(n - k).collect_vec();
    }

    let mut pi = 0;
    let mut ni = 0;
    let mut rest = k;
    let mut ret = Vec::new();
    while rest > 0 {
        let push_p = if pi + 1 < pl && ni + 1 < nl {
            pos[pi] * pos[pi + 1] >= neg[ni] * neg[ni + 1]
        } else {
            !(ni + 1 < nl)
        };

        if push_p || rest == 1 {
            ret.push(pos[pi]);
            pi += 1;
            rest -= 1;
        } else {
            ret.extend(&neg[ni..=ni + 1]);
            ni += 2;
            rest -= 2;
        }
    }

    ret
}


Measured memory_bytes: 10396
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

cnt, ans = set(), 0
for i, ti in enumerate(t):
    if (i - k in cnt) and ti == t[i - k]:
        continue
    ans += r * (ti == 's')
    ans += s * (ti == 'p')
    ans += p * (ti == 'r')
    cnt.add(i)
print(ans)


Measured memory_bytes: 81928
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

#if __has_include("debug.hpp")
#include "debug.hpp"
#else
template<typename T>
void debug(T& obj) {}
#endif

template<typename T>
T in(){
	T val;
	cin >> val;
	return val;
}

template<typename T>
vector<T> inv(ll num) {
	vector<T> val(num);
	rep(i,num) cin >> val[i];
	return val;
}

//----------------------------------------------------------------------
void solve() {

	ll n;
	cin >> n;
	vector<ll> vec(n);
	rep(i,n) cin >> vec[i];

	ll _min = LLONG_MAX;
	for (int i=1;i<101;i++) {
		ll _sum=0;
		rep(j,n) {
			_sum += (vec[j]-i)*(vec[j]-i);
		}
		_min = min(_min, _sum);
	}

	cout << _min;

}
//----------------------------------------------------------------------

int main(int argc, char* argv[]) {
	solve();
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
     
    #define REP(i,n) for(int i=0;i<(int)(n);++i)
    #define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
     
    using namespace std;
    typedef long long ll;
     
    int main(){
        int N, M;
        cin >> N >> M;
        int L[M];
        int R[M];
        
        REP(i,M){
            cin >> L[i] >> R[i];
        }

        int left = L[0];
        int right = R[0];

        FOR(i,1,M){
            if(left < L[i]) left = L[i];
            if(right > R[i]) right = R[i];
            if(left > right){
                cout << "0" << endl;
                return 0;
            }
        }

        cout << right - left + 1 << endl;
    	return 0;
    }

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
    // cin >> tt;
    while((tt)--){
      ll a,b,s=0; cin >> a >> b;
      rep(i,b){
        ll x;
        cin >> x;s+=x;
      }
      // cout << s << endl;
      if(s>=a){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
    }
}




Measured memory_bytes: 256
/*
Idea to improve:

Instead of keeping a segment tree, which contains
a vector of character frequencies for each segment,

keep, for each letter, a set<int> of indices
where that letter appears;


then when we need to query the range [l,r],
and say we want to see if there exists an 'a',
we can binary search for l, and for r,
to check whether 'a' appears in that range.

O(26*log N) per query

O(2*log N) per update, since we need only
delete from one set and insert from one set



*/
#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm>
#include <climits>

#include <stack>
#include <queue>
// #include <deque>
#include <set>
// #include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>

#include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;


typedef long long ll;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
typedef pair<long long, long long> pllll;
typedef pair<long long, int> plli;
typedef pair<int,long long> pill;
typedef vector<vector<long long>> vvll;
typedef vector<vector<long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;

#define emplace_back pb
const char el = '\n';



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

    int n; cin>>n; cin.ignore();
    string s; cin>>s; cin.ignore();

    int q; cin>>q; cin.ignore();

    vector< set<int> > v(26);

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

        char ch = s[i];
        int code = (int) (ch-'a');
        v[code].insert(i);
    }

    for (int t=0; t<q; ++t) {
        int querytype, left, right;
        int i; char ch;
        cin>>querytype;
        if (querytype==1) {
            cin>>i>>ch;
            --i;

            int origlettercode = (int)(s[i]-'a');
            // cout<<"after update, s is now "<<s<<el;
            int lettercode = (int)(ch-'a');
            if (origlettercode!=lettercode) {
                v[origlettercode].erase(i);
                v[lettercode].insert(i);
                s[i]=ch;
            }
        } else {
            assert(querytype==2);

            cin>>left>>right;
            --left, --right;
            //try for each letter to see whether it appears;
            int ret=0;
            for (int code = 0; code<26; ++code) {
                auto it = v[code].lower_bound(left);

                if (it != v[code].end() && (*it) <= right) {
                    ++ret;
                }
            }
            cout<<ret<<el;
        }
    }




}


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

public class Main {
	public static void main(String[] args) throws IOException {
		int[][][] ninzu = new int[4][3][10];
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			String line = br.readLine();
			String[] token = line.split(" ");
			int b, f, r, v;
			b = Integer.parseInt(token[0]);
			f = Integer.parseInt(token[1]);
			r = Integer.parseInt(token[2]);
			v = Integer.parseInt(token[3]);
			ninzu[b - 1][f - 1][r - 1] += v;
		}

		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 10; k++) {
					System.out.print(" " + ninzu[i][j][k]);
				}
				System.out.println();
			}
			if (i != 3) {
				System.out.println("####################");
			}
		}
	}
}

Measured memory_bytes: 24628
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<cmath>
#include<functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void sort(int &a,int &b)
{
	if(a>b)
		swap(a,b);
}
void open(const char *s)
{
#ifndef ONLINE_JUDGE
	char str[100];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
	sprintf(str,"%s.out",s);
	freopen(str,"w",stdout);
#endif
}
int rd()
{
	int s=0,c;
	while((c=getchar())<'0'||c>'9');
	do
	{
		s=s*10+c-'0';
	}
	while((c=getchar())>='0'&&c<='9');
	return s;
}
int upmin(int &a,int b)
{
	if(b<a)
	{
		a=b;
		return 1;
	}
	return 0;
}
int upmax(int &a,int b)
{
	if(b>a)
	{
		a=b;
		return 1;
	}
	return 0;
}
char s[2010];
char t[2010];
int n;
int ans;
int l[2010];
int r[2010];
int mx[2010];
void solve()
{
	int i,j;
	for(i=0;i<n;i++)
	{
		l[i]=r[i]=0;
		while(t[(i+r[i])%n]!='1')
			r[i]++;
		while(t[(i-l[i]+n)%n]!='1')
			l[i]++;
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			mx[j]=0;
		int dif=0;
		int ma=0;
		int c=0x7fffffff;
		for(j=0;j<n;j++)
			if(s[j]!=t[(j+i)%n])
			{
				upmax(mx[l[j]],r[j]-i);
				dif++;
			}
		for(j=n-1;j>=0;j--)
		{
			upmin(c,ma+j);
			upmax(ma,mx[j]);
		}
		upmin(ans,2*c+dif+i);
	}
}
int main()
{
	scanf("%s%s",s,t);
	n=strlen(s);
	int i;
	int ha=0,hb=0;
	for(i=0;i<n;i++)
		if(s[i]=='1')
			ha=1;
	for(i=0;i<n;i++)
		if(t[i]=='1')
			hb=1;
	if(!hb)
	{
		if(!ha)
			printf("0\n");
		else
			printf("-1\n");
		return 0;
	}
	ans=0x7fffffff;
	solve();
	reverse(s,s+n);
	reverse(t,t+n);
	solve();
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    long n, k;
    cin >> n >> k;

    long kk = 0;
    pair<int, int> p[n];

    int a, b;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        p[i].first = a;
        p[i].second = b;
    }

    sort(p, p + n);

    for (int i = 0; i < n; i++) {
        kk += p[i].second;

        if (kk >= k) {
            cout << p[i].first << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <ios>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
    ios::sync_with_stdio(false);

    vector<int> square;
    for(int i = 0; i * i <= 32768; ++i) {
        square.push_back(i * i);
    }
    const size_t L = square.size();
    while(true) {
        int n = 0;
        cin >> n;
        if(n == 0) {
            break;
        }

        int count = 0;
        for(int i = 0; i < L; ++i) {
            for(int j = i; j < L; ++j) {
                for(int k = j; k < L; ++k) {
                    int v = n - square[i] - square[j] - square[k];
                    if(v < square[k]) {
                        break;
                    }
                    if(binary_search(square.begin(), square.end(), v)) {
                        count += 1;
                    }
                }
            }
        }
        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 1212
def f(a, b)
  k = Math::log2(b - a).to_i
  mask = ~((1 << k) - 1)

  c = b & mask
  if b == c
    a, b = -b, -a 
    c = b & mask
  end
  b == c ? 1 : f(a, c) + f(c, b)
end

n = STDIN.gets.to_i
n.times do
  s, d = STDIN.gets.split.map(&:to_i)
  puts f(s, d)
end

Measured memory_bytes: 8652
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
using namespace std;

#define ll long long
#define sq(a) (a)*(a)
#define caset int t; cin >> t; cin.ignore(numeric_limits<streamsize>::max(),'\n'); while(t--)
#define get1(a) ll int a; cin>>a;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define line '\n'

#define vi(v)	vector < int > v;
#define	all(v)	v.begin(), v.end()


#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
//#ifndef ONLINE_JUDGE   freopen("input.txt","r",stdin);		freopen("output.txt","w",stdout); 	#endif

void solve()
{
	int n;
	string s;
	cin>>n;
	if(n%1000==0)
		cout<<"0"<<endl;
	else
		cout<<1000 - n%1000<<endl;
}

int main() {
	//fast;
	//caset{

	solve();
	//}
return 0;
}
// 11 10 1 9 2
// 8 3 7 4 6 5


Measured memory_bytes: 3600
module Main where

import           Control.Monad
import           Debug.Trace
import qualified Data.Vector.Unboxed           as VU
import           Data.List
import qualified Data.ByteString               as BS
import qualified Data.ByteString.Char8         as BSC8
import           Data.Char
import           Data.Maybe

tuplify2 (x:y:_) = (x,y)
tuplify2 _ = undefined

getVUIntFromInputLineAtBSC8 :: IO (VU.Vector Int)
getVUIntFromInputLineAtBSC8 =
    VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
getVUListIntFromInputLineAtBSC8 =
    VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine

readInt = fst . fromJust . BSC8.readInt
readIntTuple = tuplify2 . map readInt . BSC8.words
readIntList = map readInt . BSC8.words

getInt = readInt <$> BSC8.getLine
getIntList = readIntList <$> BSC8.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BSC8.getLine
getIntMatrix = map readIntList . BSC8.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BSC8.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BSC8.getLine
getIntTuples = map readIntTuple . BSC8.lines <$> BSC8.getContents

main :: IO [()]
main = do
    --s <- getLine
    --[aM,aN] <- getListIntFromInputLineAtBSC8
    --aP                   <- getVUIntFromInputLineAtBSC8
    --aQ                   <- getVUIntFromInputLineAtBSC8
    --aR                   <- getVUIntFromInputLineAtBSC8

    --vP <- VU.fromList . take aX . reverse . sort <$> getIntList
    --vQ <- VU.fromList . take aY . reverse . sort <$> getIntList
    --vR <- VU.fromList . take (aX + aY) . reverse . sort <$> getIntList

    aN <- getInt
    aA <- getIntList

    let aAP    = map (\x -> (x - 1, 1)) aA

    let cntAP  =  VU.accum (+) (VU.replicate aN 0) aAP
    let combiCntAp = VU.map (con2) cntAP
    let sum = VU.sum combiCntAp
    let cntSum = map (\x -> sum - (combiCntAp VU.! (x-1)) + (con2 (cntAP VU.! (x-1) - 1 ))) aA
    -- let cntSum = foldl (\acc1 minus -> acc1 ++ [sumCon2 minus cntAP]) [] aA
    mapM (putStrLn . show) cntSum

sumCon2 :: Int -> VU.Vector Int -> Int
sumCon2 minus cntAP = fst
    (VU.foldl
        (\(acc, cntM) x ->
            let target = if cntM == 1 then x - 1 else x
            in  ((acc + if target > 1 then con2 target else 0), cntM - 1)
        )
        (0, minus)
        cntAP
    )

con2 :: Int -> Int
con2 0 = 0
con2 1 = 0
con2 x = div (x * (x - 1)) 2



Measured memory_bytes: 30972
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    if (s.size()>=4) {
        if (s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') {
            cout<<"Yes"<<endl;
        } else {
            cout<<"No"<<endl;
        }
    } else {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int N;
int S;
int dp[10];
int nx[10];
int main(){
  int Lj4PdHRW, i, res;
  rd(N);
  for(i=1;i<10;i++){
    dp[i] = nx[i] = -1;
  }
  for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
    rd(S);
    for(i=0;i<10;i++){
      if(dp[i]!=-1){
        chmax(nx[ (i+S)%10 ], dp[i] + S);
      }
    }
    for(i=0;i<10;i++){
      dp[i] = nx[i];
    }
  }
  res = 0;
  for(i=1;i<10;i++){
    chmax(res, dp[i]);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N, S;
// int dp[10], nx[10];
// 
// {
//   int i, res;
//   rd(N);
//   rep(i,1,10) dp[i] = nx[i] = -1;
//   rep(N){
//     rd(S);
//     rep(i,10) if(dp[i]!=-1) nx[ (i+S)%10 ] >?= dp[i] + S;
//     rep(i,10) dp[i] = nx[i];
//   }
// 
//   res = 0;
//   rep(i,1,10) res >?= dp[i];
//   wt(res);
// }


Measured memory_bytes: 256
S = input()
N = len(S)
MOD = 10 ** 9 + 7

dp = [0] * 13 
dp[0] = 1
mul = 1
for i in range(0, N):
    next_dp = [0] * 13
    if S[N - i - 1] == '?':
        next_dp = [sum(dp[(j - k * mul) % 13] for k in range(10)) for j in range(13)]
    else:
        for j in range(13):
            k = int(S[N - i - 1])
            next_dp[(j + k * mul) % 13] = dp[j]
    dp = [d % MOD for d in next_dp]
    mul *= 10
    mul %= 13

print(dp[5])

Measured memory_bytes: 46440
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.nextLine());

		int answer;

		if (n % 2 != 0) {
			answer = n * 2;
		} else {
			answer = n;
		}

		System.out.println(answer);
	}

}


Measured memory_bytes: 24404
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    
    ll k;
    cin>>k;
    ll a = 0;
    ll ans = 0;
    rep(i,k){
        ans++;
        a*=10;
        a%=k;
        a+=7;
        a%=k;
        if(a%k==0){
            cout<<ans<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    
return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int H, W;
int c[10][10];
int A[205][205];

/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>H>>W;
    REP(i,0,10)REP(j,0,10) cin>>c[i][j];
    REP(i,0,H)REP(j,0,W) cin>>A[i][j];

    REP(k,0,10){
        REP(i,0,10){
            REP(j,0,10){
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    int ans = 0;

    REP(i,0,H){
        REP(j,0,W){
            if(A[i][j] != -1 && A[i][j] != 1){
                //ans += c[1][A[i][j]];
                ans += c[A[i][j]][1];
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 384
/**
       ������������    ������������
		Author : Avi J Patel
		University : DA-IICT
       ������������    ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair 
#define N 100000
#define mod 1000000007
#define large 10000000000000001

int main()
{
	int a,p;
	cin>>a>>p;
	p+=a*3;
	cout<<p/2;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Integer n = sc.nextInt();
		ArrayList<Integer> cards = new ArrayList<Integer>();
		for(int i = 0 ; i < n ; i++){
			cards.add(sc.nextInt());
		}
		Collections.sort(cards, Comparator.reverseOrder());
		Integer alice = 0;
		Integer bob = 0;
		for(int i = 0; i < n ; i = i + 2){
			alice = alice + cards.get(i);
		}
		for(int i = 1; i < n ; i = i + 2){
			bob = bob + cards.get(i);
		}
		Integer diff = alice - bob;
		System.out.println(diff);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int x[200005], y[200005];
int X[200005], Y[200005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> x[i] >> y[i];
        X[i] = x[i]+y[i], Y[i] = x[i]-y[i];
    }
    sort(X+1, X+1+n);
    sort(Y+1, Y+1+n);
    int ans = max(X[n]-X[1], Y[n]-Y[1]);
    printf("%d\n", ans);
}

Measured memory_bytes: 6844
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
	int h, m, hl, ml;
	double angle, radian, ans;
	scanf("%d%d%d%d", &hl, &ml, &h, &m);
	angle = fabs(0.5 *( h * 60 + m) - 6 * m * 0.1 * 10);
	//cout<<angle<<endl;
	if(angle > 180) angle = 360 - angle;
//	if(angle == 0) 
//	{
//		printf("%d", abs(hl - ml));
//		return 0;
//	}
//	if(angle == 180) 
//	{
//		printf("%d", hl + ml);
//		return 0;
//	}
	printf("%.20f", sqrt(hl * hl + ml *ml - 2 * hl * ml * cos(angle * M_PI/180)));
	return 0;
} 

Measured memory_bytes: 4156
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <numeric>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(123456789012345678)


unsigned GetDigit(unsigned num) {
    return std::to_string(num).length();
}


int main(void){
	int N; cin >> N;
  int h[N], x[N] = {};
  rep(i, N) cin >> h[i];
  int ans = 0;
  int flg = 1;
  while (flg)  {
    int cnt = 0;
    int mode = 1;
    rep(i, N) {
      if (x[i] != h[i]) {
        x[i] += 1;
        if (mode) {
          cnt += 1;
          mode = 0;
        }
      } else  {
        mode = 1;
      }
    }
    ans += cnt;
    if (cnt == 0) flg = 0;
  }
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//template by murugappan....Copied from chamow :p

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

#define ll long long
#define ld long double
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define priq(i,comp) priority_queue( i, vector< i >,comp)
template<class t>
t lcm(t a,t b)
{
    return ((a*b)/__gcd(a,b));
}
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

//end of template

int main()
{
    /*
        assert(freopen("input.txt","r",stdin));
        assert(freopen("output.txt","w",stdout));
    */
    ll q,h,s,d,n;
    cin>>q>>h>>s>>d>>n;
    ll temp=2;
    ll min1=min(4*q,min(2*h,s));
    ll min2=min(2*min1,d);
    ll ans=(n/2)*min2;
    ans=ans+(n%2)*min1;
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int m,r;
	while(1){
		r=0;
		scanf("%d",&m);
		if(m==0)return 0;
		m=1000-m;
		if(m>=500){
			m-=500;
			r++;
		}
		while(m>=100){
			m-=100;
			r++;
		}
		if(m>=50){
			m-=50;
			r++;
		}
		while(m>=10){
			m-=10;
			r++;
		}
		if(m>=5){
			m-=5;
			r++;
		}
		while(m>=1){
			m-=1;
			r++;
		}
		printf("%d\n",r);
	}
	return 0;
}



Measured memory_bytes: 2672
#include <bits/stdc++.h>
#define int long long 
#define ld long double
using namespace std;
const int mod = 998244353;

int32_t main(){
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    int redA[a], greenA[b], colA[c];
    
    for(int i = 0; i < a; i++){
        cin >> redA[i];
    }
    
    for(int i = 0; i < b; i++){
        cin >> greenA[i];
    }
    
    for(int i = 0; i < c; i++){
        cin >> colA[i];
    }
    
    sort(redA, redA + a);
    
    sort(greenA, greenA + b);
    
    sort(colA, colA + c);
    
    int ptrA = a - x, ptrB = b - y;
    for(int i = c - 1; i >= 0; i--){
        
        
        if(ptrB < b && ptrA < a){
            if(greenA[ptrB] < redA[ptrA]){
                if(greenA[ptrB] >= colA[i]){
                    break;
                } else {
                    greenA[ptrB] = colA[i];
                    ptrB++;
                }
            } else {
                if(redA[ptrA] >= colA[i]){
                    break;
                } else {
                    redA[ptrA] = colA[i];
                    ptrA++;
                }
            }
        } else {
            if(ptrA < a){
                if(redA[ptrA] >= colA[i]){
                    break;
                } else {
                    redA[ptrA] = colA[i];
                    ptrA++;
                }
            } else {
                if(greenA[ptrB] >= colA[i]){
                    break;
                } else {
                    greenA[ptrB] = colA[i];
                    ptrB++;
                }
            }
        }
    }
    
    int sum = 0;
    
    for(int i = a - x; i < a; i++){
        sum += redA[i];
    }
    for(int i = b - y; i < b; i++){
        sum += greenA[i];
    }
    
    cout << sum << endl;
}

Measured memory_bytes: 2560
n = int(input())

## 素因数分解
def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
  if n != 1:
    a.append(n)
  return a
  
## 素因数分解 素因数の個数を辞書で取得
import collections
c = collections.Counter(prime_factorize(n))
#print(c)

ans = 0
for k,v in c.items():
  cnt = 1
  while(v >= cnt):
    v -= cnt
    ans += 1
    cnt += 1
print(ans)    

Measured memory_bytes: 65920
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

ll dp[3001][2],cop[3001][2];
void solve() {
	int n, m; cin >> n >> m;
	rep(i, n + 1) {
		if(i<n)dp[i][0] = 1;
		else dp[i][1] = 1;
	}
	rep(i, 2 * m) {
		rep(j, n + 1) {
			rep(k, 2) {
				cop[j][k] = 0;
			}
		}
		if (i % 2 == 0) {
			rep(j, n+1) {
				rep(k, 2) {
					//red
					if (j > 0) {
						cop[j-1][k] += dp[j][k];
						if (cop[j - 1][k] >= mod)cop[j - 1][k] -= mod;
					}
					//blue
					if (j < n) {
						cop[j][k] += dp[j][k];
						if (cop[j][k] >= mod)cop[j][k] -= mod;
					}
				}
			}
		}
		else {
			rep(j, n) {
				rep(k, 2) {
					//red
					if (j < n-1) {
						cop[j + 1][k] += dp[j][k];
						if (cop[j + 1][k] >= mod)cop[j + 1][k] -= mod;
					}
					else {
						cop[j + 1][1] += dp[j][k];
						if (cop[j + 1][1] >= mod)cop[j + 1][1] -= mod;
					}
					//blue
					if (j < n - 1) {
						cop[j][k] += dp[j][k];
						if (cop[j][k] >= mod)cop[j][k] -= mod;
					}
					else {
					    cop[j][1] += dp[j][k];
						if (cop[j][1] >= mod)cop[j][1] -= mod;
					}
				}
			}
		}
		rep(j, n + 1) {
			rep(k, 2) {
				dp[j][k] = cop[j][k];
			}
		}
	}
	ll ans = 0;
	rep(i, n + 1) {
		ans += dp[i][1];
		if (ans >= mod)ans -= mod;
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 384