akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 5100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int n; cin >> n;
  vector<vector<pii>> G(n);

  rep(i,n) {
    int a; cin >> a;
    rep(j,a) {
      int x,y; cin >> x >> y;
      x--;
      G[i].pb(mp(x,y));
    }
  }
  

  int ans = 0;
  rep(bit,(1<<n)){
    int cnt = 0;
    bool ok = true;
    rep(j,n){
      if(bit & (1 << j)){
        cnt++;
        for(auto c : G[j]) {
          int x = c.first;
          int y = c.second;
          if((bit & (1 << x))){
            if(y == 0) ok = false;
          }
          else{
            if(y == 1) ok = false;
          }
        }
      }
    }
    if(ok) chmax(ans, cnt);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


x, y = MI()

for i in range(x + 1):
    total = i * 2 + (x - i) * 4
    if total == y:
        print("Yes")
        exit()

print("No")


Measured memory_bytes: 9176
n,k=map(int,input().split())
d=list(map(int,input().split()))
j=[(True if i in d else False)for i in range(10)]
for i in range(n,10**6):
    s=str(i)
    for h in range(len(s)):
        if j[int(s[h])]:
            break
    else:
        print(s)
        break

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

int main(void){
    int n;
    cin >> n;
    vector<int> time(n+1);
    vector<pair<int,int>> pos(n+1);
    time.at(0) = 0; pos.at(0) = make_pair(0,0);
    for(int i=0;i<n;i++){
        cin >> time.at(i+1);
        pair<int,int> p;
        cin >> p.first >> p.second;
        pos.at(i+1) = p;
    }

    bool ok=true;
    for(int i=0;i<n;i++){
        int dt = time.at(i+1)-time.at(i);
        int dx = pos.at(i+1).first-pos.at(i).first;
        int dy = pos.at(i+1).second-pos.at(i).second;
        if(abs(dx)+abs(dy)>dt){ok=false; break;}
        if((dt-abs(dx)-abs(dy))%2!=0){ok=false; break;}
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{

    string a;
    cin>>a;

    for(int i=0;i<a.length();i++)
        {
          if(i%2==0)
          {
              if(a[i]=='R' || a[i]=='U' || a[i]=='D')
              {
                 continue;
              }
              else
              {
                cout<<"No"<<endl;
                return 0;
              }

          }
          else
          {
              if(a[i]=='L' || a[i]=='U' || a[i]=='D')
                {
                 continue;
                }
              else
              {
                cout<<"No"<<endl;
                return 0;
              }
          }
        }
          cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	string str;
	char map[3][3];
	while (cin>>str) {
		for (int i=0; i<3; i++)
			for (int j=0; j<3; j++) map[i][j] = str[i*3+j];
		char res = 'd';
		for (int i=0; i<3; i++)
			if (map[i][0]==map[i][1]&&map[i][1]==map[i][2]&&map[i][0]!='s')
				res = map[i][0];
		for (int i=0; i<3; i++) 
			if (map[0][i]==map[1][i]&&map[1][i]==map[2][i]&&map[0][i]!='s')
				res = map[0][i];
		if ((map[0][0]==map[1][1]&&map[1][1]==map[2][2]&&map[0][0]!='s')||
				(map[0][2]==map[1][1]&&map[1][1]==map[2][0]&&map[0][2]!='s'))
			res = map[1][1];
		cout << res << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            int t; cin>>t; while(t--)
const int mod = 1000000007;
bool comp(pair<ll,ll>& a, pair<ll,ll>& b)
{
    if(a.second == b.second)
    return a.first > b.first;
    else
    return b.second < a.second;
}
int main()
{
    fast
    ll n;
    cin>>n;
    string str ="";
    while(n)
    {
        
        ll k = n/26;
        ll p = n%26;

        if(p==0)
        {
           str += (char)('z');
           k--;
        }
        else
        {
            str += (char)('a'+p-1);

        }
        n=k;
    }
    reverse(str.begin(),str.end());
    cout<<str<<endl;
    
  
    return 0;
}

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

using namespace std;

typedef pair<int, int> P_ii;
typedef pair<string, int> P_si;

int main() {
    int N;
    cin >> N;
    vector<int> b(N);
    vector<int> c;
    for (int i = 0; i < N; ++i) {
        cin >> b[i];
    }

    while (!b.empty()) {
        int found = 0;
        for (int i = (int)b.size()-1; i >= 0; --i) {
            // 右から見てi+1番目にi+1があれば抜き出す
            if (b[i] == i + 1) {
                c.push_back(i + 1);
                b.erase(b.begin() + i);
                found = 1;
                break;
            }
        }
        // 抜き出せなかったら不可能
        if (!found) {
            printf("%s\n", "-1");
            return 0;
        }
    }
    reverse(c.begin(), c.end());
    for (int i = 0; i < N; ++i) {
        printf("%d\n", c[i]);
    }
    return 0;
}


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

using namespace std;

using i64 = long long;

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(17);
  
  int N, W;
  cin >> N >> W;
  vector<int> w(N+1), v(N+1);
  for(int i = 1; i <= N; i++){
    cin >> w[i] >> v[i];
  }

  vector<vector<i64>> dp(N + 1, vector<i64>(W+1, 0));

  for(int i = 1; i <= N; i++){
    for(int j = 1; j <= W; j++){
      if(w[i] <= j) dp[i][j] = max(dp[i-1][j], dp[i-1][j - w[i]] + 1ll*v[i]);
      else dp[i][j] = dp[i-1][j];
    }
  }
  
  cout << dp[N][W] << '\n';

  return 0;
}


Measured memory_bytes: 80256
using System;
using System.Linq;

namespace ITP1_2_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] data = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            Array.Sort(data);
            int i = 1;
            foreach(int n in data)
            {
                Console.Write(n);
                if (i == data.Length) Console.WriteLine();
                else Console.Write(" ");
                i++;
            }
        }
    }
}

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

