akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
#define PI 3.1415926

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;

	vector<int> x, y;

	for (int i = 0; i < f; i++) {
		for (int j = 0; j < f; j++) {
			if(100*a*i + 100*b*j <= f) x.pb(100*a*i+100*b*j);
		}
	}
	for (int i = 0; i <= f; i++) {
		for (int j = 0; j <= f; j++) {
			if(c*i + d*j <= f) y.pb(c*i + d*j);
		}
	}

	double max = -1.0;
	int ans1 = -1, ans2 = -1;
	for (int i = 0; i < x.size(); i++) {
		for (int j = 0; j < y.size(); j++) {
			if(x[i]+y[j] <= f and (double)y[j]*100/x[i] <= (double)e){
				if(max < (double)y[j]*100 / (x[i]+y[j])){
					max = (double)y[j]*100 / (x[i]+y[j]);
					ans1 = x[i]+y[j]; ans2 = y[j];
				}
			}
		}
	}
	cout << ans1 << ' ' << ans2 << endl;

	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=1001001001001001;
const int Inf=1001001001;
const int mod=1000000007;
int main(){
    ll n;cin>>n;
    string s;cin>>s;
    vi v(n),x(n);
    v[n-1]=0;
    for(int i=n-2;i>=0;i--){
        if(s[i+1]=='E')v[i]=v[i+1]+1;
        else v[i]=v[i+1];
    }
    x[0]=0;
    REP(i,1,n){
        if(s[i-1]=='W')x[i]=x[i-1]+1;
        else x[i]=x[i-1];
    }
    ll ans=inf;
    rep(i,n){
        chmin(ans,v[i]+x[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5380
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end() 
using namespace std;

typedef long long ll;

int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int n; cin >> n;
   string s, t;
   cin >> s >> t;
   int i=0, j = 0;
   string res = "";
   for(int c=0; max(i, j)<n; ++c) {
       if(c&1) 
           res += t[j], ++j;
       else
          res += s[i], ++i; 
   }
   if(j < n)
       res += t[j];
   else
       res += s[j];
   cout << res << "\n";
   return 0;
} 


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std;

int main(void) {
	int r;
	cin >> r;
	printf("%lf\n", (double)(2 * r)*M_PI);
}

Measured memory_bytes: 3764
from collections import deque

H, W = map(int, input().split())
si, sj = map(int, input().split())
gi, gj = map(int, input().split())
si, sj, gi, gj = si - 1, sj - 1, gi - 1, gj - 1
C = [input() for i in range(H)]

dist = [[10 ** 9] * W for _ in range(H)]
dist[si][sj] = 0

que = deque()
que.append((si, sj))

while que:
    i, j = que.popleft()
    d = dist[i][j]
    if i == gi and j == gj:
        break
    for ni, nj in ((i + 1, j), (i - 1, j), (i, j + 1), (i, j - 1)):
        if not (0 <= ni < H and 0 <= nj < W):
            continue
        if d < dist[ni][nj] and C[ni][nj] == ".":
            dist[ni][nj] = d
            que.appendleft((ni, nj))
    for di in range(-2, 3):
        for dj in range(-2, 3):
            ni, nj = i + di, j + dj
            if not (0 <= ni < H and 0 <= nj < W):
                continue
            if d + 1 < dist[ni][nj] and C[ni][nj] == ".":
                dist[ni][nj] = d + 1
                que.append((ni, nj))

ans = dist[gi][gj]
print(ans if ans != 10 ** 9 else -1)


Measured memory_bytes: 91448
#include <iostream>
#include <stdio.h>

int main(){
  int n, k, q;
  std::cin >> n >> k >> q;

  int a[q];
  int score[n]= {0};
  for(int i = 0; i < q; i++){
    scanf("%d", &a[i]);
  }
  for(int i = 0; i < q; i++){
    score[a[i]-1]++;
  }

  int min_point = q-k;
  if(min_point < 0) {
    for(int i = 0; i < n; i++) std::cout << "Yes\n";
  }
  else {
    for(int i = 0; i < n; i++){
      if(score[i] > min_point) std::cout << "Yes\n";
      else std::cout << "No\n";
    }
  }

  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(void)
{
  int a,b,c;
  int ans;
  scanf("%d %d %d",&a,&b,&c);
  if(a == b)
    ans = c;
  else if(a == c)
    ans = b;
  else
    ans = a;


  printf("%d\n",ans);

  return 0;

}

Measured memory_bytes: 128
N = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i ==0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr

c = 0
for i in range(2,N+1):
    if i%2 == 1:
        s = factorization(i)
        ans = 1
        for j in range(len(s)):
            ans *= (s[j][1] +1)
        if ans == 8:
            c += 1

print(c)
    

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

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<int> s;
  vector<int> ord(n + 1, -1);
  int c = 1, l = 0, v = 1;
  while(ord[v] == -1) {
    ord[v] = s.size();
    s.push_back(v);
    v = a[v - 1];
  }
  c = s.size() - ord[v];
  l = ord[v];

  if(k < l)
    cout << s[k];
  else {
    k -= l;
    k %= c;
    cout << s[l + k];
  }
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,i,sum=0;
	char lovgqt[6];
	cin>>lovgqt;
	for(i=0;i<=6;i++)
		if(lovgqt[i]=='1')
  		    sum++;
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#define INF 1e16
#define N (1000000000+7)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;


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

ll kaijo[200010];
void init() {
	kaijo[0] = 1;
	for (ll i = 1;i <= 200000;i++)kaijo[i] = (kaijo[i - 1] * i) % N;
}
 
ll inv(ll x,ll power) {
	ll res = 1;
	ll k = power;
	ll y = x;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N*y%N) % N;
		k /= 2;
	}
	return res;
}
 
ll Comb(ll n, ll k) {
	if (n < 0 || k < 0 || (n - k) < 0)return 0;
	ll b = kaijo[n];
	ll c = kaijo[n - k];
	ll d = kaijo[k];
	ll cd = (c*d) % N;
	return ((b%N)*(inv(cd,N-2)) % N) % N;
}

int main(void){
    int n;
    cin>>n;
    ll zero = 0;
    map<P,P>mp;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        if(x==0 && y==0){
            zero++;
            continue;
        }
        ll g = gcd(x,y);
        x /= g;
        y /= g;
        if(y<0)x*=-1,y*=-1;
        if(y==0 && x<0)x*=-1,y*=-1;
        bool rot90 = (x<=0);
        if(rot90){
            ll tmp = x;
            x = y;
            y = -tmp;
        }
        if(rot90)mp[P(x,y)].first++;
        else mp[P(x,y)].second++;
    }
    ll ans = 1;
    for(auto itr : mp){
        ll f = itr.second.first;
        ll s = itr.second.second;
        ll tmp1 = inv(2LL,f)-1;
        ll tmp2 = inv(2LL,s)-1;
        ll now = (tmp1+tmp2+1)%N;
        ans = (ans*now+N)%N;
    }
    ans--;
    ans+=zero;
    cout<<(ans+N)%N<<endl;
    return 0;
}

Measured memory_bytes: 19208
import java.util.Scanner;


public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		int a,b,sum;
		while(sc.hasNext())
		{
			a = sc.nextInt();
			b = sc.nextInt();
			sum = a + b;
			System.out.println((int)Math.log10(sum) + 1);
		}
	}
}

