akhauriyash/Code-Regression huggingface dataset:
/**
 *    author: pankaj_m05
**/
#include<bits/stdc++.h>

using namespace std;

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  cout << !n << '\n';
  return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll a, b, c;
  IN(a,b,c);
  // a + 2sqrt(ab) + b < c ?
  // 2sqrt(ab) < c - a - b ?
  // 4ab < (c - a - b)^2 ?

  if(c-a-b<=0){
    OUT("No");
  }else if(4*a*b<(c-a-b)*(c-a-b)){
    OUT("Yes");
  }else{
    OUT("No");
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#define N 20
using namespace std;

int main(){
	int w, h;
	while(cin >>w >>h){
		if(w == 0 && h == 0) break;
		int cnt = 1, dxh[4] = {-1, 0, 1, 0}, dxw[4] = {0, 1, 0, -1};
		string home[N];
		queue<int> quh, quw;
		for(int i = 0; i < h; i++){
			cin >>home[i];
			for(int j = 0; j < w; j++){
				if(home[i][j] == '@'){
					 quh.push(i);
					 quw.push(j);
				}
			}
		}
		while(quh.empty() != 1){
			int nowh = quh.front(), noww = quw.front();
			quh.pop();
			quw.pop();
			for(int i = 0; i < 4; i++){
				if(nowh + dxh[i] >= h || noww + dxw[i] >= w || nowh + dxh[i] < 0 || noww + dxw[i] < 0){
					continue;
				}
				if(home[nowh + dxh[i]][noww + dxw[i]] == '.'){
					quh.push(nowh + dxh[i]);
					quw.push(noww + dxw[i]);
					cnt++;
					home[nowh + dxh[i]][noww + dxw[i]] = '#';
				}
			}
		}
		cout <<cnt <<endl;
	}
	return 0;
}

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

int main(){
	string s;
	char f[256] = {0};
	f['y'] = 1;
	f['u'] = 1;
	f['i'] = 1;
	f['o'] = 1;
	f['p'] = 1;
	f['h'] = 1;
	f['j'] = 1;
	f['k'] = 1;
	f['l'] = 1;
	f['n'] = 1;
	f['m'] = 1;

	
	while( cin >> s ){
		if( s == "#" ) break;
		
		int ans = 0;
		int state = f[ s[0] ];
		for(int i=1 ; i < (int)s.size() ; i++ ){
			if( state != f[ s[i] ] )
				ans++;
			state = f[ s[i] ];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
N = int(input())

d = {}
l = []
p = 0

for i in range(N):
  l.append(list(map(int, input().split())))

while True:
  if(l[0][2] == 0):
    l.append(l[0])
    del l[0]
  else:
    x, y, h= l[0]
    for i in range(101):
      for j in range(101):
        d[(i, j)] = abs(i- x)+ abs(j- y)+ h
    break

for k in range(N- 1):
  x, y, h = l[k+ 1]
  if(h == 0):
    for i in range(101):
      for j in range(101):
        if((i, j) in d):
          if(d[(i, j)]- abs(i- x)- abs(j- y)> 0):
            del d[(i, j)]
  else:
    for i in range(101):
      for j in range(101):
        if((i, j) in d):
          if(d[(i, j)] != abs(i- x)+ abs(j- y)+ h):
            del d[(i, j)]

zahyou, height = list(d.items())[0]
  
print("{0[0]} {0[1]} {1}".format(zahyou, height))

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

int main (){
    int N;
    cin >> N;
    vector<int> list(100010,0);
    vector<int> num(100010,0);
    int p;
    int64_t sum = 0;
    for(int i = 0;i < N;i++){
        cin >> p;
        sum += p;
        list.at(p)++;
    }
    

    int Q;
    cin >> Q;
    int B, C;
    for(int i = 0;i < Q;i++){
        cin >> B >> C;
        sum =sum + (C-B)*list.at(B);
        cout << sum << endl;
        list.at(C) += list.at(B);
        list.at(B) = 0;
    }

    


    
}

Measured memory_bytes: 4052
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];

    private T Convert<T>(string s)
    {
        return (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromString(s);
    }

    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

    public T Next<T>()
    {
        return Convert<T>(Next());
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public string[] StringArray()
    {
        Line = Console.ReadLine().Split(Separator);
        Index = Line.Length;
        return Line;
    }

    public T[] Array<T>()
    {
        var l = StringArray();
        var res = new T[l.Length];
        for (int i = 0; i < l.Length; i++)
        {
            res[i] = Convert<T>(l[i]);
        }
        return res;
    }

    public int[] IntArray()
    {
        var l = StringArray();
        var res = new int[l.Length];
        for (int i = 0; i < l.Length; i++)
        {
            res[i] = int.Parse(l[i]);
        }
        return res;
    }

    public long[] LongArray()
    {
        var l = StringArray();
        var res = new long[l.Length];
        for (int i = 0; i < l.Length; i++)
        {
            res[i] = long.Parse(l[i]);
        }
        return res;
    }
}

class Program
{
    private int A, B;
    private string S;
    private void Scan()
    {
        var sc = new Scanner();
        A = sc.NextInt();
        B = sc.NextInt();
        S = sc.Next();
    }


    public void Solve()
    {
        Scan();
        for (int i = 0; i < A; i++)
        {
            if (!IsNum(S[i]))
            {
                Console.WriteLine("No");
                return;
            }
        }
        if (S[A] != '-')
        {
            Console.WriteLine("No");
            return;
        }
        for (int i = A + 1; i < A + B + 1; i++)
        {
            if (!IsNum(S[i]))
            {
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
    }

    private bool IsNum(char c)
    {
        return '0' <= c && c <= '9';
    }

    static void Main(string[] args)
    {
        new Program().Solve();
    }
}

Measured memory_bytes: 13140
# include <bits/stdc++.h>
using namespace std;
long long n,ans,k,sumr[100005],sumb[100005],sumg[100005],cnt,bb;
string s;
long long cntg,cntb;
int main()
{
	bb=0;
	cin>>n;
	cin>>s;
	if (s[0]=='R') 
	sumr[0]=1;
	for (long long i=1; i<s.size(); i++)
	{
		if (s[i]=='R') sumr[i]=sumr[i-1]+1;
		else sumr[i]=sumr[i-1];
	}
	if (s[0]=='G') sumg[0]=1;
	for (long long i=1; i<s.size(); i++)
	{
		if (s[i]=='G') sumg[i]=sumg[i-1]+1;
		else sumg[i]=sumg[i-1];
	}
	if (s[0]=='B') sumb[0]=1;
	for (long long i=1; i<s.size(); i++)
	{
		if (s[i]=='B') sumb[i]=sumb[i-1]+1;
		else sumb[i]=sumb[i-1];
	}
	for (long long i=0; i<s.size(); i++)
	{
		if (s[i]=='R')
		{
			cnt=0;
			for (long long j=0; j<i; j++)
			{
				if (s[j]=='B')
				{
					if (s[i+(i-j)]=='G') cnt++;
				}
			}
			ans+=max(bb,sumb[i-1]*(sumg[n-1]-sumg[i-1])-cnt);
			cnt=0;
			
			for (long long j=0; j<i; j++)
			{
				if (s[j]=='G')
				{
					if (s[i+(i-j)]=='B')cnt++;
				}
			}
			ans+=max(bb, sumg[i-1]*(sumb[n-1]-sumb[i])-cnt);
		}
		if (s[i]=='B')
		{
			cnt=0;
			//manammde B ebi
			//magis mere G ebi
			for (long long j=0; j<i; j++)
			{
				if (s[j]=='R') 
				{
					if (s[i+(i-j)]=='G') cnt++; 
				}
			}
			ans+=max(bb,sumr[i-1]*(sumg[n-1]-sumg[i])-cnt);
			
			cnt=0;
			for (long long j=0; j<i; j++)
			{
				if (s[j]=='G')
				{
					if (s[i+(i-j)]=='R') cnt++;
				}
			}
			ans+=max(bb,sumg[i-1]*(sumr[n-1]-sumr[i])-cnt);
		}
		if (s[i]=='G')
		{
			cnt=0;
			for (long long j=0; j<i; j++)
			{
				if (s[j]=='R')
				{
					if (s[i+(i-j)]=='B' ) cnt++;
				}
			}
			ans+=max(bb,sumr[i-1]*(sumb[n-1]-sumb[i])-cnt);
			cnt=0;
			for (long long j=0; j<i; j++)
			{
				if (s[j]=='B')
				{
					if (s[i+(i-j)]=='R') cnt++;
				}
			}
			ans+=max(bb,sumb[i-1]*(sumr[n-1]-sumr[i])-cnt);
		}
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 3732
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>

using namespace std;

int main()
{
	int n,a,b,c,x;
	while(true)
	{
		cin >> n >> a >> b >> c >> x;
		if(n==0)break;

		vector<int> y(n);
		for(int i=0;i<n;i++)cin >> y[i];
	
		int now=0;
		int ans=-1;
		for(int i=0;i<=10000;i++)
		{
			if(x==y[now])
				now++; 
			if(now>=n)
			{
				ans=i;
				break;
			}

			x=(a*x+b)%c;

		}

		cout << ans << endl;
	}

}


Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	rep(i, 1, 50000){
		if(int(i*1.08) == n){
			print(i)
			return 0;
		}
	}
	print(":(")
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)


def rec(v):
    if dp[v] != -1: return dp[v]
    res = 0
    for nv in es[v]:
        res = max(res, rec(nv) + 1)
    dp[v] = res
    return res


N, M = map(int, input().split())
es = [[] for _ in range(N)]

for _ in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    es[x].append(y)

dp = [-1] * N

res = 0
for v in range(N):
    res = max(res, rec(v))
print(res)


Measured memory_bytes: 59008
import java.util.Scanner;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static long[] fal_rnd(int size){
		AtomicInteger l=new AtomicInteger(-1),r=new AtomicInteger(size);
		long[] res=new long[size];
		INS(size).unordered().parallel().mapToLong(Long::parseLong).forEach(v->res[ThreadLocalRandom.current().nextBoolean()?l.incrementAndGet():r.decrementAndGet()]=v);
		return res;
	}
	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static Stream<String> INS(long size){
		return StreamSupport.stream(Spliterators.spliterator(s,size,Spliterator.NONNULL&Spliterator.IMMUTABLE),false).limit(size);
	}
	public static void main(String[] __){
		int d=0;
		for(int i=s.nextInt();i>0;i--) {
			switch(s.next()){
			case "A":
				d++;
				break;
			case "Un":
				d--;
				if(d<0) {
					System.out.println("NO");
					return;
				}
				break;
			}
		}
		System.out.println(d==0?"YES":"NO");
	}
}

Measured memory_bytes: 26248
# -*- coding: utf-8 -*-


def main():
    from re import search

    s = input()
    removed_a = s.replace('A', '')

    if (len(s) < 5 or len(s) < 10) and removed_a != 'KIHBR':
        print('NO')
    else:
        pattern = r'^A?KIHA?BA?RA?$'
        is_match = search(pattern, s)

        if is_match:
            print('YES')
        else:
            print('NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
use proconio::{input, fastout};
use std::cmp::max;

#[fastout]
fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        d: i64,
    }

    let mut ans = std::i64::MIN;

    ans = max(ans, a * c);
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);
    if (a <= 0 && 0 <= b) || (c <= 0 && 0 <= d) {
        ans = max(ans, 0);
    }
    
    println!("{}", ans);
}


Measured memory_bytes: 2196
#include<stdio.h>

int A[1000000],n;

int binarySearch(int key){
    int left = 0;
    int right = n;
    int mid;
    while (left < right)
    {
        mid = (left + right)/2;
        if(key==A[mid]) return 1;
        if(key > A[mid]) left = mid + 1;
        else if(key < A[mid]) right = mid;
    }
    return 0;
}

int main(){
    int i,q,k,sum=0;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&k);
        if(binarySearch(k))sum++;
    }
    printf("%d\n",sum);

    return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>
int main(void){
	int n,i,a,max=-1000000,min=1000000;
	long long sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(max<a) max=a;
		if(min>a) min=a;
		sum+=a;
	}
	printf("%d %d %lld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2104
while True:
    a, b = [int(i) for i in input().split()]
    if a == 0 and b == 0:
        break
    else:
        for i in range(a):
            if i == 0 or i == a-1:
                print("#"*b)
            else:
                print("#{}#".format("."*(b-2)))
    print("")



Measured memory_bytes: 5620
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAX = 200005;

int N;
ll K;
int A[MAX], B[MAX], C[MAX];

int main(){
    cin >> N >> K;
    rep(i,N){
        cin >> A[i];
        A[i]--;
    }
    vector<int> V;

    int x = A[0];
    B[0] = 1;
    C[0] = 0;
    for(int i = 1; B[x] == 0; i++){
        B[x] = 1;
        C[x] = i;
        V.push_back(x);
        x = A[x];
    }
    int n = V.size() + 1;
    int m = n - C[x];
    ll a;
    if(n > K) a = K;
    else{
        a = ( (K - C[x]) % m ) + C[x];
    }
    if(a == 0) cout << 1 << endl;
    else cout << V[a-1] + 1 << endl;

    return 0;
}

Measured memory_bytes: 6636
s = input() #sys.stdin.readlineは最後が改行
n = len(s)
p=10**9+7

dp = [[0]*2 for _ in range(n)]

dp[0][0]=2
dp[0][1]=1


# dp[i][smaller]:i番目以前の商品を見たときの組み合わせの数。L以下が確定かどうか

for i in range(1,n):
        if s[i]=='1':
            dp[i][0] = (dp[i-1][0]*2)%p
            dp[i][1] = (dp[i-1][1]*3)%p + (dp[i-1][0])%p
        else:
            dp[i][0] = dp[i-1][0]*1
            dp[i][1] = (dp[i-1][1]*3)%p

print((dp[n-1][0]+dp[n-1][1])%p)



Measured memory_bytes: 54364
while line = gets
  n = line.chomp.to_i
  break if n == 0

  dolls = []
  n.times do
    dolls << gets.chomp.split.map(&:to_i)
  end

  m = gets.chomp.to_i
  m.times do
    dolls << gets.chomp.split.map(&:to_i)
  end

  dolls.sort! do |a, b|
    if a[0] == b[0]
      a[1] <=> b[1]
    else
      a[0] <=> b[0]
    end
  end

  dp = Array.new(dolls.size + 1, 0)

  for i in 1..dolls.size
    for j in 1..i
      if i - j == 0 || (dolls[i - 1][0] > dolls[i - j - 1][0] && dolls[i - 1][1] > dolls[i - j - 1][1])
        dp[i] = [dp[i], dp[i - j] + 1].max
      end
    end
  end

  puts dp.max
end

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

const int NMAX = 8;

vector<vector<bool>> graph(NMAX, vector<bool> (NMAX, false));

int dfs(int v, int n, vector<bool> visit){
  bool all_visit = true;
  
  for(int i = 0; i < n; i++){
    if(!visit[i]) all_visit = false;
  }
  
  if(all_visit) return 1;
  
  int ret = 0;
  
  for(int i = 0; i < n; i++){
    if(!graph[v][i]) continue;
    if(visit[i]) continue;
    
    visit[i] = true;
    ret += dfs(i, n, visit);
    visit[i] = false;
  }
  
  return ret;
  
}

int main(){
  int n, m; cin >> n >> m;
  vector<bool> visit(n, false);
  
  for(int i = 0; i < m; i++) {
    int a, b; cin >> a >> b;
    a--; b--;
    graph[a][b] = graph[b][a] = true;
  }
  
  visit[0] = true;
  cout << dfs(0, n, visit) << endl;

}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main(){

    int a, b;
    
    scanf("%d %d", &a, &b);
    
    if(a < b){
    printf("a < b\n");
    }
    else if(a > b){
    printf("a > b\n");
    }
    else{
    printf("a == b\n");
    }
    
    return 0;

}



Measured memory_bytes: 2512
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "trace.h"
#else
#define trace(args...)
#endif

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
void solve(int test) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int& e : a) cin >> e;
    ll funds = 1000, stocks = 0;
    bool buy = true;
    for (int i = 0; i < n - 1; i++) {
        if (a[i] > a[i + 1]) {
            if (!buy) {
                funds += stocks * a[i];
                stocks = 0;
                buy = true;
            }
        }
        if (a[i] < a[i + 1]) {
            if (buy) {
                stocks += funds / a[i];
                funds %= a[i];
                buy = false;
            }
        }
    }
    if (!buy) funds += stocks * a[n - 1];
    cout << funds;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        // cout << "Case #" << i << ": ";
        solve(i);
        cout << "\n";
    }
}


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


void solve(std::string s){
    ll a, b;
    for(a = 0; a < s.length(); a++){
        if(s.at(a) == 'A') break;
    }
    for(b=s.length()-1; b>= 0; b--){
        if(s.at(b) == 'Z') break;
    }
    cout << b-a+1 << endl;
}

int main(){
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}


Measured memory_bytes: 772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define sc second
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
	ll n, k;
	scanf("%lld %lld", &n, &k);
	n %= k;
	
	ll ans = min(n, k - n);
	printf("%lld\n", ans);
}