using namespace std;

template <class T> void swapQ(T *a, T *b, T *c, T *d)
{
	T buf;

	buf = *a;
	*a = *b;
	*b = *c;
	*c = *d;
	*d = buf;
}

class CDice
{
	int N, E, W, S, U, B, P;
public:
	CDice():U(1),S(2),E(3),W(4),N(5),B(6),P(1){}

	void  Rotate(string);
	int getPoint();
};
void CDice::Rotate(string s)
{
	//ñ]
	if(s == "North") swapQ(&U, &S, &B, &N);
	if(s == "East")  swapQ(&U, &W, &B, &E);
	if(s == "West")	 swapQ(&U, &E, &B, &W);
	if(s == "South") swapQ(&U, &N, &B, &S);
	if(s == "Right") swapQ(&S, &E, &N, &W);
	if(s == "Left")  swapQ(&S, &W, &N, &E);
	
	//Á_
	P += U; 
}
int CDice::getPoint()
{
	return P;
}

int main()
{
	int n;
	string str;
	while(1){
		cin>>n;
		if(n == 0) return 0;

		CDice dice;
		for(int i = 0; i < n; i++){
			cin>>str;
			dice.Rotate(str);
		}
		cout<<dice.getPoint()<<endl;
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>

#define div1 1000000007

using namespace std;

int main(void)
{
    string N;
    int i, ans=0;

    cin >> N;

    for(i=0; i<=3; i++){
        if(N[i] == '2'){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

using ull = unsigned long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;
using vpii = vector<pii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {
    
    int N;
    cin >>N;
    vpii paa(N+1);
    vpii pbb(N+1);
    FOR(i,1,N) {
        cin >>paa[i].fi;
        paa[i].se=i;
    }
    SORT(paa);
    pbb=paa;
    FOR(i,1,N) {
        paa[i].fi=paa[i].se;
        paa[i].se=i;
    }
    SORT(paa);
    FOR(i,1,N) {
        if(paa[i].se<=N/2) cout <<pbb[(N/2)+1].fi<<endl;
        if(paa[i].se>N/2) cout <<pbb[(N/2)].fi<<endl;
    }

    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n; ll a[100005];
int main(){
	scanf("%d",&n);
	rep(i,n) scanf("%lld",&a[i]);
	if(a[n-1] != 2){
		puts("-1"); return 0;
	}
	ll L = 2,R = 3;
	for(int i=n-2;i>=0;i--){
		ll LL = (L+a[i]-1)/a[i],RR = R/a[i];
		L = LL*a[i];
		R = RR*a[i]+a[i]-1;
		if(L > R){
			puts("-1"); return 0;
		}
	}
	cout << L << " " << R << endl;
}

Measured memory_bytes: 1024
n,m = map(int,input().split())
a = []
b = []
c = []
for i in range(n):
  a.append([int(j) for j in input().split()])
for k in range(m):
  b.append(int(input()))
for x in range(n):
  z = 0
  for y in range(m):
    z += a[x][y] * b[y]
  c.append(z)
for i in c:
  print(i)
 

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <bitset>
#include <set>
#include <chrono>
#include <string>

using namespace std;

#define endl '\n'

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

    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];

    for (int i = 0; i < 3; ++i)
    {
        if (a[i] % 2 == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }

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

    cout << 1LL * a[0] * a[1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    //偶数回出てきた数字は消す
    int N;
    cin >> N;
    unordered_map<int, int> mp;
    rep(i, N){
        int num;
        cin >> num;
        mp[num] += 1;
    }
    int ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        if(itr->second % 2 == 1)ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, m);
    vector<int> data(m);
    for (int i = 0; i < m; i++) {
        cin >> data[i];
    }
    
    sort(all(data));
    Rep(i, data.size()) {
        data[i] -= data[0];
    }
    data[0] = 0;

    vi dist;
    Rep(i, data.size()) {
        dist.pb(data[i] - data[i-1]);
    }
    sort(all(dist));

    int ans = 0;
    rep(i, (int)min((int)dist.size(), (int)m-n)) {
        ans += dist[i];
    }

    std::cout << ans << std::endl;

    return 0;
}


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

int main()
{
  int i,k,N,max,sum;
  scanf("%d\n",&N);
  vector<int> a(N);
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }
  max=a[0];
  sum=1;
  for(k=0;k<N-1;k++){
    if(max<=a[k+1]){
      sum++;
      max=a[k+1];
    }
  }
  printf("%d",sum);
  return 0;
}


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


int main() {
  ll x,k,d;
  cin >> x >> k >> d;
  if(x < 0){
    x = -x;
  }
  ll a, b;
  a = x / d;
  b = x % d;
  if(k < a){
    cout << x - d * k;
  }
  else{
    if((k - a) % 2 == 1){
      cout << d - b;
    }
    else{
      cout << b;
    }
  }
  return 0;
}




Measured memory_bytes: 3620
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 30 18:47:21 2015

@author: hirose
"""

#Repetitive Processing - Swapping Two Numbers

while 1:
    n = map(int, raw_input().split())
    x = n[0]
    y = n[1]
    
    if(x==0 and y==0):
        break
    
    if(x <= y):
        print '%(1)d %(2)d' %{'1':x, '2':y}
    else:
        print '%(1)d %(2)d' %{'1':y, '2':x}

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

int main() {
    ios::sync_with_stdio(false);
    int n, a[102] = {};
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    cout << a[n - 1] - a[0];
}


Measured memory_bytes: 256
a, b, c, d = gets.chomp.split("").map(&:to_i)
ops = ["+", "-"]
ops.each do |i|
  ops.each do |j|
    ops.each do |k|
      expr = "#{a}#{i}#{b}#{j}#{c}#{k}#{d}"
      if eval(expr) == 7 then
        puts expr+"=7"
        exit
      end
    end
  end
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define int long long int
#define all(x) (x).begin(), (x).end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef pair<int,int> pii;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ub upper_bound
#define lb lower_bound
#define present(c,x) (c.find(x) != c.end())
#define removeDuplicates(a) a.resize(unique(all(a))-a.begin())
#define endl '\n'	
#define fill(s,x,n) vector
 x(n); rep(i,0,n) cin>>x[i];
#define INF 1000000007 
#define MOD 998244353
#define INF64 1e18

void solve(){
	int n,W;
	cin>>n>>W;
	vector<int> v(n+1);
	vector<int> w(n+1);
	rep(i,1,n+1)
		cin>>w[i]>>v[i];

	vector<vector<int>> dp(n+1,vector<int> (W+1,0));

	rep(i,1,n+1){
		rep(j,1,W+1){
			dp[i][j]=dp[i-1][j];
			if(j>=w[i])
				dp[i][j]=max(dp[i-1][j-w[i]]+v[i],dp[i][j]);
		}
	}

	cout<<dp[n][W];
}
 
int32_t main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
 
	int T;
	// cin>>T;
	T=1;
	while(T--){
		solve();
	}
}

Measured memory_bytes: 83096
#include<bits/stdc++.h>
using namespace std;
int l,r;
int main(){
	scanf("%d%d",&l,&r);
	if(r-l+1>=2019){
		puts("0");
		return 0;
	}
	long long ans=1e10;
	for(int i=l;i<=r;i++)
	for(int j=i+1;j<=r;j++){
		long long k=i*1ll*j;
		ans=min(ans,k%2019);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

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

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define T int t = 0; cin >> t; while(t--)
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef long double lld;
const ll mod = 1e9 + 7;
const ll mx = 2e5 + 5;
ll fact[mx];

ll power(ll x, ll y){
    ll res = 1;
    while(y > 0){
        if(y & 1LL)res = (res * x) % mod;
        y = y >> 1LL;
        x = (x * x) % mod;
    }
    return res;
}
ll inverse(ll a){
    return power(a, mod - 2) % mod;
}
void initialize(){
    fact[0] = fact[1] = 1;
    for(ll i = 2; i < mx; ++i)fact[i] = (i * fact[i - 1]) % mod;
}
ll find_ans(ll n, ll r){
     ll num = 1;
     ll den = 1;
    if(r > n - r){
        for(ll i = r + 1; i <= n; ++i)num = (num * i) % mod;
        for(ll i = 1; i <= n - r; ++i)den = (den * i) % mod;

    }else{
        for(ll i = n - r + 1; i <= n; ++i)num = (num * i) % mod;
        for(ll i = 1; i <= r; ++i)den = (den * i) % mod;
    }
    ll ans = num % mod;
    return (ans * inverse(den % mod)) % mod;
}
void input(){
   ll n, a, b;
   cin >> n >> a >> b;
   ll ans = (power(2LL, n) - 1 + mod) % mod;
    ll x, y;
    x = find_ans(n, a);
    y = find_ans(n, b);
    ans = (ans - x + mod) % mod;
    ans = (ans - y + mod) % mod;
    cout << ans << endl;

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

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

int main(void){

  char str[1000];
  char strc[1000];
  char p[1000];
  char ord[7];
  int q, a, b, i, ii, x, y;

  scanf("%s", str);
  scanf("%d", &q);
  y = strlen(str);

  for(i = 0; i < q; i++){
    scanf("%s", ord);
    if(!strcmp(ord,"print")){
      scanf("%d%d", &a, &b);
      x = b - a + 1;
      for(ii = 0; ii < x; ii++){
	printf("%c",str[a+ii]);
      }
      printf("\n");
    }
    else if(!strcmp(ord,"reverse")){
      scanf("%d%d", &a, &b);
      x = b - a + 1;
      strcpy(strc, str);
      for(ii = 0; ii < x; ii++){
	str[a+ii] = strc[b-ii];
      }
    }
    else if(!strcmp(ord,"replace")){
      scanf("%d%d%s", &a, &b, p);
      x = b - a + 1;
      for(ii = 0; ii < x; ii++){
	str[a+ii] = p[ii];
      }
    }
  }
  return 0;
}

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

int main()
{
	int N;
	cin >> N;
	int p[100];
	int tmp=0;
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}
	for (int i = N; i > -1; i--) {
		for (int j = 0; j < N; j++) {
			if (p[j] >= i)
				tmp++;
		}
		if (tmp >= i) {
			tmp = i;
			break;
		}
		tmp = 0;
	}
	cout << tmp << endl;
	return 0;
}

Measured memory_bytes: 3076
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    xyz = LI()
    xyz[0], xyz[1] = xyz[1], xyz[0]
    xyz[0], xyz[2] = xyz[2], xyz[0]
    print(*xyz)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int A,B,T;
    cin>>A>>B>>T;
    cout<<T/A*B<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int l = 0;
    int r = n;
    while (r > l + 1) {
        int m = (l + r) / 2;
        vector<pair<int, int>> st;
        st.emplace_back(0, a[0]);
        int s = a[0];
        bool ok = true;
        for (int i = 1; i < n; i++) {
            if (a[i] > a[i - 1]) {
                st.emplace_back(0, a[i] - a[i - 1]);
                s = a[i];
            } else {
                while (s > a[i]) {
                    int t = std::min(s - a[i], st.back().second);
                    st.back().second -= t;
                    s -= t;
                    if (st.back().second == 0) {
                        st.pop_back();
                    }
                }
                while (st.size() > 0 && st.back().first == m - 1) {
                    s -= st.back().second;
                    st.pop_back();
                }
                if (st.size() == 0) {
                    ok = false;
                    break;
                }
                int q = st.back().first;
                st.back().second--;
                if (st.back().second == 0) {
                    st.pop_back();
                }
                st.push_back({q + 1, 1});
                if (s < a[i]) {
                    st.push_back({0, a[i] - s});
                    s = a[i];
                }
            }
        }
        if (ok) {
            r = m;
        } else {
            l = m;
        }
    }
    cout << r << "\n";

    return 0;
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
using ii = long long;
const ii inf = 1e18;
int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    vector<ii> dp(n, inf);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    dp[0] = 0;
    for (int i = 1; i < n; ++i) {
        dp[i] = min(dp[i], dp[i - 1] + abs(v[i] - v[i - 1]));
        if (i > 1) dp[i] = min(dp[i], dp[i - 2] + abs(v[i] - v[i - 2]));
    }
    cout << dp.back() << "\n";
}


Measured memory_bytes: 1408
#include <iostream>
#include <map>
#include <string>

using namespace std;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)

void resolve()
{
    int N;

    cin >> N;

    string tmpS;
    map<string, int> m;
    RPT1(i, N)
    {
        cin >> tmpS;
        m[tmpS]++;
    }

    int mx = 0;
    for (const auto& it : m) mx = max(it.second, mx);
    for (const auto& it : m)
        if (it.second == mx) cout << it.first << endl;
}

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


Measured memory_bytes: 23808
#include <stdio.h>
int main(void){
   int i,j,k,H,W;
   for ( k = 0; k < 300; k++ ){
   scanf("%d",&H);
   scanf("%d",&W);
                 if(H == 0&&W == 0)break;
   for ( i = 0; i < H; i++ ){
       for ( j = 0; j < W; j++ ){

       printf("#");
     }
   printf("\n");
   }
      printf("\n");
}
return 0;
}


Measured memory_bytes: 2052
#include <iostream>

 

using namespace std;

 

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    
    if (x-r >= 0 && y-r >= 0 && w > x && h > y)
       cout << "Yes" << endl;
    else
       cout << "No" << endl;
    
}


Measured memory_bytes: 3104
package main

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

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


// Rec is rec
type Rec struct {
	index int
	name  string
	score int
}


type Recs []Rec

func (a Recs) Len() int { return len(a) }
func (a Recs) Less(i, j int) bool {
	if a[i].name == a[j].name {
		return a[i].score > a[j].score
	}
	return a[i].name < a[j].name
}
func (a Recs) Swap(i, j int) { a[i], a[j] = a[j], a[i] }

func main() {

	var recs Recs
	N := oneInt()
	for index := 0; index < N; index++ {
		var r Rec
		r.index = index + 1
		r.name = oneStr()
		r.score = oneInt()
		recs = append(recs, r)
	}

	sort.Sort(recs)
	for _, v := range recs {
		fmt.Println(v.index)
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;

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

int main()
{
    ll a,b;
    while(cin>>a>>b)
    {
        ll gcd1=gcd(a,b);
        ll lcm1=a/gcd1*b;
        cout<<gcd1<<" "<<lcm1<<endl;
    }
}

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INF = 2147483647;
const long long LINF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N,M; cin >> N >> M;
    VI X(N); REP(i,N) cin >> X[i];
    VI num(100001,0), mod(M,0), p(M,0);
    REP(i,N){
        num[X[i]]++;
        mod[X[i]%M]++;
    }
    REP(i,100001) p[i%M] += num[i]/2;
    int ans = mod[0]/2;
    FOR(i,1,(M-1)/2+1){
        if(mod[i] > mod[M-i]){
            ans += mod[M-i];
            int res = mod[i] - mod[M-i];
            ans += min(res/2, p[i]);
        }
        else{
            ans += mod[i];
            int res = mod[M-i] - mod[i];
            ans += min(res/2, p[M-i]);
        }
    }
    if(M%2 == 0) ans += mod[M/2]/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int N;
int main() {
  string ms;
  cin >> N;
  int l = 0;
  int r = N - 1;
  string ls, rs;
  cout << 0 << endl;
  cin >> ls;
  if (ls == "Vacant") return 0;
  cout << N - 1 << endl;
  cin >> rs;
  if (rs == "Vacant") return 0;
  while (l <= r) {
    int mid = (l + r) / 2;
    cout << mid << endl;
    cin >> ms;
    if (ms == "Vacant") return 0;
    if ((ms != ls && ((mid - l - 1) % 2) == 1) ||
        (ms == ls && ((mid - l - 1) % 2) == 0)) {
      rs = ms;
      r = mid;
    } else {
      ls = ms;
      l = mid;
    }
  }
}

Measured memory_bytes: 852
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <cstring>
#include <cmath>

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  string S;
  cin >> S;
  bool Dancable = true;
  
  //main
  for(int i=0; i<S.length(); i++){
    if((i+1)%2 == 1){//奇数文字目
      if(S[i] == 'L') Dancable = false;
    }else{
      if(S[i] == 'R') Dancable = false;
    }
    
  }
  // output
  if(Dancable){ cout << "Yes" << endl;}
  else{ cout << "No" << endl;}
    
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

int main()
{
	string s;
	getline(cin, s);
	for (int i = 0; s.size()>i;i++)
	{
		{
			if (s[i] >= 'a'&&s[i] <= 'z') s[i] -= 32;
			cout << s[i] ;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1172
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Spandan Mishra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DAlterAltar solver = new DAlterAltar();
        solver.solve(1, in, out);
        out.close();
    }

    static class DAlterAltar {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.readInt();
            char[] c = in.readString().toCharArray();

            int ans = 0, lo = 0, hi = n - 1;

            while (lo < hi) {
                if (c[lo] == 'W' && c[hi] == 'R') {
                    ans++;
                    lo++;
                    hi--;
                } else if (c[lo] == 'R' && c[hi] == 'W') {
                    lo++;
                    hi--;
                } else if (c[lo] == 'R')
                    lo++;
                else
                    hi--;
            }

            System.out.println(ans);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String readString() {
            final StringBuilder stringBuilder = new StringBuilder();
            int c = read();
            while (isSpaceChar(c))
                c = read();
            do {
                stringBuilder.append((char) c);
                c = read();
            } while (!isSpaceChar(c));
            return stringBuilder.toString();
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 34316
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	int n, a, b;
	cin>>n>>a>>b;
	if((b-a)%2==0) cout<<"Alice"<<endl;
	else cout<<"Borys"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

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

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  rep(i,h)rep(j,w) cin >> a[i][j];
  rep(i,h)rep(j,w){
    int b; cin >> b;
    a[i][j] = abs(a[i][j]-b);
  }

  const int c = 15000;
  vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(30000,false)));
  dp[0][0][c+a[0][0]] = true;
  dp[0][0][c-a[0][0]] = true;
  rep(i,h)rep(j,w)rep(k,c*2)if(dp[i][j][k]){
    if(i!=h-1){
      dp[i+1][j][k+a[i+1][j]] = true;
      dp[i+1][j][k-a[i+1][j]] = true;    
    }
    if(j!=w-1){
      dp[i][j+1][k+a[i][j+1]] = true;
      dp[i][j+1][k-a[i][j+1]] = true;    
    }
  }

  int ans = inf;
  rep(k,c*2)if(dp[h-1][w-1][k]){
    if(abs(ans)>abs(c-k)) ans = c-k;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 24320
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    h=list(map(int,input().split()))+[INF]*2
    dp=[INF]*(N+2)
    dp[0]=0
    for i in range(N):
        dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]))
        dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]))
    print(dp[N-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 52208
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	if ((A <= 8) && (B <= 8)) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
}

Measured memory_bytes: 3616
<?php

$dp = [];
$dp[0] = 0;

for($n = 1; $n <= 100000; $n++){
    $dp[$n] = PHP_INT_MAX;
    $power = 1;
    while($power <= $n){
        $dp[$n] = min($dp[$n], $dp[$n - $power] + 1);
        $power *= 6;
        //1 + $dp[$n - 6], 1 + $dp[$n - 36]...
    }
    $power = 1;
    while($power <= $n){
        $dp[$n] = min($dp[$n], $dp[$n - $power] + 1);
        $power *= 9;
    }
}

fscanf(STDIN, "%d", $N);
echo $dp[$N];

Measured memory_bytes: 10872
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int k = sc.nextInt();
    if(b-a+1<=2*k){
      for(int i = a;i<=b;i++){
        System.out.println(i);
      }
      return;
    }
    for(int i = a;i<=a+k-1;i++){
      System.out.println(i);
    }
    for(int i = b - k + 1;i<=b;i++){
      System.out.println(i);
    }
  }
}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
	public static void main(String[] arg) {
		boolean[] notPrime = new boolean[50001];
		notPrime[0] = true;
		notPrime[1] = true;
		final int limit = (int) Math.sqrt(50000);
		for (int i = 2; i <= limit; i++) {
			if (!notPrime[i]) {
				for (int j = i + i; j <= 50000; j = j + i) {
					notPrime[j] = true;
				}
			}
		}
		int primeCount = 1;
		for (int i = 3; i <= 50000; i += 2) {
			if (!notPrime[i]) {
				primeCount++;
			}
		}

		int[] primes = new int[primeCount];
		primes[0] = 2;
		int index = 1;
		for (int i = 3; i <= 50000; i += 2) {
			if (!notPrime[i]) {
				primes[index++] = i;
			}
		}
		int[] gbc = new int[50001];
		for (int i = 0; i < primes.length; i++) {
			for (int j = i; j < primes.length; j++) {
				int val = primes[i] + primes[j];
				if (val > 50000) {
					break;
				}
				gbc[val]++;
			}
		}

		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			int n = in.nextInt();
			if (n != 0) {
				System.out.println(gbc[n]);
			}
		}

	}
}

Measured memory_bytes: 33192
N = int(input())
A = [int(i) for i in input().split()]

nums = []
memo = [0] * N
for i in range(N - 1, -1, -1):
    if A[i] != sum(memo[i :: i + 1]) % 2:
        memo[i] = 1
        nums.append(i + 1)
        
print(sum(memo))
print(' '.join(map(str, nums)))

Measured memory_bytes: 19900
#include<stdio.h>
#include<math.h>
int ju_trian(int a,int b,int c)
{
	if(a<b+c&&b<a+c&&c<a+b)
	{
		return 1;
	}
	else 
	{
		return 0;
	}
}
int main(void)
{
	int number=0;
	int sum=0;
	scanf("%d",&number);
	int tri[number];
	for(int i=0;i<number;i++)
	{
		tri[i]=0;
		
	}
	for(int i=0;i<number;i++)
	{
		scanf("%d",&tri[i]);
	}
	int index_1, index_2;
    for(index_1=1; index_1<number; index_1++)
        if(tri[index_1] < tri[index_1-1])   
        {
            int temp = tri[index_1];                       //保存要比较的值
            for(index_2=index_1-1; index_2>=0 && tri[index_2]>temp; index_2--)    //从后向前查找待插入位置
                tri[index_2+1] = tri[index_2];                    //挪位
            tri[index_2+1] = temp;                       //复制到插入位置
        }
	
	for(int i=0;i<number-2;i++)
	{
		for(int j=i+1;j<number-1;j++)
		{
			for(int k=j+1;k<number;k++)
			{
				int temp=ju_trian(tri[i],tri[j],tri[k]);
				if(temp)
				{
					sum=sum+1;
					
				}
				else{
					break;
				}
//				sum=sum+ju_trian(tri[i],tri[j],tri[k]);
			}
		}
	}
	printf("%d",sum);
	return 0;
} 


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

using namespace std;

#define deb(x) cout << #x << " " << x << endl;

typedef long long ll;
const ll mod = 1000000007;

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

int main(){
    
 //   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   // freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    int t,i,n,j,m;


    string s;
    cin>>s;
    if(s[0]!='A'&&s[1]!='A'&&s[2]!='A')
        cout<<"No";
    else if(s[0]!='B'&&s[1]!='B'&&s[2]!='B')
        cout<<"No";
    else
    {
            cout<<"Yes";
    }
    


    

    cerr << "\n\nTime elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}

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

long long comb2(long long n) {
    long long r;
    if (n % 2 & 1)
    {
        r = (n - 1) / 2 * n;
    } else {
        r = n / 2 * (n - 1);
    }

    return r;
}

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

    std::vector<std::string> s(n);
    for (int i = 0; i < n; i++) {
        std::cin >> s[i];
        std::sort(s[i].begin(), s[i].end());
    }

    std::sort(s.begin(), s.end());
    std::vector<long long> ansp;
    std::string tmp = s[0];
    int anss = 0;
    for (int i = 0; i < n; i++)
    {
        if(s[i] == tmp) {
            anss++;
        } else {
            ansp.push_back(anss);
            anss = 1;
            tmp = s[i];
        }

    }

    ansp.push_back(anss);
    ansp.push_back(0);
    long long ans = 0;
    for (int i = 0; i < ansp.size(); i++)
    {
        ans += comb2(ansp[i]);
    }

    std::cout << ans << "\n";
}

Measured memory_bytes: 8444
#include<stdio.h>


int main(void){

  int d;
  int space;
  int i;

  while(scanf("%d", &d)!=EOF){
    i=1;
    space=0;
    while(d*i!=600){
      space+=d*(d*i)*(d*i);
      i++;
    } 
    printf("%d\n", space);
  }

  return(0);
}



Measured memory_bytes: 1916
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

using namespace std;
string s;

int main() {
  cin >> s;
  int posA = INT_MAX;
  int posZ = 0;
  for (int i=0; i<s.size(); i++) {
    if (s.at(i) == 'A') {
      if (i < posA) {
        posA = i;
      }
    }
    if (s.at(i) == 'Z') {
      posZ = i;
    }
  }
  cout << posZ - posA + 1 << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
    using namespace std;
    #define 	ll 			long long
    #define 	w(t)		int t; cin>>t; while(t--)  
	#define 	AsmShuvo()  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
			
    int main()
    {
    AsmShuvo()
    	
    	ll N, sum=0, i;
		cin>>N;
			
		for(i=1; i<=N; i++){
		if(i%3 != 0 && i%5 != 0){
			sum = sum+i;
		    }
		}
		cout<<sum<<endl;
			

	}
	


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

# input
N, X = map(int, input().split())
L = list(map(int, input().split()))

# solve
D = [0]
for i in range(N):
    D.append(D[i] + L[i])

ans = [e for e in D if e <= X]

# output
print(len(ans))


Measured memory_bytes: 3060
N, X = list(map(int, input().split()))
X_l = list(map(int, input().split()))

def golden_search(func, l,r):
  # 最小値を求める
  phi = 1.618 # phi=2とすると三分探索
  if l >= r-4:
    return min([func(k) for k in range(l,r+1)])

  c1 = int((phi/(1+phi))*l + (1/(1+phi))*r)
  c2 = int((1/(1+phi))*l + (phi/(1+phi))*r)
  if func(c1) < func(c2):
    r = c2
  elif func(c1) >= func(c2):
    l = c1
  return golden_search(func, l,r)

memo = {}
def Ktimes(k):
  if k not in memo:
    memo[k] = X*k + X*N
    memo[k] += 2* sum(X_l[::-1][:k])
    memo[k] += sum([(2*(i//k)+3)*x for i,x in enumerate(X_l[::-1])])
  return memo[k]

answer = golden_search(Ktimes, 1, N)
print(answer)

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

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

vector<pair<ll, ll>> prime_factorize(ll n) {
    vector<pair<ll, ll>> res;
    for (ll p = 2; p * p <= n; p++) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) {
            num++;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    auto pri = prime_factorize(g);
    cout << pri.size() + 1 << endl;
    return 0;
}

Measured memory_bytes: 256