akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - AcCepted
            string s = Console.ReadLine();

            if (IsAccepted(s))
            {
                Console.WriteLine("AC");
            }
            else
            {
                Console.WriteLine("WA");
            }
        }

        static bool IsAccepted(string s)
        {
            if (s.StartsWith("A"))
            {
                if (CountLowers(s) == s.Length - 2)
                {
                    if (CountC(s) == 1)
                    {
                        return true;
                    }
                }
            }

            return false;
        }

        static int CountLowers(string s)
        {
            var substring = s.Substring(1, s.Length - 1);
            int count = 0;

            foreach(var c in substring)
            {
                if (char.IsLower(c))
                {
                    count++;
                }
            }

            return count;
        }

        static int CountC(string s)
        {
            var substring = s.Substring(2, s.Length - 3);
            int count = 0;

            foreach (var c in substring)
            {
                if (c == 'C')
                {
                    count++;
                }
            }

            return count;
        }
    }
}

Measured memory_bytes: 13396
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))
"""
A,B = nums()
P,Q,R = nums()

first_distance = P * B
pre_runned = (B - A) * Q
time = B + (first_distance - pre_runned) / (R + Q)
print(time)
"""
"""
N = num()
randoms = nums()
ans = 0
for i in range(N):
    today = randoms[i]
    if i == 0:
        continue
    if today > randoms[i-1]:
        ans += 1
print(ans)
"""
"""
N = num()
members = []
for i in range(N):
    members.append(input())

ans = members.count("E869120")
print(ans)
"""

N = num()
V = nums()
V.sort(reverse=True)
ans = 0
for i in range(N):
    Vi = V[i]
    ans += (Vi - i -1)
print(ans)


Measured memory_bytes: 16648
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    #→1,.→0として読み込む
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '#' else 0 for s in read()[:-1]])
        # 内包表記はpypyでは若干遅いことに注意
        # #numpy使うだろうからこれを残しておくけど
    return ret


MOD = 10**9 + 7
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

N, X, Y = read_ints()
X -= 1
Y -= 1

# 一箇所だけ短絡している
# もし短絡していなかったら簡単
# O(NN)でも間に合いそう

# 愚直にダイクストラしてもええか？
from scipy.sparse import csr_matrix  # 自分で配列を作ってからcsrに入れよう(lilに打ち込んでいくのは非常に遅い)

# ダイクストラ法 (正の単一始点最短経路) (全点間最短経路)
from scipy.sparse.csgraph import dijkstra
graph = [[0] * N for _ in range(N)]
for i in range(N - 1):
    graph[i][i + 1] = 1
    graph[i + 1][i] = 1
graph[X][Y] = 1
graph[Y][X] = 1
adj_mat = csr_matrix(graph)
D = dijkstra(adj_mat, directed=False)
cnt = Counter(D.reshape(-1))
ans=[]
for i in range(1, N):
    ans.append(int(cnt[i]) // 2)
print(*ans, sep='\n')


# D[i,j]でi→jに向かう最短経路
# indicesで始点を指定している場合は、D[j]でok


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

using namespace std;

typedef long long ll;

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

	string s;
	cin >> s;

	int ans = 0;
	int t = 0;
	rep(i, s.size()){
		if(s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T') {
			t = 0;
		}else{
			t++;
		}
		ans = max(ans, t);
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}




int main(){

  ll N;
  cin >> N;
  vector<ll> A(N);
  FOR(i,0,N) cin >> A[i];
  ll l=MOD,r=MOD;

  SORT(A);
  ll ans = A[N-1];

  priority_queue<P> pq;
  pq.push( {A[N-2],A[N-1]} );
  pq.push( {A[N-2],A[N-1]} );


  FORR(i,0,N-2){
    auto x = pq.top();
    ans += x.first;
    pq.pop();
    pq.push({A[i],x.first });
    pq.push({A[i],x.second});
  }

  cout << ans << endl;

}


Measured memory_bytes: 9020
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 13;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};


string n = "";

ll ans = 0;

void abc(){
    while (sz(n) > 1){
        ans++;
        int x = n.back()-'0';
        n.pop_back();
        x += n.back()-'0';
        n.pop_back();
        n += to_string(x);
    }
}

