akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define debug cerr << "-- " << __LINE__ << " --" << endl
#define MOD 1000000007
#define ALL(o) (o).begin(), (o).end()
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template <typename T> string to_string(const vector<T> &xs) {string s="["; for(int i=0;i<xs.size();i++) s += (i>0 ? " " : "") + to_string(xs[i]); return s + "]";}
template <typename T> ll argmax(const T &xs) {return distance(xs.begin(), max_element(xs.begin(), xs.end()));}
template <typename T> ll argmin(const T &xs) {return distance(xs.begin(), min_element(xs.begin(), xs.end()));}
ll nextLL(){ll x; scanf("%lld", &x); return x;}
int nextInt(){int x; scanf("%d", &x); return x;}
string nextString(){string s; cin >> s; return s;}

ll n;
vector<ll> p, q;

bool equal(vector<ll> &a, vector<ll> &b){
	for(ll i=0;i<a.size();i++) if (a[i] != b[i]) return false;
	return true;
}

int main(void){
	cin >> n;
	for(ll i=0;i<n;i++) p.pb(nextLL());
	for(ll i=0;i<n;i++) q.pb(nextLL());
	vector<ll> perm(n); for(ll i=0;i<n;i++) perm[i] = 1 + i;
	ll a, b, cnt = 0;
	do{
		if (equal(perm, p)) a = cnt;
		if (equal(perm, q)) b = cnt;
		cnt++;
	}while (next_permutation(ALL(perm)));

	cout << llabs(a - b) << endl;

    return 0;
}




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

int main()
{
   int x;
   cin >> x;
   int num = x/100;
   if(x>=2000)
   {
      cout<<1<<endl;
      return 0;
   }

   if(num*5>=(x%100))
   {
      cout<<1<<endl;
   }
   else
   {
      cout<<0<<endl;
   }
   

   return 0;
}

Measured memory_bytes: 256
/*input

*/
#include <iostream>
#include <fstream>
#include <bitset>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <utility>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <assert.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define MOD 1000000007ULL
#define MOD2 1000000009ULL
#define INF 1000000000ULL
#define F first
#define S second
#define eps 1e-9
#define PI 3.14159265358979
#define gcd __gcd
#define sd(x) scanf("%d", &(x))
#define slld(x) scanf("%lld", &(x))
#define ss(x) scanf("%s", x)
#define sc(x) scanf(" %c", &x)
#define pd(x) printf("%d\n", (x))
#define plld(x) printf("%lld\n", (x));
#define gc getchar

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<int, int> vii;
typedef vector<ll, ll> vll;

void scanint(int &x)
{
    register int c = gc();
    bool flag = false;
    x = 0;
    for(;((c<48 && c!=45) || c>57);c = gc());
    if(c==45)
    {
		flag = true;
		c = gc();
    }
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(flag)
    	x = x - (x<<1);
    return;
}

void scanll(ll &x)
{
	register long long c;
	bool flag = false;
	x = 0;
	for(;((c<48 && c!=45) || c>57);c = gc());
	if(c==45)
	{
		flag = true;
		c = gc();
	}
	for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
	if(flag)
    	x = x - (x<<1);
	return;
}

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

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

	// clock_t clk;
	// clk = clock();
	// freopen("in.in", "r", stdin);
	// freopen("out.out", "w", stdout);
	
	ll x, y;
	cin >> x >> y;

	ll g = gcd(x, y);
	if(g == y)
	{
		cout << "-1\n";
		return 0;
	}
	cout << x << "\n";

	// clk = clock() - clk;
	// cout << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	// printf("Time: %lf", ((double)clk)/CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 256
k, s = map(int, input().split())

n = 0
for x in range(k+1):
    ss = s - x
    if 0 <= ss < k:
        n += ss + 1
        #print('S', x, ss, ss + 1)
    elif k <= ss < 2*k +1:
        n += 2*k - ss + 1
        #print('L', x, ss, 2*k - ss + 1)
     