Measured memory_bytes: 12000
/* created   : 2019-08-29 00:20:04
 * accepted  : 2019-08-29 00:21:01
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int a; string s; cin >> a >> s;
  if (a >= 3200) {
    cout << s << '\n';
  }
  else {
    cout << "red" << '\n';
  }
}

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


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#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>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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 rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
// #define endl '\n'

int main() {
  int n;
  cin >> n;
  vi w(n);
  vi s(n + 1);
  rep (i, n) {
    cin >> w[i];
    s[i + 1] = s[i] + w[i];
  }
  
  int sum = s[n];
  int ans = inf;
  rep1 (i, n) {
    chmin(ans, abs(s[i] - (sum - s[i])));
  }
  cout << ans << endl;
}


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

int main() {
    int n, y;
    cin >> n >> y;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; i + j <= n; j++) {
            if (i*10000 + j*5000 + (n-i-j)*1000 == y) {
                cout << i << ' ' << j << ' ' << n-i-j;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1";
    return 0;
}

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

const int INF = 1001001001;
const int mod = 1000000007;

ll pow(ll base, ll order) {
	ll ans = 1;
	rep(i,order - 1) ans *= base;
	return ans;
}

int gcd(int a, int b) {
	if (a < b) {
		int c = a;
		a = b;
		b = c;
	}
	if (b == 0) return a;
	return gcd (b, a % b);
}

int main() {
	int x, y;
	cin >> x >> y;

	int ans = x + y/2;
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 256
from collections import deque
S = input()
q = deque(S)
c = 0
while len(q):
  l = q[0]
  r = q[len(q)-1]
  if l == r:
    if len(q) != 1:
      q.pop()
    q.popleft()
  elif l == 'x':
    q.append('x')
    c += 1
  elif r == 'x':
    q.appendleft('x')
    c += 1
  else:
    print(-1)
    exit()
print(c)


Measured memory_bytes: 4212
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <array>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

template<typename T>
using V = vector<T>;
using A = array<int, 3>;

int main() {
	A l;
	for (int a, b, c, N; scan(a, b, c, N);) {
		V<int> v(a + b + c, 2);
		V<A> t;
		while (N--) {
			for (int &x: l)
				x = in() - 1;
			int r;
			scan(r);
			if (r)
				for (int x: l)
					v[x] = 1;
			else
				t.push_back(l);
		}
		for (auto x:t) {
			int c = 0, i = 0;
			for (int y: x) {
				if (v[y] == 1)
					c++;
				else
					i = y;
			}
			if (c == 2)
				v[i] = 0;
		}
		for (int x: v)
			outl(x);
	}
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

int n, m, q;
int a[55], b[55], c[55], d[55];

vector<vector<int>> lst;

void dfs(int i, vector<int> v)
{
    if (i == n) {
        lst.emplace_back(v);
        return;
    }
    for (int j = v.back(); j <= m; j++) {
        auto nv = v;
        nv.emplace_back(j);
        dfs(i + 1, nv);
    }
}

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

    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }

    dfs(1, vector<int>(1, 1));

    int ans = 0;
    for (auto &e: lst) {
        int tmp = 0;
        for (int i = 0; i < q; i++) {
            if (e[b[i]] - e[a[i]] == c[i]) tmp += d[i];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;

    // debug
    // for (auto &e: lst) {
    //     for (auto &ee: e) cout << ee << ' ';
    //     cout << '\n';
    // }
    return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

template<typename T>
void trace(T *a, int s, int n) {
    for (int i=s; i<n; i++) {
	cout<<a[i]<<" ";
    }
    cout<<endl;
}



typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n;
ll a[maxn];
ll acc[maxn];

ll ans = 2e18;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n;
    for (int i=1; i<=n; i++) {
	cin>>a[i];
	acc[i]=a[i]+acc[i-1];
    }

    for (int i=2; i<=n-2; i++) {

	
	//left:1..i
	ll left=acc[i];
	int x=lower_bound(acc+1,acc+i+1,left/2)-acc;
	if (x==i) x--;
	
	//right: i+1..n
	ll right=acc[n]-acc[i];
	int y=lower_bound(acc+i+1,acc+n+1,right/2 + left)-acc;
	if (y==n) y--;
	//1..x..i...y..n

	for (int a=x-1; a<=x+1; a++) {
	    if (!(a>=1 && a<i)) continue;
	    for (int b=y-1; b<=y+1; b++) {
		if (!(b>i && b<n)) continue;
		set<ll> v;
		v.insert(acc[a]);
		v.insert(acc[i]-acc[a]);
		v.insert(acc[n]-acc[b]);
		v.insert(acc[b]-acc[i]);

		ans=min(ans,*v.rbegin() - *v.begin());
	    }
	}
	
    }

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


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}


int main (){
    int n;
    int count=0;
    ll sum=0;
    ll ans;
    cin >> n;
    vl a(n);
    rep(i,n){
        ll x;
        cin >> x;
        if(x<0) count++;
        sum+=abs(x);
        a[i]=abs(x);
    }
    if(count%2==0){
        cout << sum <<endl;
        return 0;
    }
    sort(a.begin(),a.end());
    cout << sum-2*a[0] <<endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
#define MAX 100000

int parent(int i){ return i/2; }
int left(int i){ return 2*i; }
int right(int i){ return 2*i+1; }

int main(){
    int H,i,A[MAX+1];
    
    cin >> H;
    for(i=1;i<=H;i++) cin >> A[i];
    
    for(i=1;i<=H;i++){
        cout << "node "<< i <<": key = " << A[i] <<", ";
        if(parent(i)>=1) cout <<"parent key = " << A[parent(i)] <<", ";
        if(left(i)<=H) cout<<"left key = " << A[left(i)] << ", ";
        if(right(i)<=H) cout << "right key = " << A[right(i)] <<", ";
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>

int main()
{
  int a, b, c;
  int max;
  char menu;
  
  scanf("%d %d %d", &a, &b, &c);

  max = a;
  menu = 'A';

  if (b > max) {
    max = b;
    menu = 'B';
  }
  if (c > max) {
    max = c;
    menu = 'C';
  }

  printf("%c\n", menu);

  return 0;
}


  



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

int main() {	
 int a,b;
  cin>>a>>b;
   vector<string> s(a*b);
for (int i = 0; i <a ; i++) {
  cin >> s[i];
}
  for (int i = 0; i < b+2; i++) {
    cout<<'#';
  }
  cout<<endl;
  for (int i = 0; i < a; i++) {
  cout<<'#'<<s[i]<<'#'<<endl;
  }
  for (int i = 0; i < b+2; i++) {
    cout<<'#';
  }
  cout<<endl;  
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
char a;
int b=1,n,m;
int main(void){
    scanf ("%d%d\n",&n,&m);
    for (;;b++)
    for (a='A';a-'A'<m;a++){
        string s;
        cin>>s;
        if (s=="snuke")return !printf ("%c%d\n",a,b);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//const long long MOD = 2019;

void solve(long long L, long long R){
  if(R-L+1>=2019){
    op(0);
    return;
  }
  bool flag=true;
  ll ans=100000000;
  repf(i,L,R+1){
    repf(j,i+1,R+1){
      ans=min(ans,(ll)(i*j)%2019);
      //if(ans==0&&flag) {cout<<i<<" "<<j<<endl;flag=false;}
    }
  }
  op(ans);
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long L;
    scanf("%lld",&L);
    long long R;
    scanf("%lld",&R);
    solve(L, R);
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
import math


def main():
    A, B, N = map(int, input().split())
    if B <= N:
        # x = B - 1
        print(A * (B - 1)// B)
    else:
        print((A * N) // B)



if __name__ == '__main__':
    main()


Measured memory_bytes: 9132
#include<cstdio>
int main()
{
  long long X;
  long long i=100;
  int count=0;
  scanf("%lld", &X);
  if(i==X) count++;
  while(i<X)
  {
    i=i+i*0.01;
    count++;
  }
  printf("%d", count);
  return 0;
}

Measured memory_bytes: 1736
a,b=map(int,input().split())
c=0
for i in range(40):
    j=2**i
    x,y=-(-a//(j*2))*j*2,b//(j*2)*j*2
    """
    if x>=y:
        t=0
        for p in range(a,b+1):
            t+=p&j>0
    else:
    """
    t=(y-x)//2
    t+=min(j,x-a)
    t+=max(0,b-y-j+1)
    c+=t%2*j
print(c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll n;
  cin >> n;
  vll l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(),l.end());
  ll ans = 0LL;
  for(int i = 0; i<n-2; i++) {
    for(int j = i+1; j<n-1; j++) {
      for(int k = j+1; k<n; k++) {
        if(l[i]!=l[j] && l[j]!=l[k] && l[i]+l[j]>l[k]) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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; }

int h,w,d;
int mrk[1000000];
int rs[1000000];
P z[1000000];

int main(){
    cin >> h >> w >> d;
    int hw = h * w;
    rep(i,h){
        rep(j,w){
            int a;
            cin >> a;
            z[a]=make_pair(i,j);
        }
    }
    for(int i = 1; i<=hw-d;i++){
        int kyori = abs(z[i].first-z[i+d].first)+abs(z[i].second-z[i+d].second);
        mrk[i]=kyori;
    }
    for(int i = 1;i<=hw;i++){
        if(i-d<=0){
            rs[i]=mrk[i];
        }
        else{
            rs[i]=mrk[i]+rs[i-d];
        }
    }
    int q;
    cin >> q;
    rep(i,q){
        int l,r;
        cin >> l >> r;
        int res;
        if(l-d<=0){
            res = rs[r-d];
        }
        else{
            res = rs[r-d]-rs[l-d];
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	string s; cin >> s;
	int n=s.size();
	cout << s[0] << n-2 << s[n-1] << endl;
} 

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
string s,t;
int f(string st,int p){
    for(int i = 0; i < st.size(); i++){
        if(st[i] != '?' && st[i] != t[i])
            return 0;
    }
    return 1;
}
int main(){
    cin>>s>>t;
    string out;
    int p=-1;
    for(int i = s.size()-t.size();i>=0;i--){
        if(f(s.substr(i,t.size()),i)){
            p=i;
            break;
        }
    }
    if(p==-1){
        cout<<"UNRESTORABLE";
        return 0;
    }
    for(int i = 0; i < t.size(); i++){
        s[p+i]=t[i];
    }
    for(int i = 0; i < s.size(); i++){
        if(s[i]=='?')
            cout<<'a';
        else
            cout<<s[i];
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define MAX 100000

int main() {
    int n;
    vector<int> p(MAX+10), c(MAX+10, 0);

    cin >> n;
    for (int i = 0; i < n; i++) cin >> p[i];

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        while(p[i] == i+1 & i < n) {
            cnt++;
            i++;
        }
        c[cnt]++;
        cnt = 0;
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += (i + 1) / 2 * c[i];
    }

    cout << ans << endl;
}

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

using namespace std;

int main()
{
    //system("chcp 65001");

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

    if(B % A != 0)
    {
        cout << B - A;
    }
    else
    {
        cout << A + B;
    }
    
    //cout << N;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		
		System.out.println(n * 800 - (n/15)*200);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}


}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    vector<int> isLiked(m, 0);
    for(int i = 0; i < n; i++) {
        int k; cin >> k;
        for(int j = 0; j < k; j++) {
            int a; cin >> a; a--;
            isLiked[a]++;
        }
    }
    int ans = 0;
    for(int i = 0; i < m; i++) {
        if(isLiked[i] == n) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    // preparation
    bool nonprime[10001] = {};
    nonprime[0] = nonprime[1] = true;
    for(int i = 2; i < 10001; i++){
        if(!nonprime[i]){
            for(int j = i+i; j < 10001; j += i){
                nonprime[j] = true;
            }
        }
    }

    int n;
    while(cin >> n){
        if(n == 0)  break;

        int large;
        for(large = n; ; large--){
            if(!nonprime[large] && !nonprime[large-2])  break;
        }

        cout << large-2 << " " << large << endl;
    }

    return 0;
}


Measured memory_bytes: 3020
n = int(input())
a = list(map(int,input().split()))
p = 0
x = 0
y = 1

for i in range(n):
    if a[i] != x:
        if y == 1:
            x = a[i]
        else:
            p += y // 2
            x = a[i]
            y = 1
    else:
        y += 1

if y == 1:
    print(p)
else:
    print(p + y // 2)

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

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

    int A, B;
    cin >> A >> B;
    int num = 0, numSockets = 1;
    while (numSockets < B) {
        numSockets = numSockets - 1 + A;
        num++;
    }
    cout << num << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int dp[6600][9900];

int main(){
    int n, m;
    cin >> n >> m;
    dp[0][3300] = 1;
    for(int i = 1;i <= 3*n;i++){
        for(int j = 0;j < 9900;j++){
            if(i-1 >= 0 && j-1 >= 0)(dp[i][j] += dp[i-1][j-1]) %= m;
            if(i-2 >= 0 && j+1 < 9900)(dp[i][j] += dp[i-2][j+1] * (3*n+1-i) % m) %= m;
            if(i-3 >= 0)(dp[i][j] += dp[i-3][j] * (3*n+2-i) % m * (3*n+1-i) % m) %= m;
        }
    }
    Int ans = 0;
    for(int i = 3300;i < 9900;i++){
        ans += dp[3*n][i];
        ans %= m;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	string s;
	cin >> s;
	s[5] = ' ';
	s[13] = ' ';
	cout << s << endl;
}

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

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

  ll ans = 1000;
  ll num = 0;
  for (int i = 0; i < N - 1; i++) {
    if (A[i] < A[i+1]) {
      ll temp = ans / A[i];
      num += temp;
      ans -= temp * A[i];
      if (i == N - 2) ans += num * A[i+1];
    }
    if (A[i] >= A[i+1]) {
      ans += num * A[i];
      num = 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int ll
#define pii pair <int,int>
#define pipii pair <int,pair <int,int>>
#define mp make_pair
#define sz(var) (int)var.size()
const int maxinput=2000005;
const int mod=1e9+7;
vector <int> adj[maxinput];
int n,m;
int in[maxinput],out[maxinput];
int parent[maxinput];
vector <int> pref[maxinput];
vector <int> suff[maxinput];
void dfs(int u,int par)
{
    in[u]=1;
    parent[u]=par;
    for(int j=0;j<adj[u].size();j++)
    {
        int v=adj[u][j];
        if(v!=par)
        {
            dfs(v,u);
            in[u]*=(1+in[v]);
            in[u]%=m;
            if(j==0)
                pref[u].push_back(1+in[v]);
            else
                pref[u].push_back((pref[u][j-1]*(1+in[v]))%m);

            suff[u].push_back(0);
        }
        else
        {
            if(j==0)
                pref[u].push_back(1);
            else
                pref[u].push_back(pref[u][j-1]);
            suff[u].push_back(0);
        }
    }

    for(int j=((int)adj[u].size())-1;j>=0;j--)
    {
        int v=adj[u][j];
        if(j==((int)adj[u].size())-1)
        {
            if(v!=par)
                suff[u][j]=1+in[v];
            else
                suff[u][j]=1;
        }
        else
        {
            if(v!=par)
                suff[u][j]=(suff[u][j+1]*(1+in[v]))%m;
            else
                suff[u][j]=suff[u][j+1];   
        }
    }
}
void dfs2(int u,int par)
{
    if(par==0)
        out[u]=1;
    /*
        if(par!=0)
        {
            int temp=1;
            for(int j=0;j<adj[par].size();j++)
            {
                int v=adj[par][j];
                if(v!=u && v!=parent[par])
                {
                    temp*=(1+in[v]);
                    temp%=m;
                }
            }
            temp*=out[par];temp%=m;
            out[u]=temp+1;
            out[u]%=m;
        }
    */

    for(int j=0;j<adj[u].size();j++)
    {
        int v=adj[u][j];
        if(v==par)
            continue;
        int pre=(j!=0)?pref[u][j-1]:1;
        int suf=(j!=(int)(adj[u].size()-1))?suff[u][j+1]:1;
        out[v]=(pre*suf)%m;
        out[v]=(out[v]*out[u])%m;
        out[v]+=1;
        if(v!=par)
            dfs2(v,u);
    }

}
signed main() 
{
    FAST
    cin>>n>>m;
    for(int i=1;i<n;i++)
    {
        int u,v;cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs(1,0);
    dfs2(1,0);
    
    int ans=(in[1]*out[1]);
    ans=(ans+m)%m;
    cout<<ans<<endl;
    //cout<<in[1]<<" "<<out[1]<<" "<<in[1]*out[1]<<endl;//<<" "<<out[1]<<endl;

    for(int i=2;i<=n;i++)
    {
        int ans=(in[i]*out[i]);
        ans=(ans+m)%m;
        cout<<ans<<endl;
        //cout<<in[i]<<" "<<out[i]<<" "<<ans<<endl;
        //cout<<in[i]<<" "<<out[i]<<endl;
    }
}

Measured memory_bytes: 167424
#include<stdio.h>
int main()
{
    int i,j,count=700;
    char s[4];
    gets(s);
    for(i=0;s[i]!='\0';i++)
    {
        if(s[i]=='o')
            count = count + 100;
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int N,m,Sum;
	while(~scanf("%d%d",&N,&m))
	{
		Sum=0;
		while(N--)
		{
			int x;
			scanf("%d",&x);
			if(x<=m/2) Sum+=2*x;
			else Sum+=(m-x)*2;
		}
		printf("%d\n",Sum);
	}
}

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

using namespace std;

int h, w;

int res = 0;

int a[401][401];

int a1[401], b1[401];
int diff[401][801];

int c1[401], d1[401];
int dp[401][401];

#define inf 1000000
#define FOE(i, s, t) for (int i = s; i <= t; i++)

int co(int a, int b){
	if (a > h || b > h) return 0;
	int dif = a - b + h;
	int maxlen = min(h - a + 1, h - b + 1);
//	printf("Q %d %d: %d %d %d\n", a, b, dif, maxlen, diff[maxlen][dif]);
	return diff[maxlen][dif];
}

int solve(int s1, int s2){
	if (s1 == 1 && s2 == 1) return co(1, 1);
	if (s1 < 1 || s2 < 1) return inf;
	if (dp[s1][s2] == -1){
		dp[s1][s2] = min(solve(s1 - 1, s2), solve(s1, s2 - 1));
		dp[s1][s2] += co(s1,s2);
	}
	return dp[s1][s2];
}

void f(){
	FOE(i, 1, h * 2 - 1){
		// shifiting by i - h
		int len = min(i, h * 2 - i);
		int st1 = (i <= h? 1: 1 + h - (h * 2 - i));
		int st2 = (i >= h? 1: 1 + h - (i));
//		printf("dif is %d: st1 %d st2 %d\n", i, st1, st2);
		FOE(j, 1, len){
			diff[j][i] = diff[j - 1][i];
			if (a1[st1] == b1[st2]) diff[j][i]++;
			st1++; st2++;
		}
	}
//	puts("DEBUG");
//	cout << co(1, 1) << endl;
//	cout << co(1, 2) << endl;
//	cout << co(2, 1) << endl;
	FOE(i, 0, h + 1) FOE(j, 0, h + 1) dp[i][j] = -1;
	res += solve(h + 1, h + 1);
}


int main(){
	scanf("%d%d", &h, &w);
	FOE(i, 1, h){
		string x; cin >> x;
		FOE(j, 1, w) a[i][j] = (int)(x[j - 1] - 'a' + 1);
	}

	FOE(i, 1, w - 1){
		FOE(j, 1, h) a1[j] = a[j][i];
		FOE(j, 1, h) b1[j] = a[j][i + 1];
		f();
//		cout << res << endl;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 2304
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

const int MAX = 1000;

struct P { int c, w; };
int N;
P S[MAX + 1];
bool boo[MAX + 1][MAX + 1];
int dp[MAX + 1];
int L[MAX + 1];
int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> S[i].c >> S[i].w;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			boo[i][j] = (i == j) ? true : false;
		}
	}
	L[0] = 0;
	for (int i = 1; i <= N; i++) L[i] = S[i].w + L[i - 1];
	for (int l = 1; l <= N; l++) {
		for (int i = 1; i <= N - l + 1; i++) {
			int j = i + l - 1;
			if (!boo[i][j]) continue;
			if (j + 1 <= N) {
				if (L[j] - L[i - 1] <= S[j + 1].c) {
					boo[i][j + 1] = true;
				}
			}
			if (i - 1 >= 1) {
				if (L[j] - L[i - 1] <= S[i - 1].c) {
					boo[i - 1][j] = true;
				}
			}
		}
	}
	for (int i = 0; i <= N; i++) dp[i] = INF<int>();
	dp[0] = 0;
	for (int b = 1; b <= N; b++) {
		for (int e = 1; e <= N; e++) {
			if (!boo[b][e]) continue;
			dp[e] = min(dp[e], dp[b - 1] + 1);
		}
	}
	cout << dp[N] << endl;
	return 0;
}


Measured memory_bytes: 4088
#include<cstdio>
const int N=2e5+10;
int n,a[N],ans,sum[N];
long long f[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=n;i>=1;i--)
	{
		f[i]=a[i];
		for(int j=2*i;j<=n;j+=i)f[i]+=f[j]; 
		if(f[i]%2)sum[++ans]=i;
	}
	printf("%d\n",ans);
	for(int i=1;i<=ans;i++)
		printf("%d ",sum[i]);
	return 0;
}