void solve(ll c, int d){
    if (!c) return;
    if (c&1){
        n += char(d+'0');
        c--;
    }
    if (d < 5){
        ans += c/2;
        solve(c/2, d+d);
    }
    else{
        ans += c;
        solve(c/2, d + d - 9);
    }
}

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int m;
    cin >> m;
    while (m--){
        int d;
        ll c;
        cin >> d >> c;
        solve(c, d);
      	abc();
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint dp[58][58][2575];
int x[58];
int main()
{
	int n,a;lint out=0;
	cin>>n>>a;
	rep(i,n) cin>>x[i];
	memset(dp,0,sizeof(dp));
	dp[0][0][0]=1;
	rep(i,n) rep(j,n+1) rep(k,2510){
		//if(!dp[i][j][k]) continue;
		dp[i+1][j][k]+=dp[i][j][k];dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
	}
	REP(i,1,n+1) out+=dp[n][i][a*i];
	cout<<out<<endl;
}


Measured memory_bytes: 67968
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"

using namespace std;

typedef long long int lli;

//const lli MOD = 1e9 + 7;
const lli MOD = 1000000007;	
lli inv[1000006];

int main(){
	ios_base::sync_with_stdio(false);
	inv[1] = 1;
	for(int i = 2; i < 1000006; ++i)
    	inv[i] = (MOD - (MOD/i) * inv[MOD%i] % MOD) % MOD;
	
	lli n, k;
	cin >> n >> k;
	lli res = 0;
	vector <lli> ar(n);
	for(lli &x: ar) cin >> x;
	for(int i=0; i<n; i++){
		int before = 0, after = 0;
		for(int j=0; j<i; j++){
			if(ar[j]<ar[i]) before++;
		}
		for(int j=i+1; j<n; j++){
			if(ar[j]<ar[i]) after++;
		}

		res += ((((after*(k+1LL) % MOD) * k) % MOD) * inv[2]) % MOD;
		res += (((((before*k) % MOD) * (k-1LL)) % MOD) * inv[2]) % MOD;
		res %= MOD;
	}

	cout << res;
	return 0;
}

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

//#define int long long
typedef long long ll;
const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int D;
    cin >> D;
    vector<int> c(26);
    for (int i=0;i<26;i++) cin >> c[i];
    vector<vector<int>> s(D,vector<int>(26));
    for (int i=0;i<D;i++){
        for (int j=0;j<26;j++){
            cin >> s[i][j];
        }
    }
    vector<int> t(D);
    //初期t[i]の決定
    for (int i=0;i<D;i++) {
        t[i] = i % 26;
    }

    ll oldsum = -INF;
    for (int m=0;m<100000;m++) {
        //ここでt[i]を更新していく
        int process = rand()%2;
        if (process == 0){
            int dd = rand()%D;
            int qq = rand()%26;
            int oldval = t[dd];
            t[dd] = qq;
            ll sum = 0;
            vector<int> last(26);
            for (ll i=0;i<D;i++){
                sum += s[i][t[i]];
                last[t[i]] = i+1;
                for (int j=0;j<26;j++){
                    sum -= c[j]*(i+1-last[j]);
                }
            }
            if (sum > oldsum) {
                oldsum = sum;
            } else {
                t[dd] = oldval;
            }
        } else {
            int dd1 = rand()%(D-1);
            int dd2 = dd1 + 1 + rand()%min(D-dd1-1,16);
            int qq1 = t[dd1];
            int qq2 = t[dd2];
            t[dd1] = qq2;
            t[dd2] = qq1;
            ll sum = 0;
            vector<int> last(26);
            for (ll i=0;i<D;i++){
                sum += s[i][t[i]];
                last[t[i]] = i+1;
                for (int j=0;j<26;j++){
                    sum -= c[j]*(i+1-last[j]);
                }
            }
            if (sum > oldsum) {
                oldsum = sum;
            } else {
                t[dd1] = qq1;
                t[dd2] = qq2;
            }
        }
        //=======================       
    }
    for (int i=0;i<D;i++){
        cout << t[i]+1 << "\n";
    }
}

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

int main(){

	ll n;

	cin >> n;
	vector<ll> v(10001);
	ll val;
	for(int i = 1; i <= 100; i++){
		for(int j = 1; j <= 100; j++){
			for(int k = 1; k <= 100; k++){
				val = i*i + j*j + k*k + i*j + j*k + k*i;
				if(val > 10000){
					break;
				}
				v[val]++;		
			}
		}
	}

	for(int i = 1;  i <= n; i++){
		cout << v[i] << "\n";
	}


}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef vector <int> ivector;

int seive(ivector &A, int n);

int main(void){
	ivector primes;
	int max_num=10000;
	seive(primes, max_num);

	int n, n0, lim, count;
	cin >> n;
	count = n;
	for (int i=0; i<n; i++){
		cin >> n0;
		lim = int(sqrt(n0));
		for (int j=0; j<(int)primes.size(); j++){
			int tmp=primes[j];

			if (tmp *tmp > n0)break;
			if (n0 % tmp == 0){
				count--;
				break;
			}
		}
	}
		cout<<count<<endl;
		return 0;
}

