akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstring>
#include<cstdio>
using namespace std;
 
int ans = -1000000000;
int a[10];
int n, f[100][10], p[100][11];
int max(int ans, int score)
{
	if (ans > score)
		return ans;
	else
		return score;
}
void func(void){
	int score = 0, cnt;
	for (int i = 0; i < n; i++){
		cnt = 0;
		for (int j = 0; j < 10; j++){
			if (a[j] == 1 && f[i][j] == 1)
				cnt++;
		}
			score += p[i][cnt];
	}
	ans = max(ans, score);
}
void dfs(int pos)
{
	int flag = 0;
	if (pos == 10){
		for (int i = 0; i < 10; i++){
			if (a[i] == 1)
				flag = 1;
		}
		if (flag)
		func();
		return;
	}
		a[pos] = 0; dfs(pos + 1);
		a[pos] = 1; dfs(pos + 1);
 
}
 
int main()
{
	cin >> n;
 
	for (int i = 0; i < n; i++){
		for (int j = 0; j < 10; j++)
			scanf("%d", &f[i][j]);
	}
 
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 11;j++)
		scanf("%d", &p[i][j]);
 
	dfs(0);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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 (b<a) { a=b; return 1; } return 0; }

using ll = long long;

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

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

int memo[550][550];

int main() {
  int N,M,Q;
  cin>>N>>M>>Q;
  vector<vector<int>> c(N);
  rep(i,M){
    int x,y;
    cin>>x>>y;
    c[x-1].push_back(y-1);
    memo[x-1][y-1]++;
  }
  
  rep(i,N-1){
    for(int j = i; j < N-1; j++){
      memo[i][j+1]+=memo[i][j];
    }
  }
  rep(i,Q){
    int p,q;
    cin >>p>>q;
    p--;
    q--;
    int ans = 0;
    for(int j = p; j <= q; j++) {
      ans+=memo[j][q];
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, b, c;
  in(n);
  a = n / 100;
  b = n % 10;
  c = (n / 10) % 10;
  if(a == 7 || b == 7 || c == 7)
    out("Yes");
  else
    out("No");
  memi;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int a;
    cin >> a;
    cout << a / 3 << endl;


    return 0;
}


Measured memory_bytes: 888
#ABC129-E Sum Equals Xor
"""
a+b = a^b
となる場合は、全2進数桁iに対して、
a[i] nand b[i] &1 を満たす場合になる
これは各桁に対してa[i]==b[i]==1を除く2**2-1の3通りが存在するので、
多分桁dpで制約あり/なしを求めてけば求まる
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
mod = 10**9+7
s = readline().rstrip().decode('utf-8')

################################
###########桁DP#################
################################

dp = [[0]*2 for i in range(len(s)+2)]
dp[0][0] = 1 #初期化



for i in range(len(s)):
    for j in range(2): #制約有り、なし
        nd = int(s[i])
        for d in range(3): #00,01,10 (11は条件を満たさない)
            ni = i+1
            nj = j
            if j == 0:
                if nd==0 and d > 0:continue #条件を満たさない
                elif nd == 1 and d==0:nj=1 #条件が必要なくなる遷移

            dp[ni][nj] += dp[i][j]
            dp[ni][nj]%=mod



ans = (dp[ni][0] + dp[ni][1])%mod
print(ans)

Measured memory_bytes: 54236
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;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 FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c && b >= c) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

// ??\??? ????????¨???
template<class T> bool operator==(T a, T b){return abs(a-b)< eps;}
template<class T> bool operator< (T a, T b){return a < b-eps;}
template<class T> bool operator<=(T a, T b){return a < b+eps;}
template<class T> int sig(T r) {return (r==0||r==-0) ? 0 : r > 0 ? 1 : -1;}
#define X real()
#define Y imag()

typedef bool B;
typedef long double D;
typedef complex<D> P;

P p[310];

int main(void){
	int n;
	while(cin >> n,n){
		D ix,iy;
		rep(i,n){
			cin >> ix >> iy;
			p[i].real(ix),p[i].imag(iy);
		}
		int ans=1;
		rep(i,n)rep(j,n){
			if(i<=j) continue;
			D d=norm(p[j]-p[i]);
			if(d>4.0) continue;
			P v=(p[j]-p[i])/P(2.0,0.0);
			D s=sqrt((1.0-norm(v))/norm(v));
			P cnt1=p[i]+v+s*P(v.imag(),-v.real());
			int num=2;
			rep(k,n){
				if(k==i||k==j) continue;
				if(norm(p[k]-cnt1)<1.0) num++;
			}
			ans=max(ans,num);
			P cnt2=p[i]+v+s*P(-v.imag(),v.real());
			int num2=2;
			rep(k,n){
				if(k==i||k==j) continue;
				if(norm(p[k]-cnt2)<1.0) num2++;
			}
			ans=max(ans,num2);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1268
import math

l = list(map(int, input().split()))
A = l[0]
B = l[1]
H = l[2]
M = l[3]

thita1 = 30*(H + M/60)
thita2 = 6*M
thita = abs(thita1 - thita2)
thita_ = max(thita, 360-thita)
c = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(thita_)))
print(c)


Measured memory_bytes: 9428
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;
/*
int f(int a, int b, int c, int k) {
  if(k == 0) return a + b + c;
  if(k == 1) return max(2*a, max(2*b, 2*c));
  return max(f(2*a, ))
}
*/
int main() {
  //int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int k,a,b,c;
  scanf("%d %d %d %d", &a, &b, &c, &k);
  int largest = max(a, max(b, c));
  if(largest == a) {
    for(int i = 0; i < k; ++i) a *= 2;
  }
  else
  {
    if(largest == b) {
      for(int i = 0; i < k; ++i) b *= 2;
    }
    else {

        for(int i = 0; i < k; ++i) c *= 2;
    }
  }
  printf("%d\n", a + b + c);
  return 0;
}


Measured memory_bytes: 256
var n:longint;
    i:longint;
    a:array[0..200050]of longint;
    num,ans:longint;

procedure qs(l,r:longint);
var i,j,m,t:longint;
begin
  i:=l;
  j:=r;
  m:=a[(l+r)>>1];
  repeat
    while a[i]<m do inc(i);
    while a[j]>m do dec(j);
    if i<=j then
    begin
      t:=a[i];a[i]:=a[j];a[j]:=t;
      inc(i);
      dec(j);
    end;
  until i>j;
  if l<j then qs(l,j);
  if i<r then qs(i,r);
end;
begin
  read(n);
  for i:=1 to n do
  read(a[i]);
  qs(1,n);
  for i:=1 to n do
  if a[i]<>a[i-1] then
  begin
    if num mod 2=1 then inc(ans);
    num:=1;
  end else inc(num);
  if num mod 2=1 then inc(ans);
  writeln(ans);
end.

Measured memory_bytes: 512
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();
    let H = buf_it.next().unwrap().parse::<usize>().unwrap();
    let W = buf_it.next().unwrap().parse::<usize>().unwrap();
    let A = buf_it.next().unwrap().parse::<usize>().unwrap();
    let B = buf_it.next().unwrap().parse::<usize>().unwrap();

    for i in 0..H{
        let mut row = String::new();
        for j in 0..W{
            row += if (j<A) ^ (i<B) {"0"} else {"1"};
        }
        println!("{}",row);
    }
}

Measured memory_bytes: 5244
#include<stdio.h>
//#define scanf scanf_s
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}
int main()
{
	int n, i,j,k;
	long long sum=0;
	scanf("%d", &n);
	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
			for (k = 1; k <= n; k++)
				sum += gcd(gcd(i, j), k);
	printf("%lld", sum);
}

Measured memory_bytes: 1724
n,m=map(int,input().split())
x=10**9+7
def factoring(m):
  i=2
  a=[]
  while i*i<=m:
    count=0
    while m%i==0:
      count+=1
      m=m//i
    if count>0:
      a.append(count)
    i+=1
  if m>1:
    a.append(1)
  return a
def cmb(n,r):
  if r>n-r:
    r=n-r
  if r==0:
    return 1
  if r==1:
    return n
  result=1
  denominator=[i for i in range(1,r+1)]
  numerator=[i for i in range(n-r+1,n+1)]
  for n in numerator:
    result*=n
  for d in denominator:
    result//=d
  return result
fac=factoring(m)
res=1
for b in fac:
  res*=cmb(n+b-1,b)
  res%=x
print(res)

Measured memory_bytes: 3064
using System;
using System.Linq;
class Program
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        char[] s = Console.ReadLine().ToCharArray();
        int x = 0;
        int[] xvalue = new int[n];
        for (int i = 0; i < n; i++)
        {
            if (s[i] == 'I')
                x++;
            else
                x--;
            xvalue[i] = x;
        }
        Console.WriteLine(Math.Max(xvalue.Max(), 0));
    }
}

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

int main(){
 
 string servepoint;

 int Apoint,Bpoint;

 while(1){

   cin >> servepoint;
 
   if(servepoint[0] == '0') break;

   int i;

   i = 1;
 
   Apoint = 0; Bpoint = 0;

   for(int i=1; i < servepoint.size();i++){

   if(servepoint[i] == 'A') Apoint++;
     
   else if(servepoint[i] == 'B') Bpoint++;
           
    
   }

  if(Apoint > Bpoint) Apoint++;
      
  else Bpoint++;

  cout << Apoint <<" "<< Bpoint <<endl;  

 }

 return 0;

}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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 main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i,n){
        cin >> a[i];
        a[i]-=(i+1);
    }
    sort(all(a));
    ll tmp=0;
    if(n%2==1){
        tmp=a[n/2];
    }
    else{
        if(a[n/2-1]>0){
            tmp=a[n/2-1];
        }
        if(a[n/2]<=0){
            tmp=a[n/2];
        }
    }
    ll ans=0;
    REP(i,n){
        ans+=abs(a[i]-tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
inline bool isprime(ll num)
{if(num==2||num==3)return true;
if(num%6!=1&&num%6!=5)return false;
for(int i=5;1ll*i*i<=num;i+=6){if(num%i==0||num%(i+2)==0)return false;}
return true;}
const int mod = 1e9+7;
inline ll mul(ll a,ll b,ll c){return (a*b-(ll)((ld)a*b/c)*c+c)%c;}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll g = exgcd(b,a%b,y,x);y-=a/b*x;return g;}
inline ll quick_pow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res=mul(res,a,mod);a=mul(a,a,mod);b>>=1;}return res;}
inline ll quick_pow(ll a,ll b){ll res=1;while(b){if(b&1)res=mul(res,a,mod);a=mul(a,a,mod);b>>=1;}return res;}
inline ll inv(ll x){return quick_pow(x,mod-2);}
inline ll inv(ll x,ll mod){return quick_pow(x,mod-2,mod);}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int N = 1e2+10;
int a[N];
int main(){
  int n,m;
  cin>>n>>m;
  int sum = 0;
  for(int i=0;i<n;i++)cin>>a[i],sum+=a[i];
  sort(a,a+n);
  if(a[n-m]*4*m>=sum)printf("Yes\n");
  else printf("No\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
    int Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    long long ans = 1e17;
    ans = min(ans, (long long)Q * N * 4);
    ans = min(ans, (long long)H * N * 2);
    ans = min(ans, (long long)S * N);
    if (N % 2 == 0) {
        ans = min(ans, (long long)D * N / 2);
    } else {
        ans = min(ans, (long long)D * (N / 2) + S);
        ans = min(ans, (long long)D * (N / 2) + H * 2);
        ans = min(ans, (long long)D * (N / 2) + Q * 4);
    }
    cout << ans << endl;
}


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

using namespace std;

struct UnionFind {
	vector<long long int> par;
	// sizes[i]???????????????i?????¨?????????????????????????????°???i?????????????????§????????´???????????????????????¨??????
	vector<long long int> sizes;
	
	UnionFind(long long int n) : par(n), sizes(n, 1) {
	// ???????????¨???????????????i?????°?????????i????????¨??????????????¨???????????????
	rep(i,n) par[i] = i;
	}
	
	// ?????????x????±?????????¨???????????????
	long long int find(long long int x) {
	if (x == par[x]) return x;
	return par[x] = find(par[x]);  // ????????????????????????????????°???????????????????????¢???
	}
	
	// 2???????????????x, y????±?????????¨??????????????????
	void unite(long long int x, long long int y) {
	x = find(x);
	y = find(y);
	
	if (x == y) return;
	
	par[y] = x;
	sizes[x] += sizes[y];
	}
};

int main(){
	long long int n,q;
	while(cin >> n >> q,n||q){
		int a[100002];
		a[1] = 1;
		for(long long int i=2;i<=n;i++){
			cin >> a[i];
		}
		vector<bool> roots(n);
		roots[1] = true;
		vector<pair<char,long long int>> queries;
		for(long long int i=0;i<q;i++){
			char c;
			long long int v;
			cin >> c >> v;
			if(c == 'M' && roots[v]) continue;
			if(c == 'M') roots[v] = true;
			queries.emplace_back(make_pair(c,v));
		}
		UnionFind uf(n+2);
		for(long long int i=2;i<=n;i++){
			if(!roots[i]){
				//cout << a[i] << " - " << i << endl;
				uf.unite(a[i],i);
			}
		}
		long long int sum = 0;
		for(long long int i=(long long int)queries.size()-1;i>=0;i--){
			//cout << queries[i].first << " " << queries[i].second << endl;
			if(queries[i].first == 'M'){
				uf.unite(a[queries[i].second],queries[i].second);
			}
			if(queries[i].first == 'Q'){
				//cout << uf.find(queries[i].second) << endl;
				sum += uf.find(queries[i].second);
			}
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 6692
mod = int(1e9 + 7)
def powmod(a, b):
    ans = 1
    while(b):
        if(b&1): ans = ans*a%mod
        a = a*a%mod
        b >>= 1
    return ans
x, y = map(int,input().split())
if(2*x < y or 2*y < x or (2*x-y)%3 or (2*y-x)%3): print(0)
else:
    x, y = (2*x-y)//3, (2*y-x)//3
    #print(x,y)
    fac = [0 for i in range(x+y+1)]
    inv = [0 for i in range(x+y+1)]
    fac[0] = 1
    for i in range(1,x+y+1):
        fac[i] = fac[i-1]*i%mod
    inv[x+y] = powmod(fac[x+y],mod-2)
    for i in range(x+y-1,-1,-1):
        inv[i] = inv[i+1]*(i+1)%mod
    ans = fac[x+y]*inv[x]*inv[y]%mod
    print(ans)

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

int main() {
  string s;
  ll K;
  cin >> s >> K;
  ll N = s.size();
  ll in = 1;
  vector<ll> seq;
  for (ll i = 1; i < N; i++) {
    if (s[i-1] == s[i]) in += 1;
    else {
      seq.push_back(in);
      in = 1;
    }
  }
  seq.push_back(in);
  ll RS = seq.size();
  if (RS == 1) {
    cout << N*K/2;
    return 0;
  }
  
  ll rep = 0;
  for (ll i = 1; i < RS-1; i++) rep += seq[i]/2*K;
  if (s[0] == s[N-1]) rep += seq[0]/2+seq[RS-1]/2+(seq[0]+seq[RS-1])/2*(K-1);
  else rep += seq[0]/2*K+seq[RS-1]/2*K;
  
  cout << rep << endl;
}

Measured memory_bytes: 256
n = int(input())
s1=input()
s2=input()
mod = 10**9+7
l = []
for i in range(0,n-1):
    if s1[i] != s1[i+1]:
        if s1[i] != s2[i]:
            l.append(0)
        else:
            l.append(1)
if s1[n-1]==s2[n-1]:
    l.append(1)
else:
    l.append(0)
if l[0]:
    res = 3
else:
    res = 6

for i in range(1,len(l)):
    if l[i-1] and l[i]:
        res *= 2
    elif l[i-1] and  not l[i]:
        res *= 2
    elif not l[i-1] and not l[i]:
        res *= 3

print(res % mod)

Measured memory_bytes: 3064
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()
k = int(input())
rc = [tuple(map(int, input().split())) for _ in range(k)]
LIST = []
ans = [["." for _ in range(8)] for _ in range(8)]
ALL = list(itertools.permutations(range(8)))
for i in range(len(ALL)):
    for l in range(7):
        p = 0
        for k in range(l + 1, 8):
            if ALL[i][l] == ALL[i][k]:
                p = 1
                break
            elif l == k:
                p = 1
                break
            for s in range(-7, 8):
                if ALL[i][l] + s == ALL[i][k] and l + s == k:
                    p = 1
                    break
                elif ALL[i][l] - s == ALL[i][k] and l + s == k:
                    p = 1
                    break
            if p == 1:
                break
        if p == 1:
            break
        elif l == 6:
            LIST.append(ALL[i])
for i in range(len(LIST)):
    for k in range(len(rc)):
        p = 0
        for l in range(8):
            if LIST[i][l] == rc[k][0] and l == rc[k][1]:
                p = 1
                break
        if p == 0:
            break
        if p == 1 and k == len(rc) - 1:
            for m in range(8):
                ans[LIST[i][m]][m] = "Q"
            for m in ans:
                print("".join(m))
            sys.exit()


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

n = int(input())
a = list(map(int,input().split()))

a.sort()


temp = 0
double = 0

for i in range(n):
    if temp != a[i]:
        temp = a[i]
    else:
        double += 1

if (n - double) % 2 == 0:
    print(n-double-1)
else:
    print(n-double)


Measured memory_bytes: 14388
#include <bits/stdc++.h>
using namespace std;
 
int main() {int s;
    cin >> s;
    int hundred = s / 100;
    int ten = (s - hundred * 100) /10;
    int one = (s - hundred * 100 - ten * 10);
    cout << hundred + ten + one << endl;
}

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

void func(int start,int num,int current);
int s,res;

int main(void){
  int n;
  cin >> n; cin >> s;
  while(n!=0 || s!=0){
    res = 0;
    func(0,n,0);
    cout << res << endl;
    cin >> n; cin >> s;
  }
  return 0;
}
  
void func(int start,int num,int current){
  int temp=0;
  for(int i=start; i<10; i++){
    if(current+i<=s) temp = current+i;
    else break;
    if(num!=1) func(i+1,num-1,temp);
    else if(temp==s) {
      res++;
    }
    temp=0;
  }
}

Measured memory_bytes: 1160
#ifdef CLION
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
//#define int long long

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
#define int ll
template<typename T>
using oset = tree<
        T,
        null_type,
        less<T>,
        rb_tree_tag,
        tree_order_statistics_node_update>;


#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define chkmx(a, b) (a) = max((a), (b))
#define chkmn(a, b) (a) = min((a), (b))

constexpr int MAXN = 3e3;

vector<int> g[MAXN];

int cnt = 0;
int max_deg = 0;
int k;
void run() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> p(n);
    iota(p.begin(), p.end(), 0);
    sort(p.begin(), p.end(), [&a](auto i, auto j){
        return a[i] < a[j];
    });
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 != p[i] % 2) {
            ans++;
        }
    }
    cout << (ans + 1) / 2 << '\n';
}


signed main() {

#ifdef CLION
    freopen("input.txt", "r", stdin);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int t = 1;
    //cin >> t;
    while (t--)
        run();
    return 0;
}

Measured memory_bytes: 1920
from collections import deque
import random

#  リストの先頭だけ見ても最適解は出ない
"""
def mine(k, a, b):
    bookA = deque(a)
    bookB = deque(b)

    cnt = 0
    r = k
    while r > 0:
        if len(bookA) == 0 and len(bookB) == 0:
            break
        elif len(bookA) > 0 and len(bookB) == 0:
            r -= bookA.popleft()
        elif len(bookA) == 0 and len(bookB) > 0:
            r -= bookB.popleft()
        elif len(bookA) > 0 and len(bookB) > 0:
            if bookA[0] <= bookB[0]:
                r -= bookA.popleft()
            else:
                r -= bookB.popleft()
        if r >= 0:
            cnt += 1
    return cnt
"""


#  解答
def tsundoku():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    da = [0]
    db = [0]
    for i in range(n):
        da.append(da[i] + a[i])
    for i in range(m):
        db.append(db[i] + b[i])

    cnt = 0
    j = m
    for i in range(n+1):
        if da[i] > k:
            break
        while db[j] > k - da[i]:
            j -= 1
        cnt = max(cnt, i+j)

    return print(cnt)


tsundoku()
"""
for t in range(100):
    n = random.randint(1, 200000)
    m = random.randint(1, 200000)
    k = random.randint(1, 1000000000)
    a = [random.randint(1, 1000000000) for i in range(n)]
    b = [random.randint(1, 1000000000) for i in range(m)]

    res1 = mine(k, a, b)
    res2 = answer(n, m, k, a, b)
    if res1 != res2:
        print(res1, end=' ')
        print(res2, end=' \t')
        print(a[0:3], b[0:3])
        print(k)
"""

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

using namespace std;

int main()
{
    int x;
    cin>>x;
    int ans = 0;
    ans += ((int)(x / 500) * 1000);
    x = x % 500;
    ans += ((int)(x / 5) * 5);
    cout<<ans<<endl;
    return 0;
}

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

int main() {
	//input
	string S;
	cin >> S;

	//output
	if (S[0] == S[1] && S[0] == S[2]) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
x, n = [int(i)  for i in input().split()]
if n == 0:
  print(x)
  exit()
p = list(input().split())
p = [int(i) for i in p]

  
s1=1000
s2=1000
i=0

for ii in range(n+1):
  #print((x+i),(x-i))
  if (x+i) not in p:
    s1 = (x+i)
  if (x-i) not in p:
    s2= (x-i)
  i+=1
  #print(i)
  if s1 != 1000 or s2 != 1000:
    break

if s1 > s2:
  if s2 != 1000:
    print(s2)
  else:
    print(s1)
else:
  if s1 != 1000:
    print(s1)
  else:
    print(s2)

    


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

int main(){
    int n;
    cin >> n;
    int wrong = 0;
    for(int i = 0; i < n; ++i){
        int x;
        cin >> x;
        if(x != i+1){
            wrong++;
        }
        if(wrong > 2){
            break;
        }
    }
    if(wrong > 2){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }

}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (1ll<<31)-1;
const long long MOD = 1'000'000'007; 

template<typename T>
class lazy_segment_tree{
	int n;
	T fval;
	vector<T> dat, lazy;
	vector<bool> lazyFlag;
	
public:
	
	lazy_segment_tree(){
		
	}
	
	lazy_segment_tree(int n_, T val){
		init(n_, val);
	}
	
	~lazy_segment_tree(){
		
	}
	
	void init(int n_, T val){
		fval = val;
		
		n = 1;
		
		while(n < n_) n *= 2;
		
		dat.resize(2 * n - 1);
		lazy.resize(2 * n - 1, fval);
		lazyFlag.resize(2 * n - 1, false);
	
		for(int i = 0; i < 2 * n - 1; i++) dat[i] = fval;
	}
	
	void eval(int k, int l, int r){
		
		if(lazyFlag[k]){
			dat[k] = lazy[k];
			
			if(r - l > 1) {
				lazy[2*k+1] = lazy[2*k+2] = lazy[k];
				lazyFlag[2*k+1] = lazyFlag[2*k+2] = lazyFlag[k];
			}
			
			lazyFlag[k] = false;
		}
	}
	
	void update(int a, int b, T x, int k = 0, int l = 0, int r = -1){
		if(r < 0) r = n;
		eval(k, l, r);
		if(b <= l || r <= a) {return ;}
		if(a <= l && r <= b){
			lazy[k] = x;
			lazyFlag[k] = true;
			eval(k, l, r);
		} else {
			update(a, b, x, 2*k+1, l, (l+r)/2);
			update(a, b, x, 2*k+2, (l+r)/2, r);
			dat[k] = min(dat[2*k+1], dat[2*k+2]);
		}
	}
	
	T query(int a, int b, int k = 0, int l = 0, int r = -1){
		if(r < 0) r = n;
		eval(k, l, r);
		if(r <= a || b <= l){
			return INF;
		}
		if(a <= l && r <= b){
			return dat[k];
		}else {
			T vl = query(a, b, k * 2 + 1, l, (l + r) / 2 );
			T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return min(vl, vr);
		}
	}
};

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	
	lazy_segment_tree<long long> lseg;
	
	int n, q;
	
	cin>>n>>q;
	
	lseg.init(n+10, INF);
	
	for(int i = 0; i < q; i++){
		int com, s, t, x;
		cin>>com>>s>>t;
		s++, t++;
		if(com){
			cout<<lseg.query(s,t+1)<<endl;
		} else {
			cin>>x;
			lseg.update(s, t+1, x);
		}
	}
	
	return 0;
}



Measured memory_bytes: 7176
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long
				
int32_t main() {
	fast_cin();  

	int n; cin >> n;
	int a[n + 1], sum[n + 5] = {0};
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum[i] += sum[i - 1] + a[i];
	}
	sum[n + 1] = sum[n];
	int l = 0, r = 3;
	int ans = (int)1e17;
	for (int i = 2; i <= n - 2; i++) {
		int let = sum[i];
		while (l + 1 < i && sum[l] < let / 2) {
			l++;
		}
		if (sum[l] > let / 2) l--;
		vector<int> temp;
		int cur = abs(sum[i] - sum[l] - sum[l]);
		if (sum[l] < (let / 2) && l + 1 < i && abs(sum[i] - sum[l + 1] - sum[l + 1]) < cur) {
			temp.push_back(sum[i] - sum[l + 1]);
			temp.push_back(sum[l + 1]);
			l++;
		} else {
			temp.push_back(sum[i] - sum[l]);
			temp.push_back(sum[l]);
		}
		let = sum[n] - sum[i];
		while (r + 1 < n && sum[r] - sum[i] < let / 2) {
			r++;
		}
		if (sum[r] - sum[i] > let / 2) r--;
		cur = abs(sum[n] - sum[r] - sum[r] + sum[i]);
		if (r + 1 < n && abs(sum[n] - sum[r + 1] - sum[r + 1] + sum[i]) < cur) {
			temp.push_back(sum[n] - sum[r + 1]);
			temp.push_back(sum[r + 1] - sum[i]);
			r++;
		} else {
			temp.push_back(sum[n] - sum[r]);
			temp.push_back(sum[r] - sum[i]);
		}
		sort(temp.begin(), temp.end());
		ans = min(ans, abs(temp[3] - temp[0]));
		// cout << l << " " << i << endl;
		// cout << sum[l] << " " << sum[i] - sum[l] << endl;
		// cout << r << " " << n << endl;
		// cout << sum[r] - sum[i] << " " << sum[n] - sum[r] << endl;
 	
	}
	cout << ans << endl;
	
	return 0;
}

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

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

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

    for (int i = n-1; i >= 0; i--) {
        cout << a[i];
        cout << ((i == 0)? "\n" : " ");
    }

    return 0;
}


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

int main() {
	int N,M;
	cin >> N>>M;
	int x,y;
	vector<pair<bool,int>> bo(N,pair<bool,int>(false,1));
	bo.at(0).first=true;
	int count=0;
	for (int i=0;i<M;i++){
		cin >> x>> y;
		bo.at(x-1).second+= -1;
		bo.at(y-1).second+= 1;
		if(bo.at(x-1).first && bo.at(x-1).second==0){
			bo.at(y-1).first=true;
			bo.at(x-1).first=false;
		}
		else if(bo.at(x-1).first && bo.at(x-1).second!=0){
			bo.at(y-1).first=true;
		}
	}
	
	for(int i=0;i<N;i++){
		if(bo.at(i).first){
			count++;
		}
	}
	
	cout<<count<<endl;
		
}



Measured memory_bytes: 1024
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

double maxvolume(int s) 
{
    double length = (double)s / 3.0; 
    double ss = (double)s - length;
    double breadth = ss / 2.0; 
    double height = ss - breadth; 
  
    return length * breadth * height; 
} 

int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int p;
  cin >> p;
  cout << fixed << setprecision(8) << maxvolume(p) << endl;
  return 0;
}


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

template<typename Monoid>
struct SegmentTree {
    using F = function<Monoid(Monoid, Monoid)>;
    const F f;
    const Monoid M1;
    int sz;
    vector<Monoid> dat;
    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1), sz(1) {
        while (sz < n) sz <<= 1;
        dat.assign(sz * 2, M1);
    }
    void set(int k, const Monoid &x) { dat[k + sz] = x; }
    void build() {
        for (int k = sz - 1; k > 0; k--) {
            dat[k] = f(dat[2 * k], dat[2 * k + 1]);
        }
    }
    void update(int k, const Monoid &x) {
        dat[k += sz] = x;
        while (k >>= 1) dat[k] = f(dat[2 * k], dat[2 * k + 1]);
    }
    Monoid get(int a, int b) {  // [a, b)
        Monoid L = M1, R = M1;
        for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if (a & 1) L = f(L, dat[a++]);
            if (b & 1) R = f(dat[--b], R);
        }
        return f(L, R);
    }
    Monoid operator[](const int &k) const { return dat[k + sz]; }
    friend ostream& operator<<(ostream& os, SegmentTree<Monoid> &seg) {
        for (int i = 0; i < seg.sz; i++) os << seg[i] << " ";
        return os;
    }
};

const int INF = numeric_limits<int>::max();
int main() {
    int n; cin >> n;
    SegmentTree<int> seg1(n, [](int a, int b) { return min(a, b); }, INF);
    SegmentTree<int> seg2(n, [](int a, int b) { return min(a, b); }, INF);
    for (int i = 0; i < n; i++) { int a; cin >> a; seg1.set(i, a); }
    for (int i = 0; i < n; i++) { int b; cin >> b; seg2.set(i, b); }
    seg1.build();
    seg2.build();
    int q; cin >> q;
    vector<pair<int, int>> a_his, a_upd, b_his, b_upd;
    bool init = true;
    #define eb emplace_back
    while (q--) {
        int x, y, z; cin >> x >> y >> z; y--;
        if (x == 1) a_his.eb(y, seg1[y]), seg1.update(y, z), a_upd.eb(y, z);
        if (x == 2) b_his.eb(y, seg2[y]), seg2.update(y, z), b_upd.eb(y, z);
        if (x == 3) cout << seg1.get(y, z) << endl;
        if (x == 4) cout << seg2.get(y, z) << endl;
        if (x == 5) {
            if (init) {
                for (int i = 0; i < n; i++) seg1.update(i, seg2[i]);
                init = false;
            } else {
                reverse(a_his.begin(), a_his.end());
                for (auto &p: a_his) seg1.update(p.first, p.second);
                for (auto &p: b_upd) seg1.update(p.first, p.second);
            }
            a_his.clear(), a_upd.clear(), b_his.clear(), b_upd.clear();
        }
        if (x == 6) {
            if (init) {
                for (int i = 0; i < n; i++) seg2.update(i, seg1[i]);
                init = false;
            } else {
                reverse(b_his.begin(), b_his.end());
                for (auto &p: b_his) seg2.update(p.first, p.second);
                for (auto &p: a_upd) seg2.update(p.first, p.second);
            }
            a_his.clear(), a_upd.clear(), b_his.clear(), b_upd.clear();
        }
    }
    return 0;
}


Measured memory_bytes: 7060
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll>>      vpll;
typedef		vector<ll>      vll;


int main()
{
 //O_O ;

       ll x,y;
       string a,b,c;
        cin>>a>>b;
        cin>>x>>y;
        cin>>c;
        if(a==c)
            cout<<x-1<<" "<<y<<nn;
        else
            cout<<x<<" "<<y-1<<nn;






    return 0;
}


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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int a = Integer.parseInt(strArr[0]);
		int b = Integer.parseInt(strArr[1]);
		int c = Integer.parseInt(strArr[2]);
		if (a <= c && c <= b)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}
}


Measured memory_bytes: 21076
#include<stdio.h>
int main(void)
{
  int i,j,a,b,c,flag=1,x[10000],y[10000];
  i=0;
  do{
    scanf("%d %d",&a,&b);
    if(a>b){
      c=a;
      a=b;
      b=c;
    }
  	x[i]=a;
  	y[i]=b;
  	i++;
  	if(a==0&&b==0){
  	  flag=0;
  	}
  }while(flag);
  for(j=0;j<i-1;j++){
    printf("%d %d\n",x[j],y[j]);
  }
  return 0;
}

Measured memory_bytes: 624
#include <bits/stdc++.h>
using namespace std;
#define inf 1e9+100

int n, m, u, k, v, c;
pair<int,pair<int,int> > e[10000];

// sからtに辿り着くまでに閉路が存在すればtrueを返す
// グラフに閉路が存在してもそこを経由できない場合は閉路を検出しない
bool bford(int n, pair<int,pair<int,int> > *e, int *d, int s, int t = -1) {
	fill(d, d+n, inf), d[s] = 0;
	for (int i=0; i<n*2; ++i) {
		for (int j=0; j<m; ++j) {
			int from = e[j].first, to = e[j].second.first, cost = e[j].second.second;
			if(d[from]!=inf && d[to]>d[from]+cost){
				d[to] = d[from] + cost;
				if(to==t && n-1<=i) return true;
			}
		}
	}
	return false;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> u >> k;
		for (int j = 0; j < k; ++j) {
			cin >> v >> c;
			e[m++] = {u, {v, c}};
		}
	}
	int d[100];
	if (bford(n,e,d,0)) cout << -1 << endl;
	else for (int i=0; i<n; ++i) cout << i << ' ' << d[i] << endl;
}


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

using namespace std;

int main(){
  int a, b, c;
 cin >> a >> b >> c;
vector<int> t(3, 0);
t[0] = a;
t[1] = b;
t[2] = c;
sort(t.rbegin(), t.rend());
int ans = (t[0]  - t[1]) + (t[1] - t[2]);
cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int w,n,i,l,r,a[31];

  scanf("%d%d",&w,&n);

  for(i=0;i<=n;i++)
    a[i] = i;

  for(i=0;i<n;i++){
      scanf("%d,%d",&l,&r);

      a[0] = a[l];
      a[l] = a[r];
      a[r] = a[0];
  }

  for(i=1;i<=n;i++)
    printf("%d\n",a[i]);

  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#include <map> 
using namespace std;
int main()
{
    int n,m,i,j,k;
    cin>>n>>m;
    char a[n][m];
    long long int b[n][m];
    for(i=0;i<n;i++)
    {
         for(j=0;j<m;j++)
         {
        cin>>a[i][j];
         }
    }
         for(j=0;j<m;j++)
         {
                   if(a[0][j]=='.')
                   {
                   b[0][j]=1;
                   }
                   else
                   {
                        for(k=j;k<m;k++)
                        {
                             b[0][k]=0;
                        }
                        break;
                   }
         }
              for(i=0;i<n;i++)
         {
                   if(a[i][0]=='.')
                   {
                   b[i][0]=1;
                   }
                   else
                   {
                        for(k=i;k<n;k++)
                        {
                             b[k][0]=0;
                        }
                        break;
                   }
         }
          for(i=1;i<n;i++)
    {
         for(j=1;j<m;j++)
         {
             if(a[i][j]=='.')
             {
                  b[i][j]=(b[i-1][j]+b[i][j-1])%1000000007;
             }
             else
             {
                  b[i][j]=0;
             }
         }
    }
    /*    for(i=0;i<n;i++)
    {
         for(j=0;j<m;j++)
         {
         cout<<b[i][j]<<" ";
         }
         cout<<endl;
    }*/
    cout<<b[n-1][m-1];
    
    return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vec r(a),g(b),m(c);
  for(ll i=0;i<a;i++) {
    cin >> r[i];
  }
  for(ll i=0;i<b;i++) {
    cin >> g[i];
  }
  for(ll i=0;i<c;i++) {
    cin >> m[i];
  }
  sort(r.rbegin(),r.rend());
  sort(g.rbegin(),g.rend());
  sort(m.rbegin(),m.rend());
  priority_queue<ll,vector<ll>,greater<ll>> q;
  for(ll i=0;i<x;i++) {
    q.push(r[i]);
  }
  for(ll i=0;i<y;i++) {
    q.push(g[i]);
  }
  ll idx=0;
  while(idx<c&&q.top()<m[idx]) {
    q.pop();
    q.push(m[idx]);
    idx++;
  }
  ll ans=0;
  while(q.size()) ans+=q.top(),q.pop();
  cout << ans << endl;
}

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

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define pb push_back
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 1e6 + 7;

int n, m;
int val[N];
PII sosik[N];

PII Union(PII a, PII b){
	if(a.st < b.st)
		swap(a, b);

	PII ret = {a.st, b.st};
	if(b.st < a.nd)
		ret.nd = a.nd;
	return ret;
}

int main(){
	scanf("%d", &n);
	m = 1 << n;

	for(int i = 0; i < m; ++i)
		scanf("%d", &val[i]),
		sosik[i] = {val[i], 0};
	
	for(int i = 0; i < n; ++i)
		for(int j = 0; j < m; ++j)
			if(j & (1 << i))
				sosik[j] = Union(sosik[j], sosik[j ^ (1 << i)]);
	
	int res = 0;
	for(int i = 1; i < m; ++i){
		res = max(res, sosik[i].st + sosik[i].nd);
		printf("%d\n", res);
	}

	return 0;
}

Measured memory_bytes: 11264
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int m = in.nextInt();
			int n = in.nextInt();
			out.println(power(m, n, modP));

		}

		static long power(long a, long e, long modP) {
			long ret = 1;
			for (; e > 0; e /= 2) {
				if (e % 2 != 0) {
					ret = (ret * a) % modP;
				}
				a = (a * a) % modP;
			}
			return ret;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}



Measured memory_bytes: 24428
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String str = "ABC";
    if(a >= 2800)str = "AGC";
    else if(a >= 1200)str = "ARC";
    System.out.println(str);
  }
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, a, b, c, d, n;
  cin >> N;
  a = N/1000;
  b = N/100 - 10 * a;
  c = N/10 - 100 * a - 10 * b;
  d = N - 1000 * a - 100 * b - 10 * c;
  if(b != c){
  cout << "No" << endl;    
  }
  else if((b == c && a != b && c != d)){
  cout << "No" << endl;    
  }    
  else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
  int a,b;
  string s;
  cin >> a >> b;
  cin >> s;
  for(int i = 0; i < a; i++){
    if(s[i]<'0'||s[i]>'9'){
      cout << "No" << endl;
      return 0;
    }
  }
  if(s[a]!='-'){
    cout << "No" << endl;
    return 0;
  }
  for(int i=a+1; i<a+b+1; i++){
    if(s[i]<'0'||s[i]>'9'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int v,e;
  cin>>v>>e;
  int g[v][v];
  int INF=1LL<<55LL;
  for(int i=0;i<v;i++)
    for(int j=0;j<v;j++)
      g[i][j]=(i!=j)*INF;
  for(int i=0;i<e;i++){
    int s,t,d;
    cin>>s>>t>>d;
    g[s][t]=d;
  }
  for(int k=0;k<v;k++)
    for(int i=0;i<v;i++)
      for(int j=0;j<v;j++)
	g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
  for(int i=0;i<v;i++){
    if(g[i][i]<0){
      cout<<"NEGATIVE CYCLE"<<endl;
      return 0;
    }
  }
  for(int i=0;i<v;i++){
    for(int j=0;j<v;j++){
      if(j) cout<<" ";
      if(g[i][j]>=INF/2) cout<<"INF";
      else cout<<g[i][j];
    }
    cout<<endl;
  }
  return 0;
}


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

using namespace std;

int main() {
  
  int N;
  
  while(cin >> N && N) {
    int score[(N-1)/2+5];
    fill(score, score+(N-1)/2+3, 0);
    set<int> st;
    for(int i=1; i<N; i++) {
      st.insert(i*i % N);
    }
    
    vector<int> vec;
    for(set<int>::iterator it = st.begin(); it!=st.end(); it++) {
      vec.push_back(*it);
    }
    
    int const M = st.size();
    
    for(int i=0; i<M; i++) {
      for(int j=0; j<M; j++) {
	if(vec[i] == vec[j]) continue;
	
	int diff = vec[i]-vec[j];
	if(diff < 0) diff += N;
	if((N-1)/2 < diff) {
	  diff = N - diff;
	}
	score[diff] ++;
      }
    }
    
    for(int i=1; i<=(N-1)/2; i++) {
      cout << score[i] << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1528
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GS(N);
  print(((N[0] == N[1] && N[1] == N[2]) || N[1] == N[2] && N[2] == N[3])
            ? "Yes"
            : "No");
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		double area = r*r*Math.PI;
		double length = 2*r*Math.PI;
		System.out.printf("%.6f %.6f", area,length);
	}
}


Measured memory_bytes: 28108
#include<iostream>
#include<stdio.h>
using namespace std;

int main(void) {
	int antennas[5];
	int k;
	for (int i = 0; i < 5; i++) {
		scanf("%d", &antennas[i]);
	}
	scanf("%d", &k);
	printf(antennas[4] - antennas[0] <= k ? "Yay!\n" : ":(\n");
	return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main(){
int a,b,c;cin>>a>>b>>c;
if(c>=b&&c<=a&&b<a)cout<<"Yes";
else if(c>=a&&c<=b&&b>a)cout<<"Yes";
else cout<<"No";
}

Measured memory_bytes: 256