akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

typedef signed long long ll;
typedef vector<ll> vec;
const int TP = 26;

ll compute_score(ll& D, vec& C, vector<vector<ll>>& S, vec& sol) {
    vec last(TP, 0);
    ll score = 0;
    for (int i = 0; i < D; i++) {
        int j = sol[i] - 1;
        last[j] = i + 1;
        for (int k = 0; k < TP; k++)
            score -= C[k] * (i + 1 - last[k]);
        score += S[i][j];
    }
    return score;
}

int main() {
    ll D; cin >> D;
    vector<ll> C(TP, 0);
    for (int i = 0; i < TP; i++) cin >> C[i];
    vector<vector<ll>> S(D, vector<ll>(TP, 0));
    for (int i = 0; i < D; i++)
        for (int j = 0; j < TP; j++)
            cin >> S[i][j];

    vector<ll> sol(D, 0);
    for (int i = 0; i < D; i++) cin >> sol[i];

    ll M; cin >> M;
    for (int m = 0; m < M; m++) {
        int di, qi; cin >> di >> qi;
        sol[di - 1] = qi;
        cout << compute_score(D, C, S, sol) << endl;
    }
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(ll i=a;i<=(ll)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;
ld dp[303][303][303];int n;
ld solve(int a,int b,int c) {
    if(a<0||b<0||c<0||(!a&&!b&&!c)) return 0;
    if(dp[a][b][c]) return dp[a][b][c];
    ld t=n+a*solve(a-1,b,c)+b*solve(a+1,b-1,c)+c*solve(a,b+1,c-1);
    return dp[a][b][c]=t/(a+b+c);
}
int main() {
    cs
    int x;cin>>n;
    vector<int> v(3);
    rep(i,n) {
        cin>>x;
        v[x-1]++;
    }
    cout<<fixed<<setprecision(12)<<solve(v[0],v[1],v[2]);
}

Measured memory_bytes: 432384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  string s;
  cin>>s;
  if(s=="ABC"){
    cout<<"ARC"<<endl;
  }
  else{
    cout<<"ABC"<<endl;
  }
  return(0);
}


Measured memory_bytes: 3628
# 整数を一つ入力
N = int(input())

# 文字列を一つ入力
S = input()

res = 0

R = []
G = []
B = []

for i in range(N):
    if S[i] == "R":
        R.append(i)
        continue
    if S[i] == "G":
        G.append(i)
        continue
    B.append(i)

BN = len(B)

for i in R:
    for j in G:
        res += BN
        ii,jj = i,j
        if ii > jj:
            ii,jj = jj,ii
        if ii - (jj-ii) >= 0:
            if S[ii-(jj-ii)] == "B":
                res -= 1
        if (abs(jj-ii)) % 2 == 0:
            if S[(jj+ii) // 2] == "B":
                res -= 1
        if jj + (jj-ii) <= N-1:
            if S[jj+(jj-ii)] == "B":
                res -= 1
print(res)


Measured memory_bytes: 9084
a = int(input())
b = int(input())

if a == 1:
  if b == 2:
    print('3')
  else:
    print('2')
elif a == 2:
  if b == 1:
    print('3')
  else:
    print('1')
else:
  if b == 1:
    print('2')
  else:
    print('1')


Measured memory_bytes: 3060
import java.io.PrintWriter

//private val inp = java.io.File("in")
private val inp = System.`in`
private val reader = inp.bufferedReader()
private val wr = PrintWriter(System.out.bufferedWriter())

private fun readLn(): String = reader.readLine()
private fun readInt(): Int = readLn().toInt()
private fun readStrs(): List<String> = readLn().split(" ")
private fun readInts(): IntArray = readStrs().map { it.toInt() }.toIntArray()
private fun readChars(): CharArray = readStrs().map { it.single() }.toCharArray()

fun main() {
    val (n, k) = readInts()
    val pref = LongArray(n + 2)
    val mod = 1e9 + 7
    for (i in 1..n + 1) {
        pref[i] += pref[i - 1] + i - 1
    }

    var ans = 0L
    for (i in k..n + 1) {
        val minSum = pref[i]
        val maxSum = pref[n + 1] - pref[n + 1 - i]
        ans += maxSum - minSum + 1
        ans = (ans % mod).toLong()
    }

    println((ans % mod).toLong())
}


Measured memory_bytes: 38036
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <queue>
#include <map>
#include <set>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
    int i,sx,sy,tx,ty;
    scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
    for( i=1;i<=ty-sy;++i)
        printf("U");
    for(i=1;i<=tx-sx;++i)
        printf("R");
     for( i=1;i<=ty-sy;++i)
        printf("D");
         for(i=1;i<=tx-sx;++i)
        printf("L");
        printf("L");
        for( i=1;i<=ty-sy;++i)
        printf("U");
        printf("U");
        for(i=1;i<=tx-sx;++i)
        printf("R");
        printf("RD");
        printf("R");
        for( i=1;i<=ty-sy;++i)
        printf("D");
        printf("D");
        printf("L");
          for(i=1;i<=tx-sx;++i)
        printf("L");
        printf("U\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <math.h>

#define roop(i,n,k) for(i=k;i<n;i++)

using namespace std;

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	int n, k, i, j;
	cin >> n >> k;
	int h[n];
	int count = 0;
	roop(i, n, 0) {
		cin >> h[i];
		if (h[i] >= k) count++;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#define N 1000

int main(void){
  int i,j,k,n,bi,ci;
  int a[N][10],b[N][10],c[N][11];
  int flag;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    for(j=0;j<10;j++)
      scanf("%d",&a[i][j]);
  for(i=0;i<n;i++)
    for(j=0;j<10;j++){
      b[i][j]=0;
    }
  c[i][10]=0;
  for(i=0;i<n;i++){
    flag=1;
    b[i][0]=a[i][0];
    j=1;
    bi=1;
    ci=1;
    for(;j<10;){
      if(a[i][j]<b[i][bi-1] && a[i][j]<c[i][ci-1]){
        printf("NO\n");
        flag=0;
        break;
      }else{
        if(b[i][bi-1]>a[i][j]){
          c[i][ci]=a[i][j];
          ci++;
          j++;
        }else if(c[i][ci-1]>a[i][j]){
          b[i][bi]=a[i][j];
          bi++;
          j++;
        }else if(b[i][bi-1]<a[i][j] && c[i][ci-1]<a[i][j]){
          if(a[i][j]-b[i][bi-1]<=a[i][j]-c[i][ci-1]){
            b[i][bi]=a[i][j];
            bi++;
            j++;
          }else{
            c[i][ci]=a[i][j];
            ci++;
            j++;
          }
        }
      }
    }
    if(flag==1)
      printf("YES\n");
  }
  return 0;
}

Measured memory_bytes: 0
s = raw_input()
# s = "aabbaa"

# f = [0 for _ in range(len(s)+1)]

# for i in range(len(s)+1):
#     for j in range(i):
#         if s[2*j-i:j] == s[j:i]:
#             f[i] = max(f[i], f[j]+1-f[2*j-i])
#         else:
#             f[i] = max(f[i], f[j]+1)
# print f[-1]
def max_k_single_block(s):
    if len(s) % 3 == 0:
        return len(s)/3*2
    else:
        return len(s)/3*2+1

def max_k(s):
    f = [0 for _ in range(len(s))]
    f[0] = 1

    if s[0] == s[1]:
        f[1] = 1
    else:
        f[1] = 2

    if s[1] == s[2]:
        f[2] = f[0] + 1
    else:
        f[2] = f[1] + 1

    for i in range(3, len(s)):
        if s[i] == s[i-1]:
            f[i] = f[i-3] + 2
        else:
            f[i] = f[i-1] + 1

    # print f
    print f[-1]

# max_k("aabbaa")
# max_k("aaaccacabaababc")
max_k(s)

Measured memory_bytes: 15472
use std::io::*;

mod disjoint_set {
    pub struct DisjointSet {
        parent: Vec<usize>,
        size: Vec<usize>,
    }
    impl DisjointSet {
        pub fn new(n: usize) -> DisjointSet {
            DisjointSet {
                parent: (0..n).collect(),
                size: vec![1; n],
            }
        }
        pub fn root(&mut self, x: usize) -> usize {
            if x == self.parent[x] {
                x
            } else {
                let tmp = self.parent[x];
                self.parent[x] = self.root(tmp);
                self.parent[x]
            }
        }
        pub fn merge(&mut self, x: usize, y: usize) {
            let x = self.root(x);
            let y = self.root(y);
            if x == y {
                return;
            }
            if self.size[x] > self.size[y] {
                self.size[x] += self.size[y];
                self.parent[y] = x;
            } else {
                self.size[y] += self.size[x];
                self.parent[x] = y;
            }
        }
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<(usize, usize)> = (0..n)
        .map(|_| {
            (
                itr.next().unwrap().parse().unwrap(),
                itr.next().unwrap().parse().unwrap(),
            )
        })
        .collect();

    let mut ds = disjoint_set::DisjointSet::new(200001);

    let mut root_seen = vec![false; 200001];
    let mut xseen = vec![false; 100001];
    let mut yseen = vec![false; 100001];
    let mut xsize = vec![0usize; 200001];
    let mut ysize = vec![0usize; 200001];

    for i in 0..n {
        ds.merge(a[i].0, a[i].1 + 100000);
    }

    // rootのxsize, ysizeを計算
    for i in 0..n {
        if !xseen[a[i].0] {
            xsize[ds.root(a[i].0)] += 1;
            xseen[a[i].0] = true;
        }
        if !yseen[a[i].1] {
            ysize[ds.root(a[i].1 + 100000)] += 1;
            yseen[a[i].1] = true;
        }
    }

    let mut ans = 0usize;
    for i in 0..n {
        let root = ds.root(a[i].0);
        if !root_seen[root] {
            ans += xsize[root] * ysize[root];
            root_seen[root] = true;
        }
    }
    println!("{}", ans - n);
}


Measured memory_bytes: 8312
import math

A , B , H , M = map(int,input().split())

Hour_rad = H * 30
Hour_rad += M * 0.5

Min_rad = M * 6




rad = abs(Hour_rad - Min_rad)

if rad > 180:
    rad = 360 - rad

#Hour_redとMin_radが１８０度離れていたらコサインに１引いたものを代入する。



ans = A**2 + B**2 - ( 2 * A * B * math.cos( math.radians ( rad )) )
ans = math.sqrt(ans)

print(ans)

Measured memory_bytes: 62240
#include<stdio.h>
#include<math.h>

int main(void) {
    int n;

    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        int x = i;
        if(x % 3 == 0) {
            printf(" %d", i);
        }
        else{
            while(x) {
                if(x % 10 == 3) {
                    printf(" %d", i);
                    break;
                }
                x /= 10;
            }
        }
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 2112
n = int(input())
arr = list(map(int,input().split()))
arr.sort(reverse=True)
ans = 1
limit = 10**18

if arr[-1] == 0:
  ans = 0
else:
  for i in arr:
    ans *= i
    if ans > limit:
      ans = -1
      break
print(ans)


Measured memory_bytes: 21472
//
//  main.cpp
//  switches technovation
//
//  Created by RISHAV SINGH MEHTA on 04/02/20.
//  Copyright © 2020 RISHAV SINGH MEHTA. All rights reserved.
//

#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    ll int Y,Z,ans=0;
    cin>>Y>>Z;
    ll int mx;
    if (llabs(Y-Z)<=1) {
        cout<< (Y+Z)<<endl;
    }else{
        mx = max(Y, Z);
        cout<< 2*mx - 1 <<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n, k = map(int, input().split())
x = [int(i) for i in input().split()]

mn = 0xFFFFFFFF
for i in range(n - k + 1):
    l = x[i]
    r = x[i + k - 1]
    a = abs(l) + abs(r - l)
    b = abs(r) + abs(r - l)
    mn = min(a, b, mn)
print(mn)

Measured memory_bytes: 16580
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,x,a[200040],b[200040];
string s,t;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>s>>t;
	for(;s[i];i++)x+=s[i]!=t[i];
	cout<<x;
}

Measured memory_bytes: 3788
import sys
def input():
    return sys.stdin.readline()[:-1]
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

def main():
    N = int(input())
    if N%2 == 1:
        print(0)
    else:
        t = 2*5
        s = 0
        while t <= N:
             s += N//t
             t *= 5
        print(s)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    m[i+1-a[i]]++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += m[a[i]+i+1];
  }
  cout << ans << endl;
}


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

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

  int r=0;
  int b=0;
  int g=0;

  int def =0;

  rep(i,n){
      if(s[i]=='R') r++;
      else if(s[i]=='G') g++;
      else{
          b++;
      }
  }

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

      for(int j=i+1;j<=i + (n-i)/2;j++){
           if(s[i]=='R'){
               if(s[j]=='G'){
                   if(s[j+j-i] =='B' ){
                       def++;
                   }
                }
                else if(s[j]=='B'){
                    if(s[j+j-i] =='G' ){
                       def++;
                   }
                }
           }
           else if(s[i]=='G'){
               if(s[j]=='B'){
                   if(s[j+j-i] =='R' ){
                       def++;
                   }
                }
                else if(s[j]=='R'){
                    if(s[j+j-i] =='B' ){
                       def++;
                   }
                }

           }

           else{ 
               if(s[j]=='G'){
                   if(s[j+j-i] =='R' ){
                       def++;
                   }
                }
                else if(s[j]=='R'){
                    if(s[j+j-i] =='G' ){
                       def++;
                   }
                }

           }
      }
  }

  ll ans =0;

  for(int i=0;i<n;i++){
      if(s[i]=='R'){
          r--;
          ans += g*b;
      }

      else if(s[i]=='B'){
          b--;
          ans += r*g;
      }
      else{
          g--;
          ans += r*b;
      }
  }

  cout << ans - def << endl;


}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  string s;
  cin >> s;
  REP (i, s.size() - 1) {
    if (s[i] == 'A' && s[i + 1] == 'C') {
      cout << "Yes" << endl;
      exit(0);
    }
  }
  cout << "No" << endl;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

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

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    string s;
    cin >> s;
    for( int i = 0; i < s.size(); ++i ) cout << "x";
    cout << endl;
    return 0;
}


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

using namespace std;

int main(){
    int l;
    double ans;
    //char s[200];
    //bool flag = false;

    cin >> l;

    ans = l/3.0;
    ans = pow(ans,3);

    //cout << n << endl;
    //cout << ((!flag)?"Yes":"No")<< endl;
    printf("%lf",ans);
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
	string s;
	int x, y;
	cin >> s >> x >> y;
	vector<int> xdir, ydir;
	bool mode = true;
	int count = 0;
	REP(i, s.size()){
		if(s[i]=='T'){
			if (count>0){
				if(mode){
					xdir.push_back(count);
				}else{
					ydir.push_back(count);
				}
			}
			count = 0;
			mode = !mode;
		}else{
			count++;
		}
	}
	if (count>0){
		if(mode){
			xdir.push_back(count);
		}else{
			ydir.push_back(count);
		}
	}

	bool exc = false;
	if(s[0]=='T') exc = true;

	bool DP[2][160001];

	REP(i, 160001){
		DP[0][i] = false;
	}
	DP[0][8000] = true;
	REP(i, xdir.size()){
		if(xdir.size()==0) break;
		if(i==0 && !exc){
			REP(j, 160001) DP[1][j] = false;
			DP[1][xdir[0]+8000] = true;
		}else{
			REP(j, 160001){
				bool flag1, flag2;
				if(j-xdir[i]>-1){
					flag1 = DP[i%2][j-xdir[i]];
				}else{
					flag1 = false;
				}
				if(j+xdir[i]<160001){
					flag2 = DP[i%2][j+xdir[i]];
				}else{
					flag2 = false;
				}
				DP[(i+1)%2][j] = (flag1 || flag2);
			}
		}
		/*
		REP(i, 11){
			cout << DP[0][7995+i] << " ";
		}
		cout << endl;
		REP(i, 11){
			cout << DP[1][7995+i] << " ";
		}
		cout << endl << endl;
		*/
	}

	bool res1 = DP[(xdir.size())%2][x+8000];

	REP(i, 160001){
		DP[0][i] = false;
	}
	DP[0][8000] = true;
	REP(i, ydir.size()){
		if(ydir.size()==0) break;
		REP(j, 160001){
			bool flag1, flag2;
			if(j-ydir[i]>-1){
				flag1 = DP[i%2][j-ydir[i]];
			}else{
				flag1 = false;
			}
			if(j+ydir[i]<160001){
				flag2 = DP[i%2][j+ydir[i]];
			}else{
				flag2 = false;
			}
			DP[(i+1)%2][j] = (flag1 || flag2);
		}
	}
	bool res2 = DP[(ydir.size())%2][y+8000];


	cout << ((res1 && res2) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n;
    cin>>n;
    VL l(n);
    REP(i,n)cin>>l[i];
    SORT(l);
    LL ans = 0;
    REP(i,n)FOR(j,i+1,n){
        LL x = l[n - i - 1] - l[n - j - 1];
        // l[0] ～ l[n-j-2] の範囲で > xの長さのものだけ成り立つ
        auto bound = upper_bound(l.begin(), l.begin() + (n-j-1), x);
        ans += (n - j - 1) - (bound - l.begin());
    }
    PUTS(ans);
}

Measured memory_bytes: 384
//
// Created by 12243 on 2017/10/28.
//
#include <iostream>
#include <cmath>
using  namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    long long ans=1;
    for (int i=1;i<=n;i++){
        long long temp=ans*2;
        ans+=k;
        ans=min(ans,temp);
    }
    cout<<ans;
}



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

int main() {
  std::string s;
  std::cin >> s;
  int j = 0;

  for (const auto i : s) {
    if (i == '+') {
      j++;
    } else {
      j--;
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll A,B,K;
  cin >>A>>B>>K;
  
  if(A<K){B=B+A-K;A=0;}
  if(A>=K){A=A-K;}
  if(B<0){B=0;}
  
   cout << A<<" "<<B << endl;
}


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

using namespace std;

int main()
{
    long n, m;
    cin >> n >> m;
    long k = min(n, m/2);
    long l = (m - 2*k) / 4;
    long ans = k + l;
    cout << ans << 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;
#define int long long
#define double long double
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

main(){
    int n;
    cin>>n;
    while(1){
        if(IsPrime(n)){
            cout<<n<<endl;
            break;
        }else{
            n++;
        }
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)

n=int(input())
L=list(map(int,input().split()))
data=[0]*(10**3+2)
ans=0
pre=0
S=0
L.sort()
for i in range(1,n):

    l=L[i]
    S-=sum(data[pre:l+1])
    pre=l+1
    ans+=S
    for j in range(0,i):
        if l+L[j]<=10**3:
            data[l+L[j]]+=1
        S+=1
        # print('insert',l+L[j])

print(ans)




Measured memory_bytes: 41708
using System;
namespace ConsoleApplication4.Properties
{
    public class Class1
    {
        public static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            
                        var a =Console.ReadLine();
                       String [] v= a.Split();
                       var b =Console.ReadLine();
                       String [] c= b.Split();
                       int [] vc = new int[N];
                       var sum = 0;

                       for (int i = 0; i < N; i++)
                       {
                           vc[i] = int.Parse(v[i]) - int.Parse(c[i]);
                           if (vc[i]>0)
                           {
                               sum += vc[i];
                           }
                       }

                       
 
           Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13140
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            Stack<int> queue = new Stack<int>();
            queue.Push(-1 /* dummy */);

            int count = 0;
            foreach (var c in str)
            {
                int value = c - '0';
                if (value == (queue.Peek() ^ 1))
                {
                    count += 2;
                    queue.Pop();
                }
                else
                {
                    queue.Push(value);
                }
            }

            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 13920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

void solve(long long X, long long K, long long D){
    ll toGround = abs(X)/D;
    if(toGround > K){
        cout << abs(X) - K *D << endl;
        return;
    }
    K -= toGround;
    if( K%2==0){
        cout << abs(X) - toGround *D << endl;
    }else{
        cout << (toGround+1) *D -abs(X) << endl;
    }

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long K;
    scanf("%lld",&K);
    long long D;
    scanf("%lld",&D);
    solve(X, K, D);
    return 0;
}


Measured memory_bytes: 3764
#include<iostream>
#include<algorithm>
#define MAX_N 101
#define INF 1000000001
using namespace std;
int n, a[MAX_N];
int main(){
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a[i];
    }
  int ret = 0;
  for(int i=0; i<n; i++){
    for(int j=0; j<i; j++){
      ret = max(ret, abs(a[i]-a[j]));
      }
    }
  cout << ret << endl;
  return 0;
  }

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
var [N, K] = input[0].split(' ').map(Number)
var sunuke = new Array(N).fill(0)
for (var i=0; i<K; i++) {
  input[i*2+2].split(' ').map(Number).forEach((v) => sunuke[v-1] ++)
}
console.log(sunuke.filter(v => v === 0).length)


Measured memory_bytes: 31524
f = [];
for i in range(3):
    f.append([int(i) for i in input().split()]);

n = int(input());
v = [];

for i in range(n):
    k = int(input());
    v.append(k);

#print(f);
#print(v);

for val in v:
    for i in range(3):
        for j in range(3):
            if f[i][j] == val:
                f[i][j] = 0;

flag = False;

for i in range(3):
    curr = 0;
    for j in range(3):
        curr += f[i][j];
    if curr == 0:
        flag = True;
    curr = 0;
    for j in range(3):
        curr += f[j][i];
    if curr == 0:
        flag = True;
    curr = 0;
    for j in range(3):
        curr += f[j][j];
    if curr == 0:
        flag = True;
    curr = 0;
    for j in range(3):
        curr += f[j][2 - j];
    if curr == 0:
        flag = True;

if flag == True:
    print('Yes');
else:
    print('No');


Measured memory_bytes: 3064
from heapq import heappop, heappush, heapify
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for _ in range(M):
    B, C = map(int, input().split())
    BC.append((B, C))
heapify(A)
BC = sorted(BC, key = lambda x: -x[1])

for b, c in BC:
    for j in range(b):
        a = heappop(A)
        if a < c:
            heappush(A, c)
        else:
            heappush(A, a)
            break

print(sum(A))

Measured memory_bytes: 92952
#include<bits/stdc++.h>
#define ll long long
#define fr(i,x,y) for(int i=(x);i<=(y);i++)
#define rf(i,x,y) for(int i=(x);i>=(y);i--)
#define frl(i,x,y) for(int i=(x);i<(y);i++)
using namespace std;
const int N=404;
const int p=998244353;
int n,a[N],b[N];
ll f[N][N];

void read(int &x){ scanf("%d",&x); }

ll qpow(ll sum,ll n){
	ll ans=1;
	for(;n;n>>=1,sum=sum*sum%p) if (n&1) ans=ans*sum%p;
	return ans;
}

ll mul[N],inv[N];
void init(){
	mul[0]=1;
	frl(i,1,N) mul[i]=mul[i-1]*i%p;
	inv[N-1]=qpow(mul[N-1],p-2);
	rf(i,N-2,0) inv[i]=inv[i+1]*(i+1)%p;
}

void Add(ll &x,ll y){
	x+=y;//x%=p;
	if (x<0) x+=p;
	if (x>=p) x-=p;
}

int main(){
	init();
	read(n);
	fr(i,1,n) read(a[i]),read(b[i]);
	int S=0;
	fr(i,1,n) S+=a[i];
	//S=qpow(S,p-2);
	f[0][0]=p-1;
	fr(i,1,n)
	 rf(k,400,0)
	  fr(j,0,400)
	   frl(x,0,b[i])
		if (f[j][k]) Add(f[j+x][k+a[i]],p-f[j][k]*qpow(a[i],x)%p*inv[x]%p);
	ll ans=0;
	fr(j,0,400)
	 fr(k,1,400)
	  Add(ans,mul[j]*f[j][k]%p*qpow(k,p-1-j)%p*qpow(k,p-2)%p*S%p);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> P;
const int INF = 1e9;
int N, M;
int d[100010];
int ans[100010];
vector<int> G[100010];

void dijkstra() {
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + N, INF);
    d[0] = 0;
    que.push(P(0, 0));

    while (!que.empty()){ 
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int u: G[v]) {
            if (d[u] > d[v] + 1) {
                d[u] = d[v] + 1;
                ans[u] = v + 1; 
                que.push(P(d[u], u));
            }
        }
    }
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int A, B; cin >> A >> B;
        A--, B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    dijkstra();
    cout << "Yes" << endl;
    for (int i = 1; i < N; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 11232
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    
    if op == "?":
        break
    
    if op == "+":
        ans = a + b
    elif op == "-":
        ans = a - b
    elif op == "*":
        ans = a * b
    elif op =="/":
        ans = a // b
    
    print(ans)


Measured memory_bytes: 5596
#include <stdio.h>
int main(void)
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==5&&b==5&&c==7||a==5&&b==7&&c==5||a==7&&b==5&&c==5)
        printf("YES");
    else
        printf("NO ");
    return 0;
}


Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        h: usize,
        w: usize,
        k: usize
    }
    let d = 1000000007;
    let fib = vec![0, 1, 1, 2, 3, 5, 8, 13, 21, 34];
    let mut v: Vec<Vec<usize>> = vec![vec![0; w + 2]; h + 1];
    v[0][1] = 1;
    for i in 0..h {
        for j in 1..w + 1 {
            v[i + 1][j] = (v[i][j] * fib[j] % d * fib[w - j + 1] % d + v[i][j - 1] * fib[j - 1] % d * fib[w - j + 1] % d + v[i][j + 1] * fib[j] % d * fib[w - j] % d) % d;
        }
    }
    println!("{}", v[h][k]);
}


Measured memory_bytes: 4352
#include <iostream>

int main(){
	int a, b;
	char op;
	while(1){
		std::cin >> a >> op >> b;
		switch(op){
			case '+':
				std::cout << a + b << std::endl;
				break;
			case '-':
				std::cout << a - b << std::endl;
				break;
			case '*':
				std::cout << a * b << std::endl;
				break;
			case '/':
				std::cout << a / b << std::endl;
				break;
			case '?':
				return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    
    int X=in.nextInt();
    int p,m,t,s;
   
      m=X/500;
     	p=X%500;
    t=p/5;
    s=m*1000+t*5;
    System.out.println(s);
  }
}
      
      


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


int main(){
    unsigned long long X, I;
    unsigned long long year;

    scanf("%llu", &X);

    I = 100;
    year = 1;
    while(1){
        I = I * 1.01;
        if(I >= X){
            printf("%llu", year);
            return 0;
        }
        year++;
    }

    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  queue<int> q;
  bool tobi=false;
  rep(i,n){
    if(tobi){
      tobi=false;
      continue;
    }
    if(s[i]=='A') q.push(3);
    if(s[i]=='B') {
      if(i+1<n && s[i+1]=='C') {
        q.push(2);
        tobi=true;
      }
      else q.push(0);
    }
    if(s[i]=='C') q.push(0);
  }
  
  ll ans=0;
  vector<int> p={};
  while(!q.empty()){
    int x=q.front();
    q.pop();
    if(x==0){
      if(p.empty()) continue;
      else{
        int m=p.size();
        ll moto=0;
        rep(i,m){
          if(p[i]==2) moto+=i;
        }
        sort(all(p));
        ll ato=0;
        rep(i,m){
          if(p[i]==2) ato+=i;
        }
        ans+=moto-ato;
        vector<int> r={};
        swap(p,r);
      }
    }
    else{
      p.pb(x);
    }
  }

  if(!p.empty()){
      int m=p.size();
      ll moto=0;
      rep(i,m){
        if(p[i]==2) moto+=i;
      }
      sort(all(p));
      ll ato=0;
      rep(i,m){
        if(p[i]==2) ato+=i;
      }
    ans+=moto-ato;
  }
  cout << ans << endl;
}

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

int main () {
  string S;
  cin >> S;
  int N = S.size();
  int twoans = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(i != j && S.at(i) == S.at(j)){
        twoans++;
      }
    }
  }
  if(twoans == 4){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

int main() {
    int n,a=0;
    cin>>n;
    for(int i=1;i<=n;i++) {
        int x;
        cin>>x;
        if(x&1 and i&1) a++;
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 3144
#include<cstdio>
#include<algorithm>

using namespace std;

int main(void)
{
	int a, b, c, x;

	while(scanf("%d%d%d", &a, &b, &c)==3)
	{
		int ans=0;
		int a_add, b_add, c_add;
		int a_diff, b_diff, c_diff;

		x=max(a, max(b, c));

		a_add=(x-a)/2;
		b_add=(x-b)/2;
		c_add=(x-c)/2;
		a_diff=x-(a+a_add*2);
		b_diff=x-(b+b_add*2);
		c_diff=x-(c+c_add*2);

		ans=a_add+b_add+c_add;
		switch(a_diff+b_diff+c_diff)
		{
			case 0:
				break;
			case 1:
				ans+=2;
				break;
			case 2:
				ans++;
				break;
		}
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,x;
    cin >> N >> x;
    ll ans[250010];
    if(x == 1 || x == 2*N-1){
        print("No");
    }else{
        print("Yes");
        ans[N-1] = x;
        vector<ll> v;
        rep(i,1,2*N){
            if(i != x){
                v.push_back(i);
            }
        }
        // printa(v,v.size());
        vector<ll> v2;
        rep(i,0,N-1){
            v2.push_back(v[i]);
            v2.push_back(v[2*(N-1)-i-1]);
        }
        // printa(v2,v2.size());
        ll diff = 1;
        // printa(v,v.size());
        rep(i,0,N-1){
            ans[N-1-diff] = v2[2*i];
            ans[N-1+diff] = v2[2*i+1];
            diff++;
            // ans[N-1-diff] = cnt;
            // cnt++;
            // ans[N-1+diff] = cnt;
            // cnt++;
            // diff++;
        }
        printa(ans,2*N-1);
    }

}


Measured memory_bytes: 6384
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;
import java.lang.Object;
 
public class Main {
    Scanner sc = new Scanner(System.in);
   
    public static void main(String[] args) {
        new Main(); 
    }
   
    public Main() {
        new aoj1237().doIt();
    }
    class aoj1237{
    	int length = 0;
    	int n = 0;
    	int not = 0;
    	int max = 0;
    	ArrayList<Integer> ar = new ArrayList<Integer>();
    	ArrayList<Integer> ans = new ArrayList<Integer>();
    	void dfs(int deep,int array[],int num){
    		if(deep == length){
    			if(num <= n){
    				if(max < num){
    					ans.clear();
    					for(int i = 0;i < ar.size();i++)ans.add(ar.get(i));
    					max = num;
    					not = 0;
    				}
    				else if(max == num)not++;
    			}
    		}else{
    			int cnt = 0;
    			for(int i = deep;i < length;i++){
        			cnt = cnt * 10 + array[i];
        			ar.add(cnt);
        			dfs(i+1,array,num + cnt);
        			ar.remove(ar.size() - 1);
        		}
    		}
    	}
    	void doIt(){
    		while(true){
    			max = 0;
    			n = sc.nextInt();
    			String str = sc.next();
    			length = str.length();
    			int num = Integer.parseInt(str);
    			if(n + num == 0)break;
    			int array[] = new int[length];
    			for(int i = length-1;i >= 0;i--){
    				array[i] = num % 10;
    				num = num / 10;
    			}
    			dfs(0,array,0);
    			if(not > 0)System.out.println("rejected");
    			else if(max == 0)System.out.println("error");
    			else{
    				System.out.print(max);
    				for(int i = 0;i < ans.size();i++)System.out.print(" "+ans.get(i));
    				System.out.println();
    			}
    		}
    	}
    }
}

Measured memory_bytes: 26576
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
sys.setrecursionlimit(10**6)
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & (-i)
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & (-i)
def resolve():
    N = ir()
    c = lr()
    ab = [[] for i in range(N)]
    for i in range(N-1):
        a, b = lr()
        ab[a-1].append(b-1)
        ab[b-1].append(a-1)
    tot = N*(N+1)//2
    il = [0]*N
    ol = [0]*N
    cnt = [0]
    def dfs(u, p):
        cnt[0] += 1
        il[u] = cnt[0]
        for i in ab[u]:
            if i != p:
                dfs(i, u)
        ol[u] = cnt[0]
    dfs(0, -1)
    vs = [[] for i in range(N)]
    for i in range(N):
        vs[c[i]-1].append(i)
    sl = Bit(N)
    for i in range(1, N+1):
        sl.add(i, 1)
    for i in range(N):
        his = []
        ans = tot
        tvs = sorted(vs[i], key=lambda x: il[x])[::-1]
        for v in tvs:
            n = 1
            for j in ab[v]:
                if il[j] > il[v]:
                    tmp = sl.sum(ol[j])-sl.sum(il[j]-1)
                    ans -= tmp*(tmp+1)//2
                    n += tmp
            sl.add(il[v], -n)
            his.append([il[v], n])
        tmp = sl.sum(ol[0])-sl.sum(0)
        ans -= tmp*(tmp+1)//2
        for h in his:
            sl.add(h[0], h[1])
        print(ans)
resolve()

Measured memory_bytes: 300904
#include<stdio.h>
#include<stdlib.h>
#pragma warning(disable:4996)

int main() {
	int n;
	int k;
	int pp[1005] = { 0 };
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &pp[i]);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n - i - 1; j++) {
			if (pp[j] > pp[j + 1]) {
				int temp = pp[j];
				pp[j] = pp[j + 1];
				pp[j + 1] = temp;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += pp[i];
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1696
package main

import "fmt"
var N, M int
var u, w, v int
var dp [][]int64
var A []int64
const (
	MaxInt = 1<<31 - 1
	MinInt = -MaxInt - 1
)
func max(a, b int64) int64 {
	if a > b { return a }
	return b
}

func min(a, b int64) int64 {
	if a < b { return a }
	return b
}

func abs(a int64) int64 {
	if a < 0 { return -a }
	return a
}

func main() {
	_,e := fmt.Scanf("%d", &N)
	if e != nil { return }
	A = make([]int64, N)
	dp = make([][]int64, N+2)
	for i := range dp {
		dp[i] = make([]int64, N+2)
	}
	for i:=0; i<N; i++ {
		_,e = fmt.Scanf("%d", &A[i])
		if e != nil { return }
	}

	for i:=1; i<=N; i++ {
		for j, k:=0,i-1; k<N; j,k = j+1, k+1 {
			p := (j+k+N)%2
			if p == 1 {
				dp[j+1][k+1] = max(A[j]+dp[j+2][k+1], A[k]+dp[j+1][k])
			} else {
				dp[j+1][k+1] = min(-A[j]+dp[j+2][k+1], -A[k]+dp[j+1][k])
			}
		}
	}
	fmt.Println(dp[1][N])
}


Measured memory_bytes: 47844
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
const double eps = 1e-10;
  
int main() {
  string s;
  cin >> s;
  int ans = 0;
  rep(i,sz(s)-1) {
    if(i&1) continue;
    int k = i/2;
    bool ok = true;
    rep(j,k) {
      if(s[j] != s[j+k]) {
        ok = false;
        break;
      }
    }
    if(ok) {
      chmax(ans,i);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define MAX 300000
using namespace std;
	
int main(void){
	int n;
	bool isprime[MAX];
	for(int i=0;i<MAX;i++)
		isprime[i]=true;
	isprime[0]=isprime[1]=false;
	for(int i=2;i*i<MAX;i++)
		if(isprime[i])
			for(int j=2*i;j<MAX;j+=i)
				isprime[j]=false;
	while(cin >> n,n){
		int ans=0;
		for(int i=n+1;i<=2*n;i++)
			if(isprime[i])
				ans++;
		cout << ans << endl;
	}
	return 0;
}

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

static const int MAX = 10000;
static const int INFTY = (1<<29);

class DisjointSet{
public:
  vector<int> rank,p;

  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size,0);
    p.resize(size,0);

    // rank0 n個の独立な集合を作成
    for(int i=0;i<size;i++) makeSet(i);
  }

  void makeSet(int x){
    p[x] = x;
    rank[x] = 0;
  }

  bool same(int x,int y){
    return findSet(x) == findSet(y);
  }

  void unite(int x,int y){
    link(findSet(x),findSet(y));
  }

  void link(int x,int y){
    if(rank[x] > rank[y]){
      p[y] = x;
    }else{
      p[x] = y;
      if(rank[x] == rank[y]){
        rank[y]++;
      }
    }
  }
  int findSet(int x){
    if(x != p[x]){
      p[x] = findSet(p[x]);
    }
    return p[x];
  }
};


class Edge{
public:
  int source,target,cost;
  Edge(int source = 0,int target = 0,int cost = 0):
  source(source),target(target),cost(cost){}

  bool operator < (const Edge &e) const{
    return cost < e.cost;
  }
};

int kruskal(int N,vector<Edge> edges){
  int totalCost = 0;
  sort(edges.begin(),edges.end());

  DisjointSet dset = DisjointSet(N+1);

  for(int i=0;i<edges.size();i++){
    Edge e = edges[i];
    if(!dset.same(e.source,e.target)){

      totalCost += e.cost;
      dset.unite(e.source,e.target);
    }
  }
  return totalCost;
}

int main(){
  int N,M,cost;
  int source,target;

  cin >> N >> M;

  vector<Edge> edges;
  for(int i=0;i<M;i++){
    cin >> source >> target >> cost;
    edges.push_back(Edge(source,target,cost));
  }
  cout << kruskal(N,edges) << endl;
  return 0;
}



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

#define ll long long
void solve(ll a, ll b,ll c,ll d)
{
     int X=(a+d-1)/d;
     int Y=(c+b-1)/b;
     cout<<(X>=Y?"Yes":"No")<<"\n";
}

int main()
{
	ll a,b,c,d;
	cin >> a>>b>>c>>d;

	solve(a,b,c,d);

}

Measured memory_bytes: 3576
#include <stdio.h>

char x[100010];
int count[110];
int main()
{
	int a;
	scanf("%d",&a);
	for(int i=1;i<=a;i++)
	{
		scanf("%s",x+1);
		count[x[1]-'A']++;
	}
	printf("AC x %d\n",count[0]);
	printf("WA x %d\n",count['W'-'A']);
	printf("TLE x %d\n",count['T'-'A']);
	printf("RE x %d\n",count['R'-'A']);
}

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

#define MAX_R 10
#define MAX_C 10000
#define rep(a) for(int i = 0, i < (a), ++i)

int R, C, ans;
int field[MAX_R][MAX_C];
bool flag[MAX_R] = {false};

void solve(int n);

int count();

int main(){
    while(true){
        std::cin >> R >> C;
        if(R == 0 && C == 0)
            break;
        for(int i = 0; i < R; ++i){
            for(int j = 0; j < C; ++j){
                std::cin >> field[i][j];
            }
        }
        ans = 0;
        solve(0);
        std::cout << ans << std::endl;
    }
    return 0;
}

void solve(int n){
    if(n == R){
        ans = std::max(ans, count());
        return;
    }
    
    flag[n] = true;
    solve(n + 1);
    
    flag[n] = false;
    solve(n + 1);
    
    return;
}

int count(){
    int res = 0;
    
    for(int i = 0; i < C; ++i){
        int tmp =0;
        for(int j = 0; j < R; ++j){
            if((flag[j] && !field[j][i]) || (!flag[j] && field[j][i])) ++tmp;
        }
        res += std::max(tmp, R - tmp);
    }
    
    return res;
}

Measured memory_bytes: 1548
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>

typedef long long LL;
const int N = 200050;

inline int readInt() {
  int ans = 0, c, f = 1;
  while (!isdigit(c = getchar()))
    if (c == '-') f *= -1;
  do ans = ans * 10 + c - '0';
  while (isdigit(c = getchar()));
  return ans * f;
}

int n, A[N];

int main() {
  n = readInt();
  A[0] = -1;
  for (int i = 1; i <= n; ++i) A[i] = readInt();
  LL ans = 0;
  for (int i = 1; i <= n; ++i)
    if (A[i] > A[i - 1] + 1) {
      puts("-1");
      return 0;
    } else if (i > 1) {
      ans += A[i] == A[i - 1] + 1 ? 1 : A[i];
    }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 896