akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	static Process[] stack;
	static int firstPointer = 0;
	static int lastPointer;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int processNum = sc.nextInt();
		int quanTime = sc.nextInt();
		stack  = new Process[processNum + 1];
		for(int i = 0; i < processNum; i++) {
			Process process = new Process(sc.next(), sc.nextInt());
			stack[i] = process;
		}
		sc.close();
		lastPointer = processNum;
		int time = 0;
		Process[] answerProcesses = new Process[processNum];
		int answerProcessesIndex = 0;
		while(firstPointer != lastPointer) {
			Process process = dequene();
			int processTime = process.time;
			if(processTime <= quanTime) {
				time += processTime;
				process.time = time;
				answerProcesses[answerProcessesIndex] = process;
				answerProcessesIndex++;
			} else {
				time += quanTime;
				process.time -= quanTime;
				enquene(process);
			}
		}
		for(Process process: answerProcesses) {
			System.out.println(process.name + " " + process.time);
		}
	}
	public static void enquene(Process process) {
		stack[lastPointer] = process;
		if(lastPointer == stack.length - 1) {
			lastPointer = 0;
		} else {
			lastPointer++;
		}
	}
	public static Process dequene() {
		Process process = stack[firstPointer];
		if(firstPointer == stack.length - 1) {
			firstPointer = 0;
		} else {
			firstPointer++;
		}
		return process;
	}
}
class Process {
	String name;
	int time;
	public Process(String name, int time) {
		this.name = name;
		this.time = time;
	}
}

Measured memory_bytes: 77136
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

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

int n, m, a, b, ans;
vector<int> G[100009];
int we[100009], dp[100009];
queue<int> Q;

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

    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        G[a].pb(b);
        we[b]++;
    }

    for (int i = 1; i <= n; i++)
    {
        if (we[i] == 0) Q.push(i);
    }

    while (!Q.empty())
    {
        int v = Q.front();
        Q.pop();

        for (int i = 0; i < G[v].size(); i++)
        {
            int w = G[v][i];

            dp[w] = max(dp[w], dp[v] + 1);
            we[w]--;

            if (!we[w]) Q.push(w);
        }
    }

    for (int i = 1; i <= n; i++)
    {
        ans = max(ans, dp[i]);
    }

    cout << ans << "\n";
}

Measured memory_bytes: 9768
#include <algorithm>
#include <cmath>
#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 < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (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--)

int main()
{
    int a, b;
    cin >> a >> b;

    if (a >= 1 && a <= 9 && b >= 1 && b <= 9) {
        cout << a * b << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  int n; cin >>n;
  int temp=0;
  rep(i,n){
    int a; cin >>a;
    if(temp+1==a) temp++;
  }
  int ans;
  if(temp==0) ans=-1;
  else ans=(n-temp);
  printf("%d",ans);
}

/// confirm df==0 ///


Measured memory_bytes: 256
def main():
    N = [int(x) for x in input()]
    dp0 = 0
    dp1 = 1
    for n in N:
        # そのまま払う
        a = min(dp0 + n, dp1 + 10 - n)
        # 1多めに払う
        b = min(dp0 + n + 1, dp1 + 10 - (n+1))
        dp0, dp1 = a, b
        
    print(dp0)
 
 
if __name__ == '__main__':
    main()

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  = 3.141592653589793238463;
const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code

int main()
{
  string s;
  cin>>s;
  rep(i, 0, s.length())
  {
    if(s[i] == ',') cout<<" ";
    else cout<<s[i];
  }
  cout<<endl;
  return 0;
}


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

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

    std::vector<int> T(S.length(), 0);

    int count = 0;
    for (int i = 0; i < S.length(); ++i)
    {
        if (S[i] == 'A' || S[i] == 'T' || S[i] == 'C' || S[i] == 'G')
        {
            T[count]++;
        }
        else
        {
            count++;
        }
    }

    std::cout << *std::max_element(T.begin(), T.end()) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    ll h, w; cin >> h >> w;

    if(h == 1 || w == 1){
        cout << 1 << endl;
    }
    else if(h % 2 == 1 && w % 2 == 1){
        cout << (h * w + 1) / 2 << endl;
    }
    else{
        cout << (h * w) / 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    ll k = pow(2, m);
    ll ans = (1900*m+100*(n-m))*k;
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
    if(cin >> f){in(r...);return true;}
    else return false;
}
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": "
#define debugout(x) cerr << (x) << " "
#define debugindent() cerr << '\n'
#define debug(x) debughead(x), debugout(x), debugindent()
const int INF = 1e18, MOD = 1e9 + 7;
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

main(){
    INCANT;
    int r, g, b, n, tmp, res = 0;
    string s;
    in(r, g, b, n);
    for(int i = 0; i * r <= n; i++){
        for(int j = 0; i * r + j * g <= n; j++){
            int k = n - i * r - j * g;
            if(k % b == 0){
                res++;
            }
        }
    }
    print(res);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		long N=sc.nextLong();
		long A=sc.nextLong();
		long B=sc.nextLong();
		
		long sum=(B-A)*(N-2)+1;
		
		if(A>B)System.out.println(0);
		else if(N==1){
			if(A!=B)System.out.println(0);
			else System.out.println(1);
		}
		else System.out.println(sum);
		
	}

}


