akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int mo=1000000007;
const int N=75;
int C[N*5][N*5];
int n,k,ans,used[N];
int q1[N],q2[N],suf[N];
int f[N][N];
char s[N];
void init(){
	For(i,0,N*5-1) C[i][0]=1;
	For(i,1,N*5-1) For(j,1,i)
		C[i][j]=(C[i-1][j]+C[i-1][j-1])%mo;
}
void solve(int S1,int S2){
	if (!S1&&!S2) return ++ans,void(0);
	if ((S1+S2)*2>n+1||S1+2*S2>k) return; 
	memset(used,0,sizeof(used));
	int h=0,t=*q2=0;
	For(i,1,k)
		if (s[i]=='r') q1[++t]=i;
		else if (s[i]=='b'&&h!=t&&*q2!=S2)
			used[q1[++h]]=used[i]=1,q2[++*q2]=i;
	if (*q2!=S2) return;
	For(i,1,S1)
		if (h==t) return;
		else used[q1[++h]]=1;
	Rep(i,k,1) suf[i]=suf[i+1]+(!used[i]);
	For(i,1,S2) q2[i]=suf[q2[i]];
	memset(f,0,sizeof(f));
	f[0][0]=1;
	int upp=max(2,n);
	For(i,2,upp) Rep(j,S2-1,0) For(k,2*j,upp){
		int psum=k-2*j;
		For(l,1,min(S2-j,(upp-k)/i)){
			if ((psum+=i-2)>q2[S2-j-l+1]) break;
			f[j+l][k+i*l]=(f[j+l][k+i*l]+1ll*C[j+l][l]*f[j][k])%mo;
		}
	}
	For(k,0,upp){
		int sum=2*S1+2*k-2*S2-1;
		int par=2*S1+2*k+1;
		if (sum&&sum<=n&&f[S2][k])
			ans=(ans+1ll*f[S2][k]*C[n-sum+par-1][par-1]%mo*C[S2+S1][S2])%mo;
	}
}
int main(){
	init();
	scanf("%d%d",&n,&k);
	scanf("%s",s+1);
	For(S1,0,n) For(S2,0,n) solve(S1,S2);
	printf("%d\n",ans);
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());
  int era = min(n, k);
  rep(i, era) {
    h.pop_back();
  }
  ll sum = 0;
  rep(i, h.size()) sum += h[i];
  cout << sum << endl;
  return 0;
}
    

Measured memory_bytes: 4028
package main

import (
	"fmt"
)

func main() {
	var n, sum int
	fmt.Scan(&n)
	v, c := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&v[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&c[i])
	}
	for i := 0; i < n; i++ {
		if v[i]-c[i] > 0 {
			sum += v[i] - c[i]
		}
	}
	fmt.Print(sum)
}


Measured memory_bytes: 1772
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  vi a(3);

  rep(i,3) cin >> a[i];

  vsort(a);

  cout << abs(a[2] -a[1]) + abs(a[1] - a[0]); 



  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

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

int main () {
    int N;
    int d1, d2, cnt = 0;
    bool flg = false;
    cin >> N;
    rep(i,N) {
        cin >> d1 >> d2;
        if(d1 == d2) {
            cnt++;
        } else {
            cnt = 0;
        }
        if(cnt >= 3) flg = true;
    }
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX 2001

int dp[MAX][MAX];
int arr[MAX][MAX];

void init(int N){
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < N ; j++){
      dp[i][j] = 0;
      arr[i][j] = MAX;
    }
  }
}

