akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <unordered_map>

using namespace std;

#define all(v) v.begin(), v.end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);i++)
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define VS vector<string>
#define VI vector<int>
#define I_SCAN(n) cin >> n;
#define VI_SCAN(vi,n) REP(i,n) cin >> vi[i];

int main(void) {
  int x, y;
  I_SCAN(x);
  I_SCAN(y);
  unordered_map<int, int> i2group = {
    {1,1},
    {3,1},
    {5,1},
    {7,1},
    {8,1},
    {10,1},
    {12,1},
    {4,2},
    {6,2},
    {9,2},
    {11,2},
    {2,3}
  };
  if (i2group[x] == i2group[y]) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

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

#define MaxN 2000005
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> freq(MaxN,0);
	vector<long long> ans(MaxN,0ll);
	vector<int> a(n,0);
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		freq[a[i]]++;
	}

	long long aa = 0ll;
	for(int i = 0; i < MaxN; i++)
	{
		ans[i] = (freq[i]*1ll*(freq[i]-1))/2;
		aa += ans[i];
	}

	for(int i = 0; i < n; i++)
	{
		long long temp_ans = aa - ans[a[i]];
		long long temp = freq[a[i]] - 1;
		temp_ans += (temp*1ll*(temp-1))/2;
		cout << temp_ans << endl;
	}


}

Measured memory_bytes: 26752
#include <iostream>
#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <cstring>
//typedef long long int ll;
using namespace std;
struct node{
    int left,right,index;
};
int compare(node a, node b){
    return (a.right<b.right);
}
void update(int tree[],int root, int l, int r, int x, int plus){
    if(l==r&&l==x){tree[root]+=plus; return;}
    int m=(l+r)/2;
    if(x<=m&&l<=x)update(tree,root*2,l,m,x,plus);
    else update(tree,root*2+1,m+1,r,x,plus);
    tree[root]=tree[root*2]+tree[root*2+1];
    return;
}
int query(int tree[], int root, int l, int r, int lq, int rq){
    if(l>=lq&&r<=rq)return tree[root];
    if(r<lq||l>rq)return 0;
    int m=(l+r)/2;
    //if(lq>m)return s+=query(tree,root*2+1,l,r,lq,rq,s);
    //if(rq<m)return s+query(tree,root*2,l,r,lq,rq,s);
    return query(tree,root*2,l,m,lq,rq)+query(tree,root*2+1,m+1,r,lq,rq);
}
int main() {
	// your code goes here
	int n,i,c,q,d; cin>>n>>q;
	vector<int> a; a.push_back(0);
	for(i=1;i<=n;i++){
	   cin>>c; a.push_back(c); 
	}
	
//	vector<int, pair<int,int>> v; 
   node v[q+1];
	for(i=1;i<=q;i++){
	    cin>>v[i].left>>v[i].right; 
	    v[i].index=i;
	}
	sort(v+1,v+q+1,compare);
	int b[1000001]={0};
	int tree[4*n+4]={0};
	int j,r=1; int ord[q+1];
	for(i=1;i<=q;i++){
	    while(r<=v[i].right){
	        if(b[a[r]]==0){
	            b[a[r]]=r;
	            update(tree,1,1,n,r,1);
	        }
	        else{
	            update(tree,1,1,n,b[a[r]],-1);
	            b[a[r]]=r;
	            update(tree,1,1,n,r,1);
	        }
	        r++;
	        // for(j=1;j<=10;j++)cout<<tree[j]<<" "; cout<<endl;
	    }
	   
	   
	    ord[v[i].index]=query(tree,1,1,n,v[i].left,v[i].right);
	    
	}
	
	for(i=1;i<=q;i++)printf("%d\n",ord[i]);
	return 0;
}


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

