akhauriyash/Code-Regression huggingface dataset:
H, W, A, B = map(int,input().split())

grid = [["0"] * W for _ in range(H)]

if A == 0:
    for i in range(H):
        for j in range(W):
            if 0 <= i < B:
                grid[i][j] = "1"

elif B == 0:
    for i in range(H):
        for j in range(W):
            if 0 <= j < A:
                grid[i][j] = "1"

else:
    for i in range(H):
        for j in range(W):
            if (0 <= i < B and 0 <= j < A) or (B <= i < H and A <= j < W):
                grid[i][j] = "1"

for line in grid:
    print("".join(line))

Measured memory_bytes: 11892
#include <stdio.h>
#include <vector>
#include <algorithm>
#define rep(i,n) for(i=0;i<(n);i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
typedef long long ll;
#define MOD1 1000000007
int main(void){
  ll n,i,j,result=0;
  std::vector<ll> perm;
  ll p[8],q[8];
  ll a,b,count=0;
  scanf("%lld",&n);
  rep(i,n) scanf("%lld",&p[i]);
  rep(i,n) scanf("%lld",&q[i]);
  rep(i,n) perm.push_back(i+1);
  
  do {
    rep(i,n){
      if(perm[i]!=p[i]) break;
    }
    if(i==n) a=count;
    rep(i,n){
      if(perm[i]!=q[i]) break;
    }
    if(i==n) b=count;
    count++;
  } while (std::next_permutation(perm.begin(), perm.end()));
  
  printf("%lld",zt(a,b));
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 100005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

struct edge{int to;ll cost;};

int N,M;
vector<edge> G[SIZE];
bool used[SIZE];
int S[SIZE];
bool T;

void dfs(int v,int s){
	if(used[v]){ //訪問済み
		if(S[v] != s)T=false;
		return;
	}
	//訪問
	S[v] = s;
	used[v]=true;

	for(int i=0;i<G[v].size();i++){
		dfs(G[v][i].to,s+G[v][i].cost);
	}
}
	

int main()
{
	scanf("%d%d",&N,&M);
	int L,R;
	ll D;
	T = true;
	for(int i=0;i<M;i++){
		scanf("%d%d%lld",&L,&R,&D);
		G[L].push_back((edge){R,D});
		G[R].push_back((edge){L,(-1)*D});
	}
	for(int i=1;i<=N;i++){ //dfs
		if(!used[i])dfs(i,0); //頂点に数字割当
	}
	if(T)printf("Yes\n");
	else printf("No\n");

	return 0;
}


Measured memory_bytes: 16128
#include<stdio.h>
int main(){
	
	char S1;
	char S2;
	char S3;
	
		scanf("%c %c %c",&S1,&S2,&S3);
			if(S1==S2,S1!=S3,S2!=S3){
				puts("Yes");
			}
	        else if(S1==S3,S1!=S2,S3!=S2){
	        	puts("Yes");
			}
	        else if(S2==S3,S1!=S2,S1!=S3){
	        	puts("Yes");
			}
	        else {
	        	puts("No");
			}
	return 0;
}

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

using namespace std;

int main()
{

    int X, A;
    cin>>X>>A;
    if(X<A)
    {
        cout<<"0";
    }
    else{
        cout<<"10";
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
mod = 10 ** 9 + 7
now = [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(4)]
now[3][3][3][3] = 1
for _ in range(n):
  last = now
  now = [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(4)]
  for i in range(4):
    for j in range(4):
      for k in range(4):
        for l in range(4):
          for m in range(4):
            now[j][k][l][m] += last[i][j][k][l]
            now[j][k][l][m] %= mod
  for h in range(4):
    now[h][0][1][2] = 0
    now[h][1][0][2] = 0
    now[h][0][2][1] = 0
    now[0][h][1][2] = 0
    now[0][1][h][2] = 0
ans = 0
for j in range(4):
  for k in range(4):
    for l in range(4):
      for m in range(4):
        ans += now[j][k][l][m]
        ans %= mod
print(ans)

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

typedef long long ll;
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(c) c.begin(),c.end()
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
#define pu push
#define pb push_back
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
const ll MOD = 1000000007;


int main(){
    fio();
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int diffx = tx-sx;
    int diffy = ty-sy;
    int i;
    rep(i,diffy){
        cout<<"U";
    }
    rep(i,diffx){
        cout<<"R";
    }
    rep(i,diffy){
        cout<<"D";
    }
    rep(i,diffx){
        cout<<"L";
    }
    cout<<"L";
    rep(i,diffy+1){
        cout<<"U";
    }
    rep(i,diffx+1){
        cout<<"R";
    }
    cout<<"D"<<"R";
    rep(i,diffy+1){
        cout<<"D";
    }
    rep(i,diffx+1){
        cout<<"L";
    }
    cout<<"U";




}


Measured memory_bytes: 256
N=int(input())
S=input()

max_num=0
for i in range(N):
	X=S[:i:]
	Y=S[i::]
	num=0
	for char in [chr(i) for i in range(97,97+26)]:
		if (char in X) and (char in Y):
			num=num+1
	if max_num<num:
		max_num=num
print(max_num)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int A,B,C;
  cin>>A>>B>>C;

  cout<<C<<" "<<A<<" "<<B<<endl;

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    a,b,c,x,y=map(int,input().split())
    ans=0

    # 常に x>=y としておく
    if(x<y):
        x,y=y,x
        a,b=b,a

    # はじめに a+b と 2c の大小で y を埋める
    if(a+b>=2*c):
        ans+=y*2*c
        x-=y
    else:
        ans+=y*b

    # 次に残った x を、a と 2c の大小で埋める
    if(a>=2*c):
        ans+=x*2*c
    else:
        ans+=x*a

    print(ans)
resolve()

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

const int LIMIT = 200000;
bool ifnotprime[LIMIT+1];
int sp[10001];

void set(){
    ifnotprime[0] = ifnotprime[1] = true;
    sp[0] = 0;
    int i = 0;
    for(int x = 2; x < LIMIT; x++){
        if(!ifnotprime[x]){
            if( i < 10000 ){
                sp[i+1] = sp[i] + x;
                i++;
            }
            if( x <= 1000 ){
                int y = x*x;
                while(y < LIMIT){
                    ifnotprime[y] = true;
                    y += x;
                }
            }
        }
    }
}

int main(){
    set();
    int m;
    while( true ){
        cin >> m;
        if( !m ) break;
        cout << sp[m] << endl;
    }
    return 0;
}

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

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    int N,M;
    cin>>N>>M;

    int A=100*N+1800*M;
    cout<<(A*(1<<M))<<endl;


    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
n,t=map(int,input().split())
l=[int(i) for i in input().split()]
ans=[0]*3
for i in l:
    if i>=ans[2]:
        ans[0]+=t
        ans[1]=i
        ans[2]=i+t
    else:
        ans[0]+=i+t-ans[2]
        ans[1]=i
        ans[2]=i+t
print(ans[0])

Measured memory_bytes: 25196
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double min = 1000000000;
		double max = 0;
		while(sc.hasNext()) {
			double d = sc.nextDouble();
			min = Math.min(min, d);
			max = Math.max(max, d);
		}
		sc.close();
		System.out.printf("%.5f", max - min);
	}
}


Measured memory_bytes: 28000
#include<stdio.h>
#include<algorithm>
using namespace std;
long long mod=1000000007;
int c[110];
long long dp[110][11000];
int main(){
    int a,b;scanf("%d%d",&a,&b);
    for(int i=0;i<a;i++)scanf("%d",c+i);
    dp[0][0]=1;
    for(int i=0;i<a;i++){
        for(int j=i;j>=0;j--){
            for(int k=0;k+c[i]<11000;k++){
                dp[j+1][k+c[i]]=(dp[j+1][k+c[i]]+dp[j][k]);
            }
        }
    }
    long long ret=0;
    for(int i=1;i<=a;i++)ret=(ret+dp[i][i*b]);
    printf("%lld\n",ret);
}

Measured memory_bytes: 6272
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;
#define MOD 998244353

long long powmod(int n){
    long long ret = 1;
    for(int i=0; i<n; i++){
        ret *= 2;
        ret %= MOD;
    }
    return ret;
}

bool isColinear(pair<int, int> xy1, pair<int, int> xy2, pair<int, int> xy3){
    return (xy1.first-xy2.first)*(xy3.second-xy1.second)==(xy3.first-xy1.first)*(xy1.second-xy2.second);
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<pair<int, int>> xy(N);
    for(int i=0; i<N; i++) cin >> xy[i].first >> xy[i].second;

    long long mns = 1 + N + N*(N-1)/2;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            int cnt = 2;
            for(int k=0; k<N; k++){
                if(k == i || k == j) continue;
                if(!isColinear(xy[i], xy[j], xy[k])) continue;
                if(k < j) break;
                cnt++;
            }
            if(cnt >= 3){
                mns += powmod(cnt);
                mns %= MOD;
                mns += MOD - (1 + cnt + cnt*(cnt-1)/2);
                mns %= MOD;
            }
        }
    }
    long long ans = powmod(N);
    ans += MOD - mns;
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int kaij[214514];

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kaij[x]* mod_pow(kaij[x - y], mod - 2, mod) % mod * mod_pow(kaij[y], mod - 2, mod) % mod;
}

