akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int M=1e5+4;
int a[M],b[M],c[M],dp[M][3];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i]>>b[i]>>c[i];
	for(int i=1;i<=n;i++)
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
	}
	cout<<max(max(dp[n][0],dp[n][1]),dp[n][2]);
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
void func(int,int);
int a,b,n,cnt,x,y,i,k,j,miti[17][17];
int main(void)
{
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0 && b==0) break;
		scanf("%d",&n);
		for(i=1;i<=b;i++){
			for(k=1;k<=a;k++) miti[i][k]=0;
		}
		for(i=0;i<n;i++){
			scanf("%d %d",&x,&y);
			miti[y][x]=1;
		}
		cnt=0;
		func(1,1);
		printf("%d\n",cnt);
	}
	return 0;
}
void func(int yy,int xx)
{
	if(xx==a && yy==b) cnt++;
	else{
		if(xx+1<=a && miti[yy][xx+1]==0){
			func(yy,xx+1);
		}
		if(yy+1<=b && miti[yy+1][xx]==0){
			func(yy+1,xx);
		}
	}
}


Measured memory_bytes: 2684
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int N;
  cin >> N;
  ll K;
  cin >> K;

  map<ll,ll> mp;
  for(int i = 0;i < N;i++){
    ll a,b;
    cin >> a >> b;
    mp[a] += b;
  }

  ll now_sum = 0;

  for(auto itr:mp){
    if(now_sum < K && now_sum + itr.second >= K)cout << itr.first << endl;

    now_sum += itr.second;
  }


}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Maxn = 100005;
const ll inf = 1LL << 60;
int main()
{
	ios::sync_with_stdio(0);
	int n;
	static int A[Maxn];
	static char op[Maxn];
	static ll dp[Maxn][3];
	cin >> n;
	for(int i=1;i<=n;i++) {
		if(i != 1)
			cin >> op[i];
		else 
			op[i] = '+';
		cin >> A[i];
		if(op[i] == '-')
			A[i] *= -1;
	}
	
	for(int i=1;i<=n;i++)
		for(int j=0;j<=2;j++)
			dp[i][j] = -inf;
	dp[1][0] = A[1];
	for(int i=1;i<n;i++)
		for(int j=0;j<=2;j++)
			if(dp[i][j] != -inf) {
				for(int q1=0;q1<2;q1++)
					for(int q2=0;q2<2;q2++) {
						if(op[i+1] != '-' && q2)
							continue;

						int t = j;
						if(q1 != 0)
							t--;
						if(t < 0)
							continue;
#define sg(a) (((a) % 2 == 0) ? 1 : -1)
						int val = A[i+1] * sg(t);
						if(q2 != 0)
							t++;
						if(t > 2)
							continue;
#define upd(a,b) a = max(a , b)
						upd(dp[i+1][t] , dp[i][j] + val);
#undef upd
#undef sg
					}
			}
	cout << max(dp[n][0] , dp[n][1]) << endl;
	return 0;
}


Measured memory_bytes: 3072
#include<stdio.h>

int main(){
  int i,n,c,count,left,right,A[1000000],B[1000000],mid;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);

  }

  scanf("%d",&c);
  for(i=0;i<c;i++){
    scanf("%d",&B[i]);

  }

  for(i=0;i<c;i++){
    left=0;
    right=n;

    while(left<right){

      mid=(left+right)/2;
      if(A[mid]==B[i]) {count++; break;}
      else if(B[i]<A[mid]) right=mid;
      else left = mid+1;
    }
  }
  printf("%d\n",count);
}


Measured memory_bytes: 2336
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
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 int 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 long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< 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);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'



signed main() {
	ll n, d, a;
	cin >> n >> d >> a;
	vector<pll> xh(n);
	rep (i, n) {
		cin >> xh[i].first >> xh[i].second;
	}
	sort(all(xh));
	vl x(n), h(n);
	rep (i, n) {
		x[i] = xh[i].first;
		h[i] = xh[i].second;
		if (h[i] % a == 0) h[i] = h[i] / a;
		else h[i] = h[i] / a + 1;
	}

	vl last_num(n);
	ll now = 0;
	int m = 0, r = 0;
	ll ans = 0;
	rep (i, n) {
		ll mid_x = x[i] + d;
		while (r < n - 1 and x[r + 1] - mid_x <= d) r++;
		h[i] -= now;
		if (h[i] > 0) {
			ans += h[i];
			now += h[i];
			last_num[r] += h[i];
			h[i] = 0;
		}
		now -= last_num[i];
	}
	cout << ans << endl;

}

Measured memory_bytes: 8064
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

const int mod = 1000000007;

long long int mypow(long long int a, long long int b) {
    if (b == 1) return a;
    if (b == 0) return 1;
    long long int res = mypow(a, b / 2);
    res = res * res % mod;
    if (b % 2 == 1) res = res * a % mod;
    return res;
}

