akhauriyash/Code-Regression huggingface dataset:
x, y, a, b, c = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)[:x]
Q = sorted(list(map(int, input().split())), reverse=True)[:y]
R = sorted(list(map(int, input().split())), reverse=True)
M = sorted(P+Q+R, reverse=True)
print(sum(M[:x+y]))

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

const int MAX = 5000;
const ll INF = 1e17;

int N;
ll A[MAX];

vector<int> G[MAX];

int size[MAX];
ll dp[MAX][MAX][2];

void calc(int v, int prev) {
	size[v] = 1;
	int deg = 0;
	for (int i = 0; i < MAX; i++) {
		dp[v][i][0] = INF;
	}
	for (auto to : G[v]) if (to != prev) {
		calc(to, v);
		++deg;
	}
	if (A[v] > 0) {
		dp[v][0][1] = 1;
		for (auto to : G[v]) if (to != prev) {
			vector<int> pre(size[v]);
			for (int i = 0; i < size[v]; i++) {
				pre[i] = dp[v][i][1];
				dp[v][i][1] = 0;
			}
			for (int i = 0; i < size[v]; i++) if (pre[i]) {
				for (int j = 0; j < size[to]; j++) if (dp[to][j][1]) {
					dp[v][i + j][1] = true;
				}
			}
			for (int i = 0; i < size[to]; i++) if (dp[to][i][1] || dp[to][i][0] < 0) {
				for (int j = 0; j < size[v]; j++) if (pre[j]) {
					dp[v][i + j + 1][1] = true;
				}
			}
			size[v] += size[to];
		}
	}
	dp[v][0][0] = A[v];
	size[v] = 1;
	for (auto to : G[v]) if (to != prev) {
		vector<ll> pre(size[v]);
		for (int i = 0; i < size[v]; i++) {
			pre[i] = dp[v][i][0];
			dp[v][i][0] = INF;
		}
		for (int i = 0; i < size[v]; i++) if (pre[i] != INF) {
			for (int j = 0; j < size[to]; j++) if (dp[to][j][0] != INF) {
				dp[v][i + j][0] = min(dp[v][i + j][0], pre[i] + dp[to][j][0]);
			}
		}
		for (int i = 0; i < size[to]; i++) if (dp[to][i][1] || dp[to][i][0] < 0) {
			for (int j = 0; j < size[v]; j++) if (pre[j] != INF) {
				dp[v][i + j + 1][0] = min(dp[v][i + j + 1][0], pre[j]);
			}
		}
		size[v] += size[to];
	}
}

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N - 1; i++) {
		int u, v;
		cin >> u >> v; --u, --v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	calc(0, -1);
	for (int i = 0; i < N; i++) if (dp[0][i][1] || dp[0][i][0] < 0) {
		cout << i << endl;
		break;
	}
	return 0;
}


Measured memory_bytes: 391680
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}





int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int a[27];
  int b[27];
  int max=0;
  for(int i=0;i<S.size();i++){

  for(int j=0;j<27;j++){
    a[j]=0;
    b[j]=0;
  }
  for(int k=0;k<i;k++){
    a[moji(S.at(k))]++;
  }
  for(int k=i;k<S.size();k++){
    b[moji(S.at(k))]++;
  }
  int sum=0;
  for(int l=0;l<26;l++){
    if(b[l]>0&&a[l]>0){
      sum++;
    }
  }
  if(sum>max){
    max=sum;
  }

  }
  cout<<max<<endl;






  





  



}


  