int seive(ivector &A, int n){
	ivector num(n+1,1);
	num[0]=0;
	num[1]=0;
	int count=1, limit=int(sqrt(n));
	for (int i=3; i<=n; i+=2)
		if (num[i]){
			count++;
			if (i<=limit)
				for (int j=3*i; j<=n; j+=2*i) num[j]=0;
		}

	A.resize(count);
	A[0] = 2;
	int j=1;
	for (int i=3; i<=n; i+=2)
		if (num[i]==1) A[j++]=i;
	return 0;
}

Measured memory_bytes: 1240
def dist(p, q)
  Math.sqrt((0..2).reduce(0){ |s, i| s + (p[i] - q[i]) ** 2 })
end

gets.to_i.times do
  real = gets.split.map(&:to_f)
  rank_re = real.map{ |r| real.sort.index(r) }
  real.sort!
  m = gets.to_i
  ps = m.times.map{ gets.split.map(&:to_f) }
  tbl = ps.map{ |p| ps.map{ |q| dist(p, q) } }
  (0...m).to_a.combination(3) do |i, j, k|
    idx = [i + 1, j + 1, k + 1]
    imag = [tbl[j][k], tbl[k][i], tbl[i][j]]
    rank_im = imag.map{ |im| imag.sort.index(im) }
    imag.sort!
    if imag.zip(real).map{ |i, r| i / r }.combination(2).map{ |x, y| x / y }.all?{ |v| (1 - v).abs < 0.001 }
      puts (0..2).map{ |i| idx[rank_im.index(rank_re[i])]}.join(' ')
      break
    end
  end
end

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

int main()
{
  const long long int MAX = 1000000LL;
  vector<long long int> hamming;

  long long int num = 1LL;
  for (int i = 0; ; ++i) {
    long long int five = num;
    for (int j = 0; j < i; ++j)
      five *= 5LL;

    if (five > MAX)
      break;

    for (int j = 0; ; ++j) {
      long long int three = five;
      for (int k = 0; k < j; ++k)
	three *= 3LL;

      if (three > MAX)
	break;

      for (int k = 0; ; ++k) {
	long long int two = three;
	for (int l = 0; l < k; ++l)
	  two *= 2;

	if (two > MAX)
	  break;
	hamming.push_back(two);
      }
    }
  }
  sort(hamming.begin(), hamming.end());

  long long int m, n;
  while (cin >> m >> n)
    cout << upper_bound(hamming.begin(), hamming.end(), n)
      - lower_bound(hamming.begin(), hamming.end(), m) << endl;
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#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 rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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;
}

int main() {
  int a, b;
  cin >> a >> b;
  int ans = max(a + b, max(a - b, a * b));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x;
  cin>>x;
  if (x >= 400 && x < 600) cout<<8;
  else if (x >= 600 && x < 800) cout<<7;
  else if (x >= 800 && x < 1000) cout<<6;
  else if (x >= 1000 && x < 1200) cout<<5;
  else if (x >= 1200 && x < 1400) cout<<4;
  else if (x >= 1400 && x < 1600) cout<<3;
  else if (x >= 1600 && x < 1800) cout<<2;
  else cout<<1;
  return 0;
}

Measured memory_bytes: 3620
n = int(input())
a = input()
b = input()
c = input()
ans = 0
for i,j,k in zip(a,b,c):
        if i == k and k == j:
                continue
        elif i == j or j== k or i == k:
                ans += 1
        else:
                ans+=2
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define lb long double
#define FOR(i,n) for(int i=0;i<n;i++)
#define DEBUG(x) cout << x
#define RUN ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back

using namespace std;
// VAR 
 ll a,b,ans;
// Solve
void Solve()
{
	cin >> a>> b;
	ll tmp=a+b;
	if(tmp%2==0) ans=tmp/2;
	else ans=-1; 
}
int main()
{
	RUN;
	Solve();
	if(ans==-1) cout << "IMPOSSIBLE";
	else DEBUG(ans);
	return 0;
}

Measured memory_bytes: 256
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    a = list(map(int, sys.stdin.readline().split()))#上段
    b = list(map(int, sys.stdin.readline().split()))#下段
    #どこ(i)で上段から下段に曲がればアメが最大になるか
    print(max(sum(a[:i+1])+sum(b[i:])for i in range(n)))

Measured memory_bytes: 5064
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int cnt=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='x')cnt++;
  }
  if(cnt>7){
    cout<<"NO"<<endl;
  }
  else{
    cout<<"YES"<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    boolean n = false;
    boolean w = false;
    boolean s = false;
    boolean e = false;
    for (int i = 0; i < S.length(); i++) {
      char c = S.charAt(i);
      if (c == 'N') {
        n = true;
      } else if (c == 'W') {
        w = true;
      } else if (c == 'S') {
        s = true;
      } else if (c == 'E') {
        e = true;
      }
    }
    System.out.println((n^s)||(w^e) ? "No" : "Yes");
  }
}