Measured memory_bytes: 3796
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    ll x = 0, y = 0;
    vector<int> z;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++, i++) x += max(0ll, a[i]);
    for (int i = 1; i < n; i++, i++) y += max(0ll, a[i]);
    if (!x && !y) {
        int u = 0;
        for (int i = 0; i < n; i++) if (a[i] > a[u]) u = i;
        cout << a[u] << '\n' << n - 1 << '\n';
        for (int i = n - 1; i > u; i--) cout << i + 1 << '\n';
        for (int i = 0; i < u; i++) cout << 1 << '\n';
        return 0;
    } else if (x > y) {
        cout << x << '\n';
        int l;
        while (1) {
            l = -2;
            bool w = 0;
            for (int i = 0; i < a.size(); i++, i++) if (a[i] > 0) {
                if (l == -2) l = i;
                else {
                    for (int j = (i + l) / 2; j > l; j--) z.push_back(j);
                    for (int j = i - 1; j > l; j--) a.erase(a.begin() + j);
                    a[l] += a[l + 1];
                    a.erase(a.begin() + l + 1);
                    w = 1;
                    break;
                }
            }
            if (!w) break;
        }
        for (int i = (int)a.size() - 1; i > l; i--) z.push_back(i);
        for (int i = 0; i < l; i++) z.push_back(0);
    } else {
        cout << y << '\n';
        int l;
        while (1) {
            l = -1;
            bool w = 0;
            for (int i = 1; i < a.size(); i++, i++) if (a[i] > 0) {
                if (l == -1) l = i;
                else {
                    for (int j = (i + l) / 2; j > l; j--) z.push_back(j);
                    for (int j = i - 1; j > l; j--) a.erase(a.begin() + j);
                    a[l] += a[l + 1];
                    a.erase(a.begin() + l + 1);
                    w = 1;
                    break;
                }
            }
            if (!w) break;
        }
        for (int i = (int)a.size() - 1; i > l; i--) z.push_back(i);
        for (int i = 0; i < l; i++) z.push_back(0);
    }
    cout << z.size() << '\n';
    for (int i : z) cout << i + 1 << '\n';
}


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