int h, w, a, b;
int ans;

signed main() {
	cin >> h >> w >> a >> b;
	kaij[1] = 1;
	for (int i = 2; i < 214514; i++) {
		kaij[i] = kaij[i - 1] * i % mod;
	}
	for (int i = b; i < w; i++) {
		ans += max((int)1, comb(i + (h - a - 1), i))*max((int)1, comb((a - 1) + (w - i - 1), (a - 1)));
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1920
import heapq
N, M = map(int, input().split())
Work = sorted([list(map(int, input().split())) for i in range(N)], key=lambda x: x[0])

ans = 0
can_work = []
i = 0
for m in range(M + 1):
    while (i < N) and (Work[i][0]) <= m:
        heapq.heappush(can_work, -Work[i][1])
        i += 1
    if can_work:
        ans += -heapq.heappop(can_work)

print(ans)


Measured memory_bytes: 84536
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

countone = 0
counttwo = 0
countthree = 0

for pi in P:
    if pi > B:
        countthree = countthree + 1
    if (pi <= B)&(pi > A):
        counttwo = counttwo + 1
    if (pi <= A):
        countone = countone + 1

print(min([countone, counttwo, countthree]))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
int n,d[1001];
bool D[1000000]={};
 
int main()
{
  cin>>n;
  for(int i=0;i<n;i++)cin>>d[i];
 
  reverse(d,d+n);
 
  for(int i=0;i<n;i++){
    int num=d[i],k=1;
    D[num]=true;
    for(int j=i+1;j<n;j++){
      if(k>4)break;
      num+=d[j]*pow(10,k);
      D[num]=true;
      k++;
    }
  }
  for(int i=0;i<100000;i++){
    if(!D[i]){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3380
#include<stdio.h>
int main()
{
	int h, n;
	scanf("%d %d", &h, &n);
	int i;
	int a, sum = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &a);
		sum += a;
	}
	if (sum < h)
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <vector>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define COUT(a) cout << (a);
#define ENDL cout << "\n";
int main() {
    long n;
  	long wa = 1000000007;
    scanf("%ld\n",&n);
    long long a[n],b[n];
    REP(i,n) {
        scanf("%lld",&a[i]);
        b[i] = abs(i-(n-1-i));
    }
    sort(a, a+n);
    sort(b,b+n);
    if(n%2==1 && a[0]!=0) {
      COUT(0)
      return 0;
    }
    REP(i,n) if(a[i] != b[i]) {
        COUT(0)
        return 0;
    }
  	int ans=1;
  	REP(i,n/2) {
    	ans *= 2;
    	ans %=wa;
    }
  	COUT(ans);
}



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

int main(){
  lli n;
  std::cin >> n;
  vector<lli> a(n);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
  }
  lli mini = 1, pos = 0;
  lli ans = 0;
  for (int i = 0; i < n; i++) {

    if(a[i] == mini){
      
    }else if(a[i]%mini == 0){
      ans += (a[i]/mini) - 1;
      a[i] = 1;
    }else{
      ans += a[i]/mini;
      a[i] = 1;
    }
    mini = max(mini, a[i] + 1);
    // std::cout << "mini:" << mini << " pos:" << i << " ans";
    // std::cout << ans << std::endl;
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 1152
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  char c;
  cin >> c;
  c++;
  cout << c << endl;


return 0;
}
///....


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
    int N, M, C;
    int B[21];
    int A[21][21];
    cin >> N >> M >> C;
    for (int i=0; i<M; i++) cin >> B[i];
    for (int i=0; i<N; i++) {
        for (int j=0; j<M; j++) cin >> A[i][j];
    }
    int answer = 0;
    for (int i=0; i<N; i++) {
        int sum = C;
        for (int j=0; j<M; j++) sum += A[i][j] * B[j];
        if (sum > 0) answer++;
    }
    cout << answer << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

//e-market
public class Main{
	
	class D implements Comparable<D>{
		String name;
		int gain, pay;
		public D(String name) {
			this.name = name;
		}
		public int compareTo(D o) {
			return name.compareTo(o.name);
		}
	}
	
	class R{
		char ch;
		int p;
		D dealer;
		public R(char ch, int p, D dealer) {
			super();
			this.ch = ch;
			this.p = p;
			this.dealer = dealer;
		}
	}
	
	Map<String, D> ref;
	
	D get(String name){
		if(ref.containsKey(name))return ref.get(name);
		D d = new D(name);
		ref.put(name, d);
		return d;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			ref = new HashMap<String, D>();
			int[] min = new int[26], max = new int[26], sum = new int[26], num = new int[26];
			Arrays.fill(min, 1<<29);
			List<R> buy = new ArrayList<R>();
			List<R> sell = new ArrayList<R>();
			while(n--!=0){
				String name = sc.next();
				String cmd = sc.next();
				char ch = sc.next().charAt(0);
				int p = sc.nextInt();
				if("BUY".equals(cmd)){
					int k = -1, m = 1<<29;
					for(int i=0;i<sell.size();i++){
						R r = sell.get(i);
						if(!name.equals(r.dealer.name)&&ch==r.ch&&r.p<=p&&r.p<m){
							k = i; m = r.p;
						}
					}
					if(k==-1)buy.add(new R(ch, p, get(name)));
					else {
						R r = sell.remove(k);
						int x = r.ch-'A';
						int z = (p+r.p)/2;
						min[x] = Math.min(min[x], z); max[x] = Math.max(max[x], z); sum[x]+=z; num[x]++;
						get(name).pay+=z;
						r.dealer.gain+=z;
					}
				}
				else{
					int k = -1, m = 0;
					for(int i=0;i<buy.size();i++){
						R r = buy.get(i);
						if(!name.equals(r.dealer.name)&&ch==r.ch&&p<=r.p&&m<r.p){
							k = i; m = r.p;
						}
					}
					if(k==-1)sell.add(new R(ch, p, get(name)));
					else{
						R r = buy.remove(k);
						int x = r.ch-'A';
						int z = (p+r.p)/2;
						min[x] = Math.min(min[x], z); max[x] = Math.max(max[x], z); sum[x]+=z; num[x]++;
						get(name).gain+=z;
						r.dealer.pay+=z;
					}
				}
			}
			for(int i=0;i<26;i++){
				if(num[i]==0)continue;
				System.out.println((char)(i+'A')+" "+min[i]+" "+(sum[i]/num[i])+" "+max[i]);
			}
			System.out.println("--");
			PriorityQueue<D> q = new PriorityQueue<D>();
			for(String name:ref.keySet())q.add(ref.get(name));
			while(!q.isEmpty()){
				D d = q.poll();
				System.out.println(d.name+" "+d.pay+" "+d.gain);
			}
			System.out.println("----------");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cctype>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#define LL long long
#define MAXN 100010
#define debug(x) cerr << #x << " " << x << endl
using namespace std;

inline int read() { int x = 0, f = 1; char ch = getchar();
    for(; !isdigit(ch); ch = getchar()) f = ch == '-' ? -1 : 1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; return x * f;
}

int x, y;

int main() {
    x = read(); y = read();
    cout << x + y / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include <cstddef>
#include <memory>

using namespace std;

class Node
{
public:
    shared_ptr<Node> left;
    shared_ptr<Node> right;
    int  value;
    Node()
    {
        left  = nullptr;
        right = nullptr;
        value = 0;
    }
};

using node_ptr = shared_ptr<Node>;

vector<Node> Aar;
vector<Node> Bar;


void input(vector<Node> & ar,const string & str,int & i,node_ptr & ptr)
{
    if(str[i]==')')
    {
        ++i;
        return;
    }

    ptr = make_shared<Node>();


    if(str[i]=='(')
    {
        ++i;
        input(ar,str,i,ptr->left);
    }
    if(str[i]=='[')
    {
        ++i;
        while(str[i]!=']')
        {
            ptr->value*=10;
            ptr->value+=(int)(str[i]-'0');
            ++i;
        }
        ++i;
    }
    if(str[i]=='(')
    {
        ++i;
        input(ar,str,i,ptr->right);
    }
    if(str[i]==')')
    {
        ++i;
        return;
    }
}

void output(node_ptr a, node_ptr b)
{
    if(a==nullptr || b==nullptr) return;

    cout << "(" << flush;
    output(a->left,b->left);
    cout << ")" << flush;

    cout << "[" <<a->value + b->value << "]" << flush;

    cout << "(" << flush;
    output(a->right,b->right);
    cout << ")" << flush;
}

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

    int si=0;
    node_ptr Aptr;
    input(Aar,A,si,Aptr);

    si = 0;
    node_ptr Bptr;
    input(Bar,B,si,Bptr);

    output(Aptr,Bptr);

    cout << endl;
}


Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b;
    if(a>=0&&a<=9 && b>=0&&b<=9)
    {
       c=a*b;cout<<c<<endl;
    }
    else cout<<-1<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast_io cin.tie(0);ios_base::sync_with_stdio(0);
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cout << endl; }
void show() { cout << endl; }
void pret() { cout << endl; exit(0);}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cout << " " << to_string(H); debug_out(T...);}
template <typename Head, typename... Tail> void show(Head H, Tail... T) {cout <<H<<" "; show(T...);}
template <typename Head, typename... Tail> void pret(Head H, Tail... T) {cout <<H<<" "; pret(T...);}
#define pr(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
typedef long long ll;
// #define int ll
typedef long double ld;
#define disp(x) cout<<x<<" ";
#define rep(i,a,b) for(int i=a;i<(int)b;i++)
#define fo(i,a,b) for(int i=a;i<=(int)b;i++)
#define rf(i,a,b) for(int i=a;i>=(int)b;i--)
#define mp make_pair
#define pb emplace_back
#define F first
#define S second
#define endl '\n'
//cout.setf(ios::fixed);cout.precision(18)
const int MOD = 1e9+7;
const int N = 300000+10;

int dp[N], nextId[N];

int32_t main(){
	fast_io;
	int n, m;
	cin >> n >> m;
	string st;
	cin >> st;
	dp[n] = 0;
	set<pair<int, int> >s;
	s.insert({0, n});
	rf(i, n - 1, 0){
		if(i + m + 1 <= n and s.count({dp[i + m + 1], i + m + 1})) s.erase({dp[i + m + 1], i + m + 1});
		if(s.empty()){
			pret(-1);
		}
		if(st[i] == '1') continue;
		dp[i] = (*s.begin()).first + 1;
		nextId[i] = (*s.begin()).second - i;
		s.insert({dp[i], i});
	}
	int id = 0;
	while(id < n){
		disp(nextId[id]);
		id += nextId[id];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 7052
import numpy as np
import sys

class UnionFind:
	def __init__(self, n):
		self.n = n
		self.root = [-1]*(n+1)
		self.rnk = [0]*(n+1)
		self.Maxroot = -1

	def Find_Root(self, x):
		if (self.root[x] < 0):
			return x
		else:
			self.root[x] = self.Find_Root(self.root[x])
			return self.root[x]

	def Unite(self, x, y):
		x = self.Find_Root(x)
		y = self.Find_Root(y)
		if x == y:
			return 
		elif self.rnk[x] > self.rnk[y]:
			self.root[x] += self.root[y]
			if self.root[x] < self.Maxroot:
				self.Maxroot = self.root[x]
			self.root[y] = x
		else:
			self.root[y] += self.root[x]
			if self.root[y] < self.Maxroot:
				self.Maxroot = self.root[y]
			self.root[x] = y
			if self.rnk[x] == self.rnk[y]:
				self.rnk[y] += 1

	def isSameGroup(self, x, y):
		return self.Find_Root(x) == self.Find_Root(y)

	def Count(self, x):
		return self.root[self.Find_Root(x)] * (-1)

	def Max_tree(self):
		return min(self.root) * (-1)


N, M = map(int, input().split())
AB = np.array(sys.stdin.read().split(), np.int64)
A = AB[::2][::-1]
B = AB[1::2][::-1]

solve = UnionFind(1+N)
ans = [N*(N-1)//2]

for i in range(M-1):
	if not solve.isSameGroup(A[i],B[i]):
		benefit = solve.Count(A[i]) * solve.Count(B[i])
		ans.append(max(0,ans[-1]-benefit))
	else:
		ans.append(ans[-1])
	solve.Unite(A[i],B[i])

for a in ans[::-1]:
	print(a)

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



int main(){
    int X, K;
    std::cin >> K >> X;

    int start = X - (K - 1);
    int end = X + (K + 1);

    for(int i = 0 ; i < 2*K - 1; i++){
        std::cout << start + i << " ";
    }
}


Measured memory_bytes: 3640
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
#define For(i,a,b) for(int i=(int)a;i<=(int)b;++i)
#define Fordown(i,a,b) for(int i=(int)a;i>=(int)b;--i)
#define re read()
#define maxn 100000+10
#define inf 2100000000
#define mem(a,b)memset(a,b,sizeof(a))
#define ll long long
int n,k;
int a[maxn];
void work();
inline int read()
{
    int flag=1,ans=0;
    char ch=getchar();
    while(!isdigit(ch)&&ch!='-')ch=getchar();
    if(ch=='-'){flag=-1;ch=getchar();}
    while(isdigit(ch)){ans=(ans<<3)+(ans<<1)+(ch-'0');ch=getchar();}
    return ans*flag;
}
void init()
{
	int flag=0;
	n=re;k=re;
	For(i,1,n)
	{
		a[i]=re;
		if(a[i]==k){printf("POSSIBLE\n");return;}
		if(a[i]>k)flag=1;
	}
	if(!flag)printf("IMPOSSIBLE\n");
	else work();
}
int gcd(int x,int y)
{
	if(y==0)return x;
	return gcd(y,x%y);
}
void work()
{
	int x=a[1];
	For(i,2,n)
	{
		x=gcd(max(x,a[i]),min(x,a[i]));
	}
	if(k%x==0||x==1)printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
}
int main()
{
	init();
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace std;
#pragma warning (disable: 4996)

long long fact[200009], mod = 1000000007, n, c[200009], w[200009], A, B; vector<pair<long long, long long>>X;
vector<int>x[200009]; long long col[200009], cnt, num[200009]; vector<int>Z, u[200009];

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 35; i++) {
		if ((b&(1LL << i)) != 0) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}
long long Div(long long a, long long b, long long m) {
	return (a*modpow(b, m - 2, m)) % m;
}
void dfs(int pos) {
	if (col[pos] >= 1) return;
	col[pos] = cnt; Z.push_back(c[pos]); num[c[pos]]++;
	for (int i = 0; i < x[pos].size(); i++) dfs(x[pos][i]);
}

void edges() {
	long long P = c[0], PP = 1000000;
	for (int i = 1; i < n; i++) {
		if (c[i] != P && w[0] + w[i] <= B) {
			if (PP == 1000000)PP = i; x[0].push_back(i); x[i].push_back(0);
		}
	}
	if (PP <= n) {
		for (int i = 0; i < n; i++) {
			if (c[i] != c[PP] && w[PP] + w[i] <= B) { x[PP].push_back(i); x[i].push_back(PP); }
		}
	}
	for (int i = 0; i < n; i++) u[c[i]].push_back(i);
	for (int i = 0; i <= n; i++) {
		for (int j = 1; j < (int)u[i].size(); j++) {
			if (w[u[i][j]] + w[u[i][0]] > A)continue;
			x[u[i][j]].push_back(u[i][0]);
			x[u[i][0]].push_back(u[i][j]);
		}
	}
}

int main() {
	fact[0] = 1; for (int i = 1; i <= 200008; i++) fact[i] = (1LL * fact[i - 1] * i) % mod;
	cin >> n >> A >> B;
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld", &c[i], &w[i]);
		X.push_back(make_pair(w[i], c[i]));
	}
	sort(X.begin(), X.end());
	for (int i = 0; i < n; i++) { c[i] = X[i].second; w[i] = X[i].first; }

	edges();

	long long ans = 1;
	for (int i = 0; i < n; i++) {
		if (col[i] >= 1)continue;
		for (int j = 0; j < Z.size(); j++)num[Z[j]] = 0; Z.clear();
		cnt++; dfs(i);
		long long ret = fact[Z.size()];
		sort(Z.begin(), Z.end());
		for (int j = 0; j < Z.size(); j++) {
			if (j == 0 || Z[j - 1] != Z[j])ret = Div(ret, fact[num[Z[j]]], mod);
		}
		ans *= ret; ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 33900
import math
def comb(n, k):
    if n < 0 or k < 0 or n < k: return 0
    return math.factorial(n) // math.factorial(n-k) // math.factorial(k)



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

all = 0

for i in range(k):
    add = comb(k, i) * ((k-i) ** n)
    if i & 1: all = (all - add)
    else: all = (all + add)

print(all // (math.factorial(k)) % MOD)


Measured memory_bytes: 5668
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
void ans(ll x, ll y, ll z);
ll H, W, K, count = 0, total = 0;;

int main() {


    cin >> H >> W >> K;

    vector<vector<ll>> C(H, vector<ll>(W));
    vector<ll>X(H, 0), Y(W, 0);

    string S;

    rep(i, H) {
        cin >> S;
        rep(j, W) {
            if (S[j] == '#') {
                C[i][j] = 1;
            }
            else {
                C[i][j] = 0;
            }
        }
    }

    ll count, ans =0;

    for (ll bh = 0; bh < (1 << H); bh++) {
        for (ll bw = 0; bw < (1 << W); bw++) {
            count = 0;
            for (ll i = 0; i < H; i++) {
                for (ll j = 0; j < W; j++) {
                    count += (bh >> i) & (bw >> j) & C[i][j];
                }
            }
            ans += (count == K);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
import bisect


class BTreeNode:
    def __init__(self):
        self.key = []
        self.child = []


class BTree:
    def __init__(self):
        self.root = BTreeNode()

    def search_higher(self, key):
        ptr = self.root
        ret = None
        while ptr.child:
            i = bisect.bisect_right(ptr.key, key)
            if i != len(ptr.key):
                ret = ptr.key[i]
            ptr = ptr.child[i]
        i = bisect.bisect_right(ptr.key, key)
        if i != len(ptr.key):
            ret = ptr.key[i]
        return ret

    def search_lower(self, key):
        ptr = self.root
        ret = None
        while ptr.child:
            i = bisect.bisect_left(ptr.key, key)
            if i != 0:
                ret = ptr.key[i - 1]
            ptr = ptr.child[i]
        i = bisect.bisect_left(ptr.key, key)
        if i != 0:
            ret = ptr.key[i - 1]
        return ret

    def insert(self, key):
        def insert_rec(ptr):
            b_size = 512
            if not ptr.child:
                bisect.insort(ptr.key, key)
                if len(ptr.key) == b_size * 2 - 1:
                        ret = BTreeNode()
                        ret.key = ptr.key[:b_size]
                        ptr.key = ptr.key[b_size:]
                        return ret
            else:
                i = bisect.bisect(ptr.key, key)
                temp = insert_rec(ptr.child[i])
                if temp is not None:
                    ptr.key.insert(i, temp.key.pop(-1))
                    ptr.child.insert(i, temp)
                    if len(ptr.child) == b_size * 2:
                        ret = BTreeNode()
                        ret.child = ptr.child[:b_size]
                        ptr.child = ptr.child[b_size:]
                        ret.key = ptr.key[:b_size]
                        ptr.key = ptr.key[b_size:]
                        return ret
            return None
        temp = insert_rec(self.root)
        if temp is not None:
            root = BTreeNode()
            root.key = [temp.key.pop(-1)]
            root.child = [temp, self.root]
            self.root = root

    def dump(self):
        def dump_rec(ptr, dep):
            for _ in range(0, dep):
                print("  ", end="")
            print(ptr.key)
            for c in ptr.child:
                dump_rec(c, dep + 1)
        dump_rec(self.root, 0)
        print("")


def main():
    n,*a=map(int,open(0).read().split())
    l=[0]*n
    for i,v in enumerate(a,1):l[v-1]=i
    t=BTree()
    t.insert(0)
    t.insert(n+1)
    c=0
    for i,v in enumerate(l,1):
        c+=(t.search_higher(v)-v)*(v-t.search_lower(v))*i
        t.insert(v)
    print(c)
main()

Measured memory_bytes: 25884
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int n,k;
    cin >> n >> k;
    n%=k;
    if(n==0)
        cout << n;
    else
    {
        if(k-n<n)
            cout << k-n;
        else
            cout << n;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int n=s.size();
	int m=t.size();
	vector<vector<int> > dp(n+1,vector<int> (m+1,0));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i-1]==t[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			
		}
	}
	string v;
	int i=n;
	int j=m;
	while(i>0 && j>0){
		if(s[i-1]==t[j-1]){
			v.push_back(s[i-1]);
			i--;
			j--;
			
		}
		else if(dp[i-1][j]>dp[i][j-1]) i--;
		else j--;
		
	}
	reverse(v.begin(),v.end());
	cout<<v<<endl;
	
		
		return 0;
}


Measured memory_bytes: 35584
data = raw_input().split()
#figure = [chr(i) for i in range(ord('0'), ord('9')+1)]

stack = []

for i in range(len(data)):
	if data[i] == "+":
		stack[-2] = stack[-2] + stack[-1]
		del stack[-1]
		#print stack
	elif data[i] == "-":
		stack[-2] = stack[-2] - stack[-1]
		del stack[-1]
		#print stack
	elif data[i] == "*":
		stack[-2] = stack[-2] * stack[-1]
		del stack[-1]
		#print stack
	else:
		stack.append(int(data[i]))
		#print stack

print stack[0]

Measured memory_bytes: 6468
n = int(input())
a_i = input().split()
b_i = input().split()
c_i = input().split()
ans = 0
for i in range(n-1):
  ans += int(b_i[i])
  if int(a_i[i]) + 1 == int(a_i[i+1]):
    ans += int(c_i[int(a_i[i])-1])
ans += int(b_i[n-1])
print(ans)

Measured memory_bytes: 3064
from collections import deque

N, D, A = map(int, input().split())
mons = []
for _ in range(N):
    X, H = map(int, input().split())
    mons.append((X, (H + A - 1) // A))
mons.sort()

ans = 0
q = deque([])
tot = 0
for x, h in mons:
    while q:
        x0, h0 = next(iter(q))
        if x - 2 * D <= x0:
            break
        tot -= h0
        q.popleft()
    h = max(0, h - tot)
    ans += h
    tot += h
    q.append((x, h))
print(ans)


Measured memory_bytes: 47828
/*
    Code written by Talant I.D.
*/
   
#include <bits/stdc++.h>
   
using namespace std;
   
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
   
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);
#define curMod 998244353

int main(){
		do_not_disturb
		int a, b;
		cin >> a >> b;
		cout << max(a-b, max(a+b, a*b));
		
    return 0;
} // What is to be written here?


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

int main() {

  int n, q;
  cin >> n >> q;

  vector<vector<int>> A(n);

  for (int i = 0; i < q; i++) {
    int query, x, t;
    cin >> query >> t;
    if (query == 0) {
      cin >> x;
      A[t].push_back(x);
    } else if (query == 1) {
      for (int j = 0; j < A[t].size(); j++) {
        cout << A[t][j];
        if (j != A[t].size() - 1) {
          cout << " ";
        }
      }
      cout << endl;
    } else {
      A[t].clear();
    }
  }

  return 0;

}


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

int main(void)
{
  ll N;
  ll num = 0;
  cin >> N;
  
  for (int i=0;i<=N;i++){
    if (i%3!=0 && i%5!=0){
      num += i;
    }
  }
  
  cout << num << endl;
  
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5 * 2+10;

int arr[n_max];

// void hurui(){
//     rep(i,n_max){
//         arr[i] = 1;
//     }
//     for(int i = 2; i < sqrt(n_max);i++){
//         if(arr[i]){
//             for(int j = 0; i * (j + 2) N;j++){
//                 arr[i*(j+2) = 0;]
//             }
//         }
//     }
// }

int main(){
    int n; cin >> n;
    vector<int>a(n);
    vector<int>b(n,0);
    rep(i,n)cin >> a[i];
    // int count = 0;
    vector<int> ans;
    if(n == 1){
        cout << a[0] << endl;
        if(a[0]) cout << a[0] << endl;
        return 0;
    }
    for(int i = n-1;(n/2) <= i; i--){
        b[i] = a[i];
        if(b[i]){
            ans.pb(i+1);
            // cout << i << endl;
        }
    }
    for(int i = n/2 -1;0 <= i;i--){
        int temp = n / (i+1);
        rep(j,temp-1){
            b[i] += b[i + ((j + 1) * (i+1))];
        }
        b[i] = (b[i]%2) ^ a[i];
        if(b[i])ans.pb(i+1);
    }
    cout << ans.size() << endl;
    for(auto i : ans) cout << i << " ";
    if(ans.size())cout <<endl;
    return 0;
    

}

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<cmath>
#include<unordered_set>
#define int long long
using namespace std;

int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
signed main() {
	int a; cin >> a;
	int b; cin >> b;
	for (int c = 1; c < a; c++) {
		int d; cin >> d;
		b = lcm(b, d);
	}
	cout << b << endl;
}


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

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

    long int total = 0;

    for(long int i=K;i<=N+1;i++) {
        total += (((N+N-i+1)*i/2) - ((i-1)*i/2) + 1);
    }

    cout << total%1000000007 << endl;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> a(N); for(auto& in:a) cin >> in;
    
    vector<ll> b(N,-1);
    
    for(ll n = N; n >= 1; n--){
        ll cnt = 0;
        for(ll m = 2*n; m <= N; m+=n){
            cnt += b[m-1];
        }
        cnt%=2;

        if(a[n-1] != cnt%2){
            b[n-1] = 1;
        }else{
            b[n-1] = 0;
        }
    }
    
    vector<ll> ans;
    
    for(int i = 0; i < N;i++){
        if(b[i]){
            ans.push_back(i+1);
        }
    }
    cout << ans.size() << endl;
    if(ans.empty()) return res;
    cout << ans << endl;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main() {
    vector<int>V(101,false);
    for(int i=1;i<=9;i++)for(int j=1;j<=9;j++)V[i*j]=true;
    int n;cin>>n;
    if(V[n])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

const int N_MAX = 100010;
ll Per[N_MAX] = {}; // n!
ll Per_inv[N_MAX] = {}; //(n!)^-1

ll nCr(ll n, ll r){
    if(n<r) return 0;
 
    if (n == r || r == 0)
        return 1;
    else
        return Per[n] * Per_inv[n-r] % mod * Per_inv[r] % mod;  
}

ll Perm(ll n, ll r){
    return nCr(n, r) % mod * Per[r] % mod;
}
 
// a^b mod p
ll mod_pow(ll a, ll b){
    if(b==0) return 1;
 
    // 肩が奇数
    if(b%2==1){
        return a * mod_pow(a, b-1) % mod;
    }
    else{
        return mod_pow(a*a % mod, b/2) % mod;
    }
}

void prepare_nCr(){
    // nCr高速化準備
    Per[1] = 1;
    FOR(i, 2, N_MAX){
        Per[i] = i * Per[i-1] % mod;
    }
    Per_inv[1] = 1;
    FOR(i, 2, N_MAX){
        Per_inv[i] = mod_pow(Per[i], 1000000005);
    }
}

vector<vector<ll> > G;

ll ans;
ll N, K;

// iの子を塗る
void dfs(ll i, ll prev){
    ll available_color;
    if(prev==-1){
        available_color = K-1;
    }else{
        available_color = K-2;
    }

    ll child_num;
    if(prev==-1){
        child_num = G[i].size();
    }else{
        child_num = G[i].size()-1;
    }

    if(child_num==0) return; // leaf

    ans *= Perm(available_color, child_num);
    ans %= mod;

    for(ll to : G[i]){
        if(to==prev) continue;
        dfs(to, i);
    }
}

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

    // input
    cin >> N >> K;
    G.resize(N);
    prepare_nCr();

    FOR(i, 0, N-1){
        ll u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    ans = K;
    dfs(0, -1);
    p(ans);
    
    return 0;
}

Measured memory_bytes: 10752
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }


int main(){

    ll N;
    cin >> N;
    vll A(N);
    REP(i, N){
        cin >> A[i];
    }
    sort(ALL(A));

    vector<bool> dp(A[N - 1] + 1, true);

    ll ans = 0;
    REP(i, N - 1){
        ll a = A[i];
        if (!dp[a]) continue;

        ll k = A[N - 1] / a;
        FOR(j, 1, k + 1){
            dp.at(a * j) = false;
        }
        if (a != A[i + 1]) ans++;
    }

    if (dp[A[N - 1]] ) ans++;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4784
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto S = readln.chomp.to!(char[]);
    int X = 700;
    if (S[0] == 'o') X += 100;
    if (S[1] == 'o') X += 100;
    if (S[2] == 'o') X += 100;
    writeln(X);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k[ohara];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
set<ll> st;

//-------------------------↓↓↓↓↓↓------------------------

struct UnionFind{
	std::vector<int> data;
	
	UnionFind(int n){
		data.assign(n, -1);
	}
	
	void unite(int x, int y){
		x = find(x); y = find(y);
		if(x == y) return;
		if(data[x] > data[y]) std::swap(x, y);
		data[x] += data[y];
		data[y] = x;
	}
	
	int find(int k){
		if(data[k] < 0) return k;
		return data[k] = find(data[k]);
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

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

    cin>>n>>m;
    UnionFind uf(ohara);
    vector<ll> l[n+1];
    rep(i,n){
        cin>>k[i];
        rep(j,k[i]){
            cin>>a;
            l[i].push_back(a);
        }
    }
    rep(i,n){
        rep(j,k[i]-1){
            uf.unite(l[i][j],l[i][j+1]);
        }
    }
    rep(i,n){
        rep(j,k[i]){
            st.insert(uf.find(l[i][j]));
        }
    }
    if(Size(st)==1)Cout("YES");
    else Cout("NO");
    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  bool ans = false;
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      if ((i+1)*(j+1) == N) {
        ans = true;
        break;
      }
    }
    if(ans) break;
  }
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256