akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int h,w,n;
	cin>>h>>w>>n;
	string s,t;
	int sr,sc;
	cin>>sr>>sc;
	cin>>s>>t;
	int fl = false;
	string tak = "LRUD";
	string aok = "RLDU";
	for( int k=0;k<4;k++){
		int cr = sr, cc = sc;
		for(int i=0;i<n;i++){
			if( s[i] == tak[k] ){
				if( s[i] == 'L'){
					cc--;
				}
				if( s[i] == 'R'){
					cc++;
				}
				if( s[i] == 'U'){
					cr--;
				}
				if( s[i] == 'D'){
					cr++;
				}
				if( cc <= 0 || cc > w || cr <= 0 || cr > h ){
					cout<<"NO"<<endl;
					return 0;
				}
			}
			if( t[i] == aok[k] ){
				if( t[i] == 'L' && cc >= 2){
					cc--;
				}
				if( t[i] == 'R' && cc <= w-1){
					cc++;
				}
				if( t[i] == 'U' && cr >= 2){
					cr--;
				}
				if( t[i] == 'D' && cr <= h-1){
					cr++;
				}
			}
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
ll A[5000001],bin[5000001];
vector<ll>v;
map<int,int>myMap;
set<int>mySet;
vector<pair<ll,ll> >vp;
/* Precode Start Here *\



     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);

  ll  low=1,high=50000,mid=(low+high)/2,n,k=20,f=0;
  cin>>n;
  ll d=n/1.08;
  double p=(double)d*1.08;
  double q=(double)(d+1)*1.08;
  if((ll)p==n)
  {
      cout<<d<<endl;
  }
  else if((ll)q==n)
  {
      cout<<d+1<<endl;
  }
  else
    cout<<":("<<endl;
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #include </home/edison/Coding/cpp/template/debug.cpp>

vector<int> g[55];
int dep[55], p[55];
int rule[25][2];
int lca[55][55];
vector<int> up[55], down[55];

int tag[55];

void dfs(int now, int pa) {
	p[now] = pa;
	for (int i : g[now]) if (i != pa) {
		dep[i] = dep[now] + 1;
		dfs(i, now);
	}
}

int get_lca(int u, int v) {
	if (dep[v] < dep[u]) swap(u, v);
	while (dep[v] > dep[u]) v = p[v];
	if (u == v) return u;
	while (u != v) u = p[u], v = p[v];
	return u;
}

long long dfs2(int now, int pa) {
	long long rt = 1;
	for (int i : g[now]) if (i != pa) {
		rt *= dfs2(i, now);
		tag[now] += tag[i];
	}
	if (tag[now] == 0) rt *= 2;
	return rt;
}

int main() {
	int n; cin >> n;
	for (int i = 1; i < n; ++i) {
		int u, v; cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	
	dfs(1, 0);

	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			lca[i][j] = get_lca(i, j);
		}
	}

	int m; cin >> m; for (int i = 0; i < m; ++i) {
		int u, v; cin >> u >> v;
		if (dep[v] < dep[u]) swap(u, v);
		rule[i][0] = u, rule[i][1] = v;
		up[u].push_back(i);
		down[v].push_back(i);
	}

	long long ans = 0;
	for (int z = 0; z < (1 << m); ++z) {
		int y = __builtin_popcount(z);
		memset(tag, 0, sizeof(tag));		
		for (int i = 0; i < m; ++i) if (z & (1 << i)) {
			++tag[rule[i][0]];
			++tag[rule[i][1]];
			----tag[lca[rule[i][0]][rule[i][1]]];
		}
		long long rr = dfs2(1, 0);
		// PDE(z, y, rr);
		ans += rr * (y & 1 ? -1 : 1);
	}
	cout << ans / 2 << endl;
}



Measured memory_bytes: 256
while 1:
  h, w = map(int, raw_input().split())
  if h == w == 0:
    break
  for i in  range(h):
    if i == 0 or i == h-1:
      print "#" * w
    else:
      print "#" + "." * (w - 2) + "#"
  print ""

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

#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
const long long INF=1e18;



signed main(){
  ll n;
  cin>>n;
  vector<ll> a(n);
  for(int i=0;i<n;i++){cin>>a[i];}
  sort(a.begin(),a.end());
  map<ll,ll> M;
  for(int i=0;i<n;i++){M[a[i]]=i;}
  vector<vector<ll>> dp(n,vector<ll>(n,1));
  ll mx=2;
  for(int i=0;i<n;i++){
    for(int t=0;t<i;t++){
      dp[i][t]=2;
      ll A=a[i]-a[t];
      if(M.count(a[t]-A)){
	dp[i][t]=1+dp[t][M[a[t]-A]];
	mx=max(mx,dp[i][t]);
      }
    }
  }
  cout<<mx<<endl;
  
  return 0;
}



Measured memory_bytes: 198752
from copy import deepcopy
INF = 10 ** 10
N = int(input())
A = []
for _ in range(N):
    A.append(list(map(int,input().split())))


L = []
for i in range(N-1):
    for j in range(i+1, N):
        L.append((A[i][j], i, j))
L.sort()

B = deepcopy(A)
for k in range(N):
    for i in range(N):
        for j in range(N):
            if B[i][k] != 0 and B[k][j] != 0 and B[i][j] == B[i][k] + B[k][j]:
                B[i][j] = INF

ans = 0
for i in range(N):
    for j in range(N):
        if B[i][j] != INF:
            ans += B[i][j]
ans //= 2

for k in range(N):
    for i in range(N):
        for j in range(N):
            B[i][j] = min(B[i][j], B[i][k] + B[k][j])

if A == B:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 62300
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};

int main() {

	int n;
	cin>>n;
	rep(i,n){
		long double x1,x2,x3,x4,y1,y2,y3,y4;
		cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
		long double a,b,c,d;
		a=x2-x1;
		b=y2-y1;
		c=x4-x3;
		d=y4-y3;
		if(b/a==d/c)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}

	return 0;
}



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

int main() {
	int a,b,c,d,e;
	string ans;
	cin >> a>> b>>c;
	d = b - a;
	e = c - b;
	if (d==e) {
		ans = "YES";
	}
	else {
		ans = "NO";
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N, A = gets.split.map(&:to_i)
X = gets.split.map(&:to_i)

Y = X.map{|x| x - A}
Y.unshift 100

dp = Array.new(N + 1) do |j|
  Hash.new do |h, t|
    if t == Y[j]
      h[t] = dp[j - 1][t] + dp[j - 1][t - Y[j]] + 1
    else
      h[t] = dp[j - 1][t] + dp[j - 1][t - Y[j]]
    end
  end
end

dp[0] = Hash.new(0)

puts dp[N][0]

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

int main(){
    int n; cin>>n;
    string s="";
    if(n==0)s="0";
    for(;n!=0;n/=-2){
        if(n%2==0){
            s="0"+s;
        }else{
            s="1"+s;
            n--;
        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll b[n];
    ll a[n];
    ll sum = 0;
    for(int i=0;i<n;i++){
    	cin >> a[i];
    	if(i % 2 == 0) sum += a[i];
    	else sum -= a[i];
    }
    b[0] = sum;
    for(int i=1;i<n;i++){
    	b[i] = (a[i-1] - b[i-1] / 2) * 2;
    }
    for(int i=0;i<n;i++){
    	cout << b[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=100000000000000000;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
int n,m;
vector<vector<int>> graph;
int dfs(int now,vector<bool> &visited){
    int res=0;
    bool alvisited=true;
    for(int i=0;i<n;i++)if(!visited.at(i))alvisited=false;
    if(alvisited)return 1;
    for(int i=0;i<graph.at(now).size();i++){
        if(visited.at(graph.at(now).at(i)))continue;
        visited.at(graph.at(now).at(i))=true;
        res+=dfs(graph.at(now).at(i),visited);
        visited.at(graph.at(now).at(i))=false;
    }
    return res;
}
int main(){
cin>>n>>m;
vector<bool> visited(8,false);
graph.resize(n);
for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    graph.at(a).push_back(b);
    graph.at(b).push_back(a);
}
visited.at(0)=true;
cout<<dfs(0,visited)<<endl;
}

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

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll) 1000000007
#define P pair<ll, ll>

vector<vector<ll>> s, u;
ll n, m, ans;



void md(vector<vector<ll>> a) {
	vector<vector<ll>> newa(n, vector<ll>(n));
	REP(i, n) {
		REP(j, n) {
			REP(k, n) {
				newa[i][j] += a[i][k] * a[k][j];
				newa[i][j] %= MOD;
			}
		}
	}
	u = newa;
}

void pl(vector<vector<ll>> a) {
	vector<vector<ll>> newa(n, vector<ll>(n));
	REP(i, n) {
		REP(j, n) {
			REP(k, n) {
				newa[i][j] += s[i][k] * a[k][j];
				newa[i][j] %= MOD;
			}
		}
	}
	s = newa;
}

int main() {
	cin >> n >> m;
	m--;
	s.resize(n);
	REP(i, n) {
		REP(j, n) {
			ll a;
			cin >> a;
			s[i].push_back(a);
		}
	}
	u = s;
	while (m > 0) {
		if (m % 2 == 1) pl(u);
		md(u);
		m /= 2;
	}
	REP(i, n) {
		REP(j, n) {
			ans += s[i][j];
			ans %= MOD;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
constexpr ll infl = 1ll<<60;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin>>n;
    vector<ll> a(n);
    for(auto & b : a) cin>>b;
    ll sum = 0ll;
    for(int i=60;i>=0;i--){
        ll count = 0ll,count2 = 0ll;
        for(int j=0;j<n;j++){
            if((a[j]>>i)&1){
                count++;
            }else count2++;
        }
        ll tmp = count*count2;
        tmp%=mo;
        ll s= (1ll<<i);s%=mo;
        (sum += s*tmp)%=mo;
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	string S;
	cin >> S;
	if(S.length() == 2){
		cout << S << endl;
	} else {
		cout << S[2] << S[1] << S[0] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n,m = [int(i) for i in input().split()]

l = sorted([int(i) for i in input().split()])
total = sum(l)

if total == m:
    print(n)
elif total < m: 
    print(n-1)
else:
    ct = 0
    for i in l:
        if m >= i:
            ct += 1
            m -= i
        else:
            break
    print(ct)




Measured memory_bytes: 3060
#include<stdio.h>
#define MAX 100005

typedef struct{
    int p;
    int l;
    int r;
    int depth;
}Node;

Node np[MAX];
int n,i;

void print(int i){
    int l;

    printf("node %d: parent = %d, depth = %d, ",i,np[i].p,np[i].depth);
    if(np[i].p == -1){
        if(np[i].l == -1){
            printf("root, []\n");
        }
        else{   
            l = np[i].l;
            printf("root, [");
            printf("%d",l);
            while(1){
                if(np[l].r == -1){
                    break;
                }
                printf(", %d",np[l].r);
                l = np[l].r;
            }
            printf("]\n");
        }
    }
    else if(np[i].p != -1 && np[i].l != -1){
        l = np[i].l;
        printf("internal node, [");
        printf("%d",l);
        while(1){
            if(np[l].r == -1){
                break;
            }
            printf(", %d",np[l].r);
            l = np[l].r;
        }
        printf("]\n");
    }
    else{
        printf("leaf, []\n");
    }
}

void get_depth(){
    int i,p;

    for(i = 0; i < n; i++){
        p = np[i].p;
        while(1){
            if(p == -1){
                break;
            }
            p = np[p].p;
            np[i].depth++;
        }
    }
}


int main(){
    int k,j;
    int rank,c,d;
    int m;

    scanf("%d",&n);

    for(i = 0; i < n; i++){
        np[i].p = np[i].l = np[i].r = -1;
    }

    for(i = 0; i < n; i++){
        scanf("%d%d",&rank ,&k);
        for(j = 0; j < k; j++){
            scanf("%d", &c);

            if(j == 0){
                np[rank].l = c;
                np[c].p = rank;
                m = c;
            }else{
                np[m].r = c;
                np[c].p = rank;
                m = c;
            }
        }
    }

    get_depth();

    for(i = 0; i < n; i++){
        print(i);
    }

    return 0;
}

Measured memory_bytes: 2168
#include<iostream>
using namespace std;
int main() {
  int a;
  int b;
  int c;
  int d;
  int e;
  int k;
  cin>>a;
  cin>>b;
  cin>>c;
  cin>>d;
  cin>>e;
  cin>>k;
  if((e-a)>k){
    cout<<":(";
  }
  else{
    cout<<"Yay!";
  }
} 

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

S = input()
T = ""

words = []
words.append("dream")
words.append("dreamer")
words.append("erase")
words.append("eraser")
# 候補文字列を反転
for i in range(len(words)):
    words[i] = words[i][::-1]
# Sも反転
S = S[::-1]

while len(S) != 0:
    if S[:5] == words[0] or S[:5] == words[2]:
        S = S[5:]
    elif S[:6] == words[3]:
        S = S[6:]
    elif S[:7] == words[1]:
        S = S[7:]
    else:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int n;
    map<int,int> m;
    cin >> n;
    rep(i,n){
        int x;
        cin >> x;
        m[x]++;
    }
    int cnt = 0;
    for(auto i:m){
        if(i.second%2){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e6+5;
const ll mod =   1e9+7;
ll n,k,ncr[2005][2005];
int main()
{  fast
cin>>n>>k;
for(int i=0;i<=n;i++){
	ncr[i][0]=1;
	for(int j=1;j<=i;j++)
	ncr[i][j]=(ncr[i-1][j]+ncr[i-1][j-1])%mod;
}
for(int i=1;i<=k;i++){
	cout<<ncr[n-k+1][i]*ncr[k-1][i-1]%mod<<endl;
}
}

Measured memory_bytes: 26264
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<ll> as(n); cin >> as;
    vector<ll> fs(n); cin >> fs;
    sort(as.begin(), as.end());
    sort(fs.rbegin(), fs.rend());
    ll imps = -1, ps = 1e12;
    while(imps + 1 < ps){
        ll piv = (imps + ps) / 2;
        ll rem = k;
        for(int i = 0; i < n; i++){
            ll req = piv / fs[i];
            rem -= max(0ll, as[i] - req);
        }
        if(rem >= 0){
            ps = piv;
        }else{
            imps = piv;
        }
    }
    cout << ps << '\n';
    // printde(fs);
    // printde(as);
    // for(int i = 0; i < n; i++){
    //     ll d = min(as[i], k);
    //     k -= d;
    //     as[i] -= d;
    // }
    // printde(as);
    // ll ans = 0;
    // for(int i = 0; i < n; i++){
    //     ans = max(ans, as[i] * fs[i]);
    // }
    // cout << ans << '\n';
}


Measured memory_bytes: 3328
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

int main(int argc, char **argv)
{
  const int64_t K = 753;
  
  std::string S;
  std::cin >> S;
  
  int64_t min = INT64_MAX;
  
  for (uint64_t i = 0; i <= S.size() - 3; ++i) {
    std::string T = S.substr(i, 3);
    int64_t n = std::stoi(T);
    
    std::cerr << n << std::endl;
    
    min = std::min(min, std::abs(K - n));
  }
  
  std::cout << min << std::endl;
  
  return 0;
}

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

int main() {
  int A,B,C,X,a=0,b=0;
  cin >> A >> B >> C >> X;
  for (int i=0;i<A+1;i++){
    for (int j=0;j<B+1;j++){
      for (int k=0;k<C+1;k++){
        b=500*i+100*j+50*k;
        if (X==b){
        a++;
        }
  }
  }
  }
  cout << a << endl;
}

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

int main()
{
    int a, b;

    cin >> a>> b;
    int d = a / b;
    int r = a % b;
    double f = double(a) / double(b);
    // cout << d << " "<< r << " "<< setprecision(5)<<f << endl;
    printf("%d %d %.5f\n",d,r,f);
    return 0;

}


Measured memory_bytes: 3208
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=2000+10,L=N*N;
const int mod=1e9+7;
inline int qpow(int a,int b) {
    int c=1;
    for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) c=1ll*c*a%mod;
    return c;
}

int fac[L],ifac[L];
inline void init(int n) {
    fac[0]=1;
    for (re int i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%mod;
    ifac[n]=qpow(fac[n],mod-2);
    for (re int i=n;i;--i) ifac[i-1]=1ll*ifac[i]*i%mod;
}
inline int C(int n,int m) {
    if (n<m) return 0;
    return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

int n,k,dp[N][N];

int main() {
    n=read(),k=read(); init(n*k);
    if (k==1) { puts("1"); return 0; }
    for (re int i=1;i<=n;++i) dp[i][0]=1;
    for (re int i=1;i<=n;++i)
        for (re int j=1;j<=i;++j)
            dp[i][j]=(dp[i-1][j]+1ll*dp[i][j-1]*(n-j+1)%mod*C(n*k-i-(j-1)*(k-1)-1,k-2))%mod;
    printf("%d\n",dp[n][n]);
    return 0;
}


Measured memory_bytes: 46592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n;
		int case_ = 1;
		int[][] jpg;
		final String FORMAT = "%3d";
		while ((n = in.nextInt()) != 0) {
			jpg = new int[n][n];
			System.out.println("Case " + case_++ + ":");
			int num = 1;
			for (int col = 0; col < n; col++) {
				jpg[0][col] = num;
				if (col % 2 == 1) {
					num += 2 * (col + 1);
				} else {
					num++;
				}
			}
			for (int row = 1; row < n; row++) {
				boolean isUp = (row % 2 != 0);
				for (int col = 0; col < n; col++) {
					if (col != n - 1) {
						num = jpg[row - 1][col + 1];
						num += ((isUp) ? +1 : -1);
					} else {
						num = jpg[row - 1][col];
						num += (isUp) ? +1 : ((n - row) * 2);
					}
					jpg[row][col] = num;
					isUp = !isUp;
				}
			}
			for (int[] row : jpg) {
				for (int col : row) {
					System.out.print(String.format(FORMAT, col));
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 19368
n = int(input())
low = [[0,i] for i in range(10**5+1)]
high = [[0,i] for i in range(10**5+1)]

v = list(map(int,input().split()))
for i,a in enumerate(v):
    if i%2==0:
        low[a][0] +=1
    else:
        high[a][0] +=1

low.sort(reverse=True)
high.sort(reverse=True)



if low[0][1] !=high[0][1]:
    ans = n-(low[0][0] +high[0][0])
else:
    ans = n - (low[0][0] + max(low[1][0],high[1][0]))
print(ans)

Measured memory_bytes: 41204
n = int(input())
t,a = map(int, input().split())
h = [int(i) for i in input().split()]
c = 10**10
for j in range(n):
    if c>=abs(a-(t-h[j]*0.006)):
        c = abs(a-(t-h[j]*0.006))
        ans = j
print(ans+1)

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

int main() {
    int N;
    cin >> N;
    vector<string> s(N);
    for (int i=0; i<N; i++) cin >> s.at(i);
    int M;
    cin >> M;
    vector<string> t(M);
    for (int i=0; i<M; i++) cin >> t.at(i);
    int maxi = 0;
    for (int i=0; i<N; i++) {
        int sum = 0;
        string str = s.at(i);
        for (int j=0; j<N; j++) {
            if (str == s.at(j)) sum++;
        }
        for (int j=0; j<M; j++) {
            if (str == t.at(j)) sum--;
        }
        maxi = max(maxi, sum);
    }
    cout << maxi << endl;
}

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

#define int long long
#define pb push_back
#define ff first
#define ss second
bool cmp(pair<int,int> &a,pair<int,int> &b)
{
    return a.ff+a.ss<b.ff+b.ss;
}
bool cmp1(pair<int,int> &a,pair<int,int> &b)
{
    return a.ff-a.ss<b.ff-b.ss;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin>>n;
    
    vector<pair<int,int>> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i].ff>>a[i].ss;
    
    sort(a.begin(),a.end(),cmp);
    int ans=abs(a[n-1].ss-a[0].ss)+abs(a[n-1].ff-a[0].ff);
    sort(a.begin(),a.end(),cmp1);
    ans=max(ans,abs(a[n-1].ss-a[0].ss)+abs(a[n-1].ff-a[0].ff));
    cout<<ans;
}

Measured memory_bytes: 6348
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX_D = 60;
ll inc[200005];
vector<int> found[200005];
int l[200005];
int n;
ll k;

void finish(ll idx) {
  set<int> s;
  vector<int> v;
  while(idx < n*k) {
    if(s.count(l[idx%n])) {
      while(s.count(l[idx%n])) {
        s.erase(v.back());
        v.pop_back();
      }
    }
    else {
      v.push_back(l[idx%n]);
      s.insert(l[idx%n]);
    }
    idx++;
  }
  for(int out: v) cout << out << " "; cout << "\n";
  exit(0);
}

void solve() {
  cin >> n >> k;
  for(int i = 0; i < n; i++) {
    cin >> l[i];
    found[l[i]].push_back(i);
  }
  for(int i = 0; i < n; i++) {
    if(found[l[i]].size() == 1) {
      inc[i] = n+1;
    }
    else if(found[l[i]].back() == i){
      inc[i] = n+1+found[l[i]][0] - i;
    }
    else {
      inc[i] = 1 + found[l[i]][upper_bound(found[l[i]].begin(), found[l[i]].end(), i) - found[l[i]].begin()] - i;
    }
  }
  set<int> seen;
  vector<ll> v;
  v.push_back(0);
  ll curr = 0;
  ll cycleSize = -1;
  while(true) {
    if(curr == n*k) return;
    if(seen.count(curr%n)) {
      for(ll out: v) {
        if(curr%n == out%n) {
          cycleSize = curr - out;
          break;
        }
      }
      break;
    }
    seen.insert(curr%n);
    ll nextI = curr + inc[curr%n];
    if(nextI == n*k) {
      return;
    }
    if(nextI > n*k) {
      finish(curr);
    }
    curr += inc[curr%n];
    v.push_back(curr);
  }
  assert(cycleSize > 0);
  while(curr + cycleSize <= n*k) {
    int d = 0;
    while(curr + (1LL << (d+1)) * cycleSize < n*k) {
      d++;
    }
    curr += (1LL << d) * cycleSize;
  }
  while(curr + cycleSize <= n*k) {
    curr += cycleSize;
  }
  while(curr + inc[curr%n] <= n*k) curr += inc[curr%n];
  finish(curr);
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << " ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 33136
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<int, int> P;
class BiOp {
public:
	P operator()(const P &a, const P &b) const {
		if (a.first < b.first) {
			return b;
		}
		else if (a.first > b.first) {
			return a;
		}
		else if (a.first <= b.first) {
			return a;
		}
		else {
			return b;
		}
	}
};
template<typename T, typename BiOp>
struct SegmentTree {
	vector<T> data;
	T e;
	BiOp op;
	int size;
	SegmentTree(int n, T e, BiOp op) :e(e), op(op) {
		size = 1;
		while (size < n) size *= 2;
		data.resize(size * 2 - 1);
		for (int i = 0; i < size * 2 - 1; i++) data[i] = e;
	}
	void update(int k, T v) {
		k += size - 1;
		data[k] = v;
		while (k > 0) {
			k = (k - 1) / 2;
			data[k] = op(data[k * 2 + 1], data[k * 2 + 2]);
		}
	}
	T query(int a, int b, int k, int l, int r) const {
		if (b <= l || r <= a) return e;
		if (a <= l && r <= b) {
			return data[k];
		}
		return op(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
	}
	T query(int a, int b) const {
		return query(a, b, 0, 0, size);
	}
	T get(int i) {
		return data[i + size - 1];
	}
};
ll ans[100001];
ll cnt[100001];
int a[100001];
int main() {
	int N;
	cin >> N;
	SegmentTree<P, BiOp> seg(N + 1, P(0, 1 << 30), BiOp());
	seg.update(0, P(0, 0));
	vector<int> h;
	h.push_back(0);
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
		h.push_back(a[i]);
	}
	sort(h.begin(), h.end());
	h.erase(unique(h.begin(), h.end()), h.end());
	for (int i = 1; i <= N; i++) {
		a[i] = lower_bound(h.begin(), h.end(), a[i]) - h.begin();
		cnt[a[i]]++;
		seg.update(i, P(a[i], i));
	}
	P now = seg.query(1, N + 1);
	ll sum = 0;
	while (now.second > 0) {
		P nxt = seg.query(0, now.second);
		ll tmp = (h[now.first] - h[nxt.first])*sum;
		for (int i = now.first; i > nxt.first; i--) {
			sum += cnt[i];
			tmp += (h[i] - h[nxt.first]) * cnt[i];
		}
		ans[now.second] = tmp;
		now = nxt;
	}
	for (int i = 1; i <= N; i++) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 5624
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n; cin >> n;
    vector<string> s(n + 1), u(n + 1);
    rep(i, n + 1) {
        string x; cin >> x;
        string p = "", q = "";
        rep(j, (int)x.size()) {
            if(x[j] == '?') {
                p += 'a', q += 'z';
            } else {
                p += x[j], q += x[j];
            }
        }
        s[i] = p, u[i] = q;
    }
    string t = s[n];
    sort(all(s));
    sort(all(u));
    int mi = n + 1, ma = 0;
    rep(i, n + 1) {
        if(s[i] == t) {
            chmax(ma, i);
        }
        if(u[i] == t) {
            chmin(mi, i);
        }
    }
    for(int i = mi; i <= ma; i++) {
        cout << i + 1;
        if(i != ma) cout << " ";
    }
    cout << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

#define ll long long
const int N = 1e5 + 5;

int main(){
	char type;
	ll tmp = -1;
	for(ll i = 1; i <= 1e9; i *= 10){
		cout<<"? "<<i<<endl;
		fflush(stdout);
		cin>>type;
		if(type == 'N'){
			tmp = i;
			break;
		}
	}
	if(tmp == -1){
		for(ll i = 1; i <= 1e9; i *= 10){
			cout<<"? "<<i + 1<<endl;
			fflush(stdout);
			cin>>type;
			if(type == 'Y'){
				cout<<"! "<<i<<endl;
				fflush(stdout);
				return 0;
			}
		}
	}
	tmp /= 10;
	ll lo = tmp, hi = (tmp * 10) - 1;
	while(lo < hi){
		ll mid = (lo + hi)/2;
		cout<<"? "<<mid * 10<<endl;
		fflush(stdout);
		cin>>type;
		if(type == 'Y')	hi = mid;
		else lo = mid + 1;
	}
	cout<<"! "<<lo<<endl;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	int i,j;
	int maks = (n-1) * (n-2) / 2;
	vii edge;
	if(k > maks){
		printf("-1\n");
	}else{
		for(i=2;i<=n;i++){
			edge.pb(ii(1,i));
		}
		if(maks == k){goto here;}
		for(i=2;i<=n;i++){
			for(j=i+1;j<=n;j++){
				edge.pb(ii(i,j));
				maks--;
				if(maks == k){goto here;}
			}
		}
		here:;
		printf("%d\n",(int)edge.size());
		for(i=0;i<edge.size();i++){
			printf("%d %d\n",edge[i].first, edge[i].second);
		}
		
	}
	return 0;
};

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

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

    long long K = N * 3;
    long long sol = 0;

    long long arr[K];

    for(long long k=0; k<K; k++)
    {
        cin >> arr[k];
    }

    sort(arr,arr+K);

    long long n = 0;

    for(long long k=(K-2); k>=0; k=k-2)
    {
        sol = sol + arr[k];
        n++;

        if(n == N)
        {
            break;
        }
    }

    cout << sol;
    return 0;
}



Measured memory_bytes: 5972
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define mem(a,b) memset(a,b,sizeof (a))
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll ksm(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

const int N=1e5+10;
int n,m;
int hei[N];
int h[2*N],ne[2*N],e[2*N],idx;
void add(int a,int b){
	e[idx]=b;
	ne[idx]=h[a];
	h[a]=idx++;
}
int dfs(int u){
	int res=0;
	for(int i=h[u];i!=-1;i=ne[i]){
		int j=e[i];
		if(hei[u]>hei[j]){
			continue;
		}
		return 0;
	}
	return 1;
}
int main(){
	scanf("%d%d",&n,&m);
	mem(h,-1);
	rep(i,1,n){
		scanf("%d",&hei[i]);
	}
	while(m--){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	int cnt=0;
	rep(i,1,n){
		cnt+=dfs(i);
	}
	printf("%d",cnt);
    return 0;
}


Measured memory_bytes: 6544
rooms = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(n):
    b, f, r, v= map(int, input().split())
    rooms[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print('', rooms[i][j][k], end='')
        print()
    if i < 3:
        print('#' * 20)

Measured memory_bytes: 7636
#include <bits/stdc++.h>
using namespace std;
void swap(int &a,int &b){
    int tmp=a;
    a=b;
    b=tmp;
}
void roll(int &dice1,int &dice2,int &dice3,int &dice4){
    swap(dice1,dice2);
    swap(dice2,dice3);
    swap(dice3,dice4);
}
void roll_dice(int a,int (&one)[7])
{
    if (a == 4)//E
        roll(one[1], one[3], one[6], one[4]);
    if (a == 2)//S
        roll(one[1], one[5], one[6], one[2]);
    if (a == 5)//N
        roll(one[1], one[2], one[6], one[5]);
    if (a== 3)//W
        roll(one[1], one[4], one[6], one[3]);
    if (a==6) {
        roll(one[1], one[3], one[6], one[4]);
        roll(one[1], one[3], one[6], one[4]);
    }
}
int compare_dice(int (&a)[7],int (&b)[7]){
    int tmp[7]={0};
    string m1,m2;
    int count=0,sum=0;
    if(!(b[1]==a[1]&&b[6]==a[6])){
        for(int i=1;i<7;i++)
        {
            for(int j=0;j<7;j++)
                tmp[j]=b[j];
            roll_dice(i,tmp);
            if(tmp[1]==a[1]&&tmp[6]==a[6])
                count = i;
                sum++;
        }
    }
    if(sum!=0&&count==0) return 0;
    else{
        roll_dice(count,b);
        int circle[4] = {2, 3, 5, 4};
        for (int i : circle) {
            m1 += to_string(a[i]);
            m2 += to_string(b[i]);
        };
        m1 += m1;
        return(m1.find(m2) != -1?1:0);
    }
};
int main()
{
    int num;
    cin>>num;
    int judge=0;
    int matrix[num][7]={0};
    for(int i=0;i<num;i++) {
        for(int j=1;j<=6;j++)
        {cin>>matrix[i][j];}
    }
    for(int i=1;i<num;i++) {
        judge += compare_dice(matrix[0], matrix[i]);
        //cout<<"compare_dice(matrix[0], matrix["<<i<<"]"<<compare_dice(matrix[0], matrix[i])<<endl;
    }
    //cout<<judge<<endl;
    cout << (judge==0 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const ll N =2e5+5;
ll ans[N];
ll sum[N];
int main(){
       cin.tie(0), ios::sync_with_stdio(0);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
  ll x=c/b;
  ll y=a/d;
  if(c%b!=0)
  x++;
  if(a%d!=0)
  y++;
  //cout<<x<<" "<<y<<endl;
  if(x>y)
  cout<<"No"<<endl;
  else
  cout<<"Yes"<<endl;
  
 
     }

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

//全探索
int main(){
  string S,T;cin>>S>>T;
  int ans;
  priority_queue<int> X;
  int l=S.size();
  int L=T.size();
    /*for(int i=0;i<=ans;i++){
      string X=T.substr(i,L-ans);
      for(int j=0;j<l+ans-L;j++){
        if(S.substr(j,L-ans)==X) goto Fin;
      }
    }
    ans++;*/
    for(int i=0;i<=l-L;i++){
      ans=0;
      for(int j=0;j<L;j++){
        if(S.at(i+j)==T.at(j)) ans++;
      }
      X.push(ans);
    }
 /* if(l==L){
    ans=0;
    for(int i=0;i<L;i++){
      if(S.at(i)==T.at(i)) ans++;
    }
    X.push(ans);
  }*/
  cout<<L-X.top()<<endl;
  
  
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include<algorithm>
#include <math.h>
#include <iomanip>
#include <stack>
#include <string>
#include <set>
#include <map>
using namespace std;
int main(){
    int n;cin>>n;
    string s1,s2;cin>>s1>>s2;
    if(s1==s2){
        cout<<n<<endl;
    }
    else{
        int ans=n;
        for(int i=0;i<s1.size();i++){
            bool flag=1;
            for(int j=i,x=0;j<s1.size();x++,j++){
                if(s1[j]!=s2[x])flag=0;
            }
            if(flag){
                cout<<ans<<endl;
                return 0;
            }

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)

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

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 2123450
#else
#define SIZE 2123450
#endif

int N;
int A[SIZE], B[SIZE];

void solve() {
    cin>>N;
    REP1(i,N)cin>>A[i];
    vector<int> ans;
//    vector<int> B(N + 1, 0);
    RREP1(i, N) {
        int sum = 0;
        for (int j = i; j <= N; j += i) sum += B[j];
        
        if ((sum + A[i]) % 2 == 1) {
            B[i]=1;
            ans.push_back(i);
        } else {
            B[i]=0;
        }
    }
    out("%lu\n", ans.size());
    if (ans.size()) {
        for (auto n:ans) out("%lld ", n);
        out("\n");
    }
}

Measured memory_bytes: 5620
def resolve():
    import math
    n = int(input())
    def is_prime(n):
        if n==1:
            return False
        for k in range(2, int(math.sqrt(n))+1):
            if n % k == 0:
                return False
        return True
    while True:
        flg = is_prime(n)
        if flg is False:
          n += 1
        else:
          print(n)
          exit()
resolve()

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

int main() {
	int n;
	scanf("%d", &n);
	
	bool chk = true;
	for(int i=0;i<n;i++) {
		int x;
		scanf("%d", &x);
		if(x%2==0 && x%3!=0 && x%5!=0) chk = false;
	}
	puts(chk ? "APPROVED" : "DENIED");
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <stack>
#include <vector>
using namespace std;

int main()
{
	int n;
	int cnt = 0;
	stack<int> car;
	vector<int> out;

	while (cin >> n, cin.eof() != true){
		if (n == 0){
			out.push_back(car.top());
			car.pop();
		}
		else {
			car.push(n);
		}
	}

	for (int i = 0; i < out.size(); i++){
		cout << out[i] << endl;
	}

	return (0);
}

Measured memory_bytes: 1220
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    ans = 0

    for i in range(1, n + 1):
        k = n // i
        kk = int((k + 1) * (k / 2) * i)
        # for j in range(i, n + 1, i):
        #     ans += j
        ans += kk
    print(ans)    

if __name__ == '__main__':
    main()


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

int main(){
  int n,i=0,j=0;
  char s1[100], s2[100];
  scanf("%d",&n);
  while(scanf("%s %s", s1, s2)!=EOF)
  {
  if ( strcmp(s1,s2) == 0 ){
  i=i+1;
  j=j+1;
  }
  else if ( strcmp(s1, s2) > 0 ){
  i=i+3;
  }
  else if ( strcmp(s1, s2) < 0 ){
  j=j+3;
  }
  }
  printf("%d %d\n",i,j);
  return 0;
  
}



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

using namespace std;

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

    if (A >= 13) {
        cout << B << endl;
    } else if (A >= 6) {
        cout << B / 2 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
<?php
$tmp = [];
while ($line = fgets(STDIN)) {
    $tmp[] = trim($line);
}


list($H, $W) = explode(' ', $tmp[0]);

$S = [];
for ($i = 1; $i <= $H; $i++) {
    $S[] = str_split($tmp[$i]);
}

$checkList = [[0, 1], [1, 0], [0, -1], [-1, 0]];



for ($i = 0; $i < $H; $i++) {
    for ($p = 0; $p < $W; $p++) {

        if ($S[$i][$p] === '.')
            continue;

        $exists = false;
        for ($k = 0; $k < 4; $k++) {
            $target = $S[$i + $checkList[$k][0]][$p + $checkList[$k][1]] ?? null;
            if (!is_null($target) && $target === '#')
                $exists = true;
        }

        if (!$exists)
            return print_r('No');
    }
}

print_r('Yes');

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
string a;
int ans;
int main()
{
	cin>>a;
	for(int s=1;s<a.size();s++)
	{
		if(a[s]!=a[s-1])ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int n;
  scanf("%d", &n);
  int i, a[n], c=0;
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
  }
  int f=1;
  while(f==1){
    for(i=0;i<n;i++){
      if(a[i]%2==0){
        a[i]/=2;
      }else{
        f=0;
        break;
      }
    }
    if(f==1) c++;
  }
  printf("%d", c);
  return 0;
}

Measured memory_bytes: 128
/// >>In The Name Of God
/// >>ALIREZANA

#include <bits/stdc++.h>
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define smin(x,y) (x) = min(x,y)
#define smax(x,y) (x) = max(x,y)
#define all(x) (x).begin(),(x).end()
#define _ ios_base::sync_with_stdio(0)\
                ,cin.tie(0),cout.tie(0);

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main()
{_
  int n, x;
  cin >> n >> x;
  int p = 0, ans = 1;
  for(int i = 0; i < n; i++)
  {
      int l;    cin >> l;
      p += l;
      ans += (p <= x);
  }
  cout << ans;
  return 0;
}


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


long long int factmod(long long int n){
	if(n==0){
		return 1;
	}else{
		long long int m=factmod(n-1);
		long long int preans=n*m;
		lldiv_t temp;
		temp=lldiv(preans,1e+9+7);
		return temp.rem;
	}
}

int main(){
	long long int n,m;
	scanf("%lld %lld\n",&n,&m);
	long long  diff=n-m;
	long long int ans;
	if(diff<-1||diff>1){
		ans=0;
	}else{
		lldiv_t temp;
		temp=lldiv(factmod(n)*factmod(m),1e9+7);
		ans=temp.rem;
	}
	if(diff==0) ans*=2;
	lldiv_t tempf;
	tempf=lldiv(ans,1e9+7);
	ans=tempf.rem;
	
	printf("%lld",ans);
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <float.h>
using namespace std;
int main(){
    int n,t,ans;
    double temp,anstemp;
    double a;
    ans = 0;
    anstemp = 1000000000;
    cin >> n>> t>> a;
    for(int i=1;i<=n;i++){
        int x;
        cin >> x;
        temp = t-x*0.006;
        double y = temp-a;
        if(y<0){
            y=y*(-1);
        }
        if(y<anstemp){
            anstemp = y;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
 }

Measured memory_bytes: 256
n = int(input())
s = input()

l_a = []
l_b = []

if n%2 == 0:
  for i in range(n//2):
    l_a.append(s[i])
  for i in range(n//2, n):
    l_b.append(s[i])
  if l_a == l_b:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 9112
n = int(input())
List = [int(input()) for i in range(n)]
#print(List)

import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  
print(lcm_list(List))

Measured memory_bytes: 67564
K,N=[int(x) for x in input().rstrip().split()]
A=[int(x) for x in input().rstrip().split()]

flag=1
now=0
mae=[]
back=[]
for i in range(N-1):
  mae.append(A[i+1]-A[i])
mae.append(A[len(A)-1]-A[0])

for i in range(N-1,0,-1):
  back.append(A[i]-A[i-1])
back.append(abs(A[0])+abs(K-A[N-1]))

back.sort()
mae.sort()
ans=min(sum(mae[:len(mae)-1]),sum(back[:len(back)-1]))
print(ans)

Measured memory_bytes: 26444
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
using namespace std;

struct Blocking {
    int pos;
    int first;
    int onepastlast;
};

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

    auto blocking = vector<Blocking>(n);
    for (auto &blk : blocking) {
        int s, t, x;
        cin >> s >> t >> x;

        // (s - 0.5) < (d_i + x) < (t - 0.5)
        // s <= d_i + x < t
        // s-x <= d_i < t-x

        blk.pos = x;
        blk.first = s - x;
        blk.onepastlast = t - x;
    }

    sort(blocking.begin(), blocking.end(), [](auto &a, auto &b) { return (a.pos < b.pos) || (a.pos == b.pos && a.first < b.first); });

    constexpr int huge = 2'000'000'000;
    auto distances = vector<int>(q, huge);
    // auto d_and_index = vector<std::pair<int, int>>(q); // d_i and output_index;
    auto d_and_index = set<std::pair<int, int>>(); // d_i and output_index;
    for (int i = 0; i < q; i++) {
        int d_i;
        cin >> d_i;
        // d_and_index[i] = make_pair(d_i, i);
        d_and_index.insert(make_pair(d_i, i));
    }

#if 0 // TLE
    for (auto &blk : blocking) {
        auto itr1 = lower_bound(d_and_index.begin(), d_and_index.end(), make_pair(blk.first, -1), [](auto &x, auto &y) { return x.first < y.first; });
        auto itr2 = lower_bound(itr1, d_and_index.end(), make_pair(blk.onepastlast, -1), [](auto &x, auto &y) { return x.first < y.first; });

        for (auto itr = itr1; itr != itr2; ++itr) {
            auto i = itr->second;
            distances[i] = blk.pos;
        }

        d_and_index.erase(itr1, itr2);
    }
#else
    for (auto &blk : blocking) {
        auto itr = d_and_index.lower_bound(make_pair(blk.first, -1));
        while (itr != d_and_index.end()) {
            if (itr->first >= blk.onepastlast)
                break;
            distances[itr->second] = blk.pos;
            itr = d_and_index.erase(itr);
        }
    }
#endif

    for (auto &dist : distances) {
        cout << (dist == huge ? -1 : dist) << "\n";
    }

    return 0;
}


Measured memory_bytes: 14336