int main() {
	string s, t; cin >> s >> t;
	
	for (int i = s.size() - t.size(); i >= 0; i--) {
		string tmp = s.substr(i, t.size());
		for (int j = 0; j < t.size(); j++) {
			if (tmp[j] != '?' && tmp[j] != t[j])break;
			if (j == t.size() - 1) {
				for (int k = 0; k < s.size(); k++) {
					if (i <= k && k < i + t.size())cout << t[k - i];
					else cout << (s[k] == '?' ? 'a' : s[k]);
				}
				cout << endl;
				return 0;
			}
		}
	}
	cout << "UNRESTORABLE" << endl;

	return 0;
}

Measured memory_bytes: 256
from math import sqrt
n, k = map(int, input().split())

if k == 0:
    print(n**2)
    exit()

ans = 0
for i in range(k+1, n+1):
    ans += (n//i)*(i-k)
    r = n%i
    ans += max(r-k+1, 0)
print(ans)


Measured memory_bytes: 3060
def solve():
    strN = input()
    N = int(strN)

    maxD = len(strN)

    numss = [[0]*(10) for _ in range(10)]
    for x in range(1, 10):
        for y in range(1, 10):
            num = 0
            for d in range(1, maxD-2):
                num += 10**d
            if maxD-2 > 0:
                if x < int(strN[0]):
                    num += 10**(maxD-2)
                elif x == int(strN[0]):
                    num += int(strN[1:-1]) + 1
                    if y > int(strN[-1]):
                        num -= 1
            j = x*10 + y
            if 1 <= j <= N:
                num += 1
            if x == y:
                j = x
                if 1 <= j <= N:
                    num += 1
            numss[x][y] = num

    ans = 0
    for A in range(1, N+1):
        ss = str(A)
        ans += numss[int(ss[-1])][int(ss[0])]

    print(ans)


solve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    string s;
    cin>>s;
    int n=s.length();
    int i=0;
    int a, b;
    while (i<n)
    {
        if (s[i]=='A')
        {
            a=i;
            break;
        }
        i++;
    }
    i=n-1;
    while (i>=a)
    {
        if (s[i]=='Z')
        {
            b=i;
            break;
        }
        i--;
    }
    cout<<b-a+1;
    return 0;
}