Measured memory_bytes: 22740
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=input()
n=len(s)
que=deque()
que.append([0,s[0]])
ans=0
while len(que):
    q=que.popleft()

    if q[0]==n-1:
        ans+=sum(list(map(int, q[1].split("+"))))
    else:
        que.append([q[0]+1,q[1]+s[q[0]+1]])
        que.append([q[0]+1,q[1]+"+"+s[q[0]+1]])
print(ans)


Measured memory_bytes: 5112
#include <bits/stdc++.h>
#define ll             long long
#define Max(a,b)       ((a)>(b)?(a):(b))
#define Min(a,b)       ((a)<(b)?(a):(b))
#define si(a)          scanf("%d",&a)
#define pii            pair <int, int>
#define mp             make_pair
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define mem(a,v)       memset(a,v,sizeof(a))
#define MAX 2007
#define MOD 100000007
#define LG  16
using namespace std;

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    cout<<char(a[0]-32)<<char(b[0]-32)<<char(c[0]-32);
}


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

using namespace std;

int n, m;

bool Ok(vector< vector<int> > a, int s)
{
    vector<bool> jest(m, true);
    int ile_jest = m;
    while (ile_jest > 0)
    {
        vector<int> jaki(n), ile(m, 0);
        for (int j = 0; j < n; ++j)
        {
            int k = 0;
            while (k < m && !jest[a[j][k]])
                ++k;
            jaki[j] = a[j][k];
            ++ile[jaki[j]];
        }
        int maxi = 0, nr;
        for (int j = 0; j < m; ++j)
        {
            if (ile[j] > maxi)
            {
                maxi = ile[j];
                nr = j;
            }
        }
        if (maxi <= s)
            return true;
        jest[nr] = false;
        --ile_jest;
    }
    return false;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    vector< vector<int> > a(n, vector<int>(m));
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            cin >> a[i][j];
            --a[i][j];
        }
    }
    int l = 1, p = n, s, r = -1;
    while (l <= p)
    {
        s = (l + p) / 2;
        if (Ok(a, s))
        {
            r = s;
            p = s - 1;
        }
        else
            l = s + 1;
    }
    cout << r;
    return 0;
}


Measured memory_bytes: 1056
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================





int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================
	

	ll N;
	cin >> N;

	vpll AB(N);
	for (int i = 0; i < N; i++)
	{
		cin >> AB[i].first >> AB[i].second;
	}

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

	

	cout << AB[N - 1].second + AB[N-1].first << endl;





}





Measured memory_bytes: 1792
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;


enum FACE { NORTH, SOUTH, WEST, EAST, TOP, BOTTOM };

class dice {
private:
	int num[6];

	inline void roll(FACE a, FACE b, FACE c, FACE d) {
		swap(num[a], num[b]);
		swap(num[b], num[c]);
		swap(num[c], num[d]);
	}

public:
	dice() { // ??????????????????????????£
		num[TOP] = 1;
		num[BOTTOM] = 6;
		num[NORTH] = 3;
		num[SOUTH] = 4;
		num[EAST] = 5;
		num[WEST] = 2;
	}

	void set(int t, int f) {
		if(num[EAST] == t || num[WEST] == t) west();
		while(num[TOP] != t) north();
		while(num[NORTH] != f) ccw();
	}

	inline const int &operator[](FACE f) const { return num[f]; }

    // ???????????????????§??????¢??????
	inline void north() { roll(TOP, SOUTH, BOTTOM, NORTH); }
	inline void east()  { roll(TOP, WEST, BOTTOM, EAST); }
	inline void west()  { roll(TOP, EAST, BOTTOM, WEST); }
	inline void south() { roll(TOP, NORTH, BOTTOM, SOUTH); }

	// ???????????¢????????????????????¢
	inline void ccw() { roll(SOUTH, EAST, NORTH, WEST); }
	inline void cw()  { roll(SOUTH, WEST, NORTH, EAST); }
};