print(n)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,y;
    cin >> n >> y;
    y /= 1000;
    bool ok = false;
    int i,j,k;
    for(i=0;i<=n;i++){
        for(j=0;j<=n-i;j++){
            k = n - i - j;
            if(i*10+j*5+k==y){
                ok = true;
                break;
            }
        }
        if(ok) break;
    }
    if(ok){
        cout << i << " " << j << " " << k << endl;
    }else{
        cout << -1 << " " << -1 << " " << -1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
  //#ifndef ONLINE_JUDGE
      // for getting input from input.txt
      //freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      //freopen("output.txt", "w", stdout);
  //#endif
fast();
//ll  t;cin>>t;while(t--)
{
  ll k;
  int a[3];
  cin >> a[0]>>a[1]>>a[2];
  cin>>k;
  sort(a,a+3,greater<int>());
  ll ans=pow(2,k)*a[0] + a[1]+a[2];
    //cout<<"ans ";
  cout<<ans<<endl;
  

}
return 0;
}

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

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int mod = (int) 1e9 + 7;
	static int inf = (int) 1e8;
	static int[] col;
	static int n, m, k;
	static ArrayList<Integer>[] ad;
	static int[][][] memo;
	static ArrayList<Integer> h;
	static char[][] grid;
	static int[] a;
	static boolean f;
	static int offest = 30;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		System.out.println(sc.nextInt()*sc.nextInt());
		out.flush();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 32696
// C++ program to find prime factorization of a 
// number n in O(Log n) time with precomputation 
// allowed. 
#include "bits/stdc++.h" 
using namespace std; 
  
#define MAXN   10000001
  
// stores smallest prime factor for every number 
int spf[MAXN]; 
  
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  
// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
vector<int> getFactorization(int x) 
{ 
    vector<int> ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 
  
// driver program for above function 
int main(int argc, char const *argv[]) 
{ 
    // precalculating Smallest Prime Factor 
    sieve(); 
  
    int n;
    cin>>n;
    long long int ans=0;
    for (int i=1;i<=n;i++){
        vector <int> p = getFactorization(i);
        map <int,int> m;
        for (auto j : p)
            m[j]++;
        long long int temp=1;
        for (auto j : m)
            temp*=(j.second+1);
        ans+=i*1LL*temp;    
    }
    cout<<ans<<"\n";
    return 0; 
} 


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

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int n;
	cin >> n;
	vector<long long> a(n + 1), dp(n + 1, 0), pre(n + 1, 0);
	for (int i = 1; i <= n; ++i){
		cin >> a[i];
	}
	pre[1] = a[1];
	for (int i = 2; i <= n; ++i){
		pre[i] = pre[i - 2] + a[i];
	}
	dp[1] = 0;
	for (int i = 2; i <= n; ++i){
		if (i & 1){
			dp[i] = max(dp[i - 1], dp[i - 2] + a[i]);
		}
		else{
			dp[i] = max(dp[i - 2] + a[i], pre[i - 1] );
		}
	}
	cout << dp[n];
	return 0;
}



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