Measured memory_bytes: 23892
#include<stdio.h>

int main()
{
    int A, B,i,m,n,p,q,r,s,t,u;
    int count=0;
    scanf("%d %d", &A, &B);
    for(i=A;i<=B;i++)//12345
    {
        m=i%10;//5
        n=i/10;//1234
        p=n%10;//4
        q=n/10;//123
        r=q%10;//3
        s=q/10;//12
        t=s%10;//2
        u=s/10;//1
        if(m==u && p==t)
            count++;

    }

    printf("%d", count);

    return 0;
}


Measured memory_bytes: 1716
#include <iostream>
#include <algorithm>
#include <tuple>
//#include <string>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;




int main(){
	int N;

	cin >> N;
	if (N == 1) {
		cout << "Hello World" <<endl;
	}

	if (N == 2) {
		int A, B;
		cin >> A >> B;
		cout << A + B << endl;
	}




	return 0;
}


Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int i, j, l, r;
    double[] a, x, y;
    String s;
    char[] ch;

    a = new double[8]; x = new double[4]; y = new double[4];
    for(;sc.hasNext();){
      s = sc.next();
      ch = new char[s.length()];
      for(i = 0;i < s.length();i++)ch[i] = s.charAt(i);
      j = 0; l = 0;r = 0;
      for(i = 0;i < 8;i++){
        for(;j < s.length() + 1;j++){
          if(j == s.length() || ch[j] == ','){
            r = j; a[i] = readdouble(ch, l, r); l = ++j; break;
          }
        }
      }

      for(i = 0;i < 8;i++){
        x[i / 2] = a[i++]; y[i / 2] = a[i];
      }
      if(isconvex(x, y, 4))out.println("YES");
      else out.println("NO");
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static double readdouble(char[] ch, int l, int r){
    int i;
    double res, d, s;

    s = 1;
    if(ch[l] == '-'){
      s = -1; l++;
    }
    d = 1.0; res = 0.0;
    for(i = l;i < r;i++){
      if(ch[i] == '.')break;
      d *= 10;
    }
    d /= 10;

    for(i = l;i < r;i++){
      if(ch[i] != '.'){
        res += d * (double)(ch[i] - '0');
        d /= 10;
      }
    }
    return res * s;
  }
  private static boolean isconvex(double[] x, double[] y, int n){
    int i, count1, count2;
    double ax, ay, bx, by;

    count1 = 0; count2 = 0;
    for(i = 0;i < n;i++){
      ax = x[(i + 1) % n] - x[i]; ay = y[(i + 1) % n] - y[i];
      bx = x[(i + 2) % n] - x[i]; by = y[(i + 2) % n] - y[i];
      if(ax * by - ay * bx < 0)count1++;
      if(ax * by - ay * bx > 0)count2++;
    }
    if((count1 == 0 || count2 == 0) && count1 + count2 == 4)return true;
    else return false;
  }
}

Measured memory_bytes: 17132
#include<bits/stdc++.h>
using namespace   std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define double    long double
#define ull       unsigned long long
#define mod       1000000007
#define vi        vector<ll>
#define extreme   inline
#define ppi       pair<ll,pair<ll,ll>>
#define pb        push_back
#define mp        make_pair
#define str       string
#define pi        2*acos(0.0)
#define pr(a,x,n) for(int i=x;i<n;i++){cout<<a[i]<<" ";}
#define p(a)      cout<<a;
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define test      cout<<"THIS_AND_THIS"<<endl;
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll n,k;cin>>n>>k;
	ll arr[n];
	for(int i=0;i<n;i++){cin>>arr[i];}
	sort(arr,arr+n);
	ll ans=0;
	for(int i=0;i<k;i++){ans+=arr[i];}
	cout<<ans;
}
int32_t main(){
	kehsihba();
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n); for(ll i = 0; i < ll(n); i++)
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}



int main(){
  int n;
  cin>>n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(),l.end());
  int ans=0;
  rep(i,n-2){
    for(int j=i+1; j<n-1; j++){
      for(int k=j+1; k<n; k++){
        if(max(l[i]-l[j],l[j]-l[i])<l[k]&&l[k]<l[i]+l[j]) ans++;
      }
    }
  }
  
  cout<< ans<<endl;
  return 0;
}


Measured memory_bytes: 256
def ascan; gets.split.map(&:to_i); end

N = gets.to_i
A, B = ascan
P = ascan

x1 = 0
x2 = 0
x3 = 0

P.each do |pt|
    x1 += 1 if pt <= A
    x2 += 1 if A < pt && pt <= B
    x3 += 1 if B < pt