constexpr int SIZE = 30;
int cnt[7];
int top[SIZE][SIZE];
int height[SIZE][SIZE];

constexpr int dx[4] = {0, 0, -1, 1};
constexpr int dy[4] = {-1, 1, 0, 0};
void (dice::*func[4])() = {&dice::north, &dice::south, &dice::west, &dice::east};

void drop(int x, int y, dice d) {
	typedef pair<int, FACE> P;

	while(true) {
		vector<P> v{{d[NORTH], NORTH}, {d[SOUTH], SOUTH}, {d[EAST], EAST}, {d[WEST], WEST}};
		sort(begin(v), end(v), greater<P>());

		for(int i = 0; i < 3; ++i) {
			const int num = v[i].first;
			const int dir = v[i].second;

			if(num <= 3) break;

			const int nx = x + dx[dir];
			const int ny = y + dy[dir];
			if(height[y][x] > height[ny][nx]) {
				(d.*func[dir])();
				x = nx;
				y = ny;
				goto next;
			}
		}

		--cnt[top[y][x]];
		++cnt[d[TOP]];
		top[y][x] = d[TOP];
		++height[y][x];
		return;
	next:;
	}
}

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

	constexpr int sx = SIZE / 2, sy = SIZE / 2;
	for(int n; cin >> n, n;) {
		memset(cnt, 0, sizeof(cnt));
		memset(top, 0, sizeof(top));
		memset(height, 0, sizeof(height));

		for(int i = 0; i < n; ++i) {
			int t, f;
			cin >> t >> f;

			dice d;
			d.set(t, f);
			drop(sx, sy, d);
		}

		for(int i = 1; i <= 6; ++i) {
			cout << cnt[i] << (i == 6 ? "\n" : " ");
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1212
#include <stdio.h>
#include <string.h>
int main (void)
{
	int n, i, taro=0, hanako=0;
	char card1[110], card2[110];
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%s %s",card1, card2);
		if(strcmp(card1,card2)==0)  taro +=1, hanako +=1;
		else if(strcmp(card1,card2)>0)  taro +=3;
		else if(strcmp(card1,card2)<0)  hanako +=3; 
	}
	printf("%d %d\n", taro, hanako);

	return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>

using namespace std;


int main(){
	queue<long long int>que;
	long long int n,a[200006],ireru[200006]={},count=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=n;i>=1;i--){
		if(a[i]==1&&ireru[i]%2==0||a[i]==0&&ireru[i]%2==1)
		{
			count++;
			que.push(i);
			long long int tmp=i;
			for(int j=1;j*j<=i;j++)
			{
				if(tmp%j==0){
					ireru[j]++;
					if(j*j!=tmp)
					{
						
					ireru[tmp/j]++;
					}
				}
			}
		}
	}
	cout<<count<<endl;
	while(!que.empty()){
		cout<<que.front()<<" ";
		que.pop();
	}
}


Measured memory_bytes: 5120
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<stack>
#include<algorithm>
#include<list>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
int keta(int N){
	int n=N;
	int sum=0;
	for(;;){
		sum+=n%10;
		n=n/10;
		if(n==0)
			break;
	}
	return sum;
}
int main(){
	unsigned long long X,Y;
	int count=0;
	cin>>X>>Y;
	for(unsigned long long i=X;i<=Y;i=2*i){
		count++;
	}
	cout<<count;
	return 0;
}

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

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}

fn main() {
	let a: i64 = read();
	let b: i64 = read();
	let k: i64 = read();
	if k <= a {
		println!("{} {}", a-k, b);
	} else if k <= a+b {
		println!("{} {}", 0, a+b-k);
	} else {
		println!("{} {}", 0, 0);
	}
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long int
#define forr(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
#define oo 2000000000000000000LL
using namespace std;


void _sol(){
    int n; cin >> n;
    string s; cin >> s;
    int cnt = 0,i=0,j=n-1;
    while(i<j){
        if( s[i] == 'W' && s[j] == 'R' ) cnt++ , swap(s[i] , s[j]) ;
        if( s[i]=='R' ) i++;
        if( s[j] == 'W') j--;
    }
    cout << cnt;
}

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


Measured memory_bytes: 3728
<?php
    $s = explode(' ', trim(fgets(STDIN)));
    $l = explode(' ', trim(fgets(STDIN)));
    $point = 0;
    $ans = 0;
    for($i = 0; $i <= $s[0]; $i++){
        $ans++;
        $point += $l[$i];
        if($point>$s[1]){
            break;
        }
    }
    echo $ans;
?>

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

using namespace std;

int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> memo(N);
  memo[0] = 0;
  for (int i = 1; i < N; ++i) {
    if (S[i - 1] == 'A' && S[i] == 'C') {
      memo[i] = memo[i - 1] + 1;
    } else {
      memo[i] = memo[i - 1];
    }
  }

  vector<int> ans;
  int l, r;
  for (int i = 0; i < Q; ++i) {
    cin >> l >> r;
    l--;
    r--;
    ans.push_back(memo[r] - memo[l]);
  }
  for (int i = 0; i < Q; ++i) {
    cout << ans[i] << endl;
  }

  return 0;
}