int main()
{
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	int cnt = 0;
	while (a >= b)
	{
		b *= 2;
		cnt++;
	}
	while (b >= c)
	{
		c *= 2;
		cnt++;
	}
	if (cnt <= k) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
long long gcd(long long a,long long b){
   if(b==0)return a;
   return gcd(b,a%b);
}
long long lcm(long long a,long long b){
   return a*b/gcd(a,b);
}

int main(){
   long long a,b,c,d;
   cin>>a>>b>>c>>d;
   
   long long aa,bb;
   long long e=lcm(c,d);
   aa=a-1-((a-1)/c+(a-1)/d-(a-1)/e);
   bb=b-(b/c+b/d-b/e);
   

   cout<<bb-aa<<endl;
}

   


Measured memory_bytes: 888
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n=int(input())
    A=[0]*n
    st=[[] for _ in range(n)]
    for i in range(n):
        a=int(input())
        for j in range(a):
            x,y=map(int,input().split())
            st[i].append((x,y))

    
    # bit全探索    
    # https://qiita.com/gogotealove/items/11f9e83218926211083a#%E4%BE%8B%E9%A1%8C-1
    # 昇順での探索だよ
    ans=0
    for i in range(2 ** n):
        inconsistent=False
        cnt=0
        for j in range(n):  # このループが一番のポイント
            if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                cnt+=1
                for p in st[j]:
                    if p[1]==1 and not ((i >> (p[0]-1) & 1)):
                        inconsistent=True
                    elif p[1]==0 and not not ((i >> (p[0]-1) & 1)):
                        inconsistent=True
            else:
                continue
            

        if not inconsistent:
            ans=max(ans,cnt)
    print(ans)
    

    
resolve()

Measured memory_bytes: 43248
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        int D = int.Parse(ReadLine());
        if (D == 25) WriteLine("Christmas");
        if (D == 24) WriteLine("Christmas Eve");
        if (D == 23) WriteLine("Christmas Eve Eve");
        if (D == 22) WriteLine("Christmas Eve Eve Eve");
    }
}


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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint n;


void solve(){
	string s;
	cin >> s;
	if(s=="ABC")cout << "ARC";
	else cout << "ABC";
	cout <<endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}
   

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  string S;
  cin>>S;
  
  if(S=="SUN")
    cout<<7<<endl;
    if(S=="MON")
    cout<<6<<endl;
    if(S=="TUE")
    cout<<5<<endl;
    if(S=="WED")
    cout<<4<<endl;
    if(S=="THU")
    cout<<3<<endl;
    if(S=="FRI")
    cout<<2<<endl;
    if(S=="SAT")
    cout<<1<<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  int count = 0;
  bool flag = false;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    if (a == b)
      count++;
    else
      count = 0;
    if (count == 3) {
      flag = true;
      break;
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, k;
  cin >> n >> k;
  
  if (n > k) {
    n -= (n / k) * k;
  }
  
  ll ans = min(n, k - n);
  
  cout << ans << '\n';
}

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

satisfaction = sum(B)

for i in range(N-1):
    if (A[i+1]-A[i]==1):
        satisfaction += C[A[i]-1]