Measured memory_bytes: 256
def tableTennis():
    N, A, B = map(int, input().split())
    roundTime = 0
    if (B - A) % 2 == 0:
        roundTime = int((B - A)//2)
    else:
        roundTime = int(min(A - 1,N - B) + 1 + (B-A-1)//2)

    print(roundTime)



tableTennis()

Measured memory_bytes: 2940
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;
long long int N,M;

int main(){
  cin >> N >> M;
  vector <pair<long long int,long long int> > v;
  REP(i,N){
    long long int a,b;
    cin >> a >> b;
    v.push_back(pair<long long int,long long int> (a,b));
  }
  sort(v.begin(),v.end());
  long long int now = 0;
  long long int res = 0;
  REP(i,N){
    now += v[i].second;
    if(now>=M){
      res += v[i].first *(v[i].second-now+M);
      //cout << v[i].second<< " "<<now << " "<<M << endl;
      cout << res << endl;
      return 0;
    }
    else{
      res += v[i].first * v[i].second;
      //cout << res << i << endl;
    }
  }

}


Measured memory_bytes: 2420
def judge(ind):

    maxi = A[ind] + M

    left = M * (V-1)
    over = 0
    np = P-1

    for i in range(N):
        
        if i == ind:
            continue
        
        if np > 0:
            left -= M
            np -= 1
        elif A[i] > maxi:
            return False
        else:
            left -= min(M, maxi - A[i])

    if left > 0:
        return False
    else:
        return True


N,M,V,P = map(int,input().split())

A = list(map(int,input().split()))

A.sort()
A.reverse()

l = 0
r = N

while r - l != 1:

    mid = (l+r)//2

    if judge(mid):
        l = mid
    else:
        r = mid

print (r)



Measured memory_bytes: 62576
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<=n;i++)
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=0;

int main() {
  ll N,M,c=0,K;
  cin>>N>>M>>K;
  for(int i=0;i<=N;i++){
    if(M*i==K){
      c=1;
    }
  }
  rep(i,M){
    if(N*i==K){
      c=1;
    }
  }
  rep(i,N){
    rep(j,M){
      if(i*j+(N-i)*(M-j)==K||i*j+(N-i)*(M-j)==N*M-K){
        c=1;
      }
    }
  }
  if(c){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	numList := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&numList[i])
	}
	sort.Sort(sort.IntSlice(numList))
	var max, sum int
	for i:=0; i<N-1; i++ {
		sum = numList[i] + sum
	}
	max = numList[N-1]
	if max < sum {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}


}


Measured memory_bytes: 512
/*input
10 8851025
38 87 668 3175 22601 65499 90236 790604 4290609 4894746

5 1
1 999999997 999999998 999999999 1000000000

16 10
1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408

2 100
1 10
*/
#include <bits/stdc++.h>
using namespace std;
const int MXN = 200010;
const long long INF = 1e18;
int n;
long long ans, m, a[MXN];