using namespace std;
int n, i, m, a[105];
float sum;
int main()
{
    cin>>n>>m;
    for(i=0;i<n;i++) {cin>>a[i]; sum+=a[i]*1.0/(4*m);}
    sort(a,a+n,greater<int>());
    for(i=0;i<m;i++) if(a[i]<sum){
        cout<<"No";
        return 0;}
        cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
ans_list = []

while True:
    n,m = map(int,input().split())
    if (n,m) == (0,0):
        break
    A = list(map(int,input().split()))
    N = len(A)
    ans = 0
    for i in range(N):
        for j in range(i+1,N):
            res = A[i] + A[j]
            if res <= m:
                ans = max(ans, res) 
    if ans == 0:
        ans = "NONE"
    ans_list.append(ans)

for ans in ans_list:
    print(ans)


Measured memory_bytes: 5716
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    cin >> n >> k;
 
    vl p(n);
    rep(i, n) {
        cin >> p[i];
    }
    sort(all(p));
    
    ll u = INF;
    rep(i, n-k+1) {
        chmin(u, p[i+k-1] - p[i]);
    }

    out(u);
    re0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    string a, b, c;
    cin >> a >> b >> c;

    Int next_player = 0; // 0 -> A, 1 -> B, 2 -> C
    char next_checker = ' ';
    while (1) {
        if (next_player == 0) {
            if (a == "") {
                cout << 'A' << endl;
                break;
            } else {
                next_checker = a[0];
                a.erase(a.begin());
            }
        } else if (next_player == 1) {
            if (b == "") {
                cout << 'B' << endl;
                break;
            } else {
                next_checker = b[0];
                b.erase(b.begin());
            }
        } else if (next_player == 2) {
            if (c == "") {
                cout << 'C' << endl;
                break;
            } else {
                next_checker = c[0];
                c.erase(c.begin());
            }
        }
        if (next_checker == 'a') {
            next_player = 0;
        } else if (next_checker == 'b') {
            next_player = 1;
        } else if (next_checker == 'c') {
            next_player = 2;
        }
        //cout << a << " " << b << " " << c << " " << next_checker << " " << next_player << endl;
    }
}



Measured memory_bytes: 3592
N = gets.chomp.to_i
a = Array.new(N+1)
str = gets.split
for i in 0...N do
    a[i+1] = str[i].to_i
end

ball = Array.new(N+1,0)
ball_p = Array.new(0)
i = N
j = 0
k = 0
l = 0
while i > 0
    j = i
    k = j
    l = 0
    while k <= N
        l += ball[k]
        k += j
    end
    if l%2 != a[i]
        ball[i] = 1
        ball_p.push(i)
    end
    i -= 1
end

puts ball_p.size
if ball_p.size == 0
    exit
end
while ball_p.size > 0
    print ball_p.pop
    print " "
end
puts

Measured memory_bytes: 21020
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/



signed main() {
	int n; cin >> n;
	rep(i, n) {
		int a, b; cin >> a >> b;
		if (a > b)swap(a, b);
		if (a == b && a == 1) { cout << 0 << endl; continue; }
		int memo = a * b - 1;
		int ok = 0, ng = mod;
		while (ng - ok > 1) {
			int mid = (ok + ng) / 2;
			if (mid * mid <= memo)ok = mid;
			else ng = mid;
		}
		int ans = ok * 2;
		if (memo / ok == ok)ans--;
		if (a <= ok)cout << ans - 1 << endl;
		else cout << ans << endl;
	}
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var n,r,naibu int
  fmt.Scan(&n)
  fmt.Scan(&r)

  if n>10 {
    naibu = r
  } else {
    naibu = r+100*(10-n)
  }
  fmt.Println(naibu)
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int H, W, D;
  cin>>H>>W>>D;
  int A;
  int ah[H*W], aw[H*W];
  REP(i, H) REP(j, W) {
    cin>>A;
    ah[A] = i+1;
    aw[A] = j+1;
  }
  int cost[H*W+1]={}; //1,2,...,D-1からRまで動いた時の消費魔力
  REP(i, D){
    cost[i+1]=0;
    for(int j=1; j<=H*W/D; ++j){
      A = i+1 + j*D;
      if(A > H*W) break;
      cost[A] = abs(ah[A]-ah[A-D]) + abs(aw[A]-aw[A-D]) + cost[A-D];
    }
  }
  //REP(i, H*W)cout<<cost[i+1]<<endl;

  int Q;
  cin>>Q;
  int L, R;
  REP(i, Q) {
    cin>>L>>R;
    cout<<cost[R]-cost[L]<<endl;
  }
  return 0;
}


Measured memory_bytes: 2176
using System;
public class ITP1_9_A
{
	public static void Main()
	{
	string W = System.Console.ReadLine();
	int count = 0;
	while(true)
	{
		string[] data = System.Console.ReadLine().Split(' ');
		if (data[0] == "END_OF_TEXT") break;
		for (int i = 0; i < data.Length; i++)
		{
		if (W.Equals(data[i], StringComparison.CurrentCultureIgnoreCase)) count++;
		}
	}
	System.Console.WriteLine(count);
	}
}

Measured memory_bytes: 9796
a,b,c = input().split()
a = int(a)
b = int(b)
c = int(c)
i = 0
if a > b:
    i = a
    a = b
    b = i
if c < a:
    i = a
    a = c
    c = i
if b > c:
    i = b
    b = c
    c = i
fmt = "{d} {e} {f}"
s = fmt.format(d = a,e = b,f = c)
print(s)