Measured memory_bytes: 1912
#include <stdio.h>

int
main(void)
{
	int a, b, res;
	char c;

	for (;;) {
		scanf("%d %c %d", &a, &c, &b);
		switch (c) {
		case '+':
			res = a + b;
			break;
		case '-':
			res = a - b;
			break;
		case '*':
			res = a * b;
			break;
		case '/':
			res = a / b;
			break;
		case '?':
		default:
			return 0;
		}

		printf("%d\n", res);
	}

	return 0;
}



Measured memory_bytes: 2080
#include<cstdio>
int main(){
    int a,b; char op; int ans;
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        if( op == '?' ) break;
        
        if( op == '+'){
            ans = a + b;
            printf("%d\n", ans);
        } else if( op == '-'){
            ans = a - b;
            printf("%d\n", ans);
        } else if( op == '*'){
            ans = a * b;
            printf("%d\n", ans);
        } else if( op == '/'){
            ans = (double)a / b;
            printf("%d\n", ans);
        }
    }
    
    return 0;
}



Measured memory_bytes: 2744
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map(String::toInt)
    var ans = 0.0
    if (N >= K) ans += N - K + 1
    var n = 1.0
    var k = K
    while (k > 1) {
        val l = (k + 1) / 2
        if (N >= l) {
            ans += (Math.min(N + 1, k) - l) / Math.pow(2.0, n)
        }
        n += 1.0
        k = l
    }
    println(ans / N)
}

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

int main()
{
    long long int n,i,multi=1,k=0;
    cin>>n;
    long long int x[n];
    for(i=0;i<n;i++)
    {
        cin>>x[i];
        if(x[i]==0)
        {
            cout<<0<<endl;
            return 0;
        }
    }
    for(i=0;i<n;i++)
    {
        multi*=x[i];
        k=1000000000000000000/multi;
        if(i+1<n&&x[i+1]>k)
        {
            cout<<-1<<endl;
            return 0;
        }
    }

        cout<<multi<<endl;
    return 0;
}