end

p [x1,x2,x3].min

Measured memory_bytes: 1788
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans=0
for ai in range(A+1):
    for bi in range(B+1):
        for ci in range(C+1):
            temp=ai*500+bi*100+ci*50
            if temp==X:
                ans+=1
print(ans)

Measured memory_bytes: 9080
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    PrintWriter pw = new PrintWriter(System.out);
    while (true) {
      int x = sc.nextInt();
      int y = sc.nextInt();
      if (x == 0 && y == 0)  break;
      pw.append(x > y ? y + " " + x : x + " " + y);
      pw.append("\n");
    }
    pw.flush();
    pw.close();
    sc.close();
  }
}


Measured memory_bytes: 35372
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//213
	ll n,m;
	cin>>n>>m;
	ll d = n/m;
	if(m&1) {
		cout<<d*d*d;
	} else {
		ll ans = d*d*d;
		ll now = (n+m/2)/m;
		ans+=now*now*now;
		cout<<ans;
	}
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define REP(i,n) for(int i=0;i<n;i++)
#define pb push_back


// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

int main(void) {
	// cin, coutの結びつきを解除し、速くする
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int N, i; cin >> N >> i;
	cout << N - i + 1 << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;


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

		for(int i = 1; i < 6; i++) {
			int x = scan.nextInt();
				if(x == 0) {
					System.out.println(i);
					break;
				}
		}
	}
}

Measured memory_bytes: 35624
#include <cstdio>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
const int maxn = 3010;
const int mod = (int)(1e9 + 7);
using namespace std;
int f[maxn][maxn][2];

void inline inc(int &a, int b)
{
	a = (a + b) % mod;
}

int main()
{
	int N, M, i, j;
	cin >> N >> M;
	for (j = 1; j <= N; j ++)
		f[0][j][0] = 1;
	f[0][0][0] = 0;
	f[0][0][1] = 1;
	for (i = 1; i <= M; i ++)
	{
		for (j = 0; j <= N; j ++)
		{
			// BB
			if (j > 0)
			{
				inc(f[i][j][0], f[i - 1][j - 1][0]);
				inc(f[i][j][1], f[i - 1][j - 1][1]);
			}

			// BR
			if (j < N)
			{
				inc(f[i][j][0], f[i - 1][j][0]);
				inc(f[i][j][1], f[i - 1][j][1]);
			}

			// RB
			if (j > 0)
			{
				if (j == 1)
					inc(f[i][j][1], f[i - 1][j][0]);
				else
					inc(f[i][j][0], f[i - 1][j][0]);
				inc(f[i][j][1], f[i - 1][j][1]);
			}

			// RR
			if (j < N)
			{
				inc(f[i][j][0], f[i - 1][j + 1][0]);
				inc(f[i][j][1], f[i - 1][j + 1][1]);
			}
		}
		inc (f[i][0][1], f[i][0][0]);
		f[i][0][0] = 0;
	}
	int ans = 0;
	for (j = 0; j <= N; j ++)
		inc(ans, f[M][j][1]);
	cout << ans << endl;
	//for (i = 0; i <= M; i ++)
	//{
	//	cout << i << ":" << " ";
	//	for (j = 0; j <= N; j ++)
	//		cout << "("<< f[i][j][0] << "," << f[i][j][1] << ")" ;
	//	cout << endl;
	//}
	return 0;
}

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


def solve(N: int, X: "List[int]"):
    X.sort()
    sum=0
    for i in X:
        sum+=i**2
    tempsum=0
    for p in range(X[0],X[N-1]+1):
        temp=0
        for j in range(N):
            temp+=p**2-2*p*X[j]
        tempsum=min(tempsum,temp)
    print(sum+tempsum)
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<cstdio>
using namespace std;
int N,ans,N1;
int main()
{
	scanf("%d",&N);
	N1=N;
	while(N!=0)
	{
		ans+=N%10;
		N=N/10;
	}
	if(N1%ans==0)
	printf("Yes");
	else
	printf("No");
	return 0;
}

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

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

  priority_queue<int> q1;
  priority_queue<int,vector<int>,greater<int>> q2;
  for(int i = 0; i < n; i++){
    q1.push(a[i]);
    if(q1.size() > q2.size()+1){
      int p = q1.top(); q1.pop();
      q2.push(p);
      if(q1.top() > q2.top()){
        int tmp1 = q1.top(); q1.pop();
        int tmp2 = q2.top(); q2.pop();
        q1.push(tmp2);
        q2.push(tmp1);
      }
    }
  }
  //cout << q1 << " " << q2 << endl;

  int ans = 0;
  for(int i = 0; i < n; i++){
    ans += abs(a[i] - q1.top());
  }
  cout << ans << endl;

  return 0;
}


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