Measured memory_bytes: 7696
#include <bits/stdc++.h>
    using namespace std;
    
    
    int main(){
      string str;
      long long k;
      cin >> str >>  k;
      long long t;
      t = str.length(); 
      t = min(t , k);
      for(long long i = 0 ; i < t ; i++){
          if(str[i] != '1'){
              cout << str[i] << endl;
              return 0;
          }
      }
      
      cout << "1" << endl;
      
      
      return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    string s, t; cin >> s >> t;
    int a, b; cin >> a >> b;

    string u; cin >> u;

    if(s==u) cout <<a-1 << " " << b << endl;
    else cout << a << " " << b-1 << endl;
}

Measured memory_bytes: 256
// D - String Formation
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)

int main(){
	string S; int Q; cin>>S>>Q;
	deque<char> s;
	for(auto c:S) s.push_back(c);
	int odd = 0;
	while(Q--){
		int t; cin>>t; t--;
		if(t){//type2
			int f; char c; cin>>f>>c; f--;
			if(odd ^ f) s.push_back(c);
			else s.push_front(c);
		}
		else odd ^= 1;//type1
	}
	string ans;
	if(odd) for(auto ite=s.rbegin(); ite!=s.rend(); ite++) ans.push_back(*ite);//odd
	else for(auto c:s) ans.push_back(c);//even
	cout<<ans<<endl;
}

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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

ll N, ans = 2;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> N;
    vl facs;
    
    if (N == 2) {
        cout << 1;
        return 0;
    }
    for(ll i = 2; i * i <= N; i++) {
        if ((N - 1) % i == 0) {
            ans++;
            if ((N - 1) / i > i) ans++;
        } else if (N % i == 0) {
            facs.pb(i); 
            if (N / i > i) facs.pb(N / i);
        }
    }
    
    F0R(i, sz(facs)) {
        ll cur = N;
        while (cur % facs[i] == 0) cur /= facs[i];
        cur %= facs[i];
        ans += (cur == 1);
    }
    cout << ans;
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, m;
    cin >> n >> m;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }
    priority_queue<ll> pq;
    rep(i, n){
        pq.emplace(a[i]);
    }
    rep(i, m){
        ll e = pq.top();
        pq.pop();
        pq.emplace(e >> 1);
    }
    ll ans = 0;
    while(!pq.empty()){
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2168
#include<iostream>
#include<cstring> 
#include<cstdio>
#define MN 8200
#define MM 200
#define mod 998244353
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,m,f[MM+5][MN+5],p[MN+5],inv[MN+5],w[2][MN*2+5],A[MN*2+5],B[MN*2+5],N,Inv;
inline int C(int n,int m){return m<=n?1LL*p[n]*inv[m]%mod*inv[n-m]%mod:0;}
inline void R(int&x,int y){x+=y;x>=mod?x-=mod:0;}
inline int pow(int x,int k)
{
	int sum=1;
	for(;k;k>>=1,x=1LL*x*x%mod) if(k&1) sum=1LL*sum*x%mod;
	return sum;	
}
void FFT(int*x,int r)
{
	for(int i=0,j=0;i<N;++i)
	{
		if(i>j) swap(x[i],x[j]);
		for(int k=N>>1;(j^=k)<k;k>>=1);	
	}
	for(int i=2;i<=N;i<<=1)for(int j=0;j<N;j+=i)for(int k=0;k<i>>1;++k)
	{
		int t=1LL*w[r][N/i*k]*x[j+k+(i>>1)]%mod;
		x[j+k+(i>>1)]=(x[j+k]-t+mod)%mod;
		x[j+k]=(x[j+k]+t)%mod;
	}
	if(r)for(int i=0;i<N;++i)x[i]=1LL*x[i]*Inv%mod;
}
int main()
{
	n=read();m=read();p[0]=p[1]=inv[0]=inv[1]=1;
	for(N=1;N<=n;N<<=1);N<<=1;Inv=pow(N,mod-2);
	for(int i=2;i<=n+2;++i) p[i]=1LL*p[i-1]*i%mod,inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<=n+2;++i) inv[i]=1LL*inv[i-1]*inv[i]%mod;
	for(int i=0;i<=n;++i) f[m][i]=C(n,i);int g=pow(3,(mod-1)/N);
	for(int i=0,j=1;i<=N;++i,j=1LL*j*g%mod) w[0][i]=w[1][N-i]=j;
	for(int i=0;i<=n;++i) B[n-i]=inv[i+2];FFT(B,0);
	for(int i=m;i;--i)
	{
		memset(A,0,sizeof(A));
		for(int j=0;j<=n;++j) A[j]=1LL*f[i][j]*p[j+2]%mod;FFT(A,0);
		for(int j=0;j<N;++j) A[j]=1LL*A[j]*B[j]%mod;FFT(A,1);
		for(int j=0;j<=n;++j) f[i-1][j]=1LL*A[n+j]*inv[j]%mod;
		for(int j=0;j<=n;++j) f[i-1][j]=(f[i-1][j]-1LL*f[i][j]*((j+1)*(j+2)/2-(j+1)*j/2-1)%mod+mod)%mod; 
	}
	printf("%d\n",f[0][0]);
	return 0;
}