long long int fac(long long int a, long long int b) {
    long long int res = 1;
    for (long long int i = a; i <= b; i++) {
        res = res * i % mod;
    }
    return res;
}

long long int comb(long long int a, long long int b) {
    if (a < b) return 0;
    return fac(a - b + 1, a) * mypow(fac(1, b), mod - 2) % mod;
}

int main(int argc, char *argv[]) {
    long long int x, y;
    cin >> x >> y;

    if ((2 * x - y) % 3 != 0 || (2 * y - x) % 3 != 0 || (2 * x - y) < 0 || (2 * y - x) < 0) {
        cout << 0 << endl;
        return 0;
    }

    long long int a = (2 * x - y) / 3, b = (2 * y - x) / 3;
    if (a == b) 
        cout << comb(a + b, a) % mod << endl;
    else
        cout << comb(a + b, a) % mod << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <random>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    int cnt = 0;
    for (int i = 1; i <= 9 && i <= n; i++)
    {
        cnt++;
    }
    for (int i = 100; i <= 999 && i <= n; i++)
    {
        cnt++;
    }
    for (int i = 10000; i <= 99999 && i <= n; i++)
    {
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  string S; cin >> S;
  
  // S[0]=='0'
  int cnt_ev = 0;
  rep(i,S.size()) {
    if (i%2==0 && S[i]=='1') cnt_ev++;
    else if (i%2==1 && S[i]=='0') cnt_ev++;
  }

  // S[0]=='1'
  int cnt_od = 0;
  rep(i,S.size()) {
    if (i%2==0 && S[i]=='0') cnt_od++;
    else if (i%2==1 && S[i]=='1') cnt_od++;
  }

  cout << min(cnt_ev, cnt_od) << endl;



  // cout << fixed << setprecision(6);
  return 0;
}


Measured memory_bytes: 512
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int h = S / 3600;
		int m = (S - 3600 * h) / 60;
		int s = S % 60;
		System.out.println(h+":"+m+":"+s);
	}
}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

long long calc(string s) {
  long long sum = 0;

  int first = 0;
  rep(i, s.size()) {
    if (s[i] == '+') {
      sum += std::stoll(s.substr(first, i - first));
      first = i + 1;
    }
  }
  sum += std::stoll(s.substr(first, s.size() - first + 1));

  return sum;
}

long long dfs(string s, int pos) {
  if (pos == s.size()) {
    return calc(s);
  }

  long long sum;
  // not insert
  sum = dfs(s, pos+1);
  // insert +
  if (s.size()-1 > pos) {
    sum += dfs(s.substr(0, pos+1) + '+' + s.substr(pos+1, s.size() - (pos+1)), pos+2);
  }

  return sum;
}

int main() {
  string S;
  cin >> S;

  long long sum = 0;
  sum = dfs(S, 0);

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int x = in.nextInt();
            int t = in.nextInt();
            out.println(t > x ? 0 : x - t);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

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

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <math.h>
using namespace std;


int main() {
	int L,R;
	cin >> L >> R;
 	

	int ans = 2019;
	

	if(R > L + 2019){
		ans = 0;
	}
	else{
		L = L % 2019;
		R = R % 2019;
		if(L > R){
			ans = 0;
		}
		else{
			for(int i=L;i<R;i++){
			 	for(int j=i+1;j<R+1;j++){
			 		int x = (i * j) % 2019;
			 		if(ans > x){
			 			ans = x;
			 		}
			 	}
			}
		}
	}

    cout << ans << endl;
}

    


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,v,a=0,i,x,V;
  while(1){
    a=0;
    scanf("%d",&v);
    if(v==0) break;
    else {
      for(i=1;;i++){
	V=i;
	for(x=i+1;;x++){
	  V+=x;
	  if(V<v) continue;
	  else if(V==v) {
	    a++;
	    break;
	  }
	  else if(V>v){
	    break;
	  }
	}
	if(v==i) {
	  break;
	}
      }
      printf("%d\n",a);
    }}
      return 0;
    }

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

int n, m;
int a[500];