Measured memory_bytes: 4372
//median time 65

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> Colors(9, 0);
    repi(i, N, 0)
    {
        cin >> A[i];
        if (A.at(i) > 3199)
        {
            Colors[0]++;
        }
        else if (A.at(i) > 2799)
        {
            Colors[1]++;
        }
        else if (A.at(i) > 2399)
        {
            Colors[2]++;
        }
        else if (A.at(i) > 1999)
        {
            Colors[3]++;
        }
        else if (A.at(i) > 1599)
        {
            Colors[4]++;
        }
        else if (A.at(i) > 1199)
        {
            Colors[5]++;
        }
        else if (A.at(i) > 799)
        {
            Colors[6]++;
        }
        else if (A.at(i) > 399)
        {
            Colors[7]++;
        }
        else if (A.at(i) > 0)
        {
            Colors[8]++;
        }
    }
    ll cnt = 0;
    repi(i, 9, 1)
    {
        if (Colors.at(i) > 0)
        {
            cnt++;
        }
    }
    if (cnt == 0 && Colors.at(0) > 0)
    {
        cout << 1 << " ";
    }
    else
    {
        cout << cnt << " ";
    }
    cout << int(cnt + Colors.at(0)) << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    print(A*B)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61684
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e6+1;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n, k;
	cin >> n >> k;
	int a[n], ans = 2e9;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	for (int i = k - 1; i < n; i++)
		ans = min(ans, a[i] - a[i - k + 1]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
using pll = pair<ll, ll>;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using ti3 = tuple<int, int, int>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
#pragma warning(disable:4996)
#define INF 1000000000000000.0
int n;
vector<vector<vector<vi>>> oti(n, vector<vector<vi>>(2, vector<vi>(2, vi(2))));
int otosu(vector < vector<vi>> &buf) {
	int ans = 0;
	bool f = 1;
	int cnt = 1;
	vector<int> fl(3);
	while (f) {
		f = 0;
		fill(ALL(fl), 1);
		rep(j, 16) {
			rep(k, 2)rep(l, 2) {
				if (j == 0 || buf[j - 1][k][l] != 0 && buf[j][k][l] != buf[j - 1][k][l]) {
					if (buf[j][k][l] > 1)fl[buf[j][k][l] - 2] = 0;
				}
				else if (buf[j][k][l] > 1)fl[buf[j][k][l] - 2] |= 2;
			}
		}
		if (fl[0] == 3)  fl[1] = fl[2] = 0, f = 1; else fl[0] = 0;
		if (fl[1] == 3)fl[2] = 0, f = 1; else fl[1] = 0;
		if (fl[2] == 3)f = 1;else  fl[2] = 0;
		rep(i, 16)rep(j, 2)rep(k, 2) {
			if (buf[i][j][k] > 1 && fl[buf[i][j][k] - 2])swap(buf[i - 1][j][k], buf[i][j][k]);
		}
	}
	f = 1;
	while(f){
		f = 0;
		rep(i, 16) {
			int f2 = 1;
			rep(j, 2)rep(k, 2) {
				if (!buf[i][j][k])f2 = 0;
			}
			if (f2) {
				for (; i < 15; i++) {
					rep(j, 2)rep(k, 2) {
						buf[i][j][k] = buf[i + 1][j][k];
					}
				}
				rep(j, 2)rep(k, 2) {
					buf[15][j][k] = 0;
				}
				f = 1;
				ans++;
				break;
			}
		}
	}
	return ans;
}
int dfs(vector < vector<vi>> &buf, int a) {
	if (a == n)return 0;
	int ans = 0;
	rep(i, 3)rep(j, 3) {
		auto buf1 = buf;
		int offset;
		rep(k, 2)rep(l, 2)rep(m, 2) {
			if (oti[a][k][l][m]) {
				if (l + i > 2 || j + m > 2 || l + i == 0 || j + m == 0)goto x;
				buf1[10 + 2 * a + k][l + i-1][j + m-1] = oti[a][k][l][m];
			}
		}
		offset = otosu(buf1);
		rep(i, 16)rep(j, 2)rep(k, 2)buf1[i][j][k] = buf1[i][j][k] ? 1 : 0;
		ans = max(ans, dfs(buf1, a + 1)+offset);
	x:;
	}
	return ans;
}
int main() {
	int h;
	while (cin >> h >> n, h) {
		vector < vector<vi>> buf(16, vector<vi>(2, vi(2)));
		oti.clear();
		oti.resize(n, vector<vector<vi>>(2, vector<vi>(2, vi(2))));
		rep(i, h) {
			rep(j, 2)rep(k, 2) {
				char a;
				cin >> a;
				buf[i][j][k] = a == '.' ? 0 : 1;
			}
		}
		rep(i, n) {
			rep(j, 2)rep(k, 2)rep(l, 2) {
				char a;
				cin >> a;
				oti[i][j][k][l] = a == '.' ? 0 : i + 2;
			}
		}
		cout << dfs(buf, 0) << endl;
	}
}

Measured memory_bytes: 3172
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
namespace io{
	const int L=(1<<19)+1;
	char ibuf[L],*iS,*iT,c;
	inline char Gc(){
		if(iS==iT){
			iT=(iS=ibuf)+fread(ibuf,1,L,stdin);
			return iS==iT?EOF:*iS++;
		}
		return*iS++;
	}
	template<class I>void Gi(I&x){
		for(c=Gc();c<'0'||c>'9';c=Gc());
		for(x=0;c<='9'&&c>='0';c=Gc())x=x*10+(c&15);
	}
};
using io::Gi;
int N,T;
struct edge{
	   int adj,nex;
	   edge (int a_=0,int n_=0){
			adj=a_;
			nex=n_;
	   }
}E[333333];
void add(int u,int v){
	   E[++T]=edge(v,E[u].nex);
	   E[u].nex=T;
	   E[++T]=edge(u,E[v].nex);
	   E[v].nex=T;
}
int dfs(int x,int f){
	int s=0;
	for (int i=E[x].nex;i;i=E[i].nex){
		if (E[i].adj!=f){
		   s^=(dfs(E[i].adj,x)+1);
		}
	}
	return s;
}
int main(){
	int u,v;
	Gi(N);
	T=N;
	for (int i=1;i!=N;i++){
		Gi(u);
		Gi(v);
		add(u,v);
	}
	printf(dfs(1,0)?"Alice":"Bob");
	return 0;
}

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

int main(void){
	int x,y,s;//??????????????????
	int indexL,indexR;//?????????????¨??????????(indexL????????????????????????indexR????????????)
	int i;//??????????????°
	int normal[1001];//normal[i]??????i??????x%????¨??????????????????????
	int maxMoney;//?????§???
	while(1){
		//?????????
		maxMoney=0;
		indexL=1;
		indexR=1000;
		//??\???
		scanf("%d %d %d",&x,&y,&s);
		if(x+y+s==0){
			break;
		}
		//?¨??????????i???????¨????x%???????????????????????????normal?????£??\
		for(i=1;i<1001;i++){
			normal[i]=(int)floor((i*(100+x)/100));
		}
		//?°?????????°?????¨??§????????°????????????
		while(indexL<=indexR){
			//????¨???????s???????????§?????????????????§????????°???????????????
			while(normal[indexL]+normal[indexR]>s)indexR--;
			//?¨??????§???indexL??????????????¨indexR????????????????????£???????¨???????s?????????
			if(normal[indexL]+normal[indexR]==s){
				int tempL=(int)(floor(indexL*(100+y)/100));
				int tempR=(int)(floor(indexR*(100+y)/100));
				int tempMoney=tempL+tempR;
				//?¨?????????????????????????????????§??????
				if(tempMoney>maxMoney){
					maxMoney=tempMoney;
				}
			}
			//??????????°???????????????????????¨????1????????????
			indexL++;
		}
		//?§£???
		printf("%d\n",maxMoney);
	}
	return 0;	
}

Measured memory_bytes: 604
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        s: Chars,
        t: Chars,
    }
    println!(
        "{}",
        s.windows(t.len())
            .map(|w| w.iter().zip(t.iter()).filter(|(wi, ti)| wi != ti).count())
            .min()
            .unwrap()
    );
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for(int i=m; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <typename T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0; }
template <typename T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1;} return 0; }


