akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
using namespace std;
using namespace std::chrono;
bool areach[200100] = {false};
bool breach[200100] = {false};
char s[200100];
int n, a, b, c, d;
void asearch(int x){
    if(s[x-1] == '#') return;
    if(x > n) return;
    areach[x-1] = true;
    asearch(x + 2);
    asearch(x + 1);
}

void bsearch(int y){
    if(s[y-1] == '#') return;
    if(y > n) return;
    breach[y-1] = true;
    bsearch(y + 2);
    bsearch(y + 1);
}


int main(){
    cin >> n >> a >> b >> c >> d;
    for(int i = 0; i < n; i++) cin >> s[i];
    if(d > c){
        asearch(a);
        bsearch(b);
        if(areach[c-1] == true && breach[d-1] == true) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else{
        bool check = false;
        bsearch(b);
        asearch(a);
        for(int i = 0; i < d-1; i++){
            if(areach[i] == true && breach[i+1] == true){
                if(s[i+2] == '.') check = true;
            }
        }
        if(areach[c-1] == true && breach[d-1] == true && check == true) cout << "Yes" << endl;
        else cout << "No" << endl;
    } 
}

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

int main(){
    int n, ans = 0;
    bool t = true;
    cin >> n;
    vector<int> b(n, 0);

    rep(i,n) {
        int m;
        cin >> m;
        ans += m;
        if(m % 10 != 0){
            b[i] = m;
            t = false;
        }
    }

    if(t){
        cout << 0 << endl;
        return 0;
    }

    sort(b.begin(), b.end());
    rep(i, n){
        if(ans % 10 == 0){
            ans -= b[i];
        }else
            break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll x;
    cin >> x;
    for(int i = -6208; i <= 6208; i++){
        for(int j = -6208; j <= 6208; j++){
            ll nowa = i, nowb = j;
            rep(k, 4){
                nowa *= i;
                nowb *= j;
            }
            if(nowa - nowb == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}  


Measured memory_bytes: 3620
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();

    int ans = 0;
    for(int i = 0; i < n; i++){
      int num = sc.nextInt();
      while(num % 2 == 0){
        ans++;
        num /= 2;
      }
    }

    System.out.println(ans);
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 24404
#(i,j)...i都市でj枚の銀貨を持てる最小時間(j<=2500)
ic=lambda i,c:i+c*50
n,m,s=map(int,input().split())
edge=[[]for _ in range(125100)]
for _ in range(m):
  u,v,a,b=map(int,input().split())
  u-=1
  v-=1
  for i in range(a,2501):
    edge[ic(u,i)].append((ic(v,i-a),b))
    edge[ic(v,i)].append((ic(u,i-a),b))
for i in range(n):
  c,d=map(int,input().split())
  for j in range(c,2501):
    edge[ic(i,j-c)].append((ic(i,j),d))
from heapq import heappop,heappush
def dijkstra(s,n,edge):
  inf=10**20
  ans=[inf]*n
  ans[s]=0
  h=[[0,s]]
  while h:
    c,v=heappop(h)
    if ans[v]<c:continue
    for u,t in edge[v]:
      if c+t<ans[u]:
        ans[u]=c+t
        heappush(h,[c+t,u])
  return ans
d=dijkstra(ic(0,min(2500,s)),125100,edge)
ans=[0]+[10**20]*(n-1)
for i in range(1,n):
  for j in range(2501):ans[i]=min(ans[i],d[ic(i,j)])
print(*ans[1:])

Measured memory_bytes: 126828
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N, M;
    cin >> N >> M;
    if (N == 1 || M == 1) {
        if (N == M) {
            cout << 1 << endl;
            return 0;
        } else {
            cout << max(N, M) - 2 << endl;
            return 0;
        }
    }
    cout << N * M - (2 * (N + M) - 4) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

using namespace std;

signed main() {
  IOS;
  int n, i=0;
  cin >> n;
  vector<int> b(n+1);
  for (i = 1; i <= n; i++)
    cin >> b[i];

  vector<int> ans;
  bool found = false;
  for (i = 0; i < n; i++) {
    found = false;
    for (int j = b.size()-1; j >= 1; j--) {
      if (j == b[j]) {
        ans.push_back(j);
        b.erase(b.begin()+j);
        found = true;
        break;
      }
    }
    if (!found) {
      cout << -1 << endl;
      return 0;
    }
  }

  for (auto j = ans.end()-1; j >= ans.begin(); j--) {
    cout << *j << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long a,b,c,k;
    cin>>a>>b>>c>>k;
    
    if(k<=a){
        cout << k << endl;
    }else if(k<=a+b){
        cout << a << endl;
    }else{
        cout << a-(k-a-b) << endl;
    }

    return 0;
}

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

#define rep(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i) ++)
#define scin(a) scanf("%d",&a);
#define scdo(a) scanf("%lf",&a);
#define scch(a) scanf("%s",a);
#define anin(a) printf("%d\n",a);
#define ando(a) printf("%lf\n",a);
#define anch(a) printf("%s\n",a);

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(void){
	int N,cnt(0),ans(0);
	scin(N)
	long int H[N];
	rep(i,0,N) scanf("%ld",&H[i]);
	rep(i,0,N - 1){
		if(H[i] >= H[i + 1]) cnt ++; else cnt = 0;
		if(cnt > ans) ans = cnt;
	}
	printf("%ld\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    int s,w;
    cin >> s >> w;
    if(s <= w){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void) {
	char in, out;
	cin >> in;
	if (in == 'A')
		out = 'T';
	else if (in == 'T')
		out = 'A';
	else if (in == 'G')
		out = 'C';
	else if (in == 'C')
		out = 'G';
	cout << out << endl;
}

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

int main() {
  int N, AC = 0, WA = 0, TLE = 0, RE = 0;
  cin >> N;
  vector<string> S(N);
  for(int i = 0; i < N; i++) {
    cin >> S.at(i);
    if(S.at(i) == "AC") {
      AC++;
    }
    if(S.at(i) == "WA") {
      WA++;
    }
    if(S.at(i) == "TLE") {
      TLE++;
    }
    if(S.at(i) == "RE") {
      RE++;
    }
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


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

    ll ans = N % K;
    _PR(MIN(ans,abs(ans-K)));

    return 0;
}

/*



*/

Measured memory_bytes: 256
n = int(input())


def judge(x):
    i = 1
    ans = 0
    while i*i < x:
        if x%i == 0:
            ans+=1
            if (x//i)*i == x:
                ans += 1
        i+=1
    if ans == 8:
        return True
    else:
        return False

ans = 0

for i in range(1,n+1,2):
    if judge(i):
        ans += 1
print(ans)

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

int main()
{
    int ab, bc, ca;
    cin >> ab >> bc >> ca;

    cout << ab * bc / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

ans = []

if tx > sx:
    ans.append('R'*(tx-sx))     #0
    ans.append('L'*(tx-sx))     #2
    ans.append('R'*(tx-sx+1))   #5
    ans.append('L')             #7
    ans.append('L'*(tx-sx+1))   #9
    ans.append('R')             #11
else:
    ans.append('L'*(sx-tx))     #0
    ans.append('R'*(sx-tx))     #2
    ans.append('L'*(sx-tx+1))   #5
    ans.append('R')             #7
    ans.append('R'*(sx-tx+1))   #9
    ans.append('L')             #11

if ty > sy:
    ans.insert(1,'U'*(ty-sy))   #1
    ans.insert(3,'D'*(ty-sy))   #3
    ans.insert(4,'D')           #4
    ans.insert(6,'U'*(ty-sy+1)) #6
    ans.insert(8,'U')           #8
    ans.insert(10,'D'*(ty-sy+1))#10
else:
    ans.insert(1,'D'*(sy-ty))   #1
    ans.insert(3,'U'*(sy-ty))   #3
    ans.insert(4,'U')           #4
    ans.insert(6,'D'*(sy-ty+1)) #6
    ans.insert(8,'D')           #8
    ans.insert(10,'U'*(sy-ty+1))#10

ANS = ''.join(ans)
print(ANS)

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

int main() {
	uint32_t N, K;
	cin >> N >> K;
	
	vector<uint32_t>a(N);
	for(uint32_t i=0; i<N; i++) cin >> a[i];
	
	sort(a.begin(), a.end());
	
	vector<bool> dp(K+1);

	for(uint32_t i=a[0]; i<=K; i++) {
		for(uint32_t j=0; j<N; j++) {
			if(a[j] > i) break;
			
			if(!dp[i-a[j]]) {
				dp[i] = true;
				break;
			}
		}
	}
	
	string ans = dp[K] ? "First" : "Second";
	cout << ans;
	
	return 0;
}

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

class Mult1
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');

        var first = int.Parse(input[0]);
        var second = int.Parse(input[1]);

        Console.WriteLine(first * second);
    }
}

Measured memory_bytes: 27472
#include <stdio.h>

//?????\?????????
void insertionSort(int A[], const int N)
{
    int i, j;

    for( i = 0; i < N; ++i ){
        int tmp = A[i];
        for( j = i-1; -1 < j && tmp < A[j]; --j ){
            A[j+1] = A[j];
        }
        A[j+1] = tmp;

        //??????
        for( j = 0; j < N; ++j ){
            printf("%d", A[j]);
            if( j != N-1 ) printf(" ");
        }
        printf("\n");
    }
}

int main()
{
    int i;

    //??\???
    int N;
    scanf("%d", &N);
    int A[N];
    for( i = 0; i < N; ++i )
        scanf("%d", &A[i]);

    insertionSort(A, N);

    return 0;
}

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

int main(){
	
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	int sum = 0;
	for(int i=0;i<3;i++){
		if(a[i] == 5 || a[i] == 7){
			sum += a[i];
		}else{
			sum = -1;
			break;
		}
	}

	if(sum == 17)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

int main()
{
  int cnt = 0;
  int index = 0;
  string S;
  cin >> S;

  while(true) {
    if(S.find_first_not_of(S[index], index) == string::npos) {
      // not found
      break;
    }
    index = S.find_first_not_of(S[index], index);
    cnt++;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
int a[100005],b[100005];
int cnt[100005]; 
vector<int> G[100005];
vector<P> ans;
vector<int> G2[100005];
bool used[100005];

void dfs(int v,int p){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		if(!used[G[v][i]]){
			G2[v].push_back(G[v][i]);
			dfs(G[v][i],v);
		}else if(G[v][i]!=p && v>G[v][i]){
			ans.push_back(P(v,G[v][i]));
			cnt[v]++;
		}
	}
}

bool flag=false;

void dfs2(int v,int p){
	for(int i=0;i<G2[v].size();i++){
		if(G2[v][i]!=p){
			dfs2(G2[v][i],v);
		}
	}
	if(p==-1)return;
	if(cnt[v]%2==1){
		cnt[v]++;
		ans.push_back(P(v,p));
	}else{
		cnt[p]++;
		ans.push_back(P(p,v));
	}
}


int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d",&a[i],&b[i]);
		a[i]--;
		b[i]--;
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	if(m%2==1){
		printf("-1\n");
		return 0;
	}
	dfs(0,-1);
	dfs2(0,-1);
	if(cnt[0]%2!=0){
		printf("-1\n");
	}else{
		for(int i=0;i<ans.size();i++){
			printf("%d %d\n",ans[i].first+1,ans[i].second+1);
		}
	}
	return 0;
} 

Measured memory_bytes: 23928
import math

def is_prime(n):
    if n <= 0: return None
    if n == 1: return False
    sup = math.floor(pow(n,1/2))
    for i in range(2,sup+1):
        if n % i == 0:
            return False
    return True

X = int(input())
for x in range(X, 2 * X + 1):
    if is_prime(x):
        print(x)
        break

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

int main()
{
    int h1, m1, h2, m2, k, m, h;
    scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
    if (m1>m2) {
        h2--;
        m=60-(m1-m2);
    }
    else m=abs(m1-m2);
    h=abs(h1-h2);
    m+=(h*60)-k;
    printf("%d\n", m);
    return 0;
}


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

using namespace std;

const int maxn = 410;
const long long int inf = 1e18;

int n;
int a[maxn];
long long int dp[maxn][maxn];

long long int hello(int l, int r){
	if (r - l < 2)
		return 0;
	
	if (dp[l][r] != 0)
		return dp[l][r];

	long long int sum = 0;
	for (int i = l; i < r; i++)
		sum += a[i];

	long long int res = inf;
	for (int i = l+1; i < r; i++){
		res = min(hello(l, i) + hello(i, r), res);
	}

	dp[l][r] = res + sum;
	return dp[l][r];
}

int main(){
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];

	cout << hello(0, n) << endl;
	return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>

int main()
{
    long long n, y;
    long long yukichi, higuchi, hideyo;

    scanf("%lld %lld", &n, &y);

    for (hideyo = 0; hideyo <= n; hideyo++) {
        for (higuchi = 0; higuchi <= n; higuchi++) {
            yukichi = n - (hideyo + higuchi);

            if (0 <= yukichi && 0 <= higuchi && 0 <= hideyo &&
                yukichi * 10000 + higuchi * 5000 + hideyo * 1000 == y) {
                printf("%lld %lld %lld\n", yukichi, higuchi, hideyo);
                return 0;
            }
        }
    }

    printf("-1 -1 -1\n");

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

int main(){
    int n;
    cin >> n;
    int amari = n % 1000;
    if(amari==0){
        cout << 0 << endl;
    }
    else{
        cout << 1000-amari << endl;
    }
    
    return 0;
}


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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	long long n, s = 0;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		if (i % 3 != 0 && i % 5 != 0) s += i;	
	}
	cout << s << '\n';
	return 0;
}

Measured memory_bytes: 3600
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;

    set<ll> st;

    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            if(i * i != n){
                st.insert(i);
                st.insert(n / i);
            } else {
                st.insert(i);
            }
        }
    }

    for(ll i = 1; i * i <= (n - 1); i++){
        if((n - 1) % i == 0){
            if(i * i != (n - 1)){
                st.insert(i);
                st.insert((n - 1) / i);
            } else {
                st.insert(i);
            }
        }
    }
    ll ans = 0;
    //cout << st.size() << endl;
    for(auto &i : st){
        ll num = n;
        //cout << div[i] << endl;
        if(i == 1) continue;
        if((n - 1) % i == 0){
            ans++;
            continue;
        }
        while(num % i == 0){
            num /= i;
        }
        if((num - 1) % i == 0){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll power(ll x, unsigned ll y, ll p)
{
    ll res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
void solve()
{
   string s;
   cin>>s;
   ll n=s.size();
   if(s[n-1]=='s')
    s+="es";
   else
    s+="s";
   cout<<s<<endl;

}

int main(){
ll t;
t=1;
//cin>>t;
while(t--)
{
    solve();
}


return 0;
}


Measured memory_bytes: 3632
using System;

namespace Aizu {
    class OnlineJudge {
        static void Main() {
            for (int i; (i = int.Parse(Console.ReadLine())) != 0;) {
                var t = 0;
                while (i >= 5) {
                    t += (i /= 5);
                }
                Console.WriteLine(t);
            }
        }
    }
}

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

using namespace std;

const int vy[] = {0, 1, 0, -1}, vx[] = {-1, 0, 1, 0};

int W, H, S;
string M[50], MS[10][50];
int bit[50][50], v[2][50][50][1 << 10];
int mov[50][50];

int Solve()
{
  memset(v, -1, sizeof(v));
  for(int k = 0; k < S; k++) {
    for(int i = 0; i < H; i++) {
      for(int j = 0; j < W; j++) {
        if(MS[k][i][j] == '*') bit[j][i] |= 1 << k;
      }
    }
  }
  queue< tuple< int, int, int, int > > que;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      switch(M[i][j]) {
        case '|':
          mov[j][i] = 3;
          break;
        case '_':
          mov[j][i] = 1;
          break;
        case '^':
          mov[j][i] = 2;
          break;
        case 'a' ... 'j':
          mov[j][i] = 1;
          M[i][j] -= 'a';
          break;
        case 'A' ... 'J':
          mov[j][i] = 2;
          M[i][j] -= 'A';
          break;
        case '%':
          que.emplace(0, j, i, 0);
          v[0][j][i][0] = 0;
          mov[j][i] = 1;
          break;
        case '&':
          mov[j][i] = 1;
          break;
        default:
          mov[j][i] = 0;
          break;
      }
    }
  }

  while(!que.empty()) {
    int f, x, y, button;
    tie(f, x, y, button) = que.front();
    que.pop();
    if(M[y][x] == '&') {
      return (v[f][x][y][button]);
    } else if(M[y][x] == '|') {
      int nf = f ^ 1;
      if(v[nf][x][y][button] == -1) {
        v[nf][x][y][button] = v[f][x][y][button] + 1;
        que.emplace(nf, x, y, button);
      }
    } else if(M[y][x] < 10) {
      int nbutton = button ^ (1 << M[y][x]);
      int nf = (f + ((bit[x][y] >> M[y][x]) & 1)) & 1;
      if(v[nf][x][y][nbutton] == -1) {
        v[nf][x][y][nbutton] = v[f][x][y][button] + 1;
        que.emplace(nf, x, y, nbutton);
      }
    }
    for(int i = 0; i < 4; i++) {
      int nx = x + vx[i], ny = y + vy[i];
      int isgo = (f + __builtin_popcount(bit[nx][ny] & button)) & 1;
      if(v[f][nx][ny][button] == -1 && (mov[nx][ny] & ++isgo)) {
        v[f][nx][ny][button] = v[f][x][y][button] + 1;
        que.emplace(f, nx, ny, button);
      }
    }
  }
  return (-1);
}

int main()
{
  cin >> W >> H;
  for(int i = 0; i < H; ++i) {
    cin >> M[i];
  }
  cin >> S;
  for(int i = 0; i < S; i++) {
    for(int j = 0; j < H; j++) {
      cin >> MS[i][j];
    }
  }
  cout << Solve() << endl;
}

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

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let it = stdin.lock().bytes().map(|c| c.unwrap() as char);
    let (fs, ft) = (|c: &char| c.is_whitespace(), |c: &char| !c.is_whitespace());
    let token = it.skip_while(fs).take_while(ft).collect::<String>();
    token.parse().ok().unwrap()
}
#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    f(std::io::BufWriter::new(out.lock()));
}
#[allow(unused_macros)]
macro_rules! debug {
    ($($var:expr),*) => { #[cfg(debug_assertions)] {
        $({ match &$var { v => eprint!("{}={:?} ", stringify!($var), v) } })*
        eprintln!();
    }};
}

fn main() {
    let n: usize = input();
    let m: usize = input();
    let ab: Vec<(usize, usize)> = (0..m).map(|_| (input(), input())).collect();

    let mut g = vec![vec![false; n]; n];
    for &(a, b) in &ab {
        g[a - 1][b - 1] = true;
        g[b - 1][a - 1] = true;
    }

    let mut dp = vec![false; n + 1];
    dp[0] = true;

    let mut vis = vec![false; n];
    let mut col = vec![0; n];
    let mut ok = true;
    for i in 0..n {
        if vis[i] {
            continue;
        }
        let mut cnt = vec![0; 2];
        ok = dfs(i, 0, &mut vis, &mut col, &mut cnt, n, &g);
        if !ok {
            break;
        }
        for j in (0..n + 1).rev() {
            let mut x = false;
            if j >= cnt[0] {
                x = x || dp[j - cnt[0]];
            }
            if j >= cnt[1] {
                x = x || dp[j - cnt[1]];
            }
            dp[j] = x;
        }
    }

    if !ok {
        println!("-1");
    } else {
        let mut ans = m;
        for i in 0..n + 1 {
            if dp[i] {
                let j = n - i;
                ans = std::cmp::min(ans, i * (i - 1) / 2 + j * (j - 1) / 2);
            }
        }
        println!("{}", ans);
    }
}

fn dfs(
    cur: usize,
    c: usize,
    vis: &mut Vec<bool>,
    col: &mut Vec<usize>,
    cnt: &mut Vec<usize>,
    n: usize,
    g: &Vec<Vec<bool>>,
) -> bool {
    vis[cur] = true;
    col[cur] = c;
    cnt[c] += 1;
    let mut ok = true;
    for nxt in 0..n {
        if nxt == cur || g[cur][nxt] {
            continue;
        }
        if vis[nxt] && col[nxt] == col[cur] {
            debug!(cur, nxt, vis, col);
            ok = false;
            break;
        }
        if !vis[nxt] {
            ok = dfs(nxt, 1 - c, vis, col, cnt, n, g);
            if !ok {
                break;
            }
        }
    }
    ok
}


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

int main() {
  string a,b,c;
  cin>>a>>b>>c;
  if(a.at(a.size()-1)==b.at(0)&&b.at(b.size()-1)==c.at(0)) {
    cout<<"YES"<<endl;
  }
  else {
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <ctype.h>
using namespace std;

typedef long long ll;

int dx[4] = { 0, -1, 1, 0 };
int dy[4] = { -1, 0, 0, 1 };

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

  for (int i = 0; i != s.size(); ++i) {
    if (s == t) {
      cout << "Yes" << endl;
      return 0;
    }
    rotate(s.begin(), s.begin() + 1, s.end());
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <time.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{
    struct Small_Segment_Tree{
        vector<int> a;
        int l, r;

        private:
        int __summ(int L, int R, int l, int r, int v)
        {
            if (L <= l && r <= R)
                return a[v];
            if (R <= l || r <= L)
                return 0;
            int m = (l + r) / 2;
            return __summ(L, R, l, m, 2 * v + 1) + __summ(L, R, m, r, 2 * v + 2);
        }

        void __set(int P, int l, int r, int v, int V)
        {
            if (l + 1 == r)
            {
                a[v] = V;
                return;
            }
            int m = (l + r) / 2;
            if (P < m)
            {
                __set(P, l, m, 2 * v + 1, V);
                a[v] = a[2 * v + 1] + a[2 * v + 2];
            }
            else
            {
                __set(P, m, r, 2 * v + 2, V);
                a[v] = a[2 * v + 1] + a[2 * v + 2];
            }
        }

        public:
        int Summ(int L, int R)
        {
            if (R < L)
                return 0;
            return __summ(L, R + 1, l, r, 0);
        }

        void Set(int P, int V)
        {
            __set(P, l, r, 0, V);
        }

        Small_Segment_Tree(int _n)
        {
            a.resize(4 * _n);
            l = 0, r = _n;
        }
    };
};

using std::__gcd;
using std::abs;
using namespace MySpace;

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
const ll MOD = 1e9 + 7;


ll n, k;
pll ab[255000];

bool comp2(pll aa, pll bb)
{
    return aa.second < bb.second;
}

signed main()
{
    srand(time(NULL));
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    S s;
    cin >> s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
    {
        cout << "Bad";
    }
    else
    {
        cout << "Good";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int> a(3);
    for(int i=0;i<3;i++)
    cin>>a[i];
    sort(a.begin(),a.end());
    cout<<(a[1]-a[0])+(a[2]-a[1])<<endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
int ng;

int mask(int n) {
	int ret=0;
	while(n) {
		ret |= 1<<(n%10);
		n /=10;
	}
	return ret;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,K) {
		cin>>x;
		ng |= 1<<x;
	}
	for(i=N;;i++) if((mask(i)&ng)==0) return _P("%d\n",i);
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000000
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  int N;
  string S;
  cin >> N >> S;
  int cnt = 0;
  rep(i, N-2){
    if(S.substr(i, 3) == "ABC"){
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  ll money = 1000;
  rep(i, n-1){
    ll stocks = 0;
    if(a[i] < a[i+1]) stocks = money / a[i];
    money += (a[i+1] - a[i]) * stocks;
  }
  cout << money << endl;
  return 0;
}


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

const int INF = 1001001001;

int main() {
  int N, T;
  cin >> N >> T;
  int ans = INF;
  rep(i, 0, N) {
    int c, t;
    cin >> c >> t;
    if (t > T) continue;
    ans = min(ans, c);
  }

  if (ans == INF)
    cout << "TLE" << endl;
  else
    cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n-1;i>s;i--)
#define rep_re(i,s,n)for(ll i = n-1;i>=s;i--)
ll MOD = 1e9 + 7;

char C[500001];
int main() {
	string s; cin >> s;
	rep(i, 0, s.size()) {
		C[200000 + i] = s[i];
	}
	ll C_Pr = 199999;
	ll C_Po = 200000 + s.size();
	
	ll q; cin >> q;
	bool o = true;
	rep(i, 0, q) {
		ll Q; cin >> Q;
		if (Q == 1) {
			o = !o;
		}
		else {
			ll f; char c; cin >> f >> c;

			if (o && f == 1 || !o && f == 2) {
				C[C_Pr--] = c;
			}
			else if (o && f == 2 || !o && f == 1) {
				C[C_Po++] = c;
			}
		}
	}
	if (o) {
		rep(i, C_Pr+1, C_Po) {
			cout << C[i];
		}
	}
	else {
		rep_r(i, C_Pr, C_Po) {
			cout << C[i];
		}
	}
	cout << endl;

	return 0;
}



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

static const int N = 1000;

int lcs(string X, string Y) {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for (int i = 0; i <= m; i++) c[i][0] = 0;
  for (int j = 0; j <= n; j++) c[0][j] = 0;

  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if ( X[i] == Y[j]) {
        c[i][j] = c[i - 1][j - 1] + 1;
      } else {
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }

  return maxl;
}

int main() {
  string s1, s2;
  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}



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

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    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 a: i64 = input();
    let b: i64 = input();
    let c: i64 = input();
    let d: i64 = input();
    let ans = match (a + b).cmp(&(c + d)) {
        std::cmp::Ordering::Less => "Right",
        std::cmp::Ordering::Greater => "Left",
        std::cmp::Ordering::Equal => "Balanced",
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;

int main(){
    DRII(n,m);
    VPII pp;
    REP(i,n){
        DRI(x);
        pp.PB(MP(x,0));
    }
    REP(i,m){
        DRI(x);
        pp.PB(MP(x,1));
    }
    sort(ALL(pp));
    int cnt[2]={};
    LL an=0;
    REP(i,n+m){
        if(pp[i].S==0)an+=(LL)pp[i].F*min(m+1,m-cnt[1]+1);
        else an+=(LL)pp[i].F*min(n+1,n-cnt[0]+1);
        cnt[pp[i].S]++;
    }
    cout<<an<<endl;
    return 0;
}


Measured memory_bytes: 2420
package main

import "fmt"

func main(){
	var N int;

	fmt.Scan(&N);
	ans := 0;
	for i := 1 ; i <= 9 ; i++ {
		for j:= 1; j <= 9 ; j++{
			if i*j == N {
				fmt.Println("Yes");
				ans = 1;
				break;
			}
		}
		if ans==1 {break;}
		
	}
	
	if ans == 0{
		fmt.Println("No");
	}
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    for (auto _ : irange(0L, t)) {
        int64_t n, d;
        array<int64_t, 3> c;
        cin >> n >> c[0] >> c[1] >> c[2] >> d;

        unordered_map<int64_t, int64_t> costs;
        costs[n] = 0;

        priority_queue<pair<int64_t, int64_t>, vector<pair<int64_t, int64_t>>,
                       std::greater<>>
                q;
        q.emplace(0L, n);

        while (!q.empty()) {
            auto [cost, m] = q.top();
            q.pop();

            if (m == 0) {
                cout << cost << endl;
                break;
            }

            array e{2L, 3L, 5L};
            for (auto i : irange(0L, 3L)) {
                for (auto k : irange(max(1L, m - e[i] + 1), m + e[i])) {
                    if (k % e[i] == 0) {
                        auto next = k / e[i];
                        auto new_cost = cost + abs(k - m) * d + c[i];
                        if (costs.count(next) == 0 || costs[next] > new_cost) {
                            costs[next] = new_cost;
                            q.emplace(new_cost, next);
                        }
                    }
                }
            }

            if (m < ((1L << 60) - cost) / d) {
                auto new_cost = cost + m * d;
                if (costs.count(0) == 0 || costs[0] > new_cost) {
                    costs[0] = new_cost;
                    q.emplace(new_cost, 0L);
                }
            }
        }
    }
}

Measured memory_bytes: 4208
n,m=map(int,input().split())
p=[list(map(int,input().split()))for i in range(m)]
c=[]
for i in p:
	a,b=i
	if a>=n:o=0
	else:o=n-a
	c.append(o)
c.sort()
c.pop()
print(sum(c))

Measured memory_bytes: 7900
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int t = sc.nextInt();
		int[][] field = new int[h][w];
		int p = sc.nextInt();
		for (int i = 0; i < p; i++) {
		    int ww = sc.nextInt();
		    int hh = sc.nextInt();
		    int tt = sc.nextInt();
		    field[hh][ww]++;
		}
		long total = 0;
		for (int i = 0; i < h; i++) {
		    for (int j = 0; j < w; j++) {
		        if (sc.nextInt() == 1) {
		            total += field[i][j];
		        }
		    }
		}
	    System.out.println(total);
	}
}



Measured memory_bytes: 32032
#include <stdio.h>

#define NMAX 20
#define QMAX 200

int solve (int ,int );
int n,na[NMAX],q;

int main (void){
  int i,j,result,m[QMAX];

  scanf ("%d",&n);
  for (i = 0 ; i < n ; i++)
    scanf ("%d",&na[i]);
  scanf ("%d",&q);
  for (i = 0 ; i < q ; i++)
    scanf ("%d",&m[i]);
  
  for (i = 0 ; i < q ; i++){
      result = solve (0,m[i]);
    if (result)
      printf ("yes\n");
    else
      printf ("no\n");
  }

  return 0;
}

int solve (int i, int m)
{
  if (m == 0)
    return 1;
  if (i >= n)
    return 0;

  if (solve (i + 1,m) || solve (i + 1,m - na[i]))
    return 1;
  else return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}
int main() {
    ll n;
    cin >> n;
    auto div = divisor(n);
    int ans = INT_MAX;
    for(auto e : div) {
        int a = to_string(e).size();
        int b = to_string(n / e).size();
        ans = min(ans, max(a, b));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/* 
*/

//=================================================
int N;
vector<int> A;
//=================================================
void input()
{
    cin >> N;
    A = vector<int>(N + 1);
    rep(i, N)
    {
        cin >> A[i + 1];
    }
}

//=================================================
void solve()
{
    map<int, int> ans;
    vector<bool> b(N + 1);
    for (int i = N; i >= 1; --i)
    {

        int cnt = 0; // iの倍数(iを除く)で何個ボールをいれたか．
        for (int j = i * 2; j <= N; j = j + i)
        {
            cnt ^= b[j];
        }

        if (cnt != A[i])
        {
            b[i] = true; // ボールを入れたフラグ.
            ans[i]++;    // i番目の箱にボールをいれる．
        }
        else
        {
            // DO NOTHING.
            // ボールをいれない.
        }
    }

    // OUTPUT.
    cout << ans.size() << endl;
    for (auto x : ans)
    {
        cout << x.first << " ";
    }
    cout << endl;
}

//=================================================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const double eps=1e-10;
struct node
{
    double x,y;
    node operator -(const node &nd)const
    {
        return {x-nd.x,y-nd.y};
    }
    double operator * (const node &nd)const
    {
        return x*nd.x+y*nd.y;
    }
};
struct line
{
    double A,B,C;
    line(node a,node b)
    {
        A=b.y-a.y;
        B=a.x-b.x;
        C=b.x*a.y-a.x*b.y;
    }
    bool operator ==(const line &L)const
    {
        if(abs(A*L.B-B*L.A)<eps&&abs(B*L.C-C*L.B)<eps&&abs(A*L.C-C*L.A)<eps) return 1;
        return 0;
    }
    void show()
    {
        printf("A=%f,B=%f,C=%f\n",A,B,C);
    }
};
double X(node aa,node bb)
{
    return aa.x*bb.y-aa.y*bb.x;
}
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        node a,b,c,d;
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&a.x,&a.y
              ,&b.x,&b.y
              ,&c.x,&c.y
              ,&d.x,&d.y);
        if(a.x>b.x) swap(a,b);
        if(c.x>d.x) swap(c,d);
        line L1(a,b),L2(c,d);
       // L1.show();
       // L2.show();
        if(L1==L2)
        {
            //puts("重合");
            if((c-a)*(c-b)<=0||(d-a)*(d-b)<=0||(a-c)*(a-d)<0||(b-c)*(b-d)<0)
            {
                puts("1");
            }
            else
                puts("0");
        }
        else if(abs(L1.A*L2.B-L1.B*L2.A)<eps)
        {
            //puts("平行");
            puts("0");
        }
        else
        {
            //puts("直线相交");
            double xx=(L2.C*L1.B-L1.C*L2.B)/(L1.A*L2.B-L2.A*L1.B);
            double yy=(L1.A*L2.C-L2.A*L1.C)/(L2.A*L1.B-L1.A*L2.B);
            //printf("%f %f\n",xx,yy);
            node t;
            t.x=xx,t.y=yy;
            if((t-a)*(t-b)<=0&&(t-c)*(t-d)<=0) puts("1");
            else puts("0");

        }
    }
    return 0;
}



Measured memory_bytes: 3240
using System;

namespace Free_1
{
    class Program
    {
        static void Main(string[] args)
        {
           long[] ary = new long[4];
            string[] str = Console.ReadLine().Split();
            long a = long.Parse(str[0]);
            long b = long.Parse(str[1]);
            long c = long.Parse(str[2]);
            long d = long.Parse(str[3]);

            ary[0] = a * d;
            ary[1] = a * c;
            ary[2] = b * c;
            ary[3] = b * d;

            Array.Sort(ary);
            Console.WriteLine(ary[3]);



        }
    }
}

Measured memory_bytes: 27536
#include<bits/stdc++.h>
using namespace std;
int main(){
 string o,e;
 cin>>o>>e;
 for(int i=0;i<e.size();i++)cout<<o[i]<<e[i];
 if(o.size()!=e.size())cout<<o[o.size()-1];
 cout<<endl;
 return 0;
}

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

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

  map<int, int> a;

  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    a[x]++;
    a[x + 1]++;
    a[x - 1]++;
  }

  int max = 0;
  for (auto p : a) {
    auto k = p.first;
    auto v = p.second;

    if (max < v) max = v;
  }

  cout << max << endl;
}


Measured memory_bytes: 4736
#include <stdio.h>
int main(void)
{
    int N;
    int A[110];
    scanf("%d", &N);
    for(int i=0;i<N;i++) scanf("%d", &A[i]);
    int max=1;
    int min=1000000000;
    for(int i=0;i<N;i++){
        if(max<A[i]) max=A[i];
        if(min>A[i]) min=A[i];
    }
    printf("%d\n",max-min);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
        System.out.println(Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
    }
}



Measured memory_bytes: 27968
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> query;
typedef vector<vector<ll>> matrix;

int n;
map<int, ll> numToCount;
map<int, int> numToMin;
ll ret[100005];
void solve() {
  cin >> n;
  int idx = n;
  for(int i = 0; i < n; i++) {
    int t;
    cin >> t;
    if(numToCount[t]++ == 0) {
      numToMin[t] = i;
    }
  }
  int lastNum = numToMin.rbegin()->first;
  ll amt = 0;
  while(numToCount.size()) {
    int currNum = numToCount.rbegin()->first;
    ret[idx] += (lastNum - currNum) * amt;
    idx = min(idx, numToMin.rbegin()->second);
    amt += numToCount[currNum];
    numToCount.erase(currNum);
    numToMin.erase(currNum);
    lastNum = currNum;
  }
  ret[idx] += amt * lastNum;
  for(int i = 0; i < n; i++) cout << ret[i] << "\n";
}

void casesolve() {
  int t;
  cin >> t; cin.ignore();
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 12800
N,Q=map(int, input().split())
S=input()
list=[0]*N
#計算量が多いので、さきに文字列のACの数を数えておく。
for i in range(1,N):
  if S[i-1:i+1]=="AC":
    list[i]=list[i-1]+1
  else:
    list[i]=list[i-1]
for i in range(Q):
  l,r=map(int,input().split())
  print(list[r-1]-list[l-1])

Measured memory_bytes: 6140
from  itertools import permutations
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
P = list(permutations(range(N)))
ans = 0
for p in P:
  for i in range(N-1):
    ans += ((X[p[i+1]][0] - X[p[i]][0]) ** 2 + (X[p[i+1]][1] - X[p[i]][1]) ** 2) ** (1/2)
ans /= len(P)
print(ans)

Measured memory_bytes: 8052