print(satisfaction)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int x;
  cin>>x;
  if(x>=30){
    cout<<"Yes"<<'\n';
  }
  else{
    cout<<"No"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 3688
import math
N = int(input())
csf = [list(map(int, input().split())) for _ in range(N - 1)]

for n in range(N):
    ans = 0
    for c, s, f in csf[n:]:
        if ans > s:
            tmp = math.ceil((ans - s) / f)
            ans = s + tmp * f + c
        else:
            ans = s + c
    print(ans)



Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
N = int(input())
An = list(map(int, input().split()))
DIV = 10**9 + 7

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

abs_cnt = {}
for Ai in An:
    if Ai in abs_cnt:
        abs_cnt[Ai] += 1
    else:
        abs_cnt[Ai] = 1

# print(abs_cnt)

jijo = 0
if N%2 == 0:
    for k,v in abs_cnt.items():
        if k % 2 == 1 and v == 2:
            jijo += 1
        else:
            print(0)
            exit()
else:
    for k, v in abs_cnt.items():
        if k % 2 == 0 and v == 2:
            jijo += 1
        elif k == 0 and v == 1:
            pass
        else:
            print(0)
            exit()

print(2**jijo%DIV)


Measured memory_bytes: 14436
/*
 * atcoder/abc128/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int N, M;
vector<int> S[11];
bool P[11];

ll all = 0;

void solve() {
  cin >> N >> M;
  int k, s;
  loop(m,0,M) {
    cin >> k;
    loop(i,0,k) {
      cin >> s; s--;
      S[m].push_back(s);
    }
  }
  loop(m,0,M) cin >> P[m];
  loop(n,0,N) all |= (1<<n);

  ll count = 0;
  for (ll T=0; T<=all; T++) {
    bool inc = true;
    loop(m,0,M) {
      int count = 0;
      for (auto &&s: S[m]) {
        count += (T>>s);
      }
      inc &= count%2 == P[m];
    }
    count += inc;
  }
  cout << count << endl;
}
int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  int N;
  cin >> N;
  vector<int> l(N);
  for (auto& elm : l) {
    cin >> elm;
  }

  int result = 0;
  rep(i, N) rep(j, i) rep(k, j) {
    if (l[i] != l[j] and l[j] != l[k] and l[k] != l[i] and
        l[i] < l[j] + l[k] and l[j] < l[k] + l[i] and l[k] < l[i] + l[j]) {
      result++;
    }
  }
  cout << result << endl;
  return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    for(int i=0;i<=1009;++i){
        if(floor(i*0.08) == a && floor(i*0.10) == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
import sys


def main():
    n, m = map(int, input().split())
    As = sorted(list(map(int, input().split())))[::-1]

    all_vote = sum(As)
    for i in range(m):
        if all_vote/(4*m) > As[i]:
            print('No')
            sys.exit()

    print('Yes')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define reps(i, n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define repi(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n+1);
    reps(i,n) cin>>a.at(i);
    
    for(int i=n/2;i>=1;i--){
        int sum=0;
        for(int j=i*2;j<=n;j+=i) sum+=a.at(j);
        if(sum%2==1) a.at(i)=1-a.at(i);
    }
    
    int ans=0;
    reps(i,n) ans+=a.at(i);
    cout<<ans<<endl;
    reps(i,n){
        if(a.at(i)==1) cout<<i<<endl;
    }
    
}


Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  ll rem=0;
  if(n%2==0)rem=1;
  else rem=2;
  auto dp=vec(n+1,rem+1,-INF);
  dp[0][0]=0;
  rep(i,0,n){
    rep(j,0,rem+1){
      ll idx=i+2-(i==0);
      rep(o,0,rem+1){
        if(j+o>rem||idx-1+o>=n)continue;
        chmax(dp[idx+o][j+o],dp[i][j]+a[idx-1+o]);
      }
    }
  }
  //debug(dp,n+1,rem+1);
  ll ret=-INF;
  if(n&1){
    chmax(ret,dp[n][1]);
    chmax(ret,dp[n][2]);
    rep(i,0,rem+1)chmax(ret,dp[n-1][i]);
    chmax(ret,dp[n-2][0]);
  }
  else{
    rep(i,n-1,n+1)rep(j,0,rem+1)chmax(ret,dp[i][j]);
  }
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 15876
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
typedef long long lint;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	string N;


		cin >> N;

		vector<vector<vector<int>>> dp(N.size() + 1, vector<vector<int>>(2, vector<int>(8)));
		dp[0][0][0] = 1;
		for (int i = 0; i < N.size(); i++) {

			dp[i + 1][1][0] = 1;
			for (int mask = 0; mask < 8; mask++) for (int bit = 0; bit <= 2; bit++) dp[i + 1][1][mask | (1 << bit)] += dp[i][1][mask];
			if (N[i] > '3') {
				for (int mask = 0; mask < 8; mask++) dp[i + 1][1][mask | 1] += dp[i][0][mask];
			}
			if (N[i] > '5') {
				for (int mask = 0; mask < 8; mask++) dp[i + 1][1][mask | 2] += dp[i][0][mask];
			}
			if (N[i] > '7') {
				for (int mask = 0; mask < 8; mask++) dp[i + 1][1][mask | 4] += dp[i][0][mask];
			}
			if (N[i] == '3') {
				for (int mask = 0; mask < 8; mask++) dp[i + 1][0][mask | 1] += dp[i][0][mask];
			}
			if (N[i] == '5') {
				for (int mask = 0; mask < 8; mask++) dp[i + 1][0][mask | 2] += dp[i][0][mask];
			}
			if (N[i] == '7') {
				for (int mask = 0; mask < 8; mask++) dp[i + 1][0][mask | 4] += dp[i][0][mask];
			}
		}

		cout << dp[N.size()][0][7] + dp[N.size()][1][7] << "\n";


	return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		int ans = 0;
		for(int i = 0;i<S.length();i++){
			if(S.charAt(i) == '1'){
				ans += 1;
			}else{
				ans -= 1;
			}
		}
		System.out.println(S.length() - Math.abs(ans));
	}
}


Measured memory_bytes: 25044
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

struct CountUnionFind{
    int sz;     // vertex number
    vector<int> par;
    vector<int> rank;
    vector<int> cnt;

    CountUnionFind(int n) : sz(n) {
        par.resize(sz);
        rank.assign(sz, 0);
        cnt.assign(sz, 1);
        for(int i = 0; i < sz; ++i){
            par[i] = i;
        }
    }

    int find(int x){
        if(par[x] == x) return x;
        else    return par[x] = find(par[x]);
    }

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

    void unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y)  return;
        if(rank[x] < rank[y]){
            par[x] = y;
            cnt[y] += cnt[x];
        }
        else{
            par[y] = x;
            cnt[x] += cnt[y];
            if(rank[x] == rank[y])  ++rank[x];
        }
    }

    int get_cnt(int x){
        return cnt[find(x)];
    }
};

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

    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    for(int i = 0; i < m; ++i)  cin >> a[i] >> b[i], --a[i], --b[i];
    vector<ll> output(m);
    output[m-1] = (ll)n * (n - 1) / 2;

    CountUnionFind uf(n);
    for(int i = m - 1; i > 0; --i){
        if(uf.same(a[i], b[i])) output[i-1] = output[i];
        else{
            output[i-1] = output[i] - (ll)uf.get_cnt(a[i]) * uf.get_cnt(b[i]);
            uf.unite(a[i], b[i]);
        }
    }
    for(int i = 0; i < m; ++i)  cout << output[i] << "\n";
}

Measured memory_bytes: 4096
#![allow(unused)]

use proconio::input;
use proconio::marker::{Bytes, Chars, Usize1};
use std::cmp::{Reverse, min, max};
use itertools::Itertools;

#[proconio::fastout]
fn main() {
    input! {
        a: i64,
        b: i64,
    }
    println!("{}", a * b);
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define LL long long 
const int mod=1000000007;
const int N=500;
using namespace std;
char a[N],b[N];
int n;
LL ans;
int main()
{
	scanf("%d",&n);
	scanf("%s",&a);
	scanf("%s",&b);
	for(int i=n;i>=1;--i) a[i]=a[i-1],b[i]=b[i-1];
    
//for(int i=1;i<=n;++i)
// printf("%c",b[i]);
// cout<<endl;    
    
    for(int i=1;i<=n;)
    {
      if(i==1)
      {
      	if(a[i]==b[i]) ans=3,i=i+1;
      	else ans=6,i=i+2;
	    continue;
	  }
	  else 
	  {
	    if(a[i]==b[i]) 
	     {
	     	if(a[i-1]==b[i-1]) ans=(LL)ans*2*1LL%mod,i=i+1;
	     	else  i=i+1;
            continue;
		 }
		else
		{
		  if(a[i-1]!=b[i-1]) ans=(LL)ans*3%mod,i=i+2;
		  else ans=(LL)ans*2%mod,i=i+2;
		  continue;
		}
	  }
	}
	cout<<ans%mod<<endl;
}
/*
5
abbWW
acctt

52
RvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn
RLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn
*/

Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;

fn read_str_as_char_vec () -> Vec<char>
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().chars().collect()
}

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn main() {
    let s = read_str_as_char_vec();
    
    if s[0] == s[1] && s[1] == s[2] {
        println!("No");
    } else {
        println!("Yes");
    }
}


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