int main() {
  int k,a,b; cin>>k>>a>>b;
  bool ok=0;
  rep(i,a,b+1){
      if(i%k==0) ok=1;
  }

  if(ok) cout<<"OK"<<endl;
  else cout<<"NG"<<endl;

}

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

vector<bool> g(long long A)
{
    vector<bool> f;
    for (long long i = 0; i <= 50; i++)
    {
        if (i == 0)
        {
            if (A % 4 == 1 || A % 4 == 2)
            {
                f.push_back(1);
            }
            else
            {
                f.push_back(0);
            }
        }
        else
        {
            long long r = A % ((long long)(pow(2, i + 1)));
            if (r >= pow(2, i) && r % 2 == 0)
            {
                f.push_back(1);
            }
            else
            {
                f.push_back(0);
            }
        }
    }
    return f;
}

vector<bool> lltobool(long long n, long long l)
{
    vector<bool> rep;
    for (long long i = 0; i <= l; i++)
    {
        rep.push_back(n % 2);
        n /= 2;
    }
    return rep;
}

long long booltoll(vector<bool> b, long long l)
{
    long long n = 0;
    for (long long i = 0; i <= l; i++)
    {
        if (b.at(i) == true)
        {
            n += pow(2, i);
        }
    }
    return n;
}

int main()
{
    long long A, B;
    cin >> A >> B;
    vector<bool> g_1 = g(A), g_2 = g(B);
    vector<bool> f;
    for (long long i = 0; i <= 50; i++)
    {
        f.push_back(g_1[i] != g_2[i]);
    }
    vector<bool> f_1 = lltobool(A, 50);
    vector<bool> ans_b;
    for (long long i = 0; i <= 50; i++)
    {
        ans_b.push_back(f[i] != f_1[i]);
    }
    cout << booltoll(ans_b, 50) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Numerics;

namespace AtCoder.E
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, X, M) = Read3Longs();
            var mods = new List<long>();
            var modsHash = new HashSet<long>();

            mods.Add(X);
            modsHash.Add(X);
            var loopStartMod = 0L;
            for (int i = 1; i < M; i++)
            {
                var mod = mods[i - 1] * mods[i - 1] % M;
                if (modsHash.Contains(mod))
                {
                    loopStartMod = mod;
                    break;
                }

                modsHash.Add(mod);
                mods.Add(mod);
            }

            var loopStartIndex = mods.IndexOf(loopStartMod);

            // 一巡目以内なら合計してしまう
            if (N <= mods.Count)
            {
                return mods.Take((int)N).Sum();
            }

            var beforeLoopSum = mods.Take(loopStartIndex).Sum();
            var loopList = mods.Skip(loopStartIndex).ToList();

            var loopCount = (N - loopStartIndex) / loopList.Count;

            var result = (BigInteger)0;
            result += beforeLoopSum;
            result += loopCount * loopList.Sum();
            var take = (N - loopStartIndex) % loopList.Count;
            for (int i = 0; i < take; i++)
            {
                result += loopList[i];
            }

            return result;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 34064
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

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