int main(){
  string s;

  while(cin >> s){
    string t = s;
    reverse(t.begin(), t.end());
 
    int len = s.size();  init(len+1);
    for(int i = 0 ; i < len ; i++){
      for(int j = 0 ; j < len ; j++){
        if(s[i] == t[j]){
          dp[i+1][j+1] = dp[i][j] + 1;
          arr[i+1][j+1] = 0;
        }else{
          if(dp[i][j+1] < dp[i+1][j]){
            dp[i+1][j+1] = dp[i+1][j];
            arr[i+1][j+1] = -1;
          }else{
            dp[i+1][j+1] = dp[i][j+1];
            arr[i+1][j+1] = 1;
          }
        }
      }
    }
    string str;
    for(int i = len, j = len ; i > 0 && j > 0 ;){
      if(!arr[i][j]){
        str += s[i-1];
        i--, j--;
      }else if(arr[i][j] == 1){
        i--;
      }else{
        j--;
      }
    }
    cout << str << endl;
  }

  return 0;
}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(void)
{
    int i,j;
    int cnt,num;
    string s,p;
    getline(cin,s);
    getline(cin,p);
    s+=s;
    cnt=0;
    num=1;
    //cout<<p.size()<<endl;
    REP(i,s.size()) {
        if(s[i]==p[cnt]) {
            cnt++;
            for(j=i+1;s[j]==p[cnt];j++,cnt++) {
                num++;
                //cout<<s[j]<<num;
            }
            if(p.size()==num) {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        cnt=0;
        num=1;
    }
    cout<<"No"<<endl;
}



Measured memory_bytes: 3216
#include"bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> & l, const pair<T1, T2> & r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> & l, const pair<T1, T2> & r) { return make_pair(l.first - r.first, l.second - r.second); }


template <std::int_fast64_t Modulus>
class modint
{
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept
	{
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept
	{
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept
	{
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept
	{
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept
	{
		a += rhs.a;
		if (a >= Modulus)
		{
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept
	{
		if (a < rhs.a)
		{
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept
	{
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept
	{
		u64 exp = Modulus - 2;
		while (exp)
		{
			if (exp % 2)
			{
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
const lint MOD = 1e9 + 7;
typedef modint<MOD> ModInt;
#pragma endregion

ModInt func[200000];
void funcinit(int N)
{
	func[0] = 1;
	for (int i = 1; i <= N; i++)
	{
		func[i] = func[i - 1] * i;
	}
}
ModInt comb(ModInt n, ModInt r)
{
	if (n.a <= 0 || n.a < r.a)
	{
		return 0;
	}
	return func[n.a] / (func[r.a] * func[(n - r).a]);
}
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	lint N, K;
	cin >> N >> K;
	funcinit(N + 1);
	ModInt ans = 0;
	REP(i, min(N, K + 1)) {
		ans += comb(N, i) * comb(N - 1, N - i - 1);
	}
	cout << ans.a;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,L;
  cin >> N >> L;
  vector<int>A(N);
  vector<int>B(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    A.at(i) = L + i;
    sum += A.at(i);
    B.at(i) = abs(A.at(i));
  }
  sort(B.begin(), B.end());

  for (int i = 0; i < N; i++) {
    if (B.at(0) == abs(A.at(i))){
      sum -= A.at(i);
    }
  }
  
  cout << sum << endl;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  char A = S.at(0);
  string B = "No";
  for(int i = 0; i < S.size(); i++){
    if(S.at(i) != A){
      B = "Yes";
      break;
    }
  }
  cout << B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    long long n, k;
    cin >> n >> k;

    long long ans = LLONG_MAX;
    int count = 0;
    while (true) {
        n = min(n % k, abs(n - k));
        if (ans > n) {
            ans = n;
            count = 0;
        } else
            count++;
        if (count == 3) break ;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3564
// D - Walk and Teleport
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	int n,a,b; cin>>n>>a>>b;
	ll cur = 0, nxt = 0;
	int xi,xj; cin>>xj;
	for(int i=0; i<n-1; i++){
		xi = xj; cin>>xj;
		cur = nxt = cur + min((ll)b, (ll)(xj-xi)*a);
	}
	cout<< cur <<endl;
}

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

int main(){
  int i,j,k,l,cnt=0;
  int n;
  cin>>n;
  int a[n];
  int x[n+1][n+1],y[n+1][n+1];
  for(i=1;i<=n;i++){
    cin>>a[i];
    for(j=1;j<=a[i];j++)cin>>x[i][j]>>y[i][j];
  }
  int p[n+1];
  int ma=0;
  int b=(int)round(pow(2,n));
  for(i=1;i<b;i++){
    cnt=0;
    for(j=0;j<n;j++){
      p[j+1]=(i/(int)round(pow(2,j)))%2;
      if(p[j+1]==1)cnt++;
    }
    for(k=1;k<=n;k++){
      for(l=1;l<=a[k];l++){
        if(p[k]==1 && (y[k][l]!=p[x[k][l]])){
          cnt=0;
          break;
        }
      }
    }
    ma=max(cnt,ma);
  }
  cout<<ma;
}

Measured memory_bytes: 256
for _ in range(50):
    try:
        n = int(input()) # 1 <= n <= 50
        ans =set()
        for a in range(10):
            if (n - a) >= 1:
                for b in range(10):
                    if(n - a -b) >= 1:
                        for c in range(10):
                            if(n - a - b - c) >= 1:
                                for d in range(10):
                                    if(n - a - b - c - d) == 0:
                                        ans.add("{},{},{},{}".format(a,b,c,d))
                                        ans.add("{},{},{},{}".format(b,c,d,a))
                                        ans.add("{},{},{},{}".format(c,d,a,b))
                                        ans.add("{},{},{},{}".format(d,a,b,c))
        print(len(ans))
    except EOFError:
        break

Measured memory_bytes: 7656
#include <iostream>
#include <string>
#include <vector>


using namespace std;

int main(){

    int K, X;
    cin >> K >> X;
    
    
    int satrt = X-K+1;
    int fin = X+K-1;
    
    for (int i = satrt; i <= fin; i++) {
        cout << i;
        if (i != fin) {
            cout << " ";
        }
        
    }
    cout << endl;
    
    
    
    
    return 0;
    
}


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

void IDENTIFY(string S, string T)
{
    for (int i = 0; i < S.length(); i++)
        if (S[i] != T[i])
        {
            cout << "No";
            return;
        }
    cout << "Yes";
}

int main() 
{
    string S, T;
    cin >> S >> T;
    IDENTIFY(S, T);
}

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

#include <stdio.h>

#include <math.h>
/********
*	?????¢????±???????????????°??????
*********/	
/*********??¢?????´?????????
*	(1)??°????????\???
*	(2)?¨???????????????????
*********/

int main(void)
{
	double answer;
	double x1,x2,y1,y2;
	
	cin  >> x1 >> y1>> x2 >> y2 ;
	answer =sqrt( (y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
	
	printf("%f",answer);
	
	return 0;
}

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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;
const int inf = 2147483647;
const int mod = 1e9 + 7;
const int N = 5e3 + 1;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I LL read() {
	LL 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 << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

int f[N][2], bin[N], T[N], g[N], q[N][2], z[N];

int main() {
	reg n = read(), A = read(), B = read();
	if(A < B) swap(A, B);
	q[0][1] = 1;
	fo(i, 0, A - 1) {
		fo(k, 0, 1) if(q[i][k]) {
			fo(h, 1, A - 1 - i) {
				if(k == 1) {
					q[i + h][k ^ 1] = (q[i + h][k ^ 1] + q[i][k]) % mod;
				} else {
					if(h < B) continue;
					q[i + h][k ^ 1] = (q[i + h][k ^ 1] + q[i][k]) % mod;
				}
			}
		}
	} fo(i, 1, A - 1) T[i] = q[i][0];
	fo(i, 1, A - 1) {
		fo(j, 1, i - B) g[i] = (g[i] + T[j]) % mod;
		g[i] = (g[i] + T[i]) % mod;
	} fo(i, 1, A - 1) {
		fo(j, 1, i - B) z[i] = (z[i] + g[j]) % mod;
		z[i] = (z[i] + g[i]) % mod;
	}
	f[0][0] = f[0][1] = 1;
	fo(i, 0, n) {
		fo(k, 0, 1) if(f[i][k]){
			fo(h, 1, n - i) {
				reg lim = k == 0 ? B : A;
				reg p = h >= lim;
				if(p) continue;
				if(k == 0) f[i + h][k ^ 1] = (f[i + h][k ^ 1] + f[i][k]) % mod;
				else {
					if(i == 0 && i + h == n) f[i + h][k ^ 1] = (f[i + h][k ^ 1] + (LL)f[i][k] * z[h]) % mod;
					else if(i == 0 || i + h == n) f[i + h][k ^ 1] = (f[i + h][k ^ 1] + (LL)f[i][k] * g[h]) % mod;
					else f[i + h][k ^ 1] = (f[i + h][k ^ 1] + (LL)f[i][k] * T[h]) % mod;
				}
			}
		}
	} bin[0] = 1; fo(i, 1, n) bin[i] = bin[i - 1] << 1, bin[i] = bin[i] >= mod ? bin[i] - mod : bin[i];
	reg ans = bin[n];
	ans = ((LL)ans - f[n][0] - f[n][1]) % mod;
	pr2(ans < 0 ? ans + mod : ans);
	return 0;
}



Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(2e5)+5;


int main()
{
    idfc;
    int n;
    cin>>n;
    string a="AC";
    string b="WA";
    string c="TLE";
    string d="RE";
    int x=0;
    int y=0;
    int z=0;
    int w=0;

    string s;
    while(n--)
    {
        cin>>s;
        if(s==a)w++;
        else if(s==b)x++;
        else if(s==c)y++;
        else z++;
    }
    cout<<a<<" x "<<w<<"\n";
    cout<<b<<" x "<<x<<"\n";
    cout<<c<<" x "<<y<<"\n";
    cout<<d<<" x "<<z;

    return 0;
}

Measured memory_bytes: 3660
#include <stdio.h>
#include <iostream>
#include <math.h>

using namespace std;

int main() {
	int n,m;
	int a,b;
	int t = 0;
	int s;

	cin >> n;

	cin >> m;

	s = m;

	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		m = m + a - b;
		if (m < 0) {
			t = 1;
		}
		s = max(s,m);
	}

	if (t == 1) {
		cout << 0 << endl;
	} else {
		cout << s << endl;
	}

	return 0;

}

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

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

  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  if (A1 + A2 + A3 >= 22) {
    cout << "bust" << '\n';
  } else {
    cout << "win" << '\n';
  }
  
  return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum mod = 10L^^9 + 7;
enum inf = 10^^9;

void main() {
    int n;
    scan(n);

    auto a = readln.split.to!(int[]);
    auto asum = a.sum();

    int d = inf;
    int ans = -1;

    foreach (i ; 0 .. n) {
        if (d > abs(asum - a[i]*n)) {
            ans = i;
            d = abs(asum - a[i]*n);
        }
    }

    writeln(ans);
}





























void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

using namespace std;

int main()
{
  const int inf = 1 << 25;
  int a, b, d;
  while(cin >> a >> b >> d, a || b || d) {
    int X = inf, Y = inf;
    for(int x = 0; x < 100000; x++) {
      if((a*x + d) % b == 0) {
	int y = (a*x + d) / b;
	if(x + y < X + Y || x + y == X + Y && a*x + b*y < a*X + b*Y) X = x, Y = y;      
      }
      if(a*x - d >= 0 && (a*x - d) % b == 0) {
	int y = (a*x - d) / b;
	if(x + y < X + Y || x + y == X + Y && a*x + b*y < a*X + b*Y) X = x, Y = y;      	
      }
      if(d - a*x >= 0 && (d - a*x) % b == 0) {
	int y = (d - a*x) / b;
	if(x + y < X + Y || x + y == X + Y && a*x + b*y < a*X + b*Y) X = x, Y = y;	
      }	
    }
    cout << X << " " << Y << endl;
  }
  return 0;
}
   

Measured memory_bytes: 1156
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;

namespace AtCoder
{
    class Program
    {
        private static long mod = 1000000007;
        static void Main(string[] args)
        {
            var n = long.Parse(ReadLine());
            //var line = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();
            var aList = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();
            aList = aList.OrderByDescending(value => value).ToArray();
            
            var firstValue = aList[0];
            var valueList = new List<long>();
            var valueListIndex = 0;
            var dictionary = new Dictionary<long, int>();
            long count = -aList[0];

            foreach(var a in aList)
            {
                if(!dictionary.ContainsKey(a))
                {
                    dictionary.Add(a, 0);
                    valueList.Add(a);
                }
                dictionary[a] += 2;

                count += valueList[valueListIndex];
                dictionary[valueList[valueListIndex]]--;
                if(dictionary[valueList[valueListIndex]] == 0)
                {
                    valueListIndex++;
                }
            }

            WriteLine(count);
        }
    }
}


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

using namespace std;

#define N 105

int n,m,I,J,a[N][N],r[N][N],c[N][N],ans;
char s[N];

void upd(int &x,int y){x=max(x,y);}

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i){
		scanf("%s",s+1);
		for (int j=1;j<=m;++j){
			a[i][j]=s[j]=='o';
			if (s[j]=='E'){I=i; J=j;}
		}
	}
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j){
			r[i][j]=r[i][j-1]+a[i][j];
			c[i][j]=c[i-1][j]+a[i][j];
		}
	int f[I+1][n-I+1][J+1][m-J+1];
	memset(f,0,sizeof f);
	for (int i1=0;I-i1>=1;++i1)
		for (int i2=0;I+i2<=n;++i2)
			for (int j1=0;J-j1>=1;++j1)
				for (int j2=0;J+j2<=m;++j2){
					ans=max(ans,f[i1][i2][j1][j2]);
					if (I-i1-1>i2) upd(f[i1+1][i2][j1][j2],f[i1][i2][j1][j2]+r[I-i1-1][min(J+j2,m-j1)]-r[I-i1-1][max(J-j1,1+j2)-1]);
					if (I+i2+1<=n-i1) upd(f[i1][i2+1][j1][j2],f[i1][i2][j1][j2]+r[I+i2+1][min(J+j2,m-j1)]-r[I+i2+1][max(J-j1,1+j2)-1]);
					if (J-j1-1>j2) upd(f[i1][i2][j1+1][j2],f[i1][i2][j1][j2]+c[min(I+i2,n-i1)][J-j1-1]-c[max(I-i1,1+i2)-1][J-j1-1]);
					if (J+j2+1<=m-j1) upd(f[i1][i2][j1][j2+1],f[i1][i2][j1][j2]+c[min(I+i2,n-i1)][J+j2+1]-c[max(I-i1,1+i2)-1][J+j2+1]);
				}
	printf("%d\n",ans);
	
	return 0;
}
			

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

int main(){
    int a, b;
    
    while(true){
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        for ( int i = 0; i < a; i++ ){
            for ( int j = 0; j < b; j++ ){
                if((i + j) % 2 == 0) cout << "#";
                else cout << ".";
            }
        cout << endl;
        }
    cout << endl;
    }
    
}


Measured memory_bytes: 3080
#include<iostream>
using namespace std;
#define maxn 200005
#define ll long long
//int a[maxn];
int main ()
{  ll N,D;
   cin>>N>>D;
   ll x,y;
   D=D*D;
   int ans=0;
   for(int i=1;i<=N;i++)
   { cin>>x>>y;
     if(x*x+y*y<=D) ans++; 
   }
   cout<<ans<<endl;
}

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


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
int d[200];
int ans;
signed main(){
  int n;
  cin >> n;
  REP(i,n){
    cin >> d[i];
  }
  REP(i,n){
    for(int j=i+1;j<n;j++){
      ans += d[i]*d[j];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>


/* ----- Type Alias ----- */
using Bool = bool;
using Int = long long int;
using Real = long double;
using Char = char;
using String = std::string;
template <class T, class U>
using Pair = std::pair<T, U>;
template <class... Ts>
using Tuple = std::tuple<Ts...>;

template <class T>
using Vector = std::vector<T>;
template <size_t N>
using Bits = std::bitset<N>;
template <class T>
using Queue = std::queue<T>;
template <class T>
using Stack = std::stack<T>;
template <class T>
using Deque = std::deque<T>;

template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
using Set = std::set<T>;
template <class T, class U>
using Map = std::map<T, U>;

template <class T, class... Us>
using Func = std::function<T(Us...)>;

template <class T>
T genv(T v) { return v; }

template <class T, class... Ts>
auto genv(size_t l, Ts... ts) {
    return Vector<decltype(genv<T>(ts...))>(l, genv<T>(ts...));
}

template <class Cost = Int>
struct Edge {
    Int src, dst;
    Cost cost;
    Edge(Int src = -1, Int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = Int>
using Edges = Vector<Edge<Cost>>;
template <class Cost = Int>
using Graph = Vector<Vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    Int precision;
    Fout(Int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}


/* ----- Constants ----- */
// constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// constexpr Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

int main() {
    Int n, k;
    String s;
    std::cin >> n >> s >> k;
    Char rem = s[k - 1];
    for (Char c : s) {
        std::cout << (c == rem ? c : '*');
    }
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
m = abs(t - 0.006*h[0] - a)
k = 0
for i in range(1, n):
  x = abs(t - 0.006*h[i] - a)
  if x < m:
    m = x
    k = i
print(k+1)


Measured memory_bytes: 3060
import numpy as np

D = int(input())
c = np.array( list(map(int, input().split())) )
#
s = [[] for i in range(D)]
for i in range(D):
  s[i] = np.array( list(map(int, input().split())) )
#
v = 0
cc =  np.array( [0]*26 )
last = np.array( [-1]*26 )
for d in range(D):
  cc += c
  av = s[d] - sum( cc ) + cc
  m = max(av)
  for t in range(26):
    if av[t] == m:
      cc[t] = 0
      v += av[t]
      print(t+1)
      break
#
#print( v )


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int f(int s){
    if(s % 2 == 0) return s/2;
    else return s*3 + 1;
}

int main(void){
    int s; cin >> s;
    vector<int> cnt;
    cnt.resize(1000001, 0);
    cnt[s]++;
    int m = 2;
    while(true){
        s = f(s);
        if(cnt[s] == 1){
            cout << m << endl;
            break;
        }
        else cnt[s]++;
        m++;
    }
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main()
{
    int x, y, a, b, c;

    cin >> x >> y >> a >> b >> c;
    int x_ = x;
    int y_ = y;

    vector<ll> p(a), q(b), r(c);
    rep(i, a) cin >> p[i];
    rep(i, b) cin >> q[i];
    rep(i, c) cin >> r[i];
    sort(ALL(p), greater<ll>());
    sort(ALL(q), greater<ll>());
    rep(i, x) r.push_back(p[i]);
    rep(i, y) r.push_back(q[i]);
    sort(ALL(r), greater<ll>());
    ll ans = 0;
    rep(i, x + y)
    {
        ans += r[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6256
n=int(input())
a=list(map(int,input().split()))
a1=0
a2=0
a3=0
for i in a:
  if i%4==0:
    a1+=1
  elif i%4==2:
    a2+=1
  else:
    a3+=1
    
if a3==0:
  print("Yes")
else:
  if a2==0:
    if a1>=a3-1:
      print("Yes")
    else:
      print("No")
  else:
    if a1>=a3:
      print("Yes")
    else:
      print("No")

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

template<typename T>
istream &operator>>(istream &is, vector<T> &v) {
	for (auto &x : v) is >> x;
	return is;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, x, t; cin >> n >> x >> t;
	int d = ceil(n / (double) x);
	cout << d * t << '\n';
	return 0;
}


Measured memory_bytes: 3648
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: usize1,
        p: [usize1; n],
        q: [usize1; n]
    }
    let mut tab: Vec<Vec<usize>> = vec![Vec::new(); 6];
    tab[0] = p.clone();
    tab[1] = q.clone();
    for i in 2..6 {
        tab[i] = perm_prod(&perm_inv(&tab[i - 2]), &tab[i - 1]);
    }
    let a = perm_pow(&perm_prod(&p, &tab[3]), k / 6);
    let ans = perm_prod(&perm_prod(&perm_inv(&a), &tab[k % 6]), &a);
    print!("{}", ans[0] + 1);
    for i in 1..n {
        print!(" {}", ans[i] + 1);
    }
    println!("");
}

fn perm_prod(p: &Vec<usize>, q: &Vec<usize>) -> Vec<usize> {
    let n = p.len();
    (0..n).map(|i| q[p[i]]).collect()
}

fn perm_pow(a: &Vec<usize>, mut p: usize) -> Vec<usize> {
    let n = a.len();
    let mut ret: Vec<usize> = (0..n).collect();
    let mut r = a.clone();
    while p > 0 {
        if p % 2 == 0 {
            r = perm_prod(&r, &r);
            p /= 2;
        } else {
            ret = perm_prod(&ret, &r);
            p -= 1;
        }
    }
    ret
}

fn perm_inv(p: &Vec<usize>) -> Vec<usize> {
    let n = p.len();
    let mut ret: Vec<usize> = vec![0; n];
    for i in 0..n {
        ret[p[i]] = i;
    }
    ret
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n;
  cin >> n;
  vll a(n);
  REP(i,n) cin >> a[i];
  ll q;
  cin >> q;
  REP(i,q){
    ll b, e;
    cin >> b >> e;
    reverse(a.begin()+b,a.begin()+e);
  }
  REP(i,n){
    if(i) cout << " ";
    cout << a[i];
  }
  cout <<endl;
    
  return 0;
}




Measured memory_bytes: 3148
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

int main(void)
{
    int n, k;
    int d = 0;

    cin >> n >> k;

    while (n / k > 0)
    {
        d++;
        n /= k;
    }

    cout << d + 1 << endl;
}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, rev;
    long double cap;
	Edge(ll _to, long double _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, long double cap, bool revFlag, long double revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

template<typename T, typename F>
class SegmentTree {
private:
	T e;
	F op;
	ll n;
	vector<T> dat;
public:
	SegmentTree(F f, T _e, vector<T> v) :op(f), e(_e) {
		int _n = v.size();
		n = 1;
		while (n < _n)n *= 2;
		dat.resize(2 * n - 1, e);
		REP(i, _n)dat[n + i - 1] = v[i];
		for (int i = n - 2; i >= 0; i--)dat[i] = op(dat[i * 2 + 1], dat[i * 2 + 2]);
	}
	SegmentTree(F f, T _e, int _n) :op(f), e(_e) {
		n = 1;
		while (n < _n)n *= 2;
		dat.resize(2 * n - 1, e);
		for (int i = n - 2; i >= 0; i--)dat[i] = op(dat[i * 2 + 1], dat[i * 2 + 2]);
	}
	void update(int i, T x) {
		i += n - 1;
		dat[i] += x;
		while (i > 0) {
			i = (i - 1) / 2;
			dat[i] = op(dat[i * 2 + 1], dat[i * 2 + 2]);
		}
	}
	T query(int l, int r) {
		//[l,r)でのクエリ処理
		T left = e, right = e;
		l += n - 1; r += n - 1;
		while (l < r) {
			if ((l & 1) == 0)left = op(left, dat[l]);
			if ((r & 1) == 0)right = op(dat[r - 1], right);
			l = l / 2;
			r = (r - 1) / 2;
		}
		return op(left, right);
	}
};



void solve(){
    ll n,q;
    cin>>n>>q;

    Array a(n,0);
    auto op = [](ll a, ll b) {return a + b; };
    SegmentTree<ll, decltype(op)> seg(op,0,a);

    REP(_,q){
        ll t,x,y;
        cin>>t>>x>>y;
        x--;
        if(t==0){
            seg.update(x,y);
        }else{
            cout<<seg.query(x,y)<<en;
        }
    }

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}



Measured memory_bytes: 6404
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  vi A(N);
  rep(i, N) {
    cin >> A[i];
  }
  
  vi ct(100000);
  rep(i, N) {
    ct[A[i] - 1] ++;
  }
  
  int oddc = 0;
  int evenc = 0;
  int unqc = 0;
  rep(i, 100000) {
    if(ct[i] >= 1) unqc ++;
    if(ct[i] >= 2) {
      if((ct[i] - 1) % 2 == 0) {
        evenc ++;
      } else {
        oddc ++;
      }
    }
  }
  
  if(oddc % 2 == 0) {
    //0 or 偶数
    fin(unqc);
  } else {
    fin(unqc - 1);
  }
}

Measured memory_bytes: 1152
def n_ary1(l,d): # リストl中の文字でd桁を全列挙(sorted)
    if d == 1:
        return(l)
    ll = n_ary1(l,d-1)
    lll = []
    for i in l:
        for j in ll:
            lll.append(i+j)
            #lll.append(int(i+j)) ## n進数の場合
    return(lll)
In = list(input())
In = [int(i) for i in In]
op = n_ary1([[0],[1]],3)

for i in op:
    s = In[0]
    for j in range(3):
        if i[j]:
            s += In[j+1]
        else:
            s -= In[j+1]
    if s == 7:
        ansl = i
        break


ans = str(In[0])
for i in range(3):
    if ansl[i] :
        ans = ans + '+' + str(In[i+1])
    else:
        ans = ans + '-' + str(In[i+1])
ans = ans + '=7'
print(ans)


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

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define FOR(i,j,k) for(int i=j;i<=k;i++)
#define REV(i,j,k) for(int i=j;i>=k;i--)
#define LL long long
#define MAX 4000005
#define F first
#define S second
typedef pair<int,int> pii;

pii dp[(1<<19) + 10];

void update(int p,int v)
{
    if(dp[p].F < v)
    {
        dp[p].S = dp[p].F;
        dp[p].F = v;
    }
    else dp[p].S = max(dp[p].S, v);
}

void solve()
{

    int n, v, m;

    scanf("%d", &n); m = (1<<n) - 1;
    FOR(i,0,m)
    {
        scanf("%d", &v);
        dp[i] = {v, -1};

    }

    FOR(bit,0,n-1)
        FOR(mask,0,m)
            if(mask & (1<<bit))
            {
                int u = dp[mask ^ (1<<bit)].F, v = dp[mask ^ (1<<bit)].S;
                update(mask, u);
                update(mask, v);
            }

    int prin = 0;
    FOR(i,1,m)
    {
        prin  = max(prin, dp[i].F + dp[i].S);
        printf("%d\n", prin);
        ///cout << prin << endl;
    }
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 7168
#include <iostream>
using namespace std;
typedef long long ll;

ll memo[64][64];
ll ncr(ll n , ll r){
	if(memo[n][r])return memo[n][r];
	long long ans = 1;
	int d[64] = {0};
	for(int i = 1 ; i <= r ; i++) d[i] = 1;
	for(int i = 0 ; i < r  ; i++){
		ans *= n-i;
		for(int j = 1 ; j <= r ; j++)
			if(d[j] && ans % j == 0){
				ans /= j;
				d[j] = 0;
			}
	}
	return memo[n][r] = ans;
}

string f(ll n,ll bit,ll m){
	if(m == 0 || bit == 0) return string(n,'0');
	ll cur = 0;
	for(int i = bit ; i <= n ; i++){
		ll next = cur+ncr(i-1,bit-1);
		if(m <= next && m >= cur+1) return f(i-1,bit-1,m-cur) + "1" + string(n-i,'0');
		cur = next;
	}
	return f(n,bit+1,m-cur);
}
int main(){
	ll n,m;
	while(cin >> n >> m && (n||m) ){
		string r = f(n,1,m-1);
		for(int i = 0 ; i < r.size() ; i++) cout << r[r.size()-1-i];
		cout << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int N,K; cin >> N >> K;
    int K2 = (K<<1);
    vector<vector<int>> grid(K2,vector<int>(K2,0));
    rep(i,N) {
        int a,b; char c;
        cin >> a >> b >> c;
        if (c == 'B') b += K;
        a %= K2; b %= K2;
        grid[a][b] ++;
    }

    vector<vector<int>> A(K2 + 1,vector<int>(K2 + 1,0));
    rep(i,K2) {
        rep(j,K2) {
            A[i + 1][j + 1] = A[i][j + 1] + A[i + 1][j] - A[i][j] + grid[i][j];
        }
    }

    int ans = 0;
    rep(i,K)rep(j,K) {
        int ret = 0;
        ret += A[i][j + K] + A[i + K][j] - 2*A[i][j];
        ret += A[i + K][K2] - A[i + K][j + K] - A[i][K2] + A[i][j + K];
        ret += A[K2][j + K] - A[K2][j] - A[i + K][j + K] + A[i + K][j];
        ans = max(ans,ret);
        ans = max(ans,N - ret);
    }
    cout << ans << '\n';
    return 0;
}

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

int main() {
    int A,P; cin >> A >> P;
    int S = A*3+P; cin >> S;
    if (S % 2 == 1) {
        cout << (S-1)/2 << endl;
    }
    else cout << S/2 << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
MOD = 10 ** 9 + 7

ans = 0
for i in range(k, n + 2):
    t1 = (i - 1) * i // 2
    t2 = n * (n + 1) // 2 - (n - i) * (n - i + 1) // 2
    ans += t2 - t1 + 1
    ans %= MOD
print(ans)


Measured memory_bytes: 9176
#include <stdio.h>

#define M (1000000007LL)

/***************************************
    繰り返し二乗法
    (a**n%m)
***************************************/
long powm( long a, long n, long m )
{
    long long ret = 1;
    for( ; n>0; n>>=1, a=(long long)a*a%m ) {
        if( n % 2 == 1 ) {
            ret = ret * a % m;
        }
    }

    return( ret );
}

/***************************************
    aからbまでの掛け算を計算
    ((a(a+1)(a+2)…(b))%m)
***************************************/
long multiplem( long a, long b, long m )
{
    int i;
    long long ret = 1;

    if( a > b ) {
        i = a;
        a = b;
        b = i;
    }

    for( i=a; i<=b; i++ ) {
        ret = (ret * i) %m;
    }

    return( ret );
}

/***************************************
    組み合わせ計算(nCa%m)
***************************************/
long combinationm( long n, long a, long m )
{
    int i;
    long long ret;

    if( n-a < a ) a = n-a;

    if( a == 0 ) return( 1 );

    // 分母を計算
    ret = multiplem( n, n-a+1, m );

    // 1/(a!)を計算して嬰かける
    for( i=1; i<=a; i++ ) {
        ret = (ret * powm( i, m-2, m ) ) % m;
    }

    return( ret );
}

/***************************************
    main
***************************************/
int main( int argc, char *argv[] )
{
    long n, a, b;
    long long ret;

    scanf( "%d%d%d", &n, &a, &b );

    ret = powm( 2, n, M ) - 1;
    ret -= combinationm( n, a, M );
    ret -= combinationm( n, b, M );

    while( ret < 0 ) ret+= M;

    printf( "%lld\n", ret );
}


Measured memory_bytes: 128
MOD = int(1e9 + 7)
n = int(input())
a = list(map(int, input().split()))
sum_a = 0
for i in range(n):
    sum_a += a[i]
    sum_a %= MOD
ans = 0
for i in a:
    sum_a -= i
    ans += sum_a * i % MOD
    ans %= MOD
print(ans)

Measured memory_bytes: 31440
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑


int main() {
	int n;
	string h;
	cin >> n >> h;
	if (n < 3200) { h = "red"; }

	cout << h << endl;
}

Measured memory_bytes: 256