const int MAX = 510000;
const int MOD = 1000000007;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  long long N,M,K;
  cin >> N >> M >> K;
  COMinit();
  long long ans=N*M*(3*N*M*(N+M-2)-N*(M-1)*(M-2)-M*(N-1)*(N-2))/12%MOD*COM(N*M-2,K-2)%MOD;
  cout << ans << endl;
}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
typedef long long ll;
const int INF = 1<<29;
const int N = 1e6 + 9;
ll a[N];
bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b)
{
    if(a.second == b.second){
        return a.first < b.first;
    }
    return a.second < b.second;
}
int main()
{
    fio;
    string s;
    cin >> s;
    map <char, ll> m;
    for(int i = 0; i < s.size(); i ++){
        m[s[i]] ++;
    }
    if(m['A'] > 0 && m['B'] > 0){
        cout << "Yes" ;
    }
    else cout << "No";
    return 0;
}


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

int main(){
    int ab, bc, ca;
    cin >> ab >> bc >> ca;
    if(ab > bc && ab > ca){
        cout << bc * ca /2<<endl;
    }
    else if(bc > ab && bc > ca){
        cout << ab * ca /2<<endl;
    }
    else if(ca > ab && ca > bc){
        cout << ab * bc /2 <<endl;
    }    
    
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
dp = [0] * n
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i-2]))
print(dp[n - 1])