Measured memory_bytes: 7040
package main

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

func main() {
	s := IOInitialize()
	N := Int(s)
	K := Int(s)
	if N%K == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(1)
	}
}

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

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
    cin.sync_with_stdio(false);
    int n, m;
    while(cin >> n >> m, n | m) {
        vector<P> v(n);
        rep(i, n) cin >> v[i].se >> v[i].fi;
        sort(v.rbegin(), v.rend());

        int p = 0, d = 0;
        rep(i, n) {
            if (v[i].se <= m) {
                m -= v[i].se;
            } else {
                v[i].se -= m;
                m = 0;
                p += v[i].se * v[i].fi;
            }
            d += v[i].se;
        }

        cout << p << endl;
    }

    return 0;
}

Measured memory_bytes: 3172
N = int(input())
a_list = [int(i) for i in input().split()]
ans = ""
ans_list = [0]*N
for i in range(N, 0, -1):
  sum_ = 0
  for j in range(1, N//i+1):
    if j == 1:
      sum_ += ans_list[i*j-1]
    sum_ += ans_list[i*j-1]
    sum_ %= 2
  if sum_ != a_list[i-1]:
    ans_list[i-1] = 1

for i in range(N, 0, -1):
  sum_ = 0
  for j in range(1, N//i+1):
    sum_ += ans_list[i*j-1]
    sum_ %= 2
  if sum_ != a_list[i-1]:
    print(-1)
    exit()

for i, a in enumerate(ans_list):
  if a == 1:
    ans += str(i+1) + " "
print(sum(ans_list))
if ans:
  print(ans[:-1])

Measured memory_bytes: 10036
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

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

Measured memory_bytes: 3572
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

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

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}



int main(){
    IOS;
    make(ll,n);
    makevec(ll,vec,n);
    sort(vec.begin(),vec.end());
    ll a=vec[0];
    bool flag=1;
        ll ans=0;
        if(n==1) cout<<"1 \n";
        else{
        unordered_map <ll,ll>umap;
        ll i=0;
        while(i<n){
                ll k=i;
               while(k<n && vec[k]==vec[i]) k++;
               if(!umap[vec[i]] && k==i+1) ans++;
            for(ll j=vec[i];j<1e6+10;j+=vec[i]){
                umap[j]++;
                }
            i=k;

        }
        cout<<ans<<endl;

        }

    return 0;
}


Measured memory_bytes: 44204
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int n,m;
  cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  cin >> m;
  vector<string> t(m);
  rep(i,m) cin >> t[i];
  int ans = 0;
  rep(i,n){
    int cnt = 0;
    rep(j,n){
      if(s[i] == s[j])cnt++;
    }
    rep(j,m){
      if(s[i] == t[j])cnt--;
    }
    ans = max(ans,cnt);
  }
  cout << ans << endl;
}

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