Measured memory_bytes: 3776
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
int main(){
	while(true){
		int n,cnt=0;
		cin>>n;
		if(n==0) break;
		for(int i=0;i*i<=n;i++){
			for(int j=i;i*i+j*j<=n;j++){
				for(int k=j;i*i+j*j+k*k<=n;k++){
					for(int h=k;i*i+j*j+k*k+h*h<=n;h++){
						if(i*i+j*j+k*k+h*h==n) cnt++;
					}
				}
			}
		}
		cout << cnt<<endl;
	}
}

Measured memory_bytes: 1160
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <tuple>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;

using ll=long long;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vll> vl2d;
typedef vector <vi> vi2d;
typedef vector <char> vc;
typedef vector <bool> vb;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <char,int> mci;
typedef map <int,int> mii;
typedef map <long,long> ml;
typedef map <string,string> mss;
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
//Swift related stuff

#define guard(_condition) if (bool(_condition)){}

ll dp[21][1<<21];
vl2d match(21, vll(21,0));
ll n;

void addSelf(ll &a, ll b) {
    a = a+b;
    if(a>=1000000007) {
        a-=1000000007;
    }
}

ll solve(ll mi, ll mask) {
    guard(dp[mi][mask] == -1) else {
        return dp[mi][mask];
    }
    guard(mi<n-1) else {
        rep(i,0,n) {
            guard(match[mi][i] && ((1<<i) & mask) == 0) else {
                continue;
            }
            return 1;
        }
        return 0;
    }
    
    ll res = 0ll;
    rep(i,0,n) {
        guard(match[mi][i] == 1 && ((1<<i) & mask) == 0) else {
            continue;
        }
        addSelf(res, solve(mi+1, mask|(1<<i)));
    }
    dp[mi][mask] = res;
    return res;
}