int main() {
    scanf("%d%d", &n, &m);
    for(int i = 0; i < m; i++) scanf("%d", &a[i]);
    if(m == 1) {
        if(n == 1) printf("%d\n%d\n%d\n", 1, 1, 1);
        else printf("%d\n2\n%d %d\n", n, n - 1, 1);
    }
    else {
        vector<int>f, g;
        for(int i = 0; i < m; i++)
        if(a[i] % 2) f.push_back(a[i]);
        else g.push_back(a[i]);

        if(f.size() > 2) {
            cout << "Impossible" << endl;
            return 0;
        }
        vector<int>ans, ans1;

        if(f.size()) ans.push_back(f[0]);
        for(int i = 0; i < g.size(); i++) ans.push_back(g[i]);
        if(f.size() > 1) ans.push_back(f[1]);

        if(ans[0] == 1) {
            for(int i = 1; i < ans.size(); i++)  {
                int t = ans[i];
                if(i == ans.size() - 1) t++;
                if(t) ans1.push_back(t);
            }
        }
        else {
            ans1.push_back(ans[0] - 1);
            for(int i = 1; i < ans.size(); i++) {
                int t = ans[i];
                if(i == ans.size() - 1) t++;
                ans1.push_back(t);
            }
        }
        for(int i = 0; i < m; i++) cout << ans[i] << " ";
        cout << endl;
        cout << ans1.size() << endl;
        for(int i = 0; i < ans1.size(); i++) cout << ans1[i] << " ";
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll nxt[200005];
ll n,k;
ll RK;
ll xh,bs;
int vis[200005];
ll p,stp;
inline void read(ll &x)
{
	ll f=1;char c;
	for(x=0,c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48); x*=f;
}
inline ll mx(ll _x,ll _y)
{
	return _x>_y?_x:_y;
}
inline ll mn(ll _x,ll _y)
{
	return _x<_y?_x:_y;
}
int main()
{
	read(n);read(RK);
	for(int i=1;i<=n;i++)
		read(nxt[i]);
	p=1;
	vis[p]=1;
	while(1)
	{
		xh++;
		p=nxt[p];
		vis[p]++;
		if(vis[p]==2) break;
	}
	stp=1;
	bs=0;
	while(vis[stp]!=2)
	{
		++bs;
		stp=nxt[stp];
	}
	xh=1;
	p=nxt[stp];
	while(vis[p]!=2) 
	{
		p=nxt[p];
		xh++;
	}
	if(RK<=bs)
	{
		p=1;
		k=RK;
		while(k)
		{
			p=nxt[p];
			k--;
		}
	}
	else
	{
		k=RK-bs;
		k%=xh;
		p=stp;
		while(k)
		{
			p=nxt[p];
			k--;
		}
	}
	printf("%lld\n",p);
	return 0;
}


Measured memory_bytes: 6104
n = gets.to_i
num = n.to_s.length
if num == 6
    puts  90909
elsif num == 5
    ans = (n-9999) + 900 + 9
    puts ans
elsif num == 4
    puts 909
elsif num == 3
    ans = (n-99) + 9
    puts ans
elsif num == 2
    puts 9
elsif num == 1
    puts n
end

Measured memory_bytes: 1788
#include <stdio.h>

int main()
{
    int A,B,C,D,E;
    int data[5],delay[5];
    int temp,counter,ans;
    int i;

    scanf("%d\n",&A);
    scanf("%d\n",&B);
    scanf("%d\n",&C);
    scanf("%d\n",&D);
    scanf("%d\n",&E);

    data[0]=A;
    data[1]=B;
    data[2]=C;
    data[3]=D;
    data[4]=E;

    for(i=0;i<5;i++){
        delay[i]=10-(data[i]%10);
        
        if(delay[i]==10){
            delay[i]=0;
        }
    }

    temp=delay[0];
    counter=0;

    for(i=1;i<5;i++){
        if(delay[i]>temp){
            temp=delay[i];
            counter=i;
        }
    }

    ans=0;

    for(i=0;i<5;i++){
        if(i!=counter){
            ans=ans+data[i]+delay[i];
        }
        else{
            ans=ans+data[i];
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <set>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<int> p(n);
  for (auto &x: p) {
    cin >> x;
    x--;
  }

  vector<int> q(n);
  for (int i = 0; i < n; i++) q[i] = i;
  sort(q.begin(), q.end(), [&](auto &a, auto &b){ return p[a] < p[b]; });

  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) a[i] = (i + 1) * 30000;
  for (int i = n-1; i >= 0; i--) b[i] = (n - i) * 30000 + q[i];

  for (auto &x: a) cout << x << " ";
  cout << endl;
  for (auto &x: b) cout << x << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 1024
def get_ind(l, r):
    mod = 3
    return OFFSET * (l % mod) + r

s = input()
n = len(s)
k = int(input())

dp = [[0] * ((n + 1) * 3) for i in range(k + 1)]
OFFSET = n + 1

# 長さ1のときの初期化
for i in range(n):
    dp[0][get_ind(i, i + 1)] = 1

# 長さ2~nのときのDP
for length in range(2, n + 1):
    for l in range(n + 1):
        for ki in range(k + 1):
            r = l + length
            if r > n:
                break
            if s[l] == s[r - 1]:
                dp[ki][get_ind(l, r)] = max(2 + dp[ki][get_ind(l + 1, r - 1)], dp[ki][get_ind(l, r)])
            else:
                dp[ki][get_ind(l, r)] = max(dp[ki][get_ind(l + 1, r)], dp[ki][get_ind(l, r - 1)], dp[ki][get_ind(l, r)])
                if ki - 1 >= 0:
                    dp[ki][get_ind(l, r)] = max(dp[ki - 1][get_ind(l + 1, r - 1)] + 2, dp[ki][get_ind(l, r)])

ans = 0
for i in range(k + 1):
    for j in range(3 * (n + 1)):
        ans = max(ans, dp[i][j])
print(ans)

Measured memory_bytes: 50520
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    int h, w;
    cin >> h >> w;
    vs mp;
    mp.resize(h);
    for(int i=0; i<h; i++) cin >> mp.at(i);
    vpi stp;
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            if(mp.at(i).at(j) == '.') stp.push_back(make_pair(i, j));
        }
    }
    int nax = 0;
    for(auto st : stp)
    {
        vii cmp(h, vi(w, -1));
        cmp.at(st.first).at(st.second) = 0;
        queue<pii> q;
        q.push(st);
        while(!q.empty())
        {
            pii cp = q.front();
            q.pop();
            for(int i=0, x=-1, y=0; i<4; x+=y, y=x-y, x=y-x, i++)
            {
                int ni = cp.first + y;
                int nj = cp.second + x;
                if(ni < 0 || h <= ni || nj < 0 || w <= nj || mp.at(ni).at(nj) == '#' || cmp.at(ni).at(nj) != -1) continue;
                else
                {
                    q.push(make_pair(ni, nj));
                    cmp.at(ni).at(nj) = cmp.at(cp.first).at(cp.second) + 1;
                }
            }
        }
        int lnax = 0;
        for(auto &v : cmp)
        {
            for(auto &num : v)
            {
                lnax = max(lnax, num);
            }
        }
        nax = max(nax, lnax);
        // cout << "st; (" << st.first << ", " << st.second << ") : " << lnax << endl;
    }
    cout << nax << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
n = int(input())
a = list(map(int, input().split()))

box = [0 for _ in range(n+1)]
result = []
for i in range(n, 0, -1):
    counter = 0
    for j in range(1, (n//i)+1):
        counter += box[j*i]
    if counter % 2 != a[i-1]:
        box[i] = 1
        result.append(i)
for i in range(1, n+1):
    counter = 0
    for j in range(1, (n//i)+1):
        counter += box[j*i]
    if counter%2 != a[i-1]:
        print(1)
        sys.exit()

print(len(result))
if len(result) != 0:
    print(*result[::-1])        

Measured memory_bytes: 15516
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
lli lcm(lli num1, lli num2){
    return num1 / gcd(num1, num2) * num2;
}
lli repow(lli n,lli k,lli m){
  if(k==0)return 1;
  else if(k%2==1)return repow(n,k-1,m)*n%m;
  else{
    lli temp=repow(n,k/2,m);
    return temp*temp%m;
  }
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> K >> S;
  sum=2*K;
  rep(i,1,N)if(S[i]==S[i-1])sum++;
  if(sum>N-1)sum=N-1;
  Out(sum);
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  int N,M; cin >> N >> M;
  map<ll,ll> data;
  ll ans = 0;
  ll cntMinus = 0;
  for ( int i = 0; i < N; i++ ) {
    int A; cin >> A;
    data[A]++;
  }

  for ( int i = 0; i < M; i++ ) {
    int B,C; cin >> B >> C;
    cntMinus += B;
    data[C] = data[C]+B;
  }


  for ( auto itr = data.begin(); itr != data.end(); ++itr ) {
    ans += itr->first * itr->second;
  }


  ll cnt = 0;
  for ( auto itr = data.begin(); itr != data.end(); ++itr ) {
    ans -= itr->first * itr->second;
    cnt += itr->second;
    if ( cnt == cntMinus ) break;
    else if ( cnt > cntMinus ) {
      ans += (cnt-cntMinus)*itr->first;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12800
#include<iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const int ma=1e6,mo=1e9+7;
typedef long long ll;
ll ans=0;
int a,b;
int c[ma];
int mi=mo;
priority_queue<int> pq;
void solve()
{
    while(b--)
    {
        int ch=pq.top();
        pq.pop();
        ch/=2;
        pq.emplace(ch);
    }
    while(pq.size())
    {
        ans+=pq.top();
        pq.pop();
    }
}
main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>a>>b;
    rep(i,a)
    {
        cin>>c[i];
        pq.emplace(c[i]);
    }
    solve();
    cout<<ans<<endl;
    return 0;
}


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

int h[26];
int main(){
  string str;
  cin >> str;
  int l = str.size();
  for (int i = 0; i < l; i++){
    h[str[i]-'a']++;
  }
  for (int i = 0; i < 26; i++){
    if (h[i] == 0){
      printf("%c\n", i+'a');
      return 0;
    }
  }
  printf("None\n");
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<map>

using namespace std;

typedef long long ll;

int main(){
	ll n, ans = 0;
	cin >> n;
	string s;
	map<string, ll> mp;
	for(int i = 0 ; i < n ; i++){
		cin >> s;
		sort(s.begin(), s.end());
		++mp[s];
	}
	for(map<string,ll>::iterator it = mp.begin() ; it != mp.end() ; it++){
		ans += (it->second  * (it->second - 1)) >> 1;
	}
	cout << ans << '\n';
	return 0;
}


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

int main() {
  string s, p;
  cin >> s >> p;
  string sc = s;
  string ans = "No";
  for(int i = 0; i < s.size(); i++) {
    if(sc.find(p) != string::npos) {
      ans = "Yes";
      break;
    }
    sc.push_back(s.at(i));
  }
  cout << ans << "\n";
}


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

using namespace std;

#define pb push_back
#define pp pop_back
#define ft first
#define sd second


typedef long long ll;
typedef long double ld;

void INeedIt() {
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}          
ll a[105];  
int main () {
	INeedIt();
	ll n, k=1000000001;
	cin>>n;
	for (int i=0;i<n;i++) {
		cin>>a[i];
	}
	for (int i=-101;i<=101;i++) {
		ll sum=0;
		for (int j=0;j<n;j++) {
			sum+=(a[j]-i)*(a[j]-i);
		}
		k=min(k, sum);
	}
	cout<<k;
	return 0;
}
 

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
count1 =0
count2 = 0
for i in a:
    if i%2==0:
        count1+=1
        if i%3==0 or i%5 == 0:
            count2+=1
    else:
        pass
if count1 == count2:
    print('APPROVED')
else:
    print("DENIED")

Measured memory_bytes: 3060
#!/usr/bin/env python
# coding: utf-8

# In[4]:


a,b = map(str, input().split())
ab = int(a+b)


# In[18]:


sq = [i**2 for i in range(1,319)]


# In[20]:


if ab in sq:
    print("Yes")
else:
    print("No")


# In[ ]:






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

#define INF 1e9
using namespace std;

int main() {

    int N, M; cin >> N >> M;

    vector<vector<pair<int, int>>> city(1e5+1); //ここの数に注意
    for (int i = 0; i < M; ++i) {
        int P, Y;
        cin >> P >> Y;
        --P;
        city[P].push_back({Y, i});
    }

    vector<pair<int, int>> ans(M);
    for (int i = 0; i < N; ++i) {
        //県の中でソート
        sort(city[i].begin(), city[i].end());

        for (int j = 0; j < city[i].size(); ++j) {
            //最初の順番でコンテナに入れていく
            ans[city[i][j].second] = make_pair(i+1, j+1);
        }
    }

    for (int i = 0; i < M; ++i) {
        cout << setw(6) << setfill('0') << ans[i].first;
        cout << setw(6) << setfill('0') << ans[i].second << endl;
    }
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a = 0, b = 0, c = 0, d = 0;
  cin >> n;
  vector<string> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  for (int i=0; i < n; i++){
    if(vec.at(i)=="AC"){
      a++;
    }else if(vec.at(i)=="WA"){
      b++;
    }else if(vec.at(i)=="TLE"){
      c++;
    }else if(vec.at(i)=="RE"){
      d++;
    }
  }
  cout << "AC x  " << a <<  endl;
  cout << "WA x  " << b <<  endl;
  cout << "TLE x  " << c <<  endl;
  cout << "RE x  " << d <<  endl;
}

Measured memory_bytes: 6348
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y, ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        if(y%2==0)
         return (p*p)%z;
        else
        return (x*((p*p)%z))%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
ll po(ll x)
{
    ll c=0;
    while(x>0)
    {
        x=x&(x-1);
        c++;
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    string s;
    cin>>s;
    ll x=0;
    for(int i=0;i<s.length();i++)
    x=x+s[i]-'0';
    if(x%9==0)
    cout<<"Yes";
    else
    cout<<"No";}

Measured memory_bytes: 3712
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "string"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	int l, r;
	cin >> l >> r;
	if (r - l + 1 >= 2019) {
		cout << 0 << endl;
		return 0;
	}
	int ans = 2018 * 2018;
	for (int i = l; i <= r; ++i) {
		for (int j = i + 1; j <= r; ++j) {
			int p = i % 2019;
			int q = j % 2019;
			int r = p * q;
			r = r % 2019;
			ans = min(ans, r);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3576
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
	char a,b,c;
	char d,e,f;
	scanf(" %c %c %c",&a,&b,&c);
	scanf(" %c %c %c",&d,&e,&f);
	if(a==f&&b==e&&c==d)
		printf("YES\n");
	else
		printf("NO\n");
}

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

using namespace std;
int n, d[N][N][2];
long long A[N], F[N][N][2];

long long Magic(int l, int r, int play)
{
    if(r<l) return 0;
    if(d[l][r][play]) return F[l][r][play]; d[l][r][play] = 1;
    int role = play - (play^1);
    if(role>0) return F[l][r][play]=max(A[l]+Magic(l+1, r, play^1), A[r]+Magic(l, r-1, play^1));
    return F[l][r][play]=min(Magic(l+1, r, play^1)-A[l], Magic(l, r-1, play^1)-A[r]);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    for(int i=1; i<=n; i++) cin>>A[i];
    cout<<Magic(1, n, 1);
    return 0;
}


Measured memory_bytes: 131688
def main():
    s = input()
    abcd = [int(s[i:i+1]) for i in range(len(s))]
    op_n = len(abcd) - 1

    for i in range(2 ** op_n):
        operator = ["-"] * op_n
        for j in range(op_n):
            if ((i >> j) & 1):
                operator[(op_n - 1) -j ] = "+"

        ans = [0] * (len(abcd) + 1)
        formula = "{}+".format(ans[0])
        for k in range(len(abcd)):
            if k == 0:
                ans[k+1] = (ans[k] + abcd[k])
                formula += str(abcd[k])
            else:
                ans[k+1] = add_or_sub(ans[k], abcd[k], operator[k-1])
                formula += (operator[k-1] + str(abcd[k]))

        if ans[len(abcd)] == 7:
            print(formula[2:] + "=7")
            break

def add_or_sub(num1, num2, op):
    if op == "+":
        return num1 + num2
    else:
        return num1 - num2

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));		

		int n = Integer.parseInt(reader.readLine());
		int[] numbers = new int[n];
		String[] strArray = reader.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			numbers[i] = Integer.parseInt(strArray[i]);
		}
		int q = Integer.parseInt(reader.readLine());
		int[] targets = new int[q];
		strArray = reader.readLine().split(" ");
		for (int i = 0; i < q; i++) {
			targets[i] = Integer.parseInt(strArray[i]);
		}		
	
		int ans = 0;
		for (int i = 0; i < q; i++) {
			for (int j = 0; j < n; j++) {
				if (targets[i] == numbers[j]) {
					ans++;
					break;
				}
			}
		}
		
		System.out.println(ans);
	}
}


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

using ll = long long;

int a[60];

ll nPr(ll in, ll ir)
{
    if(in<ir)return 0;
    ll ret=1;
    for(ll i=in;i>=ir+1;i--)ret*=i;
    return ret;
}

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

    int n,p;cin>>n>>p;
    bool odd=false;
    for(int i=0;i<n;i++)
    {
        int ia;cin>>ia;

        if(ia%2)odd=true;
    }

    ll ans=1;
    
    if(odd)
    {
        for(int i=0;i<n-1;i++)ans*=2;
    }
    else
    {
        if(p) ans=0;
        else for(int i=0;i<n;i++)ans*=2;
    }
    
    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define inf 2000000000
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false);cin.tie(NULL)
#define rng_23 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef set<int> si;
typedef multiset<int> msi;
typedef map<int,int> mii;
int main()
{
    int i,j,k;
    string str;
    cin>>str;
    for(i=0;i<str.length();i++)
        if(str[i]=='?')
            str[i]='D';
    
    cout<<str;
}


Measured memory_bytes: 3752
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		long N = GetLong();
		long A = GetLong();
		long B = GetLong();
		long C = GetLong();
		long D = GetLong();

		long diff = B - A;
		for(long k = 0; k < N; k++)
		{
			if((diff >= k * C - (N - 1 - k) * D) &&
			   (diff <= k * D - (N - 1 - k) * C))
			{
				Console.WriteLine("YES");
				return;
			}
		}

		Console.WriteLine("NO");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13140
object Main{
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    loop()

    def loop(): Unit = {
      val n = sc.nextInt()
      if (n != 0) {
        val t = (1 to n).map(_ => {
          val a, b = sc.nextInt()
          (b, a)
        }).sorted

        var ans: Boolean = true
        var sum = 0
        t.foreach(ti => {
          if (ans) {
            sum += ti._2
            if (sum > ti._1) {
              ans = false
            }
          }
        })
        println(if (ans) "Yes" else "No")
        loop()
      }
    }
  }
}

Measured memory_bytes: 50300
#include <stdio.h>

int main() {
	int a, b, temp, ans;
	scanf("%d %d", &a, &b);
	if (a > b) {
		temp = a;
		a = b;
		b = temp;
	}
	ans = b;
	b--;
	if (a > b)
		ans += a;
	else
		ans += b;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define N 200005

int n, m;
int tot = 0, fir[N], nxt[N << 1], to[N << 1];
int x[N << 1], y[N << 1], z[N << 1];

inline void addEdge(int u, int v) {
    nxt[++tot] = fir[u], fir[u] = tot, to[tot] = v;
}

int vis[N], d[N];

void dfs(int u) {
    vis[u] = 1;
    for (int i = fir[u], v; i; i = nxt[i]) {
        v = to[i]; if (vis[v]) continue;
        dfs(v);
        if (d[v]) z[(i + 1) / 2] ^= 1, d[v] = 0, d[u] ^= 1;
    }
}

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    cin >> n >> m;
    for (int i = 1; i <= m; ++i)
        scanf("%d%d", x + i, y + i),
        addEdge(x[i], y[i]), addEdge(y[i], x[i]), d[x[i]] ^= 1, z[i] = 1;
    dfs(1);
    if (d[1]) {
        puts("-1");
        return 0;
    }
    for (int i = 1; i <= m; ++i)
        if (z[i]) printf("%d %d\n", x[i], y[i]);
        else printf("%d %d\n", y[i], x[i]);
    return 0;
}


Measured memory_bytes: 14208
N, K = gets.split.map(&:to_i)
v = gets.split.map(&:to_i)
ans = 0

1.upto(K) do |i|
  0.upto(i).each do |j|
    v_copy = v.clone
    h = []
    # shift
    j.times {|k| h << v_copy.shift unless v_copy.empty? }

    # pop
    (i-j).times {|k| h << v_copy.pop unless v_copy.empty? }

    # drop
    h.sort!
    (K - i).times do
      unless h.empty?
        if h.first < 0
          h.shift
        else
          break
        end
      end
    end
    tmp = h.inject(&:+) || 0
    ans = tmp if tmp > ans
  end
end

puts ans

Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    cout << (N - 2) * 180 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main(void)
{
  int n;
  set<string> s;
  cin >> n;
  rep(i,n) {
    string tmp;
    cin >> tmp;
    s.insert(tmp);
  }

  cout << s.size() << endl;
}


Measured memory_bytes: 19260
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		char[] s = saori.nextHayami().toCharArray();
		char[] t = saori.nextHayami().toCharArray();
		boolean flg = false;
		int slen = s.length - 1;
		int tlen = t.length - 1;
        for (int i = slen; i >= tlen; i--) {
            char[] c = s.clone();
            flg = true;
            for (int j = 0; j < tlen + 1; j++) {
                if (s[i-j] == t[tlen-j] || s[i-j] == '?') {
                    c[i-j] = t[tlen-j];
                } else {
                    flg = false;
                    break;
                }
			}

			if (flg) {
                s = c;
                break;
            }
		}
		

		if (flg) {
            for (char ans : s)
				if(ans == '?'){
					System.out.print('a');
				} else {
					System.out.print(ans);
				}
        } else {
            System.out.println("UNRESTORABLE");
        }
		
		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, M;
    cin >> N >> M;
    int a[M+1];
    fill_n(a, M+1, 0);
    int ans = 0;
    rep(i, N){
        int K;
        cin >> K;
        rep(j, K){
            int x;
            cin >> x;
            a[x]++;
        }
    }
    rep(i, M+1){
        if(a[i] == N) ans++;
    }
    cout << ans;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    vi a(5);
    int tot = 0;
    multiset<int> r;
    
    rep(i, 5) {
        cin >> a[i];
        if(a[i] % 10 != 0) r.insert(10 - a[i] % 10);    
        a[i] = (a[i] + 9) / 10;
        a[i] *= 10;
        tot += a[i];
    }
    
    // cout << tot << endl;
    // cout << *r.rbegin() << endl;
    if(r.empty()) cout << tot << endl;
    else cout << tot - *r.rbegin() << endl;
    return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

int main() {
  int N, M;
  scanf("%d%d", &N, &M);

  vector<tuple<int, int, int>> pref_year_id(M);
  for (int i = 0; i < M; i++) {
    int pid, year;
    scanf("%d%d", &pid, &year);
    pref_year_id.at(i) = make_tuple(pid, year, i);
  }

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

  vector<int> pref_id(M), city_id(M), cnt(N + 1);
  for (auto& pyi : pref_year_id) {
    int pid, id;
    tie(pid, ignore, id) = pyi;
    pref_id.at(id) = pid;
    cnt[pid]++;
    city_id.at(id) = cnt[pid];
  }

  for (int i = 0; i < M; i++) {
    cout << setfill('0') << setw(6) << pref_id.at(i);
    cout << setfill('0') << setw(6) << city_id.at(i) << endl;
  }
  return 0;
}


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

#define lli long long
#define FOR(i,a,b) for (lli i=(a);i<(b);i++)
#define REP(i,n) for (lli i=0;i<(n);i++)
#define rep(i,n) for (lli i=0;i<(n);i++)

#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(),(a),end()
#define pll pair<lli,lli>

int main(){
	lli N,x,count=0;
	lli ans[4], out[4];
	cin >> N >> x;
	if (N == 2 and x == 2){
		cout << "Yes" << endl;
		cout << 1 << endl;
		cout << 2 << endl;
		cout << 3 << endl;
		return 0;
	}
	if (x != 1 and x != 2 * N - 1){
		cout << "Yes" << endl;
		if (x < N){
			ans[0] = x + 2;
			ans[1] = x;
			ans[2] = x - 1;
			ans[3] = x + 1;
			rep(i, 4){
				out[i] = N - 1 + i;
				rep(j, 4){
					if (ans[j] == out[i])out[i] = 0;
				}
			}
			sort(out, out + 4,greater<lli>());
			FOR(i,1,2*N){
				if (i >= N - 1 and i <= N + 2){
					cout << ans[i - (N - 1)] << endl;
				}
				else if (i >= x - 1 and i <= x + 2){
						cout << out[count] << endl;
						count++;
				}
				else{
					cout << i << endl;
				}
			}
		}
		else{
			ans[0] = x - 2;
			ans[1] = x;
			ans[2] = x + 1;
			ans[3] = x - 1;
			rep(i, 4){
				out[i] = N - 1 + i;
				rep(j, 4){
					if (ans[j] == out[i])out[i] = 0;
				}
			}
			sort(out, out + 4, greater<lli>());
			FOR(i,1,2*N){
				if (i >= N - 1 and i <= N + 2){
					cout << ans[i - (N - 1)] << endl;
				}
				else if (i >= x - 2 and i <= x + 1){
					cout << out[count] << endl;
					count++;
				}
				else{
					cout << i << endl;
				}
			}
		}
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef double D;

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

    int n;
    cin>>n;

    int arr[n + 7], b[n+7];
    arr[0]=0;
    b[n+1]=0;
    b[0]=0;
    int p;
    for(int i=1;i<=n;i++){
        cin>>b[i];
        arr[i]=arr[i-1]+abs(b[i-1]-b[i]);
    }
    arr[n+1]=arr[n]+abs(b[n]);


    for(int i=1;i<=n;i++){
       cout<<arr[n+1] - abs(b[i-1]-b[i])-abs(b[i]-b[i+1]) + abs(b[i-1]-b[i+1]) <<endl;
    }

    return 0;
}


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

int n, mid, l, r, ty;
string s;

int check(int i)    {
    cout << i << '\n'; cout.flush();
    cin >> s;
    if(s == "Male") return 1;
    else if(s == "Female") return 2;
    else return 0;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> n;
    int l = 0, r = n - 1;
    int las = check(0);
    if(!las) return 0;
    int lasr = check(n - 1); if(!lasr) return 0;

    while(l + 1 != r)    {
        int mid = (l + r) / 2;
        int tmp = check(mid);
        if(abs(tmp - las) != mid % 2) r = mid;
        else l = mid;
    }

    las = check(l); cout.flush();
    if(!las) return 0;
    else {
        cout << r << '\n'; cout.flush();
    }

    return 0;
}


Measured memory_bytes: 852
import bisect
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n = ri()
ls = ris(n)
ls = [-x for x in ls]

dp = [float('inf')] * n
for x in ls:
    dp[bisect.bisect_right(dp, x)] = x
print(bisect.bisect_left(dp, float('inf')))

Measured memory_bytes: 11064
l, r = gets.split.map{|i|i.to_i}
mini = (2e9 + 1).to_i

if r-l > 2018
  puts 0
  exit
else
  l.upto(r) do |i|
    (i+1).upto(r) do |j|
      mini = [mini, i*j%2019].min
    end
  end
end

puts mini

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
long long a[3000];
long long sum[3000];
int main()
{
    int n,k;
    cin >> n>>k;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }
    vector<long long> v[2];
    for(int i = 1; i<= n; i++)
    {
        for(int j = 0; j< i;j++)
        {
            v[0].push_back(sum[i] - sum[j]);
        }
    }
    for(int i = 60; i>= 0; i--)
    {
       // cout<<'!';
        long long s = (1ll << i);
        int cnt = 0;
        int t;
        int t1;
        if(i % 2)
        {
            t = 1;
            t1 = 0;
        }
        else
        {
            t1 = 1;
            t = 0;
        }
        for(auto x: v[t])
        {
           // cout<<x<<' ';
            if(x & s)
                cnt++;
        }
        //cout<<endl;
        v[t1].clear();
        for(auto x: v[t])
        {
            if(cnt >= k && !(x & s))
            {
                continue;
            }
            v[t1].push_back(x);
        }
        //return 0;
    }
    //return 0;
    long long ans = (1ll << 61) - 1;
  //  for(auto x: v[0])
    //        cout <<'!'<<x<<endl;
  //  cout << v[0][0]<<' '<<v[0][1]<<endl;
    for(int i = 0; i<k; i++)
    {
        //cout << <<v[0][i]<<endl;;
        ans &= v[0][i];
    }
    cout<<ans;
}



Measured memory_bytes: 11756