Measured memory_bytes: 3584
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repr(i,a,b) for(int i=a,i > b;--i)
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)

#define null NULL
#define eps 0.000000001
#define mod 1000000007
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (ll)V.size()
#define _ <<" "<<

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <iterator>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <limits.h>
#include <iomanip>
#include <cctype>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef pair <double, double> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<int> vii;

vi p(1e5+2);
vi mark(1e5+2);

void swap(int i,int j){
	int temp=p[i];
	p[i]=p[j];
	p[j]=temp;
	return ;
}
int main(){
	int n;
	cin>>n;
	int ans=0;
	rep(i,1,n+1) {cin>>p[i]; if(p[i]==i) mark[i]=1;}
	for(int i=1;i<n;){
		if(mark[i]){
			swap(i,i+1); i+=2;
			ans++;
		}
		else i++;
	}
	if(p[n]==n) {swap(n,n-1); ans++;}
	cout<<ans<<endl;

}









Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }
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()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll D, G;
    cin >> D >> G;
    vec p(D), c(D);
    rep(i, D) cin >> p[i] >> c[i];

    ll ans = 1e18;

    rep(i, 1 << D){
        ll now = i;
        ll tp = 0, sc = 0;
        ll tag = G;
        rrep(j, D){
            if(now & 1){
                tp += p[j];
                sc += p[j] * 100 * (j + 1) + c[j];
                tag -= p[j] * 100 * (j + 1) + c[j];
            }
            now >>= 1;
        }
        now = i;
        rrep(j, D){
            if(!(now & 1)){
                if(tag <= 0) continue;
                ll ct = min(devc(tag, (100 * (j + 1))), p[j] - 1);
                tp += ct;
                sc += ct * 100 * (j + 1);
                tag -= ct * 100 * (j + 1);
            }
            now >>= 1;
        }

        if(tag <= 0) chmin(ans, tp);
    }

    print(ans);

    return 0;
}

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