int main() {
    memset(dp, -1, sizeof dp);
    cin>>n;
    rep(i,0,n) {
        rep(j,0,n) {
            cin>>match[i][j];
        }
    }
    cout<<solve(0,0)<<endl;
    return 0;
}


Measured memory_bytes: 347712
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define DB double
#define SG string
#define LL long long
#define Fp(A,B,C,D) for(A=B;A<=C;A+=D)
#define Fm(A,B,C,D) for(A=B;A>=C;A-=D)
#define Clear(A) memset(A,0,sizeof(A))
#define Copy(A,B) memcpy(A,B,sizeof(A))
using namespace std;
const LL Max=1e3+5;
const LL Mod=1e9+7;
const LL Inf=1e18;
inline LL Read(){
	LL X=0;char CH=getchar();bool F=0;
	while(CH>'9'||CH<'0'){if(CH=='-')F=1;CH=getchar();}
	while(CH>='0'&&CH<='9'){X=(X<<1)+(X<<3)+CH-'0';CH=getchar();}
	return F?-X:X;
}
inline void Write(LL X){
	if(X<0)X=-X,putchar('-');
	if(X>9)Write(X/10);
	putchar(X%10+48);
}
int main(){
	LL I,J,K;
	LL N=Read(),M=Read();
	if(M==100){
		if(N==0){
			puts("101");
		} else if(N==1){
			puts("10100");
		} else {
			puts("1010000");
		}
	} else {Write(M);
		Fp(I,1,N<<1,1){
			putchar('0');
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long N;
vector<long long> A;

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

	cin >> N;
	for(int i=0; i<N; i++){
		long long tmp;
		cin >> tmp;
		A.push_back(tmp);
	}

	long long b = 0;
	for(int i=0; i<N; i++){
		b = b ^ A[i];
	}
	for(int i=0; i<N; i++){
		long long ans = b ^ A[i];
		printf("%lld ", ans);
	}
	printf("\n");
	return 0;

}

Measured memory_bytes: 5316
#!/usr/bin/env python3
# -*- Coding: utf-8 -*-

import sys


input = sys.stdin.readline


def main():
    A, B, C = map(int, input().split())

    if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
        print(0)
    else:
        ary = [A, B, C]
        ary.sort()
        print(ary[0]*ary[1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
n, m = map(int, input().split())
h = list(map(int, input().split()))
edge = [[] for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(h[b])
    edge[b].append(h[a])

cnt = 0
for v in range(n):
    res = True
    for i in edge[v]:
        if h[v] <= i: res = False
    if res: cnt += 1

print(cnt)

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

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

  vector<int> gsb_A(3), gsb_B(3);
  cin >> gsb_A[0] >> gsb_A[1] >> gsb_A[2];
  cin >> gsb_B[0] >> gsb_B[1] >> gsb_B[2];

  // A -> B
  // dp[n] :=  with n acrons, chokudai can gain dp[n] profit
  // dp[n] = max(dp[n], dp[n - g_A] + (g_B - g_A));
  vector<long long> dp1(N + 1);
  vector<int> profits(3);
  for(int i = 0; i < 3; i++){
    profits[i] = max(0, gsb_B[i] - gsb_A[i]);
  }
  for(int n = 0; n <= N; n++){
    for(int i = 0; i < 3; i++){
      if(n >= gsb_A[i]){
        dp1[n] = max(dp1[n], dp1[n - gsb_A[i]] + profits[i]);
      }
    }
  }

  long long N2 = dp1[N] + N;
  for(int i = 0; i < 3; i++){
    profits[i] = max(0, gsb_A[i] - gsb_B[i]);
  }
  vector<long long> dp2(N2 + 1);
  for(int n = 0; n <= N2; n++){
    for(int i = 0; i < 3; i++){
      if(n >= gsb_B[i]){
        dp2[n] = max(dp2[n], dp2[n - gsb_B[i]] + profits[i]);
      }
    }
  }
  cout << dp2[N2] + N2 << endl;
  
}


Measured memory_bytes: 195584
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
//const int MAX_INT = (1 << 31) - 1;

const int MAXI = 1024 * 128;

int n, h;
int a[MAXI], b[MAXI];


int main() {

	cin >> n >> h;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	
	sort(a, a + n);
	sort(b, b + n);

	int maxDamage = a[n - 1];
	int ans = 0;

	for (int i = n - 1; i >= 0; i--) {
		if (maxDamage < b[i] && h > 0) {
			ans++;
			h -= b[i];
		}
	}

	if (h > 0) {
		int temp = h / maxDamage;
		if (h > maxDamage * temp)
			temp++;
		ans += temp;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#ABC155B_PapersPlease.rb
n = gets.to_i
ar = gets.split.map(&:to_i)

ar.each do |a|
  if a%2==0
    if a%3==0 || a%5==0
    else
      puts "DENIED"
      exit
    end
  end
end
puts "APPROVED"


Measured memory_bytes: 1916
n = int(input())
S = [str(input()) for _ in range(n)]

d = {}
ans = 0
for i in range(n):
    s = S[i]
    s = list(s)
    s.sort()
    s = ''.join(s)
    if s in d:
        ans += d[s]
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
print(ans)


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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;

int main(){
    vi a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a);
    cout << 10*a[2]+a[1]+a[0] << endl;
    return 0;
}


Measured memory_bytes: 256
/*
    title: e_picking_goods.cpp
    author: Akhil
    date: 2020-09-19
    time: 09:16:14
*/
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <climits>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <numeric>
#include <cmath>
#include <stdio.h>

long long inf = -1e15;

using namespace std;

int main()
{
    int R, C, K; cin >> R >> C >> K;
    vector<vector<int>> mat(R + 1, vector<int>(C + 1, 0));
    for (int i = 0; i < K; i++)
    {
        int r, c, v; cin >> r >> c >> v;
        mat[r][c] = v;
    }
    vector<vector<vector<long long >>> dp(R + 1, vector<vector<long long >> (C + 1, vector<long long> (4, 0)));
    for (int k = 0; k < 4; k++) dp[R][C][k] = (k) ? mat[R][C] : 0; 
    for (int r = R; r >= 1; r--)
    {
        for (int c = C; c >= 1; c--)
        {
            for (int k = 0; k < 4; k++)
            {
                if (r < R) 
                {
                    for (int k1 = 0; k1 < 4; k1++)
                        dp[r][c][k] = max(dp[r][c][k], ((k) ? dp[r + 1][c][k1] + mat[r][c] : dp[r + 1][c][k1]));
                    dp[r][c][k] = max(dp[r][c][k], dp[r + 1][c][k]);
                }
                if (c < C) 
                {
                    dp[r][c][k] = max(dp[r][c][k], (k) ? dp[r][c + 1][k - 1] + mat[r][c] : dp[r][c + 1][0]);
                    dp[r][c][k] = max(dp[r][c][k], dp[r][c + 1][k]);
                }
            }
        }
    }
    long long ans = 0; 
    for (int k = 0; k < 4; k++) ans = max(ans, dp[1][1][k]); 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 671848
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define BIT(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, T;
  cin >> N >> T;
  int ans = INF;
  REP(i, N) {
    int p, q;
    cin >> p >> q;
    if (q <= T) {
      ans = min(ans, p);
    }
  }
  if (ans == INF) {
    cout << "TLE"
         << "\n";

  } else {
    cout << ans << "\n";
  }
}

Measured memory_bytes: 256
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cstring>
#include <climits>
#include <set>

//#define int long long
//typedef long long ll;
using ll = long long;
//using R = double;

//#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define MOD 1000000007

const int INF = int(1e9);

using namespace std;

typedef vector<int> V;
typedef vector<V> VV;



signed main()
{
    int A, B;
    
    cin >> A >> B;
    if (A == 1) A = 14;
    if (B == 1) B = 14;
    if (A > B) {
        cout << "Alice" << endl;
    } else if (A == B) {
        cout << "Draw" << endl;
    } else {
        cout << "Bob" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= 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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

ll a, b, n;
ll f(ll x) {
    return floor(a*x/b)-a*floor(x/b);
}

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


    cin >> a >> b >> n;

    cout << f(min(b-1, n)) << endl;

    return 0;
}


Measured memory_bytes: 3520
n,a,b = map(int,input().split())
ab = 0
b1 = 0
for i in list(input()):
    if i == "a":
        if ab < a+b:
            print("Yes")
            ab +=1
        else:
            print("No")
    elif i == "b":
        if ab < a+b and b1 < b:
            ab += 1
            b1 += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")



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

class ScoreBoard{
public:
    //  1: win
    // -1: lose
    // enum
    vector<vector<int>> board;
    vector<int> wincounts;
    vector<int> X, Y;
    
    ScoreBoard(int N){
        board = vector<vector<int>>(N, vector<int>(N));
        wincounts.resize(N);
    }
    inline void update(int x, int y){
        board[x][y] = 1;
        board[y][x] = -1;
        wincounts[x]++;
    }
    inline void remove(int x, int y){
        board[x][y] = board[y][x] = 0;
        wincounts[x]--;
    }
    inline bool allok(){
        for(int i=0; i<board.size(); i++)
            if(wincounts[i] > (board.size()-1)/2)
                return false;
        return true;
    }
    inline bool ok(int x, int y){
        return wincounts[x] < (board.size()-1)/2;
    }
    void view(){
        cout << "============" << endl;
        for(int x=0; x<board.size(); x++){
            for(int y=0; y<board.size(); y++){
                if(x == y)
                    cout << ". ";
                else
                    cout << (board[x][y]==1) << " ";
            }
            cout << endl;
        }
    }
    void init(){
        for(int x=0; x<board.size(); x++){
            for(int y=x+1; y<board.size(); y++){
                if(board[x][y] != 0)
                    continue;
                X.push_back(x);
                Y.push_back(y);
            }
        }
    }
    int dfs(int idx){
        if(X.size() == idx){
//            view();
            return 1;
        }
        
        int res = 0;
        if(ok(X[idx], Y[idx])){
            update(X[idx], Y[idx]);
            res += dfs(idx+1);
            remove(X[idx], Y[idx]);
        }
        if(ok(Y[idx], X[idx])){
            update(Y[idx], X[idx]);
            res += dfs(idx+1);
            remove(Y[idx], X[idx]);
        }
        return res;
    }
};


int main(){
    int N, M;
    while(cin >> N, N){
        cin >> M;
        auto sb = ScoreBoard(N);
        
        for(int i=0; i<M; i++){
            int x, y; cin >> x >> y;
            x--; y--;
            sb.update(x, y);
        }
        sb.init();
        if(sb.allok())
            cout << sb.dfs(0) << endl;
        else
            cout << 0 << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3164
package main

import (
	"bufio"
	"errors"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()

	x := sc.ReadInt()
	y := sc.ReadInt()
	a := sc.ReadInt()
	b := sc.ReadInt()
	c := sc.ReadInt()

	p := make([]int, a)
	for i := 0; i < a; i++ {
		p[i] = sc.ReadInt()
	}
	q := make([]int, b)
	for i := 0; i < b; i++ {
		q[i] = sc.ReadInt()
	}
	r := make([]int, c)
	for i := 0; i < c; i++ {
		r[i] = sc.ReadInt()
	}

	sort.Sort(sort.Reverse(sort.IntSlice(p)))
	sort.Sort(sort.Reverse(sort.IntSlice(q)))
	sort.Sort(sort.Reverse(sort.IntSlice(r)))

	total := 0
	for _, pi := range p[:x] {
		total += pi
	}
	for _, qi := range q[:y] {
		total += qi
	}

	sg := NewStackGroup([][]int{p[:x], q[:y]}, func(a int, b int) bool { return a < b })

	for _, ri := range r {
		popped, err := sg.Pop()
		if err != nil {
			break
		}
		if ri <= popped {
			break
		}

		total += ri - popped
	}

	fmt.Println(total)
}

type StackGroup struct {
	stacks         [][]int
	stackPositions []int
	above          func(int, int) bool
}

func NewStackGroup(stacks [][]int, above func(int, int) bool) *StackGroup {
	stackPositions := make([]int, len(stacks))
	for i, stack := range stacks {
		stackPositions[i] = len(stack) - 1
	}

	return &StackGroup{stacks, stackPositions, above}
}

func (sg *StackGroup) Pop() (int, error) {
	popStackIndex := -1
	var popValue *int = nil
	for stackIndex, stack := range sg.stacks {
		pos := sg.stackPositions[stackIndex]
		if pos < 0 {
			continue
		}

		v := stack[pos]
		if popValue == nil || sg.above(v, *popValue) {
			popStackIndex = stackIndex
			popValue = &v
		}
	}

	if popValue == nil {
		return 0, errors.New("empty")
	}

	sg.stackPositions[popStackIndex]--
	return *popValue, nil
}

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 5504
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
#define maxn 10010
#define llg int
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
llg n,m,x,p1;
int main()
{
//	yyj("A");
	cin>>n;
	for (llg i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if (x%2) p1++;
	}
	if (p1%2) cout<<"NO";else cout<<"YES";
	return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>){
    val (n,h,w) = readLine()!!.split(" ").map { i-> i.toInt() }

    var count = 0
    repeat(n){
        val (a,b) = readLine()!!.split(" ").map { i->i.toInt() }
        if(a>=h && b>=w)count++
    }
    println(count)

}

Measured memory_bytes: 38188
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] v = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = in.nextInt();
        }
        for (int i = 0; i < n; i++) {
            c[i] = in.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans += Math.max(0, v[i] - c[i]);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}

void solve(std::string b){
    if(b=="A")cout<<"T"<<endl;
    if(b=="T")cout<<"A"<<endl;
    if(b=="C")cout<<"G"<<endl;
    if(b=="G")cout<<"C"<<endl;
}

int main(){
    std::string b;
    std::cin >> b;
    solve(b);
}


Measured memory_bytes: 256
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from fractions import Fraction
from itertools import combinations
from math import gcd
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    K = int(input())
    ss = set({})
    mod = 7 % K
    count = 1
    while True:
        if mod == 0:
            print(count)
            exit()
        if mod in ss:
            print(-1)
            exit()
        ss.add(mod)
        mod = (mod * 10 + 7) % K
        count += 1

if __name__ == '__main__':
    main()

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

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;
}

int dp[1005][(1 << 12) + 5];

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> v;
    fill(dp[0], dp[1005], INF);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        int temp;
        int mask = 0;
        rep(j, b) {
            cin >> temp;
            mask += 1 << (temp - 1);
        }
        // debug(mask);
        v.emplace_back(a, mask);
    }

    dp[0][0] = 0;
    rep(i, m) {
        rep(j, 1 << n) {
            int mask = v[i].second;
            // debug(mask);
            // debug(j);
            chmin(dp[i + 1][j | mask], dp[i][j] + v[i].first);
            chmin(dp[i + 1][j], dp[i][j]);
            // debug(i);
            // debug(j);
            // debug(dp[i][j]);
            // debug(dp[3][3]);
        }
    }

    if (dp[m][(1 << n) - 1] == INF) {
        out(-1);
    } else {
        // debug((1 << n) - 1);
        out(dp[m][(1 << n) - 1]);
    }
    return 0;
}


Measured memory_bytes: 16384