Measured memory_bytes: 20616
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let _n: usize = input();
    let k: usize = input();
    let mut s: Vec<char> = input::<String>().chars().collect();

    let k = k - 1;
    if s[k] == 'A' {
        s[k] = 'a';
    } else if s[k] == 'B' {
        s[k] = 'b';
    } else {
        s[k] = 'c';
    }
    println!("{}", s.iter().cloned().collect::<String>());
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
  
  
int gcds(int i,int j ,int k){
int e=gcd(i,j);
  int d=gcd(e,k);
  return d;
}
int main(){
int k;
cin>>k;
int sum=0;
for(int i=1;i<k+1;i++){for(int j=1;j<k+1;j++){for(int l=1;l<k+1;l++){
  sum=sum+gcds(i,j,l);
}}}
  cout<<sum<<endl;
}

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

using namespace std;

const int N = 100005;

int n, m, f[N];
vector <int> g[N];

int call (int u) {
  if (f[u]) return f[u];
  f[u] = 1;
  for (int v : g[u]) {
    f[u] = max(f[u], 1 + call(v));
  }
  return f[u];
}

int main() {
  cin >> n >> m;
  while (m--) {
    int u, v;
    scanf("%d %d", &u, &v);
    g[u].push_back(v);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans = max(ans, call(i));
  }
  cout << ans - 1 << '\n';
  return 0;
}



Measured memory_bytes: 7424
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//??°?????????
		while(true){


		//n?????°?????????
		int n = sc.nextInt();
		//x?????°????????? ????????°??§??????
		int x = sc.nextInt();
		//n??¨x???0????????????
		if(n == 0 && x == 0){
			break;
		}
		int sum = 0; //?????????

		for(int i = 3; i <= n; i++){
			for(int j = 2; j < i;j++){
				for(int k = 1; k < j; k++){
					if(x == (i + j + k)){
						sum++;
					}
				}
			}
		}
		//???????????¨???
		System.out.println(sum);
		}
	}
}

Measured memory_bytes: 26496
MAX_VALUE =10 ** 9 + 1
$count = 0

def merge(array, left, mid, right)
  array_left = array[left..mid]
  array_right = array[mid+1..right]
  array_left << MAX_VALUE
  array_right << MAX_VALUE
  l = 0
  r = 0
  sorted = []

  (right-left+1).times do 
    if (array_left[l] > array_right[r]) then
      sorted << array_right[r]
      $count += (array_left.size - 1 -l)
      r += 1
    else
      sorted << array_left[l]
      l += 1
    end
  end

  array[left, right-left+1] = sorted
end