int main(){
  string a;cin >> a;
  if(a <= "z" && a >= "a")cout << "a";
  else cout << "A";
  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cmath>
using namespace std;
int main(){
long n,i;
double x,y,t,pi=3.14159265358979;
while(cin>>n){
if(n==-1)break;
for(x=1,y=0,t=0,i=1;i<n;i++){
x+=cos(t+pi*0.5);y+=sin(t+pi*0.5);t=atan2(y,x);
}
cout<<x<<endl<<y<<endl;
}
return 0;
}

Measured memory_bytes: 1312
#include<bits/stdc++.h>
using namespace std;
long long a,b;
int main(){
	cin>>a>>b;
	if((a<0 && b>0) || (a==0 || b==0)){
		cout<<"Zero";
	}
	else if(((a<0 && b<0) && (abs(b-a)%2)==1) || (a>0 && b>0)){
		cout<<"Positive";
	}
	else{
		cout<<"Negative";
	}
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const ll MOD = 998244353;

int main() {
	cin.tie(0)->sync_with_stdio(false);
	int n, k; cin >> n >> k;
	vector<int> l(k), r(k);
	REP(i, k) cin >> l[i] >> r[i];
	vector<ll> dp(n + 1, 0);
	dp[0] = 1;
	dp[1] = -1;
	REP(i, n) {
		dp[i] = ((dp[i] % MOD) + MOD) % MOD;
		dp[i + 1] = (dp[i + 1] + dp[i]) % MOD;
		REP(j, k) {
			if (i + l[j] < n) dp[i + l[j]] += dp[i];
			if (i + r[j] + 1 < n) dp[i + r[j] + 1] -= dp[i];
		}
	}
	cout << dp[n - 1] << '\n';
	return 0;
}


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

int main()
{
    long long n,a,b,ans;
    cin >> n>>a>>b;
    ans=a/n;
    if(ans*n>=a && ans*n<=b)
    cout << "OK";
    else if((ans+1)*n>=a && (ans+1)*n<=b)
    cout << "OK";
    else
    cout << "NG";
    
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), is_sorted(),

int n;
int v[300005];
int suf[64][300005][2];

signed main(){
    FASTER;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>v[i];
    
    for(int i=0;i<64;i++){
        for(int j=n;j>=1;j--){
            suf[i][j][1]=suf[i][j+1][1]+((v[j]>>i)&1);
            suf[i][j][0]=suf[i][j+1][0]+(1-((v[j]>>i)&1));
        }
    }
    int ans=0;
    for(int i=0;i<64;i++){
        for(int j=n;j>=1;j--){
            int z=suf[i][j+1][0];
            int o=suf[i][j+1][1];
            if((v[j]>>i)&1){
                ans+=(1LL<<i)%MOD*z%MOD;
            }else{
                ans+=(1LL<<i)%MOD*o%MOD;
            }
            ans%=MOD;
        }
    }
    cout<<ans;
}



Measured memory_bytes: 306004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int T,A,B,C,D;ll n;
map<ll,ll>mp;
ll calc(ll n){
	if(n<2)return n*D;
	if(mp.count(n))return mp[n];
	ll&t=mp[n]=1ll<<62;
	if(t/D>=n)t=n*D;
	ll x;
	x=n/2;t=min(t,calc(x)+A+1ll*D*abs(x*2-n));
	x=(n+1)/2;t=min(t,calc(x)+A+1ll*D*abs(x*2-n));
	x=n/3;t=min(t,calc(x)+B+1ll*D*abs(x*3-n));
	x=(n+2)/3;t=min(t,calc(x)+B+1ll*D*abs(x*3-n));
	x=n/5;t=min(t,calc(x)+C+1ll*D*abs(x*5-n));
	x=(n+4)/5;t=min(t,calc(x)+C+1ll*D*abs(x*5-n));
	return t;
}
int main(){
	for(scanf("%d",&T);T--;){
		mp.clear();
		scanf("%lld%d%d%d%d",&n,&A,&B,&C,&D);
		printf("%lld\n",calc(n));
	}
}

Measured memory_bytes: 4580
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define MIN(x) *min_element(all(x))
#define MAX(x) *max_element(all(x))
#define el  cout << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define pb push_back
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main() {
    int N, T, A, ans = 0;
    double min = 20000;
    VI vi;
    cin >> N;
    cin >> T >> A;
    REP(i, N){
        int in;
        cin >> in;
        vi.pb(in);
    }
    REP(i, N){
        double temp;
        temp = T - vi[i] * 0.006;
        temp = abs(A - temp);
        if(chmin(min, temp))
            ans = i+1;
    }

    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

void YesNo(bool x) {
    cout << (x ? "Yes" : "No") << endl;
}

int main() {
    string s, t;
    cin >> s >> t;
    int ret = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == t[i])ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long int
#define mem(x) memset(x,0,sizeof(x))
#define setbits(x)  __builtin_popcount(x)
#define ull unsigned long long int
#define all(c) (c).begin(),(c).end()
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define cps CLOCKS_PER_SEC
#define complex cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / cps << '\n';
#define db double
#define endl "\n"
#define  fbo(x) find_by_order(x)
#define  ook(x) order_of_key(x)

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os1;
typedef tree<int, null_type, greater<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os2;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair<ll,ll > ii;
typedef pair<ll,int> li;
inline void fast()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
const ll pi=31;
const ll MOD[2] = {1187278649, 1149736019};//for double hashing
const ll mod=(ll)(1e9)+7;
ll pmod(ll x,ll n){
  ll r=1;
  while(n)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
  }
  return r;
}

//think recursively also


void solve()
{   
  string s,t;
  cin>>s>>t;
  t.erase(t.size()-1,1);
  if(s.compare(t)==0)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }

    
  
}
int main()
{
   fast();
  
   // int t;
   // cin>>t;
   // for(int casee=1;casee<=t;casee++)
  {// cout<<"Case #"<<casee<<": ";
    solve();
  }
 
 
 
}


Measured memory_bytes: 3644
// 66DTG
// 26052020
#include<bits/stdc++.h>
using namespace std;
#define bolt ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef long double ld;
const ld pi=3.1415926535897932384626433;
const int mod = 1000000007;
const ll inf=3e18;
int main()
{
   bolt;
   ll n;
   cin>>n;
   ll k=n%10;
   if (k==0 or k==1 or k==6 or k==8)
   {
      cout<<"pon";
      return 0;
   }
   if (k==3)
   {
      cout<<"bon";
      return 0;
   }
   cout<<"hon";
   return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=2005;
bool ok[N][N],can[N][N];
int h,w,hig[N][N],l[N],r[N],sta[N],top,ans;
char c[N];
bool judge(int x,int y){
	return !((ok[x][y]+ok[x+1][y]+ok[x][y+1]+ok[x+1][y+1])&1);
}
int main(){
	ios::sync_with_stdio(false);
	cin>>h>>w;
	for(int i=1;i<=h;i++){
		cin>>c;
		for(int j=0;j<w;j++)
			ok[i][j+1]=(c[j]=='#');
	}
	for(int i=1;i<h;i++)
		for(int j=1;j<w;j++){
			can[i][j]=judge(i,j);
			if(can[i][j]) hig[i][j]=hig[i-1][j]+1;
		}
	for(int i=1;i<h;i++){
		sta[top=1]=0;
		for(int j=1;j<w;j++){
			while(top&&hig[i][sta[top]]>=hig[i][j]) top--;
			l[j]=sta[top],sta[++top]=j;
		}
		sta[top=1]=w;
		for(int j=w-1;j>=1;j--){
			while(top&&hig[i][sta[top]]>=hig[i][j]) top--;
			r[j]=sta[top],sta[++top]=j;
		}
		for(int j=1;j<w;j++)
			ans=max(ans,(hig[i][j]+1)*(r[j]-l[j]));
	}
	cout<<max(ans,max(h,w));	
	return 0;
}

Measured memory_bytes: 23808
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;
int n;
string s;

int main() {
  cin >> n;
  cin >> s;
  long long ans = 0;
  int m = (1 << n);
  map<string, long long> mp;
  for (int i = 0; i < m; i++) {
    string t1, t2;
    for (int j = 0; j < n; j++)
      if (((i >> j) & 1) == 1)
        t1.push_back(s[j]);
      else
        t2.push_back(s[j]);
    mp[t1 + " " + t2]++;
  }
  int l = n * 2;
  for (int i = 0; i < m; i++) {
    string t1, t2;
    for (int j = 0; j < n; j++)
      if (((i >> j) & 1) == 1)
        t1.push_back(s[l - j - 1]);
      else
        t2.push_back(s[l - j - 1]);
    ans += mp[t1 + " " + t2];
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 67200
l= input()
a,b,c = list(map(int, l.split()))
if a < b < c:
    print(f"{a} {b} {c}")
elif a > b:
    if b > c:
        print(f"{c} {b} {a}")
    elif a > c:
        print(f"{b} {c} {a}")
    else:
        print(f"{b} {a} {c}")
elif a > c:
    if b > c:
        print (f"{c} {a} {b}")
else:
    print (f"{a} {c} {b}")


Measured memory_bytes: 5608
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}/*swap 交換*/
ll max2(ll a,ll b){return a>=b?a:b;}/*2つのうち大きい数を返す*/ 
ll min2(ll a,ll b){return a>=b?b:a;}/*2つのうち小さい数を返す*/ 
ll ABS(ll a){return a>=0?a:(-a);}/*絶対値*/ 
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll num; //number
    ll par; //parent
    ll height; //height
    ll wdif;
    ll weight;
}WUF;

void WUFmake(ll n, WUF b[n]){for(ll i=0;i<n;i++){
    b[i].par = i; b[i].num = i; b[i].height = 1; b[i].wdif = 0; b[i].weight = 0;}}

ll WUFroot(ll n, ll a, WUF b[n]){
    // b[a].weight = b[b[a].par].weight + b[a].wdif;
    // return a==b[a].par ? a : WUFroot(n,b[a].par,b) ;
    ll c= a==b[a].par ? a : WUFroot(n,b[a].par,b) ;
    b[a].weight = b[b[a].par].weight + b[a].wdif;
    return c;
}

// b[x]+z=b[y]
void WUFunite(ll n, ll x, ll y, ll z, WUF b[n]){
    ll xroot = WUFroot(n,x,b), yroot = WUFroot(n,y,b);
    if(b[xroot].height > b[yroot].height){
        b[yroot].par = xroot;
        b[yroot].wdif = b[x].weight+z-b[y].weight;
    }else{
        b[xroot].par = yroot;
        b[yroot].height = max2(b[yroot].height,b[xroot].height+1);
        b[xroot].wdif = b[y].weight-b[x].weight-z;
    }
}

ll WUFsame(ll n, ll x, ll y, WUF b[n]){
    return WUFroot(n,x,b) == WUFroot(n,y,b) ? 1 : 0; 
    // if( WUFroot(n,x,b) == WUFroot(n,y,b) ){
    //     return 1;
    // }
    // return 0;
}


int main(void){
    ll n,q,i;
    scanf("%lld%lld",&n,&q);
    ll query[q],x[q],y[q],z[q];
    WUF tree[n];
    WUFmake(n,tree);
    rep(i,0,q){
        scanf("%lld",&query[i]);
        if(query[i]==0){
            scanf("%lld%lld%lld",&x[i],&y[i],&z[i]);
        }else{
            scanf("%lld%lld",&x[i],&y[i]);
        }
    }
    rep(i,0,q){
        if(query[i]==0){
            if(!WUFsame(n,x[i],y[i],tree)){
                WUFunite(n,x[i],y[i],z[i],tree);
            }
        }else{
            if(WUFsame(n,x[i],y[i],tree)){
                printf("%lld\n",tree[y[i]].weight-tree[x[i]].weight);
            }else{
                printf("?\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 11864
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;
//#define _USE_MATH_DEFINES

int main(void) {
	LL n, k, num, j = 0, m = 0;
	cin >> n >> k;

	vector<LL> a(n);

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

	m = 1 + (int)((n - k)/(k-1));
	if(0<n-k && (n-k)%(k-1) != 0)m++;
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N, K; cin >> N >> K;
  int R, S, P; cin >> R >> S >> P;
  string T; cin >> T;
  vector<bool> win(N);
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    if (i < K || T.at(i - K) != T.at(i) || !win.at(i - K)) {
      if (T.at(i) == 'r') ans += P;
      if (T.at(i) == 's') ans += R;
      if (T.at(i) == 'p') ans += S;
      win.at(i) = true;
    }
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 512
a,b,k = map(int,input().split())

for i in range(k):
  if(i%2 == 0):
    if(a%2==1):
      a -= 1
    s = int(a/2)
    a -= s
    b += s
  else:
    if(b%2==1):
      b -= 1
    s = int(b/2)
    b -= s
    a += s

print("{} {}".format(a,b))

Measured memory_bytes: 3316
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
que = []
for i in range(a):
    que.append(p[i]*3)
for i in range(b):
    que.append(q[i]*3+1)
for i in range(c):
    que.append(r[i]*3+2)
que.sort(reverse = True)
cnt = [0]*2
sm = 0
up = [x, y]
ans = 0
for i in range(a+b+c):
    v = que[i]
    if v%3 == 2:
        sm+=1
    elif cnt[v%3] == up[v%3]:
        continue
    else:
        cnt[v%3]+=1
        sm+=1
    ans+=v//3
    if sm == x+y:
        break
print(ans)



Measured memory_bytes: 117988
package main

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

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func main() {
	_, K := getStdinInt2()
	p := getStdinIntArr()

	sort.Ints(p)

	sum := 0
	for i := 0; i < K; i++ {
		sum += p[i]
	}

	fmt.Printf("%d", sum)
	/*
		fmt.Println(permutation([]int{50, 2, 1, 9}, 3))
	*/
	fmt.Printf("\n")
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func remove(ar []int, i int) []int {
	tmp := make([]int, len(ar))
	copy(tmp, ar)
	return append(tmp[0:i], tmp[i+1:]...)
}

func permutation_full(ar []int) [][]int {
	var result [][]int
	if len(ar) == 1 {
		return append(result, ar)
	}
	for i, a := range ar {
		for _, b := range permutation_full(remove(ar, i)) {
			result = append(result, append([]int{a}, b...))
		}
	}
	return result
}

//順列
func permutation(ar []int, n int) (result [][]int) {
	for _, a := range combination(ar, n) {
		result = append(result, permutation_full(a)...)
	}
	return
}

//組み合わせ
func combination(ar []int, n int) (result [][]int) {
	if n <= 0 || len(ar) < n {
		return
	}
	if n == 1 {
		for _, a := range ar {
			result = append(result, []int{a})
		}
	} else if len(ar) == n {
		result = append(result, ar)
	} else {
		for _, a := range combination(ar[1:], n-1) {
			result = append(result, append([]int{ar[0]}, a...))
		}
		result = append(result, combination(ar[1:], n)...)
	}
	return
}


Measured memory_bytes: 2216
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;

ll a[100005];
int main(){
	ll t;
    ll x,y;
    cin>>x>>y;
    ll f=0;
    for(ll i=0;i<=200;i++){
    	for(ll j=0;j<=200;j++){
    		if(i+j==x &&  2*i+4*j==y){f=1;break;}
		}
	}
	if(f)cout<<"Yes";
	else cout<<"No";
    	
    
	
	
	
	
    
}

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

bool match(char c1, char c2) {
    return c1 == 'S' && c2 == 'T';
}

int main() {
    string X;  cin >> X;
    int N = X.size();
    stack<char> st;
    for (int i = 0; i < N; ++i) {
        if (!st.empty() && match(st.top(), X[i])) st.pop();
        else st.push(X[i]);
    }
    cout << st.size() << endl;
}


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

using namespace std;

int main(){
        string S, s;
        cin>>S;
        int res=0;
        for(int i=0;i<(int)S.size();i+=2){
                s+=S[i];
                s+=S[i+1];
                if(s.substr(0, i/2)==s.substr(i/2, i/2)){
                        res=i;
                }
        }
        cout<<res<<endl;
        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

typedef long long ll;

const int MAX_N = 51;
const int MAX_DAY = 31;

ll dp[MAX_N][MAX_DAY]; // N??????????????????D??\????????§???????????????????????§?????°????????????

int main() {
	int N;
	while(cin >> N, N) {
		vector<vector<bool>> schedules(N, vector<bool>(MAX_DAY, false));
		fill_n((ll *)dp, sizeof(dp) / sizeof(ll), 0);

		rep(n, N) {
			int f0, fi;
			cin >> f0;
			rep(j, f0) {
				cin >> fi;
				schedules[n][fi] = true;
			}
		}
		
		rep(n, N) dp[n][0] |= (1LL<<n);
		
		REP(d, 1, MAX_DAY) {
			rep(n, N) {
				if(!schedules[n][d]){
					dp[n][d] = dp[n][d-1];
					continue;
				}	
				rep(i, N) {
					if(!schedules[i][d]) continue;
					dp[i][d] |= dp[n][d-1];
				}
			}
		}
		
		bool is_clear = false;
		const ll CLEAR = (1LL<<N)-1;
		int ans = 0;
		rep(d, MAX_DAY) {
			rep(n, N) {
				if(dp[n][d] == CLEAR && !is_clear) {
					ans = d;
					is_clear = true;
				}
			}
		}
		cout << ((is_clear) ? ans : -1) << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var N, K, S int
	fmt.Scan(&N, &K, &S)
	wtr := bufio.NewWriter(os.Stdout)
	for i := 0; i < N; i++ {
		if i < K {
			fmt.Fprintf(wtr, "%d ", S)
		} else {
			var r int
			if S == 1 {
				r = 2
			} else {
				r = S/2 + 1
			}
			fmt.Fprintf(wtr, "%d ", r)
		}
	}
	fmt.Fprintln(wtr)
	wtr.Flush()
}


Measured memory_bytes: 2432
#ifndef TEMPLATE_HPP
#define TEMPLATE_HPP
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())
using namespace std;
using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename U> vector<U> make_vector(T&& n, U&& val) { return vector<U>(forward<T>(n), forward<U>(val)); }
template <typename T, typename... Args> decltype(auto) make_vector(T&& n, Args&&... args) { return vector<decltype(make_vector(forward<Args>(args)...))>(forward<T>(n), make_vector(forward<Args>(args)...)); }
const int INF = 1001001001;
const i64 LINF = 1001001001001001001ll;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
#endif

void solve() {
  int n;
  cin >> n;
  vi32 l(n);
  cin >> l;
  int ans = 0;
  rep(i, n) rep(j, i) rep(k, j) {
    vi32 v;
    v.push_back(l[i]);
    v.push_back(l[j]);
    v.push_back(l[k]);
    sort(all(v));
    if (v[0] + v[1] <= v[2]) continue;
    if (v[0] == v[1] || v[1] == v[2]) continue;
    ans += 1;
  }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  solve();
  return 0;
}

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

using namespace std;

int main()
{
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    bool reverse = false;
    string S1, S2;
    while(Q--)
    {
        int Ti;
        cin >> Ti;
        if(Ti == 1)
        {
            if(reverse) reverse = false;
            else reverse = true;
        }
        else if(Ti == 2)
        {
            int Fi;
            char Ci;
            cin >> Fi >> Ci;
            if(reverse){
                if(Fi == 1) S2 += Ci;
                else S1 += Ci;
            }
            else{
                if(Fi == 1) S1 += Ci;
                else S2 += Ci;
            }
        }
    }
    if(reverse)
    {
        int lo = 0;
        int hi = S.length() - 1;
        while(lo < hi)
        {
            char c = S[lo];
            S[lo] = S[hi];
            S[hi] = c;
            lo++;
            hi--;
        }
        lo = 0;
        hi = S2.length() - 1;
        while(lo < hi)
        {
            char c = S2[lo];
            S2[lo] = S2[hi];
            S2[hi] = c;
            lo++;
            hi--;
        }
        cout << S2 + S + S1 << endl;
    }
    else
    {
        int lo = 0;
        int hi = S1.length() - 1;
        while(lo < hi)
        {
            char c = S1[lo];
            S1[lo] = S1[hi];
            S1[hi] = c;
            lo++;
            hi--;
        }
        cout << S1 + S + S2 << endl;
    }
}

Measured memory_bytes: 1348