int digit_sum(int n)
{
    int dig, sum = 0;
    while (n)
    {
        dig = n % 10;
        sum += dig;
        n /= 10;
    }
    return sum;
}

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

    cout << (n % digit_sum(n) ? "No" : "Yes") << endl;
    return 0;
}

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

using namespace std;

inline bool IsBoin(const char c) {
    return c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o';
}

int MaxK(const string s1, const string s2) {
    const int size = min(s1.size(), s2.size());
    for (int i = 0; i < size; ++i) {
        if (s1[i] != s2[i]) return i + 1;
    }
    return size + 1;
}

int Solve(const int n, vector<string> &s) {
    for (int i = 0; i < n; ++i) {
        const int size = s[i].size();
        string new_s(1, s[i][0]);

        for (int j = 1; j < size; ++j)
            if (IsBoin(s[i][j - 1])) new_s.push_back(s[i][j]);

        s[i] = new_s;
    }

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

    int max_k = 0;
    for (int i = 0; i + 1 < n; ++i) {
        if (s[i] == s[i + 1]) return -1;
        max_k = max(max_k, MaxK(s[i], s[i + 1]));
    }

    return max_k;
}

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

    int n;

    while (cin >> n, n) {
        vector<string> s(n);
        for (int i = 0; i < n; ++i) cin >> s[i];

        cout << Solve(n, s) << '\n';
    }

    return 0;
}

Measured memory_bytes: 3240
#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 *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     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 cnt=0;
 string s;
 cin>>s;
 for(int i=0;i<s.size();i++)
 {
     if(s[i]!=s[s.size()-1-i])
     {
         cnt++;
         s[i]=s[s.size()-1-i];
     }
 }
 cout<<cnt<<endl;
return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	
	int n;
	
	cin >> n;
	
	long long int sum = 0;
	
	for (int i=1; i<=n; i++) {
		if (i%3!=0 and i%5!=0){
			sum+=i;
		}
	}
	
	cout << sum << endl;
	return 0;
	
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ cin >> p.first >> p.second; return s;}
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    int N; cin >> N;
    vi a(N); cin >> a;
    
    bool all_even = all_of(all(a), [](int x) { return x % 2 == 0; });

    cout << (all_even ? "second" : "first") << endl;
}


Measured memory_bytes: 640