int main()
{
	scanf("%d %lld", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%lld", &a[i]), a[i] = a[i-1] + a[i];
	ans = INF;
	for (int i = 1; i <= n; i++)
	{
		long long s = m * (i + n);
		for (int j = n, x = 1; j >= 1 && s < ans; j -= i, x++)
		{
			int k = max(j - i + 1, 1);
			if (j == n) s += 2 * (a[j] - a[k - 1]);
			s += (2 * x + 1) * (a[j] - a[k-1]);
		}
		ans = min(ans, s);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll mod=1e9+7;

struct UnionFind {
    int n, cnt;
    vector<int> par, rank, sz;

    UnionFind(int n) : n(n), cnt(n), par(n), rank(n), sz(n, 1) {
        iota(par.begin(), par.end(), 0);
    }

    int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }

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

    int size(int x) {
        return sz[find(x)];
    }

    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
            sz[y] += sz[x];
        } else {
            par[y] = x;
            sz[x] += sz[y];
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
        cnt--;
    }
};


int main(){
  int i,j;
  int n;
  cin>>n;
  int a[n],b[n];
  int aa[n],bb[n];
  map<int,int> ma;
  map<int,int> ma2;
  for(i=0;i<n;i++){
    cin>>a[i];
    aa[i]=a[i];
    ma2[aa[i]]=i;
  }
  for(i=0;i<n;i++){
    cin>>b[i];
    bb[i]=b[i];
    ma[bb[i]]=i;
  }
  int cnt=0;
  for(i=0;i<n;i++){
    if(a[i]<=b[i]) cnt++;
  }
  if(cnt==0) {
    cout<<"No"<<endl;
    return 0;
  }
  sort(a,a+n);
  sort(b,b+n);
  for(i=0;i<n;i++){
    if(a[i]>b[i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  for(i=1;i<n;i++){
    if(a[i]<=b[i-1]){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  for(i=0;i<n;i++){
    if(ma2[a[i]]==ma[b[i]]){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  
  UnionFind uf(n);
  for(i=0;i<n-1;i++){
    if(uf.same(ma2[a[i]],ma[b[i]])) {
      cout<<"Yes"<<endl;
      return  0;
    }
    uf.unite(ma2[a[i]],ma[b[i]]);
  }
  cout<<"No"<<endl;
}


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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

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

	vector<ll> h(N);
	for (int i = 0; i < N; ++i) {
		cin >> h[i];
	}

	sort(h.begin(), h.end());

	ll ans = 10000000000;
	for (int i = 0; i <= N - K; ++i) {
		ans = min(ans, h[i + K - 1] - h[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4060
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break

    ans = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            if j < x - i - j <= n:
                ans += 1
            elif x - i - j <= j:
                break
        if i + j >= x:
            break
    print(ans)


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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 (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	rep(i,5){
		int a;
		cin>>a;
		if(a==0){
			cout<<i+1<<endl;
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
    using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n;
string s;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> s;
    vector<ll> r, g, b;
    rep(i, n)
    {
        if (s[i] == 'R')
            r.push_back(i);
        if (s[i] == 'G')
            g.push_back(i);
        if (s[i] == 'B')
            b.push_back(i);
    }
    ll ans = 0;
    rep(i, r.size())
    {
        rep(j, g.size())
        {
            ll temp = b.size();
            if (2 * r[i] - g[j] < n && 2 * r[i] - g[j] >= 0)
            {
                if (s[2 * r[i] - g[j]] == 'B')
                    temp--;
            }
            if (2 * g[j] - r[i] < n && 2 * g[j] - r[i] >= 0)
            {
                if (s[2 * g[j] - r[i]] == 'B')
                    temp--;
            }
            if (abs(r[i] - g[j]) % 2 == 0)
            {
                if (s[abs(r[i] - g[j]) / 2+min(r[i],g[j])] == 'B')
                    temp--;
            }
            ans += temp;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,roop=0,ans[100];
    while(cin>>n&&n!=0){
        int k[n],cou=0;
        for(int i=0;i<n;i++){
            cin>>k[i];
            if(k[i]>0) cou++;
        }
        sort(k,k+n);
        if(k[n-1]<2) ans[roop]=-1;
        else ans[roop]=cou+1;
        roop++;
    }
    for(int i=0;i<roop;i++){
       if(ans[i]!=-1) cout<<ans[i]<<endl;
       else cout<<"NA"<<endl;
    }
}

Measured memory_bytes: 3112
#include <stdio.h>
int main(void)
{
	int H,W,i,j;
		
	while(1){
		scanf("%d %d",&H,&W);
	if(H==0 && W==0) break;
	for(j=0; j<H;j++){
	    for(i=0; i<W;i++){
			if((i+j)%2 == 0)
			putchar('#');
			else
			putchar('.');
			
	    }

	putchar('\n');
	}
	putchar('\n');
	}
	return 0;
}



Measured memory_bytes: 2104
#include<cstdio>

int main() {
	int n1, n2, t, cnt = 0;
	scanf("%d", &n1);
	int A[n1];
	for (int i = 0; i < n1; i++) {
		scanf("%d", &A[i]);
	}
	scanf("%d", &n2);
	for (int i = 0; i < n2; i++) {
		scanf("%d", &t);
		int left = 0;
		int right = n1;
		int mid;
		while (left < right) {
			mid = (left + right) / 2;
			if (t == A[mid]) {
				cnt++;
				break;
			} else if (t < A[mid]) {
				right = mid;
			} else {
				left = mid + 1;
			}
		}
	}
	printf("%d\n", cnt);

	return 0;
}

Measured memory_bytes: 1416
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[N], b[N];
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];
    int ans = 0;
    for(int v = (1 << 28); v != 0; v >>= 1) {
        rep(i, N) a[i] &= (v*2-1);
        rep(i, N) b[i] &= (v*2-1);
        sort(a, a+N); sort(b, b+N);
        int t = 0;
        for(int i = N - 1, j = 0, k = 0, l = 0; i >= 0; i--) {
            while(j < N && a[i] + b[j] < v) j++;
            while(k < N && a[i] + b[k] < 2*v) k++;
            while(l < N && a[i] + b[l] < 3*v) l++;
            t += k-j + N-l;
            t &= 1;
        }
        if (t) ans |= v;
    }
    cout << ans << endl;

    return 0;
}


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

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

Measured memory_bytes: 256
import java.util.*; 
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        int[] a = new int[n+1];
        for(int i = 0;  i < n; i++){
            a[i] = sc.nextInt();
        }
        long ans = Long.MAX_VALUE;
        for(int i = 0;  i+k-1 < n; i++){
            ans = Math.min(ans, Math.min(Math.abs(a[i]) + Math.abs(a[i] - a[i+k-1]), Math.abs(a[i+k-1]) + Math.abs(a[i] - a[i+k-1])));
        }
        System.out.println(ans);
    }
 }



Measured memory_bytes: 50284
// +build ignore
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func gcd(x, y int) int {
	if x%y != 0 {
		return gcd(y, x%y)
	}
	return y
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	N := sc.nextInt()
	K := sc.nextInt()
	Sunuke := make([]int, N)
	for i := 0; i < K; i++ {
		d := sc.nextInt()
		for j := 0; j < d; j++ {
			idx := sc.nextInt() - 1
			Sunuke[idx] = 1
		}
	}

	sum := 0
	for i := 0; i < N; i++ {
		if Sunuke[i] == 0 {
			sum++
		}
	}

	fmt.Println(sum)

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 1760
#include<iostream>
using namespace std;
int main(){
	int i,j;
    string s,a;
    cin >> s;
    j=0;
    for(i=0;i<s.size();i++){
    	if(s[i]=='0')
    		a[j++]='0';
    	else if(s[i]=='1')
    		a[j++]='1';
    	else{
    		if(j>0)
    			j--;
		}
    }
    for(i=0;i<j;i++)
    	cout << a[i];
    cout << endl;
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    switch(n%10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout<<"hon"<<endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout<<"pon"<<endl;
            break;
        case 3:
            cout<<"bon"<<endl;
            break;
    }
}

Measured memory_bytes: 3564
#define _LIBCPP_DEBUG 0

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int ans=c-a+b;
  if(ans<0){
    cout<<0<<endl;
    return 0;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define c(a,n) for(int i = 0; i < n; i++) cin >> a[i];
#define ffor(n) for(int i = 0; i < n; i++)
#define float long double
typedef vector<int> vi;
typedef vector<float> vf;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef unordered_map<string,int> umsi;
 
 
int32_t main()
{
    fast_io;
    
       int n,k;
       cin>>n>>k;
       vi a(n);
       c(a,n);
       vi dp(k+1,0);
       dp[0]=0;
       if(k<a[0])
           cout<<"Second";
         
       else{

       for(int i=1;i<=k;i++)
       {
           for(int j=0;j<n;j++){
               if(i-a[j]>=0 ){
                   if(dp[i-a[j]]==0){dp[i]=1;break;}
               }
           }
       }
        if(!dp[k])cout<<"Second";
        else cout<<"First";
       }
    return 0;
}

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

__int128 div_floor(__int128 x, __int128 y) {
  if (x >= 0) return x / y;
  // x < 0
  if (x % y == 0) return x / y;
  return x/y - 1;
}

__int128 div_ceil(__int128 x, __int128 y) {
  if (x >= 0) return (__int128(x)+y-1) / y;
  if (x % y == 0) return x / y;
  return x/y + 1;
}

int main(){
  long long N, q, L0, R0;
  cin >> N >> q >> L0 >> R0;
  __int128 L = L0;
  __int128 R = R0;
  vector<long long> A(N);
  for(int i = 0; i < N; ++i){
    cin >> A[i];
  }
  //fprintf(stderr, "%lld %lld %lld %lld (NqLR)\n", N, q, L, R);
  vector<long long> Q(q), X(q), S(q), T(q);
  for(int i = 0; i < q; ++i){
    cin >> Q[i] >> X[i] >> S[i] >> T[i];
  }
  for(int i = q-1; i >= 0; --i){
    //fprintf(stderr, "%lld %lld %lld %lld (qxst)\n", Q[i], X[i], S[i], T[i]);
    if(Q[i] == 1){
      // R = R/T[i] - S[i];
      // L = (L+T[i]-1)/T[i] - S[i];
      __int128 R_ = div_floor(R, T[i]) - S[i];
      __int128 L_ = div_ceil(L, T[i]) - S[i];
      //fprintf(stderr,"R_ = %lld, L_ = %lld, X[i] = %lld\n",R_,L_, X[i]);
      if(R_ > X[i]) R = R_;
      else if(R > X[i]) R = X[i];
      if(L_ > X[i]) L = L_;
      else if(L > X[i]) L = X[i];
    }else{
      __int128 R_ = R*T[i];
      __int128 L_ = L*T[i];
      if(R_ >= 0) R_ += T[i]-1;
      if(L_ <= 0) L_ -= T[i]-1;
      R_ += S[i];
      L_ += S[i];
      if(R_ < X[i]) R = R_;
      else if(R < X[i]) R = X[i];
      if(L_ < X[i]) L = L_;
      else if(L < X[i]) L = X[i];
    }

    R = min<__int128>(R, LLONG_MAX);
    L = max<__int128>(L, LLONG_MIN+1);
    //cerr << L << " " << R << endl;
  }
  //cerr << L << " " << R << endl;
  int ans = 0;
  for(auto a : A){
    if(a >= L and a <= R)
      ++ans;
  }
  cout << ans << endl;
}




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

using namespace std;
const int MAX_SIZE=1e5+10;
typedef long long ll;
ll arr[MAX_SIZE];

int main(){
    ios::sync_with_stdio(false);
    long long n,m;
    cin>>n>>m; 
    long long sum=0;
    for(int i=1;i<=m;i++){
        long long t;
        cin>>t;
        sum+=t;
    }
    if(sum<=n) cout<<n-sum;
    else cout<<-1;
    return 0;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int dp[100005];
int main(){
    vector<int>a;
    a.push_back(1);
    rep(i,8)a.push_back(a.back()*9);
    a.push_back(6);
    rep(i,10)a.push_back(a.back()*6);
    rep(i,100001){
        if(i>0)dp[i] = INT_MAX;
        rep(j,a.size())if(i>=a[j])dp[i] = min(dp[i],dp[i-a[j]]+1);
    }
    int n;
    cin >> n;
    cout << dp[n] << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  int ok=1;
  
  rep(i,n){
    if(a[i]%2==0){
      if(a[i]%3!=0 && a[i]%5!=0)ok=0;
    }
  }
  cout<<(ok?"APPROVED":"DENIED");
}

Measured memory_bytes: 256
y,x = map(int, raw_input().split(" "))
mines = []
answer = []
for t in range(y):
    mines.append(list(raw_input()))

for i in range(y):
    notes = ""
    for h in range(x):
        if mines[i][h] == '.':
            count = 0
            if i != 0:
                if h != 0:
                    if mines[i-1][h-1] == "#":
                        count += 1
                if mines[i-1][h] == "#":
                    count += 1
                if h != x-1:
                    if mines[i-1][h+1] == "#":
                        count += 1
            if h != 0:
                if mines[i][h-1] == "#":
                    count += 1
            if mines[i][h] == "#":
                count += 1
            if h != x-1:
                if mines[i][h+1] == "#":
                    count += 1
            if i != y-1:
                if h != 0:
                    if mines[i+1][h-1] == "#":
                        count += 1
                if mines[i+1][h] == "#":
                    count += 1
                if h != x-1:
                    if mines[i+1][h+1] == "#":
                        count += 1
            mines[i][h] = str(count)
    notes = "".join(mines[i])
    print notes


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

typedef long long ll;

ll lcm(ll a, ll b) {
  return a*b/__gcd(a, b);
}

int main() {
  int a[3], m[3];
  
  while(true) {
    for(int i=0; i<3; i++) {
      cin >> a[i]; cin >> m[i];
    }
    if(a[0] == 0) break;
    
    ll x = 1, y = 1, z = 1;
    ll cnt[3] = {};
    for(;;) {
      x = a[0] * x % m[0];
      cnt[0] ++;
      if(x == 1) break;
    }
    for(;;) {
      y = a[1] * y % m[1];
      cnt[1] ++;
      if(y == 1) break;
    }
    for(;;) {
      z = a[2] * z % m[2];
      cnt[2] ++;
      if(z == 1) break;
    }
    cout << lcm(lcm(cnt[0], cnt[1]), cnt[2]) << endl;
  }
  
  return 0;
}

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


int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> jobs(M);

    for (int i = 0; i<N; ++i){
        int a, b;
        cin >> a >> b;
        if (a > M)
            continue;
        jobs[M - a].push_back(b);
    }
    priority_queue<int> q;
    long int ans = 0;
    for (int i = M - 1; i >= 0; --i){
        for (int b: jobs[i]){
            q.push(b);
        }
        if( !q.empty() ){
            ans += q.top();
            q.pop();
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <climits>
#include <stack>
#include <cstdio>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <regex>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) obj.begin(), obj.end()
#define UNIQUE(v) v.erase(unique(All(v)), v.end());
typedef long long ll;

typedef pair<int, int> P;
vector<P> vecp;
int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1};

#define N 1000
// input

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> p;
  REP(i,n){
    int a;
    cin >> a;
    p.push_back(a);
  }
  int count =0;
  int min = INT32_MAX;
  REP(i,n){
    if (p[i] < min){
      min = p[i];
      count++;
    }
  }
  cout << count;
}

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

ll solve(vector<ll> &arr, int ind, vector<ll> &memo ) {
	if( ind >= arr.size() )
		return INT_MAX;
	if( ind == arr.size()-1 )
		return 0;

	if( memo[ind] != -1 ) 
		return memo[ind];

	ll cost = INT_MAX;
	if( ind+1 < arr.size() )
		cost = min(cost, abs(arr[ind]-arr[ind+1]) + solve(arr, ind+1, memo) );
	if( ind+2 < arr.size() )
		cost = min(cost, abs(arr[ind]-arr[ind+2]) + solve(arr, ind+2, memo) );

	return memo[ind] = cost;
}

int main() {

  	int n;
  	cin>>n;
  	vector<ll> arr(n, 0);
  	vector<ll> memo(n, -1);
  	for( int i=0;i<n;i++ ) cin>>arr[i];

  	cout<<solve(arr, 0, memo);

  	return 0;
}

Measured memory_bytes: 9600
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;
// 最大公約数求める関数
int my_gcd(int n , int m){
  if(n < m){
    int tmp = n;
    n = m;
    m = tmp;
  }
  int l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

//char⇒int関数
 int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}



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

int ans = -1;
for(int i = 1; i <= 1000; i++){
	if(i * 8 / 100 == A && i * 10 / 100 == B){

		ans = i;
		break;
	}
}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll h, n; cin >> h >> n;
    ll asum = 0;
    rep(i, n) {
        ll a; cin >> a;
        asum += a;
    } 
    if (asum >= h) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
import sys
dataset = sys.stdin.readlines()
for n in dataset:
	n = int(n)
	counter = 0
	for a in range(10):
		for b in range(10):
			for c in range(10):
				for d in range(10):
					if a + b + c + d == n:
						counter += 1
	print(counter)

Measured memory_bytes: 7516
import java.util.Scanner;

public class Main {
	public static void main(String [] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		while(true){
			//H ??????????????????
			int H = sc.nextInt();
			//W ?¨????????????????
			int W = sc.nextInt();
			//????????????H??¨W???0?????´?????????
			if(W ==0&& H==0){
				break;
			}
			//??????????????¨???
			for(int i = 0; i< H; i++){
				String A= " ";
			//?¨????????????¨???
				for(int j = 0; j <W; j++){
					//?????????????????¶????????????????????????"#"?????¨???
					if(i ==0 || j ==0 || W-1 == j || H-1 == i){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 35092
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

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

if(N%K==0){
    cout<<"0";
}
else{
    cout<<"1";
}
 return 0;
}
/*


*/

Measured memory_bytes: 256
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,y = readInts()
for m in range(n+1):
    for f in range(n-m+1):
        #print(m,f)
        if 10000 * m + 5000 * f + 1000 * (n - m - f) == y:
            print(m,f,(n-m-f))
            exit()
print(-1,-1,-1)


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

typedef long long llong;

using namespace std;

llong cnt [128];

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

  for (int i = 0; i < (int) s.size(); i++) {
    cnt[s[i]]++;
  }

  llong ans = (llong) s.size() * ((llong) s.size() - 1) / 2 + 1;

  for (int i = 'a'; i <= 'z'; i++) {
    ans -= cnt[i] * (cnt[i] - 1) / 2;
  }

  cout << ans << endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, k;
	cin >> n >> k;

	vector<int> x(n);
	for (auto &v : x) {
		cin >> v;
	}

	int ans = INT_MAX;
	for (int l = 0; l <= n - k; l++) {
		int r = l + k - 1;
		ans = min(ans, x[r] - x[l] + min(abs(x[l]), abs(x[r])));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		String s = sc.next();
		
		if(a >= 3200) {
			System.out.println(s);
		}else {
			System.out.println("red");
		}
	}

}


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

int main() {
  vector<int> n(4);
  for (int i=0; i<4; i++) cin >> n.at(i);
  sort(n.begin(), n.end());
  if (n.at(0)==1 && n.at(1)==4 && n.at(2)==7 && n.at(3)==9)
    cout << "YES" << endl;
  else
    cout << "NO"<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B == C + D){
    cout << "Balanced" << endl;
  }
  else if (A + B > C + D){
    cout << "Left" << endl;
  }
  else if (A + B < C + D){  
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vs a;
vvi b,dp;

int main(){
	cin>>n;
	a=vs(n);
	b=dp=vvi(n,vi(n,1));
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++){
		string s;
		for(int j=0;j<n;j++) for(int k=0;k<n;k++) dp[j][k]=0;
		for(int j=0;j<n;j++) s+=a[(2*n+i-j)%n][j];
		for(int j=0;j<n;j++) dp[j][(j+1)%n]=dp[j][j]=1;
		for(int d=2;d<=n;d++) for(int l=0;l<n;l++){
			int r=(l+d)%n;
			if(dp[(l+1)%n][(r+n-1)%n]&&s[l]==s[(r+n-1)%n]) dp[l][r]=1;
		}
		for(int j=0;j<n;j++) for(int k=0;k<n;k++) if((!dp[j][k]||!dp[k][j])&&j!=k){
			b[(i-k+n+1)%n][j]=0;
		}
		for(int j=0;j<n;j++){
			string s_=s;
			reverse(s_.begin(),s_.end());
			if(s!=s_) b[(i-j+n+1)%n][j]=0;
			string t=s.substr(1,n-1)+s[0];
			s=t;
		}
	}
	int res=0;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) res+=b[i][j];
	cout<<res<<endl;
}

Measured memory_bytes: 1152
from collections import deque
n,m = map(int,input().split())

path = [[] for _ in range(n)]

for _ in range(m):
    l,r,d = map(int,input().split())
    path[l-1].append((r-1, d))
    path[r-1].append((l-1,-d))

pos = [None] * n

q = deque([0])
not_take = set(range(1,n))

ans = "Yes"

while q:
    
    a = q.popleft()
    if pos[a] is None:
        pos[a] = 0
    
    for b,dx in path[a]:
        
        if pos[b] is None:
            pos[b] = pos[a] + dx
            q.append(b)
            not_take.discard(b)
        elif pos[b] != pos[a] + dx:
            ans = "No"
            break
    if ans == "No": break
        
    if (not q) and (not_take != set()):
        q.append(not_take.pop())

if ans == "Yes" and max(pos) - min(pos) > 1e9:
    ans = "No"

print(ans)

Measured memory_bytes: 72016
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();


  ll n, p;
  cin >> n >> p;
  ll s = 0;
  ll t = 0;
  rep(i,n) {
    ll q;
    cin >> q;
    if (q%2 == 0) ++s;
    else ++t;
  }
  ll ans = 0;
  if (n == s) {
    if (p == 0) ans += pow(2,n);
  }
  else {
    ans += pow(2,n-1);
  }
  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}



Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int a[7],kp=0,num;
    ll mn=1e5,sum=0;
    for(int i=0;i<5;i++)
    {
        cin>>a[i];
        num=a[i]%10;
        if(num<mn&&num!=0)
        {mn=num;
        kp=i;}
    }

    for(int i=0;i<5;i++)
    {
        if(i!=kp&&a[i]%10>0)
        {
            num=a[i]/10;
            sum+=(num*10+10);
        }
        else
            {sum+=a[i];}

    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public final class Main{
    public static void main(String[] args){
        FastScanner stdIn = new FastScanner(System.in);
        
        int n = (int)stdIn.nextInt();
        long[] a = new long[n];
        for(int i=0; i<a.length; i++){
            a[i] = stdIn.nextLong();
        }

        if(n%3 == 0){
            int [] counter = new int[30];
            for(int i=0; i<a.length; i++){
                for(int j=30; j>0; j--){
                    if(a[i] >= twoD(j)){
                        a[i] -= twoD(j);
                        counter[j-1]++;
                    }
                }
            }
            for(int i=0; i<counter.length; i++){
                if(counter[i] != 0 && counter[i] != 2 * n / 3){
                    System.out.println("No");
                    return;
                }
            }
            System.out.println("Yes");
            return;
        }else{
            for(int i=0; i<a.length; i++){
                if(a[i] != 0){
                    System.out.println("No");
                    return;
                }
            }
            System.out.println("Yes");
            return;
        }
    }

    static long twoD(int n){
        long num = 1;
        for(int i=0; i<n; i++){
            num*=2;
        }
        return num;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

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

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

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

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

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

}


Measured memory_bytes: 33452
from collections import Counter
n = int(input())
A = list(input().split())
q = int(input())
ansList = [0]*q
d = Counter(A)
Sum = sum(map(int,A))

for i in range(q):
    b,c = input().split()
    Sum = Sum - int(b)*d[b] + int(c)*d[b]
    if b in d:
        if c in d:
            d[c] += d.pop(b)
        else:
            d[c] = d.pop(b)
    ansList[i]  +=  Sum

[print(ans) for ans in ansList]

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

count1=0
count2=0
count4=0
for i in range(n):
    if a[i]%4==0: count4+=1
    elif a[i]%2==0: count2+=1
    else: count1+=1

if count2==0:
    if count4+1>=count1: print("Yes")
    else: print("No")
else:
    if count4>=count1: print("Yes")
    else: print("No")



Measured memory_bytes: 14252
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
struct edge{int from,to,cost;};
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
signed main(){
    string s;cin>>s;
    int n;cin>>n;
    rep(i,0,n){
        string m,k;int a,b;cin>>m>>a>>b;
        if(m=="print"){
            string ans=s.substr(a,b-a+1);
            cout<<ans<<endl;
        }
        else if(m=="reverse")reverse(s.begin()+a,s.begin()+b+1);
        else{
            cin>>k;
            s.replace(a,b-a+1,k);
        }
    }
    return 0;
}


Measured memory_bytes: 3144
a =int(input())
b =int(input())
c =int(input())
d =int(input())
e =int(input())
k =int(input())

if b-a > k:
  print(':(')
elif c-a > k:
  print(':(')
elif d-a > k:
  print(':(')
elif e-a > k:
  print(':(')
elif c-b > k:
  print(':(')
elif d-b > k:
  print(':(')
elif e-b > k:
  print(':(')
elif d-c > k:
  print(':(')
elif e-c > k:
  print(':(')
elif e-d > k:
  print(':(')
else:
  print('Yay!')

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    double result = 0;
    for(int i = 1; i <= N; ++i){
        if(i < K) {
            int m = (int)ceil(log2((double)K) - (double)log2(i));
            result += 1/((double)N*(double)(pow(2, m)));
        }
        else{
            result += 1/((double)N);
        }
    }
    cout << setprecision(12) << result;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long h,n,maryoku,power;
  cin>>h>>n;
  vector<long> ans(h+1);
  for(long i=0; i<h+1; i++){
    ans.at(i)=100000000;
  }
  ans.at(0)=0;
  for(long i=0; i<n; i++){
    cin>>power>>maryoku;
    for(long j=0; j<h+1; j++){
      if(j<power){
        ans.at(j)=min(ans.at(j),maryoku);
      }
      else{
        ans.at(j)=min(ans.at(j),ans.at(j-power)+maryoku);
      }
    }
  }
  cout<<ans.at(h);
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cmath>
#include <time.h>
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) ((c).rbegin(),(c).rend())
#define ll long long
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;
int a[1001];

inline bool main2(int a) {
	vector<int> v;
	if (a < 10 && a>0)return 1;
	while (a > 0) {
		v.push_back(a % 10);
		a /= 10;
	}
	for (int i = v.size()-1; i>=1; i--) {
		if (v[i] - v[i - 1] != -1) {
			return 0;
		}
	}
	return 1;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int maxans = -3;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i != j) {
				if (main2(a[i] * a[j])) {
					maxans = max(maxans, a[i]*a[j]);
				}
			}
		}
	}
	if (maxans == -3)cout << -1 << endl;
	else cout << maxans << endl;
	return 0;
}

Measured memory_bytes: 3140
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void){
	long long int n,a[100000],i,cnt,c;
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i];
	cnt=0; c=0;
	for(i=0;i<n;i++){
		if(a[i]%4==0) cnt++;
		if(a[i]%2==0&&a[i]%4!=0) c++;
	}
	cnt+=c/2;
	if(n%2==1) n--;
	if(cnt>=n/2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    int t; cin>>t;
    // for(int i=1; i<=100; i++){
        // int t=i;
    string ans="";
    while(t){
        int x=t%26;
        if(x==0){ x=26; t--;}
        char c=x+'a'-1;
        ans+=c;
        t/=26;
    }
    reverse(all(ans));
    cout<<ans<<"\n";
    // }
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}	

Measured memory_bytes: 3656
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    // auto q = new BinaryHeap!(Array!int); // TLE(3 sec)
    auto q = BinaryHeap!(int[])(new int[2_000_001], 0);

    string s;
    while ((s = readln.chomp).length > 0) {
        if (s == "end")
            break;

        if (s[0] == 'e') { // extract
            writeln(q.front);
            q.popFront;
        }
        else {
            auto ss = s.split;
            int x = ss[1].to!int;
            q.insert(x);
        }
    }
}



Measured memory_bytes: 11108