public class Main
{
    public static void main(String[] args)
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            int i;
            int n = Integer.parseInt(br.readLine());
            ArrayDeque<String> list = new ArrayDeque<String>();
            String[] num = new String[2];
            String command;
            char c;
            for(i=0; i<n; i++)
            {
                command = br.readLine();
                c = command.charAt(0);

                if(c == 'd')
                {
                    c = command.charAt(6);
                    if(c == 'F')
                    {
                        list.pollFirst();
                    }
                    else if(c == 'L')
                    {
                        list.pollLast();
                    }
                    else
                    {
                        num = command.split(" ",0);
                        list.remove(num[1]);
                    }
                }
                else
                {
                    num = command.split(" ",0);
                    list.offerFirst(num[1]);
                }
            }

            StringBuilder s = new StringBuilder();
            s.append(list.poll());
            while(list.size()>0)
            {
                s.append(" ").append(list.poll());
            }
            System.out.println(s);
        }
        catch(Exception e)
        {
        }
    }
}

Measured memory_bytes: 221696
n = int(input())
A = list(map(int, input().split()))

sum_l = sum(A)
sum_r = 0
half_abs = 2020202020
for a in A:
    sum_l -= a
    sum_r += a
    tmp_abs = abs(sum_l-sum_r)
    half_abs = min(half_abs, tmp_abs)
print(half_abs)


Measured memory_bytes: 26060
'use strict'

const main = input => {
	const args = input.trim().split('\n')
	const k = parseInt(args[0].split(' ')[1], 10)
	const s = args[1]
	console.log(`${s.slice(0, k - 1)}${s.slice(k - 1, k).toLowerCase()}${s.slice(k)}`)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main(){
  int N,count=0;
  string S;
  cin >> N >> S;
  for(int i=0;i<N-2;i++){
    if(S.at(i)=='A' && S.at(i+1)=='B' && S.at(i+2)=='C'){
      count++;
    }
  }
  cout << count << endl;
}
    

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}



int main(){
	int n, q;
	cin >> n >> q;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	rep(qi,q){
		long long int x;
		cin >> x;
		long long int ans = 0;
		long long int s = 0;
		int r = 0;
		rep(l, n)
		{
			while(r < n && s + a[r] <= x){
				s += a[r];
				r++;
			}
			ans += (r - l);
			if (l == r)
				r++;
			else
				s -= a[l];
		}
		cout << ans << endl;
	}

	return 0;
}




Measured memory_bytes: 3160
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF32		INT32_MAX
#define	INF64		INT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

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