int main(){
        ll a, b, k;
        scanf("%ld %ld %ld", &a, &b, &k);
        if(b-a>=2*k){
                rep(i, a, a+k) printf("%ld\n", i);
                rep(i, b-k+1, b+1) printf("%ld\n", i);
        }else{
                rep(i, a, b+1) printf("%ld\n", i);
        }
        return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  
    string a,b;
    cin>>a;
    cin>>b;
    int n=a.size(),m=b.size();
    int dp[n+1][m+1],c[n+1][m+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            dp[i][j]=0;
           
        }
    }
    
    
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(a[i-1]==b[j-1])
            {
            
            dp[i][j]=dp[i-1][j-1]+1;
           
            }
            else
            {
                if(dp[i-1][j]>dp[i][j-1])
                {
                    dp[i][j]=dp[i-1][j];
                    
                }
                else
                {
                dp[i][j]=dp[i][j-1];
               
                }
            }
        }
        
    }
    vector<char>v;
    
    int i=n,j=m;
    if(dp[n][m]==0)
    cout<<"";
    else
    {
    
    while(i>0&&j>0)
    {
         if(a[i-1]==b[j-1])
         {
             v.push_back(a[i-1]);
             i--;j--;
         }
         else if(dp[i-1][j]>dp[i][j-1])
         i--;
         else
         j--;
    }
    
    }
    for(int i=v.size()-1;i>=0;i--)
    cout<<v[i];


    
}


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

#define FOR(s, i, n) for(int i = s; i n; i++)
typedef long long ll;
const int INF = 1e9;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	string words[3] = {"hon", "pon", "bon"};
	int ref[10] = {1, 1, 0, 2, 0, 0, 1, 0, 1, 0};
	cin>>n;
	cout<<words[ref[n%10]]<<'\n';
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int x;
    cin>>x;
    if(x==0) cout<<1<<endl;
    else if(x==1) cout<<0<<endl;
} 


Measured memory_bytes: 3592
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		boolean isOdd = ((a&b)&1)==1;
		System.out.println(isOdd ? "Odd" : "Even");
	}
}


Measured memory_bytes: 21076
N,A,B,C=map(int,input().split())
l=[int(input()) for _ in range(N)]
INF=10**9
def dfs(cur,a,b,c):
    if cur==N:
        if min(a,b,c)>0:
            return abs(a-A)+abs(b-B)+abs(c-C)-30
        else:
            return INF
    res0=dfs(cur+1,a,b,c)
    res1=dfs(cur+1,a+l[cur],b,c)+10
    res2=dfs(cur+1,a,b+l[cur],c)+10
    res3=dfs(cur+1,a,b,c+l[cur])+10
    return min(res0,res1,res2,res3)
print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long 
#define clr(c) memset(c,0,sizeof(c))
#define inf 0x7fffffff
const int mod=1e9+7;
const int M=4e5+5;
const int N=2e5+10;
using namespace std;
inline ll read()
{
	ll sum=0,b=1;char c=getchar();
	while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
	while(isdigit(c)){sum=sum*10+c-'0';c=getchar();}
	return b*sum;
}
ll t,n,m,k;
ll a,b,c;
ll ans;
constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
constexpr int MAX=510000;
ll fact[MAX], fact_inv[MAX];

// 繰り返し二乗法
ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

ll comb(ll n, ll r){
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}