def merge_sort(array, left, right)
  mid = (left + right) / 2
  if (right - left > 1) then
    merge_sort(array, left, mid)
    merge_sort(array, mid+1, right)
    merge(array, left, mid, right)
  elsif (right - left == 1) then
    merge(array, left, mid, right)
  end
end

n = gets.chomp.to_i
array = gets.chomp.split.map(&:to_i)
merge_sort(array, 0, n-1)
puts $count

Measured memory_bytes: 50080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int strsum(const int n){
    string s = to_string(n);
    int b(0);
    rep(i,s.size()){
        b += s[i]-'0';
    }
    return b;
}

int main(){
    int s,w;
    cin >> s >> w;

    if(w>=s)    puts("unsafe");
    else    puts("safe");

    return 0;
}

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

using namespace std;

typedef long long ll;

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

	ll a, b, c;
	cin >> a >> b >> c;

	if(c < a + b){
		cout << "No" << endl;
		return 0;
	}
	
	if(a * b * 4 < (c - a - b) * (c - a - b)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

}


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

signed main() {

    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n){
        cin >> p[i];
    }

    int ans = 0;
    rep(i, n){
        if(p[i] == i+1){
            if(i+1 == n){
                swap(p[i], p[i-1]);
            }
            else{
                swap(p[i], p[i+1]);
            }
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


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

#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
#define vec vector<int>
#define dead not_bad
#define bad gooood

#define left not_right
#define y1 what

using namespace std;

const int N = (int) 2e5 + 10;
const int M = (int) 20;
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const int ALPHA = 26;
const int mod = INF + 2;
const double PI = 3.14159265359;
const ld EPS = (ld) 1e-12;

const int nx[4] = {0, 0, -1, 1};
const int ny[4] = {1, -1, 0, 0};

int n;
int a[N];
int x, y;

int main() {
  #define fn "saddle"
  #ifdef witch
      freopen("input.txt", "r", stdin);
  //    freopen("output.txt", "w", stdout);
  #else
      //freopen(fn".in", "r", stdin);
      //freopen(fn".out", "w", stdout);
  #endif
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort (a + 1, a + n + 1);
  int mn = INF, id = 1;
  for (int i = 1; i <= n; i++) {
    int cur = min(abs((a[n] + 1) / 2 - a[i]), abs(a[n] / 2 - a[i]));
    if (mn > cur) {
        id = i;
        mn = cur;
    }
  }
  cout << a[n] << ' ' << a[id];
  return 0;
}


Measured memory_bytes: 640
from collections import deque
n, m = list(map(int, input().split()))
connects = [[] * n for _ in range(n)]
for _ in range(m):
    i, j = list(map(int, input().split()))
    connects[i - 1].append(j - 1)
    connects[j - 1].append(i - 1)
stack = deque([0, ])
visited = [-1] * n
while stack:
    x = stack.popleft()
    for dx in connects[x]:
        if visited[dx] == -1:
            visited[dx] = x + 1
            stack.append(dx)
        else:
            continue
print('Yes')
[print(i) for i in visited[1:]]

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    vector<ll> a(n); cin >> a;
    each(x, a) --x;
    vector<ll> pos(n);
    rep(i, n) pos[a[i]] = i;
    vector<ll> dp(n, 1);
    rep(i, n) {
        if (a[i] > 0 && pos[a[i]-1] < i) {
            chmax(dp[i], dp[pos[a[i]-1]]+1);
        }
    }
    ll ans = n - *max_element(all(dp));
    cout << ans << endl;
}


Measured memory_bytes: 4992
import sys
input = sys.stdin.readline
S = int(input())
mod = 10 ** 9 + 7

class Factorial:
  def __init__(self, n, mod):
    self.mod = mod
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod
  def permi(self, n, k):
    return self.f[n] * self.i[n - k] % self.mod

f = Factorial(S, mod)

res = 0
for x in range(1, S // 3 + 1):
  r = S - x * 3
  res += f.combi(x + r - 1, r)
  res %= mod
print(res)

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

using namespace std;

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

    for (int i = 0; i < n.length(); ++i) {
        if (n[i] == '1')
            cout << '9';
        else
            cout << '1';
    }
    cout << '\n';
}


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

string ACL = "ACL";

int main() {
  int K;
  cin >> K;
  for (int i = 0; i < K; i++) {
    cout << ACL;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cmath>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  ll d, n;
  cin >> d >> n;
  if(d==2 && n==100){
    cout << 1010000 << endl;
    return 0;
  }
  if(n == 100){
    cout << pow(100, d) * 101 << endl; 
  }else{
    cout << pow(100, d) * n << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.10lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[6] = {-1,-1,0,0,1,1};
int dy[6] = {-1,0,-1,1,0,1};

int n;
int a[200005];


int main(){
    string s;
    cin>>s;
    string x="";
    for(int i=0;i<s.size();++i){
        x+='x';
    }
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N; ll K;
int ans[MAX_N][2];

void add(int i, int a, int b) {
	ans[i][0] = a; ans[i][1] = b;
}

void solve() {
	cin >> N >> K;
	if(N - 1 > 2 * (N - K)) {
		cout << -1 << "\n"; return;
	}
	rep(i, 0, (N + 1) / 2) {
		add(i, i * 2, (N - 1) / 2 - i);
	}
	rep(i, 0, N / 2) {
		add(i + (N + 1) / 2, i * 2 + 1, N - 1 - i);
	}
	rep(i, 0, N) {
		cout << ans[i][0] + K << " " << ans[i][1] + N + K << " " << 2 * N + i + K << "\n";
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

using namespace std;

int n, a, m, sum;

int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> a;
		sum += a;
	}
	if (sum > n)
		cout << -1;
	else
		cout << n - sum;
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
int P[50];
int main(){
  int i, k;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(P[Lj4PdHRW]);P[Lj4PdHRW] += (-1);
    }
  }
  k = 0;
  for(i=0;i<N;i++){
    if(P[i]!=i){
      k++;
    }
  }
  if(k <= 2){
    wt_L("YES");
    wt_L('\n');
  }
  else{
    wt_L("NO");
    wt_L('\n');
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
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;
}
const long long INF = 1LL << 60;

//入力
string s, t;

//DPテーブル
int dp[3100][3100] = {0}; //初期値も初期条件も0

int main()
{
    cin >> s >> t;

    //DP roop
    for (int i = 0; i < s.size(); ++i)
    {
        for (int j = 0; j < t.size(); ++j)
        {
            if (s[i] == t[j])
                chmax(dp[i + 1][j + 1], dp[i][j] + 1);
            chmax(dp[i + 1][j + 1], dp[i + 1][j]);
            chmax(dp[i + 1][j + 1], dp[i][j+1]);
        }
    }

    //復元
    string res = "";
    int i = (int)s.size(), j = (int)t.size();
    while (i > 0 && j > 0)
    {
        //(i, j-1)->(i, j)と更新されていた場合
        if (dp[i][j] == dp[i - 1][j])
        {
            --i; //DPの遷移を遡る
        }
        //(i-1, j-1) ->(i, j)と更新されていた場合
        else if (dp[i][j] == dp[i][j - 1])
        {
            --j; //DPの遷移を遡る
        }
        //(i-1, j-1)->(i,j)と更新されていた場合
        else
        {
            res = s[i - 1] + res; //この時、s[i-1] == t[j-1]なので、t[j-1]+resでもOK
            --i, --j;
        }
    }
    cout << res << endl;
}

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

int main(){
  int n, b, f, r, v;
  int nor[5][4][11]={};

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>b>>f>>r>>v;
    nor[b][f][r]+=v;
  }

  for(int i=1;i<=4;i++){
    for(int j=1;j<=3;j++){
      for(int k=1;k<=10;k++){
	cout<<" "<<nor[i][j][k];
      }
      cout<<endl;
    }
    if(i!=4) cout<<"####################"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3096