// main function
int main()
{
	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll ans_max = 0;

	cin >> N >> A >> B;
	ans_max = max<ll>(A + B - N, 0);
	cout << min(A, B) << " " << ans_max;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pll;
typedef pair<int,pll> P;
struct unionfind{
  int par[110]; // 親ノード  必要に応じて要素数を変えよう
  int rank[110]; // ランク　必要に応じて要素数を変えよう
  unionfind(int n){
    init(n);
  }
  void init(int n){
    for(int i=0;i<=n;i++){
      par[i]=i;
      rank[i]=1;
    }
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    }
    else {
      return par[x] = root(par[x]);
    }
  }
  int size(int x){
    return rank[root(x)];
  }
  bool same(int x,int y) {
    return root(x) == root(y);
  }
  void unite(int x,int y) {
    x=root(x);
    y=root(y);
    if(x==y){
      return;
    }
    if(rank[x]<rank[y]){
      swap(x,y);
    }
    rank[x]=rank[x]+rank[y];
    par[y]=x;
  }
};
int main(){
  while(1){
    int n,m,i;
    cin >> n >> m;
    if(n==0 && m==0){
      return 0;
    }
    unionfind tree(n);
    vector<P> g;
    for(i=0;i<m;i++){
      int a,b,c;
      cin >> a >> b >> c;
      g.push_back(make_pair(c,pll(a,b)));
    }
    sort(g.begin(),g.end());
    int ans=0;
    for(i=0;i<m;i++){
      if(!tree.same(g[i].second.first,g[i].second.second)){
        tree.unite(g[i].second.first,g[i].second.second);
        ans+=g[i].first;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

template <typename T>
struct edge
{
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x)
    {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

//Weighted edge set
template <typename T>
using Edges = vector<edge<T>>;

//Weighted graph
template <typename T>
using WeightedGraph = vector<Edges<T>>;

//Unweighted graph (adjacency matrix)
//Initialize : vector<vector<int>>(N, vector<int>(N, 0))
template <typename T>
using UnweightedGraph = vector<vector<T>>;

//distance matrix
template <typename T>
using Matrix = vector<vector<T>>;

template <typename T>
vector<T> BellmanFrod(Edges<T> &edges, int N, int source)
{
    const auto INF = numeric_limits<T>::max();
    vector<T> dist(N, INF); //distance from source
    dist[source] = 0;
    for (int i = 0; i < N - 1; i++)
    {
        for (auto &e : edges)
        {
            if (dist[e.src] == INF)
                continue;
            dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
        }
    }
    vector<bool> neg(N);
    int cnt = N;
    while (cnt--)
    {
        for (auto &e : edges)
        {
            if (dist[e.src] == INF)
                continue;
            if (dist[e.src] + e.cost < dist[e.to])
                neg[e.to] = true;
            if (neg[e.src] == true)
                neg[e.to] = true;
        }
    }
    if (neg[N - 1] == true)
        return vector<T>();
    return dist;
}

int N, M;
int P;

int main()
{
    cin >> N >> M >> P;
    Edges<int> G;
    for (int i = 0; i < M; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        c -= P;
        G.emplace_back(a, b, -c);
    }

    auto d = BellmanFrod(G, N, 0);

    if (d.size() == 0)
        cout << -1 << endl;
    else
        cout << max(0, -d[N - 1]) << endl;
}

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

using namespace std;

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

const ll INF = 1e15;

int R, C, N;
vector<P> g[200010];
vector<ll> memo;

bool dfs(int cur, ll& x, ll& y) {
	for (P p : g[cur]) {
		if (memo[p.first] != INF) {
			if (memo[p.first] + memo[cur] != p.second) return false;
			continue;
		}
		memo[p.first] = p.second - memo[cur];
		if (p.first < R) x = min(x, memo[p.first]);
		else y = min(y, memo[p.first]);
		if (!dfs(p.first, x, y)) return false;
	}
	return true;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> R >> C >> N;
	for (int i = 0; i < N; i++) {
		int r, c, a;
		cin >> r >> c >> a;
		r--;
		c--;
		g[r].emplace_back(R + c, a);
		g[R + c].emplace_back(r, a);
	}

	memo.resize(R + C, INF);
	bool ans = true;
	for (int i = 0; i < R + C; i++) {
		if (memo[i] == INF) {
			memo[i] = 0;
			ll x = INF, y = INF;
			if (i < R) x = 0;
			else y = 0;
			if (!dfs(i, x, y) || x + y < 0) {
				ans = false;
				break;
			}
		}
	}

	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 15872
def main():
    N, M = [int(v) for v in input().split(' ')]
    X = sorted([int(v) for v in input().split(' ')])

    if N >= M:
        print(0)
        return

    l = []
    x0 = X[0]
    for x in X[1:]:
        dx = x - x0
        l.append(dx)
        x0 = x

    sl = sorted(l)

    count = 0
    for v in sl[0:M - N]:
        count += v
    print(count)


main()


Measured memory_bytes: 13840
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

int main(){
   int H, W, D;
   std::cin >> H >> W >> D;
   int A;
   std::vector<int> px(H*W);
   std::vector<int> py(H*W);
   for(int i=0; i<H; ++i){
      for(int j=0; j<W; ++j){
	 std::cin >> A;
	 px[A-1] = i;
	 py[A-1] = j;
      }
   }

   int d[H*W+1];
   for(int i=1; i<=H*W; ++i){
      if(i<=D) d[i] = 0;
      else d[i] = d[i-D] + abs(px[i-1]-px[i-D-1]) + abs(py[i-1]-py[i-D-1]);
   }

   int Q;
   std::cin >> Q;
   int L[Q], R[Q];
   for(int itest=0; itest<Q; ++itest)
      std::cin >> L[itest] >> R[itest];

   for(int itest=0; itest<Q; ++itest){
      std::cout << d[R[itest]] - d[L[itest]] << std::endl;
   }

   return 0;

}


Measured memory_bytes: 2944
def main():
    N, L, *A = map(int, open(0).read().split())
    L = [i for i,(x,y) in enumerate(zip(A, A[1:]), 1) if x+y >= L]
    if L:
        print("Possible")
        B = [i for i in range(L[0], N)]+[i for i in range(1,L[0])][::-1]
        print(*B[::-1], sep="\n")
    else:
        print("Impossible")


if __name__ == "__main__":
    main()

Measured memory_bytes: 17372
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<functional>
#include<deque>
#include<string.h>
#include<ctype.h>
using namespace std;

int sub(int x, int k){
  for (int i = 0; i < k; i++){
    x *= 2;
  }
  return x;
}

int main(){
  int a[3], k, ans;
  for (int i = 0; i < 3; i++){
    cin >> a[i];
  }
  cin >> k;
  sort(a, a+3);
  ans = sub(a[2], k) + a[0] + a[1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {
        Console.ReadLine();
        string s = Console.ReadLine();
        int r = 0,b = 0;
        for(int i = 0; i < s.Length; i++)
        {
            if (s[i] == 'R')
                r++;
            else
                b++;
        }
        if (r > b)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}

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


def solve(N: int, T: int, t: "List[int]"):
    l = [t[i+1]-t[i] if (t[i+1]-t[i] < T) else T for i in range(N-1) ]
    print(sum(l)+T)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    t = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, T, t)

if __name__ == '__main__':
    main()


Measured memory_bytes: 28732
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long L = GetLong();
		long R = GetLong();
		long d = GetLong();
		long cnt = 0;
		for(long i = L; i <= R; i++)
		{
			if(i % d == 0)
				cnt++;
		}
		WriteLine(cnt);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  // A 赤
  // B 緑
  // C 青
  //
  // 1. 緑 > 赤
  // 2. 青 > 緑
  // 青 > 緑 > 赤

  int counter = 0;
  while (B <= A) {
    B = B * 2;
    counter++;
  }

  while (C <= B) {
    C = C * 2;
    counter++;
  }

  if (counter <= K) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3616
/*
    Takayuki Inubushi
    2014.06.25
    C language Lecture week 2
*/

#include <stdio.h>

int main (void) {
    
    int x;
    int ans = 1;
    int power = 3;
    
    scanf ( "%d", &x );
    for ( int cnt = 0; cnt < power; cnt ++ ){
        ans *= x;
    }
    
    printf ("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, x, n) for(int i = x; i < n; i++) 
#define pb push_back
#define int long long
#define hii cout << "hii" << endl
#define si size()
#define ff first 
#define ss second
#define all(s) s.begin(), s.end()

const int N = 1e5 + 5;

int arr[N], cost[N];

int ans = -999999;



int32_t main()
{
   
   int n;
   cin >> n;
   
   int cnt(0), z(0), sum(0);
   
   int mx = -99999999;
   int mn = 99999999;
   
   FOR(i, 0, n) cin >> arr[i], cnt += (arr[i] < 0), z += (arr[i] == 0) , sum += abs(arr[i]);
   FOR(i, 0, n) if(arr[i] < 0) mx = max(mx, arr[i]);else mn = min(arr[i], mn);
   
   
   if(cnt % 2 == 0)
   {
       cout << sum;
   }
   else if((cnt + z) % 2 == 0)
   {
       cout << sum;
   }
   else
   {
       cout << max(sum - 2*mn, sum + 2*mx);
   }
   
}

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

inline void ioThings() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#endif
}

#define debug(x)    cerr << #x << ": <" << (x) << ">\n"
#define dotc()      int tcs; if (cin >> tcs) for (int tc = 0; tc < tcs; tc++)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second
#define mod         1000000007

using ll = long long;
using vi = vector<int>;

int main() {
  ioThings();

  int n, r; cin >> n >> r;
  cout << r + max(10 - n, 0) * 100;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ll long long 
#define N 1000005
typedef std::pair<int,int> pii;
int n,a[N],c[N],cpy[N],cnt,sum[N],up;
struct tree{
	void clear(){memset(c,0,sizeof(c));}
	inline void upd(int x,int v){for(;x<=up;x+=x&-x) c[x]+=v;}
	inline int qry(int x,int ret=0){for(;x;x-=x&-x) ret+=c[x]; return ret;}
} T;
bool check(int mid){
	T.clear();
	ll ret=0; up=0;
	rep(i,1,n) sum[i]=a[i]>=mid?1:-1;
	rep(i,1,n) sum[i]+=sum[i-1],ret+=sum[i]>=0;
	rep(i,1,n) up=std::max(up,sum[i]+=n+1);
	rep(i,1,n) ret+=T.qry(sum[i]),T.upd(sum[i],1);
	return 1ll*n*(n-1)/2+n-ret<(1ll*n*(n-1)/2+n)/2+1;
}
int main(){
	std::ios::sync_with_stdio(0);
	std::cin.tie(0),std::cout.tie(0);
	std::cin>>n;
	rep(i,1,n) std::cin>>a[i],cpy[i]=a[i];
	std::sort(cpy+1,cpy+n+1);
	cnt=std::unique(cpy+1,cpy+n+1)-cpy-1;
	rep(i,1,n) a[i]=std::lower_bound(cpy+1,cpy+cnt+1,a[i])-cpy;
	int l=1,r=cnt,ans=-1;
	while(l<=r){
		int mid=l+r>>1;
		if(check(mid)) l=mid+1,ans=mid;
		else r=mid-1;
		
	}
	std::cout<<cpy[ans]<<'\n';
	return 0;
}

Measured memory_bytes: 8764