int main()
{
	string S;
	cin>>S;
	
	if(S[2]==S[3]&&S[4]==S[5])
		cout<<"Yes";
	else
		cout<<"No";

	return 0;
}  

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A[int(2e5+5)], now[int(2e5+5)];
vector <int> ans;

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

  for (int i = N; i >= 1; i--){
    if (now[i] % 2 == A[i]) continue;
    ans.push_back(i);
    for (int j = 1; j * j <= i; j++){
      if (i % j != 0) continue;
      now[j]++;
      if (j * j != i) now[i/j]++;
    }
  }

  if (now[1] % 2 != A[1]){
    cout << -1 << endl;
    return 0;
  }

  int M = ans.size();
  cout << M << endl;
  if (M > 0){
    cout << ans[0];
    for (int i = 1; i < M; i++) cout << " " << ans[i];
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 5280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define repl(i,a,b) for(int (i)=(int)a;(i)<(int)(b);++(i))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cerr<<#x<<"="<<x<<endl

long double cnt[44][44];
long double dp[44][44];

long double calc(int m,int n,int x){
    long double p1=(long double)m/(long double)(m+n);
    long double p2=(long double)n/(long double)(m+n);

    rep(i,44)rep(j,44)dp[i][j]=cnt[i][j]=0;
    cnt[0][0]=1;
    rep(h,x){
        rep(l,h+1){
            int r=h-l;
            long double d=pow(p1,l)*pow(p2,r);
            {
                cnt[l+1][r]+=cnt[l][r];
                dp[l+1][r]+=dp[l][r];
            }
            {
                cnt[l][r+1]+=cnt[l][r];
                dp[l][r+1]+=dp[l][r]+d*p1*cnt[l][r];
            }
        }
    }

    long double res=0;
    rep(l,x+1){
        int r=x-l;
        res+=pow(p1,l)*pow(p2,r)*(dp[l][r]+cnt[l][r]*pow(p1,l)*pow(p2,r));
    }
    return res;
}

int main(){
    int M,N,X,K,L,Y;
    cin>>M>>N>>X>>K>>L>>Y;
    long double a=calc(N,M,X);
    long double b=calc(L,K,Y);
    printf("%.10Lf\n",a*b);

    return 0;
}



Measured memory_bytes: 3472
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
#include<complex>
#include<cmath>

using namespace std;

const double EPS=1e-8;
const double INF=1e9;

typedef complex<double>Point;

#define EQ(a,b) (fabs((a)-(b))<EPS)
#define EQV(a,b) (abs((a)-(b))<EPS)
struct Segment{
    Point p1,p2;
    Segment(Point p1=Point(),Point p2=Point()):p1(p1),p2(p2){}
};

typedef Segment Line;

struct Circle{
    Point c;
    double r;
    Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};

typedef vector<Point>Polygon;

double dot(Point a,Point b){
    return real(a)*real(b)+imag(a)*imag(b);
}

double cross(Point a,Point b){
    return real(a)*imag(b)-imag(a)*real(b);
}

bool isOrthogonal(Point a,Point b){
    return EQ(dot(a,b),0.0);
}

bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
    return isOrthogonal(a1-a2,b1-b2);
}

bool isOrthogonal(Line l1,Line l2){
    return isOrthogonal(l1.p2-l1.p1,l2.p2-l2.p1);
}

bool isParallel(Point a,Point b){
    return EQ(cross(a,b),0.0);
}

bool isParallel(Point a1,Point a2,Point b1,Point b2){
    return isParallel(a1-a2,b1-b2);
}

bool isParallel(Line l1,Line l2){
    return isParallel(l1.p2-l1.p1,l2.p2-l2.p1);
}

Point project(Line l,Point p){
    Point base=l.p2-l.p1;
    double r=dot(p-l.p1,base)/norm(base);
    return l.p1+base*r;
}

Point reflect(Line l,Point p){
    return p+(project(l,p)-p)*2.0;
}
int main(){
    Line L;
    scanf("%lf%lf",&L.p1.real(),&L.p1.imag());
    scanf("%lf%lf",&L.p2.real(),&L.p2.imag());

    int N;
    scanf("%d",&N);
    while(N--){
        Point P;
        scanf("%lf%lf",&P.real(),&P.imag());
        Point prj=reflect(L,P);
        printf("%.8f %.8f\n",prj.real(),prj.imag());
    }

    return 0;
}

Measured memory_bytes: 1268
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <iomanip>
#include <bitset>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
int main() {
	ll n;cin>>n;
	cout<<n*(n-1)/2<<endl;
	return 0;
}



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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N;
    cin >> N;

    vector<i64> h(N);
    rep(i,0,N){
        cin >> h[i];
    }

    i64 ans=0;
    rep(i,0,N){
        while(h[i]>0) {
            i64 r = i;
            rep(j, i, N) {
                if(h[j]>0){
                    r=j;
                }else{
                    break;
                }
            }
            rep(j,i,r+1){
                --h[j];
            }
            ++ans;
        }
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(int argc, const char * argv[]) {
 
 
 
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    /////////////////////
    // Write code below /
    /////////////////////
    int n,a,b,c;
    
    cin >> n;
    
    a = n / 100;
    b = n/10;
    b = b % 10;
    c = n % 10;
    
    if(a == 7 || b == 7 || c == 7 )
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

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

const int INF = 1001001001;

int x[110];
int y[110];

int main() {
 int K,S;
 cin>>K>>S;
 int count=0;
 for(int i=0;i<=K;i++){
   for(int j=0;j<=K;j++){
     int z=S-i-j;
       if(z>=0&&z<=K){count++;}
     }
   }
 
 cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256