akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    for(int i=0; i<h; ++i){
        string s;
        cin >> s;
        cout << s << endl
             << s << endl;
    }

    return 0;
}


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

int main(){
    int N;  cin >> N;
    vector<string> s(N);

    int ans = 0;
    for(int i=0; i<N; i++){
        cin >> s[i];
        int len = s[i].length();
        for(int j=0; j<len-1; j++){
            if(s[i][j]=='A' && s[i][j+1]=='B') ans++;
        }
    }

    vector<int> cnt(3,0);
    for(int i=0; i<N; i++){
        if(s[i][0]!='B' && s[i][s[i].length()-1]=='A') cnt[0]++;
        if(s[i][0]=='B' && s[i][s[i].length()-1]=='A') cnt[1]++;
        if(s[i][0]=='B' && s[i][s[i].length()-1]!='A') cnt[2]++;
    }

    // cerr << ans << " " << cnt[0] << " " << cnt[1] << " " << cnt[2] << endl;
    if(cnt[0]>0 && cnt[1]>0 && cnt[2]>0){
        ans += cnt[1]+1;
        cnt[0]--;
        cnt[2]--;
        cnt[1] = 0;
    }else if(cnt[0]==0 && cnt[1]>0 && cnt[2]>0){
        ans += cnt[1];
        cnt[2]--;
        cnt[1] = 0;
    }else if(cnt[0]>0 && cnt[1]>0 && cnt[2]==0){
        ans += cnt[1];
        cnt[0]--;
        cnt[1] = 0;
    }else if(cnt[0]==0 && cnt[1]>0 && cnt[2]==0){
        ans += cnt[1]-1;
    }

    
    if(cnt[0]>0 && cnt[2]>0){
        ans += min(cnt[0], cnt[2]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <utility>

using namespace std;

struct card
{
	char suit;
	int value;
};

void output(int n, card elements[])
{
	for (int i = 0; i < n - 1; i++)
		cout << elements[i].suit << elements[i].value << " ";
	cout << elements[n - 1].suit << elements[n - 1].value << endl;
}

int bubble_sort(int n, card elements[])
{
	int swap_count = 0;
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; i < j; j--) {
			//output(n, elements);
			if (elements[j].value < elements[j - 1].value)
				swap(elements[j], elements[j - 1]), swap_count++;
		}
	}
	return swap_count;
}


int selection_sort(int n, card elements[])
{
	int swap_count = 0;
	for (int i = 0; i < n; i++) {
		int minimam = i;
		// select minimam element
		for (int j = i + 1; j < n; j++) {
			if (elements[j].value < elements[minimam].value)
				minimam = j;
		}
		// output(n, elements);
		if (minimam != i)
			swap(elements[i], elements[minimam]), swap_count++;
	}
	return swap_count;
}

bool equals_suit(int n, card elements1[], card elements2[])
{
	for (int i = 0; i < n; i++)
		if (elements1[i].suit != elements2[i].suit) return false;
	return true;
}

int main()
{
	int n;
	card bubble_elems[36], sel_elems[36];

	// input
	cin >> n;
	for (int i = 0; i < n; i++) {
		char input[3]; // 0: suit, 1: value, 2: NULL(\0)
		cin >> input;
		bubble_elems[i].suit = input[0];
		bubble_elems[i].value = input[1] - '0';
		sel_elems[i] = bubble_elems[i];
	}

	// sort bubble_sort
	bubble_sort(n, bubble_elems);
	output(n, bubble_elems);
	cout << "Stable" << endl;
	
	// sort selection_sort
	selection_sort(n, sel_elems);
	output(n, sel_elems);
	// judge stable
	if (equals_suit(n, bubble_elems, sel_elems))
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;
	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}
int gcd(ll(a), ll(b)) {
	ll q = a;
	ll w = b;
	ll e = q;
	while (q % w != 0) {
		e = q % w;
		q = w;
		w = e;
	}
	return w;

}





int main() {
	string s;
	cin >> s;
	cout << s.at(0) << s.size()-2 << s.at(s.size()-1) << endl;


	
	
}

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

int main(){
  int n,i;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n,greater<int>());
  int alice=0,bob=0;
  for(i=0;i<n;i++){
    if(i%2==0)alice+=a[i];
    else bob+=a[i];
  }
  cout<<alice-bob;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
  ll n, t;
  cin>>n>>t;
  ll ans = 0;
  vi a(n);
  rep(i,n){
    cin >> a[i];
  }
  for (ll i = 1; i < n;i++){
    ans += t;
    if(a[i]-a[i-1]<t){
      ans -= t - (a[i]-a[i - 1]);
    }
  }
  ans += t;
  print(ans);
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

#define MAX_N 100
#define MAX_M 100

int main() {
    int n;
    cin >> n;
    vector<int> b(n), ans;
    REP(i, n) cin >> b[i];

    REP(i, n) {
        bool seikou = false;
        int idx;
        REP(j, b.size()) {
            if(j+1 == b[j]) {
                seikou = true;
                idx = j;
            }
        }
        if(seikou) {
            ans.push_back(b[idx]);
            b.erase(b.begin()+idx);
        } else if (!seikou) {
            cout << "-1" << endl;
            return 0;
        }
    }

    reverse(ans.begin(), ans.end());
    REP(i, ans.size()) {
        cout << ans[i] << endl;
    } 
}

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

int main(){
    int h,w;
    while(cin>>h>>w,h){
        char D[h][w];
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>D[i][j];
            }
        }
        map<string,int> M;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                for(int di=-1;di<=1;di++){
                    for(int dj=-1;dj<=1;dj++){
                        if(!di&&!dj) continue;
                        string S;
                        int I=i,J=j;
                        while(true){
                            S.push_back(D[I][J]);
                            M[S]++;
                            I+=di;
                            if(I<0)I=h-1;
                            if(I>=h)I=0;
                            J+=dj;
                            if(J<0)J=w-1;
                            if(J>=w)J=0;
                            if(I==i&&J==j) break;
                        }
                    }
                }
            }
        }
        string ans;
        for(auto p:M){
            // cout<<p.first<<' '<<p.second<<endl;
            if(p.second<=1) continue;
            else{
                string S = p.first;
                if(ans.size()<S.size()){
                    ans=S;
                }else if(ans.size()==S.size()){
                    ans=min(ans,S);
                }
            }
        }
        if(ans.size()==1)cout<<0<<endl;
        else cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 37908
from collections import defaultdict
n,x,m = list(map(int,input().split()))

def fact(n):
    freq = defaultdict(int)
    if n==0:
        return freq
    while n%2==0:
        freq[2]+=1
        n = n//2
    for i in range(3,int(n**0.5)+1):
        if n%i==0:
            freq[i]+=1
            n = n//i
    if n>1:
        freq[n]+=1
    return freq

can = True
freqx = fact(x)
freqm = fact(m)

for pf in freqm:
    if freqx[pf]==0:
        can = False

if can or n<=m:
    s = x%m
    op = 1
    while op<n:
        rem = x%m
        rem = (rem*rem)%m
        if(rem==0):
            break
        s+=rem
        x = rem
        op+=1
    print(s)
else:
    x = x%m
    lo = [-1 for i in range(m)]
    series = [x]
    lo[x] = 0
    rep = -1
    for i in range(1,m+5):
        rem = (x*x)%m
        if lo[rem]>=0:
            rep = i-lo[rem]
            break
        else:
            series.append(rem)
            lo[rem] = i
        x = rem
    if rep>=0:
        st = len(series)-rep
        n-=st
        mul = n//rep
        ex = n%rep
        s = 0
        for i in range(st):
            s+=series[i]
        for i in range(st,len(series)):
            s+=(mul*series[i])
        for i in range(ex):
            s+=series[st+i]
    print(s)


Measured memory_bytes: 77076
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int X = Integer.parseInt(sc.get());
		int N = Integer.parseInt(sc.get());
		BitSet bs = new BitSet(100 + 1);
		for (int i = 0; i < N; i++) {
			int p = Integer.parseInt(sc.get());
			bs.set(p);
		}

		int abs = X + 1;
		int value = -1;
		for (int i = 0; i <= 101; i++) {
			if (bs.get(i)) continue;
			if (abs > Math.abs(X - i)){
				abs = Math.abs(X - i);
				value = i;
			}
		}
		System.out.println(value);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

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

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		StringTokenizer to;
		double[] nums = new double[6];
		String s;
		while ((s=reader.readLine()) != null) {
			to  = new StringTokenizer(s);
			for (int i = 0; i < 6; i++) {
				nums[i] = Double.parseDouble(to.nextToken());
			}
			double det = nums[0] * nums[4] - nums[1] * nums[3];
			double x = (nums[4] * nums[2] - nums[1] * nums[5]) / det;
			double y = (-nums[3] * nums[2] + nums[0] * nums[5]) / det;

			if (x == -0.0)
				x = 0.0;
			if (y == -0.0)
				y = 0.0;
			builder.append(String.format("%.3f %.3f\n", x, y));

		}
		System.out.print(builder);
	}
}

Measured memory_bytes: 16960
N, M = map(int, input().split())
maxL = 1
minR = N
for _ in range(M):
    l, r = map(int, input().split())
    maxL = max(maxL, l)
    minR = min(minR, r)
print(max(minR - maxL + 1, 0))
# 交差しない場合を考慮する


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
typedef unsigned long long int ull;

using namespace std;

int main(void){
  int N,ans=1,count=1;
  cin >> N;
  int H[N];
  rep(i,N) cin >> H[i];
  rep(i,N-1){
    if(H[i]>=H[i+1]){
      count++;
      if(ans<count) ans=count;
    }
    else count=1;
  }
  cout << ans-1 << endl;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  string S;
  cin >> S;
  vector<int> a(4);
  REP(i, 4){
    a[i] = S[i] - '0';
  }

  REP(i, 2){
    REP(j, 2){
      REP(k, 2){
        int ans = a[0];
        if(i == 0){
          ans += a[1];
        }
        else{
          ans -=a[1];
        }
        if(j==0){
          ans+=a[2];
        }
        else{
          ans -=a[2];
        }
        if(k==0){
          ans+=a[3];
        }
        else{
          ans -=a[3];
        }
        if(ans ==7){
          cout << a[0] << (i ? '-':'+') << a[1] << (j ? '-':'+') << a[2] << (k ? '-':'+') << a[3] << "=7"<< endl;
          return 0;
        }
      }
    }
  }
  return 0;
}


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

int main(void)
{
	int R, G, B;
	cin >> R >> G >> B;

	if ((R * 100 + G * 10 + B) % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

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

int main(){
  int N,M; cin >> N >> M;
  vector<vector<int>> k_s(M,vector<int>(N+1));
  vector<int> p(M,0);
  for(int i = 0; i < M; i++){
      int k;
      cin >> k ;
      k_s.at(i).at(0) = k;
      for(int j = 1; j < k + 1; j++){
          cin >> k_s.at(i).at(j);
      }
  }
  
  /*for(int i = 0; i < M; i++){
      for(int j = 0; j < N+1; j++){
          cout << k_s.at(i).at(j) << ' ';
      }
      cout << endl;
  }*/
  int ON = 0;
  for(int i = 0; i < M; i++){
      cin >> p.at(i);
  }
  
  for(int bit = 0; bit < (1 << N); bit++){
      
      vector<bool> S(N,false);
      for(int i = 0; i < N; i++){
          if(bit & (1 << i)){
              S.at(i) = true;
          }
      }
      /*for(int i = 0; i < N; i++){
          if(S.at(i) == true) cout << 1;
          else cout << 0;
      }
      cout << endl;*/
      
      bool allOK = true;
     
      for(int i = 0; i < M; i++){
          int n_on = 0;
           for(int j = 1; j < k_s.at(i).at(0) + 1; j++){
              bool a = S.at(k_s.at(i).at(j)-1);
              if(a) n_on++;
          }
          if(n_on % 2 != p.at(i)) allOK = false;
      }
      if(allOK) ON++;
  }
  cout << ON << endl;
}



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

int main ()
{
	string s;
	string p;
	cin >> s >> p;
	for (int i = 0;i < s.size() * 2;i++)
	{
		int k = i;
		for (int j = 0;j < p.size();j++)
		{
			if (k >= s.size()) k %= s.size();
			if (s[k] != p[j])
			{
				break;
			}
			else
			{
				k++;
			}
			if (j == p.size()-1)
			{
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n";
	return 0;
} 


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

using namespace std;

using ll = long long;

int main(){

  int a, b, c;

  cin >> a >> b >> c;

  if(a == b){
    if(a != c){
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(a == c){
    if(a != b){
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(b == c){
    if(a != b){
      cout << "Yes" << endl;
      return 0;
    }
  }

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


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

using namespace std;

int n, m, x;
int a[21][21];
int c[21];
int val[14];

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

    cin >> n >> m >> x;

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

        for(int j = 0; j < m; j++)
            cin >> a[i][j];
    }

    int ans = 1e9, cost;
    for(int mask = 0; mask < (1 << n); mask++){
        cost = 0;
        memset(val, 0, sizeof(val));

        for(int bit = 0; bit < n; bit++){
            if(mask & (1 << bit)){
                cost += c[bit];

                for(int k = 0; k < m; k++){
                    val[k] += a[bit][k];
                }
            }
        }

        bool valid = true;
        for(int k = 0; k < m; k++)
            if(val[k] < x) valid = false;

        if(valid) ans = min(ans, cost);
    }

    if(ans == 1e9) ans = -1;

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

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

const int MAXN = 20;
int n;

vector<pair<int, int> > a[MAXN];

signed main(){
	cin >> n;
	for(int i=0; i< n; ++i){
		int m; cin >> m;
		while(m--){
			int x, y; cin >> x >> y;
			a[i].push_back({--x, y});
		}
	}
	int ans = 0;
	for(int mask = 0; mask < (1<<n); ++mask){
		int honest = 0;
		bool ok  = true;
		for(int i=0; i< n; ++i){
			if((mask>>i)&1){
				++honest;
				for(pair<int, int> test: a[i])
					ok&= (((mask>>test.first)&1) == test.second);
			}
		}
		if(ok) ans = max(ans, honest);
	}
	cout << ans;
}

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

class Cmondai
{
    static void Main()
    {
        var line = new List<decimal>();
        decimal N = 0;
        for (int i = 0; i < 6; ++i)
        {
            var a = decimal.Parse(Console.ReadLine());
            if (i == 0) N = a;
            else line.Add(a);
        }
        var min = line.Min();
        decimal ans = 0;
        if (min < N) ans = Math.Ceiling(N /min) + 4;
        else ans = 5;
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
ll mod=1e18;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res%mod;}
long modInverse(long a) {return powmod(a, mod-2);}
ll my_rand(){ll a=rand();ll b=rand();return (a*RAND_MAX+1)+b;}
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()


int main(){
    ios::sync_with_stdio(false);
    srand(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0);
    cout.tie(0);
    cout.precision(20);
    int n;
    cin>>n;
    long double res=2*PI*n;
    cout<<res<<endl;

    return 0;
    }


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

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


		int A = 0, B = 0;
		String[] box = buff.readLine().split(" ");
		A = Integer.parseInt(box[0]);
		B = Integer.parseInt(box[1]);

		if(A * B % 2 == 0){
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}

	static long f() {
		long ans = 0;


		return ans;
	}
}

Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5;
int n,s,l,r,x[maxn];
long long ans=0,p[maxn];

int main(){
	scanf("%d%d",&n,&s);
	for(int i=1;i<=n;i++){scanf("%d%lld",&x[i],&p[i]);}
	int l=1,r=n;
	while(1){
		if(x[l]>=s){ans+=x[r]-s;break;}
		if(x[r]<=s){ans+=s-x[l];break;}
		ans+=(x[r]-x[l]);
		if(p[l]<p[r]){
		    while(p[l]<p[r]&&l<r){
		    	p[r]+=p[l];l++;
		    }
		}
		else{
		    while(p[l]>=p[r]&&l<r){
		    	p[l]+=p[r];r--;
		    }
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int mikon(vector<int>x,vector<int>y, int cnt){
	double sum=0;
    for(int i=0;i<x.size();i++){
		sum+=pow((max(x[i],y[i])-min(x[i],y[i])),cnt);
    }
    printf("%.7f\n",pow(sum,1.0/cnt));
}

int main(){
    int n;
    cin >>n;
    vector<int>A(n);
    vector<int>B(n);
    
    for(int i=0;i<n;i++) cin >>A[i];
    for(int i=0;i<n;i++) cin >>B[i];
    
    
    mikon(A,B,1);
    mikon(A,B,2);
    mikon(A,B,3);
  	
  	int max_ans = 0;
    for(int i=0;i<n;i++){
      max_ans = max(max_ans,abs(A[i] - B[i]));
    }
  	cout << max_ans << endl;
}


Measured memory_bytes: 3476
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c;
	cin>>b>>c>>a;
	if(b-a<=0)cout<<0<<" "<<((c+b-a)<=0?0:(c+b-a));
	else cout<<b-a<<" "<<c;
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)

def main():
    s = input()
    k = int(input())
    n = len(s)
    # aajvurediaaa aajvurediaaa
    pri = 1
    suf = 0
    for i in range(n - 1):
        if s[i] != s[i + 1]:
            pri = i + 1
            break
    else:
        print(n * k // 2)
        exit()
    for i in range(n - 1, 0, -1):
        if s[i] != s[0]: break
        suf += 1
    pre = s[pri]
    mid = 0
    cnt = 1
    for i in range(pri + 1, n):
        if pre == s[i]:
            cnt += 1
        else:
            mid += cnt // 2
            cnt = 1
            pre = s[i]
    if s[0] != s[-1]:
        mid += cnt // 2
    # print(mid, pri, suf)
    print(mid * k + pri // 2 + suf // 2 + ((pri + suf) // 2) * (k - 1))

main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int w = sc.nextInt();
		int[] sticks = new int[w + 1];
		int n = sc.nextInt();

		for (int i = 1; i < sticks.length; i++)
			sticks[i] = i;
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] swaps = str.split(",");
			int a = Integer.parseInt(swaps[0]);
			int b = Integer.parseInt(swaps[1]);
			int temp = sticks[b];
			sticks[b] = sticks[a];
			sticks[a] = temp;
		}
		for (int i = 1; i < sticks.length; i++)
			System.out.println(sticks[i]);

	}

}

Measured memory_bytes: 17340
import numpy as np
N = int(input())
A = [int(i) for i in input().split()]
total = sum(A)
X = np.zeros(N)
X[0] = total 

n =int((N-1)/2 )
for i in range(1,n+1):
    X[0] = X[0] - 2*A[2*i-1]
for j in range(1,N):
    X[j] = 2*A[j-1] - X[j-1]
for i in range(N):
    print("{}".format(int(X[i])),end=" ") 
    

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

int main(){
	std::vector < std::string > s1(3);
	s1[0] = "Sunny";
	s1[1] = "Cloudy";
	s1[2] = "Rainy";
	std::string s2;
	std::cin >> s2;
	for(int i=0; i<3; i++){
		if(s2 == s1[i]){
			std::cout << s1[(i+1)%3];
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cassert>
#include<algorithm>
#include <tuple>
#include <utility>
#include<string>
#include <cmath>
#include <functional>
#define ll long long
using namespace std;

typedef pair<int, int> pair;

ll A[15][15];
ll C[15];

int main(){
    int A,B,H,M;
    double zi_kaku, hun_kaku, kaku;
    static const double pi = 3.141592653589793;
    double ans = 1e9;
    cin >> A >> B >> H >> M;

    zi_kaku = M / 2.0 + 30*(H%12);
    hun_kaku = 6*M;
    if(zi_kaku > hun_kaku){
        kaku = min(zi_kaku - hun_kaku, hun_kaku + (360-zi_kaku));
    }else{
        kaku = min(hun_kaku - zi_kaku, zi_kaku + (360-hun_kaku));
    }
    // cout << kaku << endl;
    // cout << (2*pi*kaku)/360.0 << endl;
    // cout << cos((2*pi*kaku)/360.0) << endl;
    ans = pow(A,2) + pow(B,2) - 2 * A * B * cos((2*pi*kaku)/360.0);
    // cout << ans << endl;
    printf("%.10f\n", sqrt(ans));
    // cout << sqrt(ans) << endl;
}


Measured memory_bytes: 4224
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int n,k;
    cin>>n>>k;
    vector<int> v;

    for(int i=1;i<=min(k-1,n);i++){
        int j=i;
        int kk=0;
        while(j<k){
            j*=2;
            kk++;
        }
        v.push_back(kk);

    }
    double kkk=k;
    double ans=0;
    rep(i,v.size()){

        double j=pow(2,v[i]);
        j=1.0/j;

        ans+=j;
    }
    double nn=n;
    double ans1=ans/nn;
    double nk;
    if(n>=k-1){
         nk=n-(k-1);
         while(nk>0){
             ans1+=(1.0/nn);
             nk--;
         }

    }else{


    }



printf("%.12f",ans1);



    return 0;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

type IntHeap []int

func (h IntHeap) Len() int {
	return len(h)
}

func (h IntHeap) Less(i, j int) bool {
	return h[i] > h[j]
}

func (h IntHeap) Swap(i, j int) {
	h[i], h[j] = h[j], h[i]
}

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	M, _ := strconv.Atoi(sc.Text())

	A := make(IntHeap, N)
	for i := 0; i < N; i++ {
		sc.Scan()
		A[i], _ = strconv.Atoi(sc.Text())
	}
	heap.Init(&A)
	heap.Fix(&A, 0)

	for i := 0; i < M; i++ {
		highest := heap.Pop(&A)
		heap.Push(&A, highest.(int)/2)
	}

	sum := 0
	for _, price := range A {
		sum += price
	}
	fmt.Println(sum)
}


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

int main() {
  int a, b, c, d;

  cin >> a >> b >> c >> d;

  if (a + b > c + d) {
    cout << "Left" << endl;
  } else if (a + b < c + d) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}


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

int main() {
 int N;
 cin>>N;
 bool flag = true;
 int i=1;
 while(i<=N){
   i++;
   string hoge;
   cin>>hoge;
   if(hoge =="Y") {flag=false;}
 }
 if(flag == true){
   cout<<"Three"<<endl;
 }else{
   cout<<"Four"<<endl;
 }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
inline int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int k=1,kk=0;if (c=='-')c=getchar(),k=-1;
	while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return kk*k;
}using namespace std;
int n,a[10000],mi,ma,z1[10000],z2[10000],d;
signed main(){
	n=read();for (int i=1;i<=n;i++)a[i]=read();mi=ma=1;
	for (int i=2;i<=n;i++){
		if (a[mi]>a[i])mi=i;if (a[ma]<a[i])ma=i;
	}if ((-a[mi])>a[ma]){
		for (int i=n-1;i>=1;i--)
			while (a[i+1]<a[i]){
				a[i]+=a[mi];z1[++d]=mi;z2[d]=i;
				if (a[i]<a[mi])mi=i;
			}
	}else{
		for (int i=2;i<=n;i++)
			while (a[i-1]>a[i]){
				a[i]+=a[ma];z1[++d]=ma;z2[d]=i;
				if (a[i]>a[ma])ma=i;
			}
	}cout<<d<<endl;for (int i=1;i<=d;i++)cout<<z1[i]<<' '<<z2[i]<<endl;
}


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

#define LL long long
#define pii pair<int,int>
using namespace std;
const int inf = 2147483647;
const int mod = 1e9 + 7;
const int N = 100001;

int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
    return x * f;
}
void put(int x) {
	if(x < 0) putchar('-'), x = -x;
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

int add(int x, int y) {
	x += y;
	return x >= mod ? x - mod : x;
}

struct Bit {
	int n, s[N];
	
	int lowbit(int x) {return x & -x;}
	void change(int x, int c) {for(int i = x; i <= n; i += lowbit(i)) s[i] = add(s[i], c);}
	int getsum(int x) {int sum = 0; for(int i = x; i; i -= lowbit(i)) sum = add(sum, s[i]); return sum;}
} s;
struct node {int x, y;} a[N];
int xx[N], yy[N];

bool cmp(node a, node b) {
	if(a.x == b.x) return a.y > b.y;
	return a.x < b.x;
}

int main() {
	int n = read(), m = read();
	for(int i = 1; i <= n; i++) xx[i] = read();
	for(int i = 1; i <= m; i++) yy[i] = read();
	int l = 1; while(l <= n && xx[l] <= yy[1]) l++;
	int r = n; while(r >= 1 && xx[r] >= yy[m]) r--;
	n = r - l + 1; for(int i = l; i <= r; i++) xx[i - l + 1] = xx[i];
	int tp = 0, u = 0;
	for(int i = 1; i <= m; i++) {
		while(tp < n && xx[tp + 1] < yy[i]) tp++, a[++u].x = xx[tp] - yy[i - 1], a[u].y = yy[i] - xx[tp];
		while(xx[tp + 1] == yy[i]) tp++;
	} n = u;
	sort(a + 1, a + n + 1, cmp); u = 0;
	for(int i = 1; i <= n; i++) {
		if(a[i].x != a[i - 1].x || a[i].y != a[i - 1].y) a[++u] = a[i];
	} n = u;
	for(int i = 1; i <= n; i++) xx[i] = a[i].y;
	sort(xx + 1, xx + n + 1);
	int ll = unique(xx + 1, xx + n + 1) - (xx + 1);
	for(int i = 1; i <= n; i++) a[i].y = lower_bound(xx + 1, xx + ll + 1, a[i].y) - xx;
	int ans = 0;
	s.n = ll; for(int i = 1; i <= n; i++) {
		int u = add(1, s.getsum(a[i].y - 1));
		s.change(a[i].y, u), ans = add(ans, u);
	} put(add(ans, 1)), puts("");
	return 0;
}



Measured memory_bytes: 1920
a = input()
b = list(map(int, input().split()))
c = input()
d = list(map(int, input().split()))

def binary_search(A, f, t, val):
    n = (t + f) // 2
    # この終了条件ではt と f　間の関係が見えない。
    # if n < 0 or len(A) <= n: return None
    if f > t: return None
    elif val == A[n]: return A[n]
    elif val > A[n]: return binary_search(A, n + 1, t, val)
    elif val < A[n]: return binary_search(A, f, n - 1, val)
A = [e for e in d if binary_search(b, 0, len(b) - 1, e) is not None]
print(len(A))


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  for(int i=0;i<h;i++){
    cin >> s[i];
  }
  vector<vector<int>> ff(h,vector<int>(w,0));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if((i+j)%2){
        if(s[i][j]=='#') ff[i][j]=1;
      }else{
        if(s[i][j]=='.') ff[i][j]=1;
      }
      // cout << ff[i][j];
    }
    // cout << endl;
  }
  vector<vector<bool>> f(h,vector<bool>(w,true));
  queue<pair<int,int>> bfs;
  pair<int,int> now;
  LL ans=0,count[2];
  int c,nx,ny;
  int vx[4]={0,1,0,-1},vy[4]={1,0,-1,0};
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(f[i][j]){
        // cout << "!" SP i SP j << endl;
        f[i][j]=false;
        c=ff[i][j];
        bfs.push({i,j});
        count[0]=count[1]=0;
        count[(i+j)%2]++;
        while(!bfs.empty()){
          now=bfs.front();
          bfs.pop();
          for(int k=0;k<4;k++){
            nx=now.second+vx[k];
            ny=now.first+vy[k];
            if(0<=ny&&ny<h&&0<=nx&&nx<w){
              // cout << "?" SP ny SP nx << endl;
              if(f[ny][nx]&&(ff[ny][nx]==c)){
                // cout << ny SP nx << endl;
                bfs.push({ny,nx});
                count[(nx+ny)%2]++;
                f[ny][nx]=false;
              }
            }
          }
        }
        // cout << count[0] SP count[1] << endl;
        ans+=count[0]*count[1];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

const int mx = 707;

bool adj[mx][mx];
vector<int> G[mx];
int n, m;

void kill(){
    cout << -1 << '\n';
    exit(0);
}

void input(){
    cin >> n >> m;
    for(int i = 0, a, b; i < m; i++){
        cin >> a >> b;
        adj[a][b] = adj[b][a] = 1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            if(!adj[i][j]){
                G[i].push_back(j);
                G[j].push_back(i);
            }
        }
    }
}

int col[mx];
void dfs(int x, int c, int sz[2]){
    col[x] = c;
    ++sz[c-1];
    for(int u : G[x]){
        if(col[u] == c) kill();
        if(!col[u]){
            dfs(u, 3-c, sz);
        }
    }
}

int compo[mx][2];
int num_c;
bool dp[2][mx + mx];

inline int C2(int x){return x * (x-1) / 2;}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    input();
    for(int i = 1; i <= n; i++){
        if(!col[i]){
            ++num_c;
            dfs(i, 1, compo[num_c]);
            //cout << "compo[" << num_c << "] = " << compo[num_c][0] << ' ' << compo[num_c][1] << '\n';
            compo[num_c][0] = abs(compo[num_c][0] - compo[num_c][1]);
        }
    }
    dp[0][mx] = 1;
    for(int i = 1, w = 1; i <= num_c; i++, w = !w){
        memset(dp[w],0,sizeof(dp[w]));
        for(int j = mx-n; j <= mx+n; j++){
            if(dp[!w][j]) dp[w][j + compo[i][0]] = dp[w][j - compo[i][0]] = 1;
        }
    }
    int k = num_c & 1;
    for(int i = 0; i <= n; i++){
        if(dp[k][mx+i] || dp[k][mx-i]){
            int t = n/2 - i/2;
            //cout << "diff = " << i << '\n';
            cout << C2(t) + C2(n-t) << '\n';
            return 0;
        }
    }
    assert(0);
    return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>
 
int count=0;
int stack[100];
 
void push(int x){
  count++;
  stack[count]=x;
}

int pop(){
  count--;
  return stack[count+1];
}
 
int main(){
  int x;
  char s[100];
  int a,b;
  
  while(scanf("%s",s) != EOF ){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    } 
    else if(s[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    } 
    else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",stack[count]);
  return 0;
}

Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  vector<int> a(5); REP (i, 5) cin >> a[i];
  int mi = 100;
  int idx = -1;
  REP (i, 5) if (chmin(mi, (a[i] - 1) % 10)) idx = i;
  int ans = 0;
  REP (i, 5) {
    if (i == idx) {
      ans += a[i];
    } else {
      ans += ((a[i] + 9) / 10) * 10;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    int A, B;  cin >> A >> B;

    for(int i = 1 ; i <= 1100 ; i++){
      int a = i * 0.08, b = i * 0.10;
      if(a == A && b == B){
        cout << i << endl;
        return 0;
      }
    }

    cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    ll h,n,a,x=0;
    cin >> h >> n;
    for(ll i=0;i<n;i++){
        cin >> a;
        x+=a;
    }
    if(x>=h) cout << "Yes";
    else    cout << "No";
}   

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

int main() {
  int n;
  cin >> n;
  vector<string> name(n);
  vector<int> time(n);
  for(int i=0;i<n;i++){
    cin >> name.at(i) >> time.at(i);
  }
  string a;
  cin >> a;
  int f=0;
  for(int i=0;i<n;i++){
    if(name.at(i) == a){
      f=i;
    }
  }
  int b=0;
  for(int i=f+1;i<n;i++){
    b=b+time.at(i);
  }
  cout << b << endl;
}


Measured memory_bytes: 256
player_list = ['a', 'b', 'c']

s = {player_list[n]: list(raw_input()) for n in xrange(len(player_list))}

current_turn = player_list[0]

get_winner = lambda x, s: x.upper() if not s[x] else get_winner(s[x].pop(0), s)

print get_winner(current_turn, s)

Measured memory_bytes: 2820
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T>

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

vvi adl_input(int N,int M){ //N頂点M辺
  vvi L(N);
  rep(i,M){
    int a,b;
    cin >> a >> b;
    //a--;b--;
    L[a].push_back(b);
    L[b].push_back(a);
  }
  return L;
}

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

vector<int> bfs(vvi L,int S){ //List,Start
  vector<int> v(L.size(),-1);
  v[S]=0;
  queue<int> q;
  q.push(S);
  while(!q.empty()){
    int a=q.front();
    q.pop();
    for(int x:L[a]){
      if (v[x]==-1){
        v[x]=v[a]+1;
        q.push(x);
      }
    }
  }
  return v;//startからの距離
}

void initialize(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << fixed << setprecision(15);
}

/////////////////////////////////////////

int main(){
  initialize();
  int N;
  cin >> N;
  int a[N];
  int b[N];
  rep(i,N){
    cin >> a[i];
    b[i]=0;
  }
  int cnt=0;
  vector<int> v;
  rep(i,N){
    int x=N-i;
    int s=0;
    for(int j=x*2;j<=N;j+=x){
      s+=b[j-1];
    }
    b[x-1]=(s+a[x-1])%2;
    if(b[x-1]==1){
      cnt++;
      v.push_back(x);
    }
  }
  cout << cnt << endl;
  rep(i,cnt) cout << v[cnt-i-1] << (i==cnt-1?"\n":" ");
  return 0;
}


Measured memory_bytes: 3192
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

// const abcd = "abcdefghijklmnopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var dr = [...]int{0, 1, 1, 1, 0, -1, -1, -1, 0}
var dc = [...]int{1, 1, 0, -1, -1, -1, 0, 1, 0}

func main() {
	log.SetFlags(log.Lshortfile)
	nextReader = NewScanner()
	N := nextInt()
	words := make([]string, N)
	for i := 0; i < N; i++ {
		words[i] = nextString()
	}
	check := map[string]int{}
	ans := "Yes"
	for i := 0; i < N; i++ {
		check[words[i]]++
		if check[words[i]] > 1 {
			ans = "No"
		}
	}
	for i := 1; i < N; i++ {
		b1 := []byte(words[i-1])
		b2 := []byte(words[i])
		if b1[len(b1)-1] != b2[0] {
			ans = "No"
		}
	}
	fmt.Println(ans)
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

var nextReader func() string

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

typedef complex<double> Complex;

vector<Complex> fft(vector<Complex> A, int n, int sgn = 1) {

	if (n == 1) return A;

	vector<Complex> f0, f1;
	for (int i = 0; i < (n / 2); i++) {
		f0.push_back(A[i * 2 + 0]);
		f1.push_back(A[i * 2 + 1]);
	}

	f0 = fft(f0, n / 2, sgn), f1 = fft(f1, n / 2, sgn);

	Complex zeta = Complex(cos(2.0 * M_PI / n), sin(2.0 * M_PI / n) * sgn);
	Complex pow_zeta = 1;

	for (int i = 0; i < n; i++) {
		A[i] = f0[i % (n / 2)] + pow_zeta * f1[i % (n / 2)];
		pow_zeta *= zeta;
	}
	return A;
}

vector<Complex> inv_fft(vector<Complex> A, int n) {
	auto ret = fft(A, n, -1);
	for (int i = 0; i < n; i++) { ret[i] /= n; }
	return ret;
}

vector<Complex> multiply(vector<Complex>& X, vector<Complex>& Y) {
	int n = 1;
	while (n < (X.size() + Y.size() + 1)) n *= 2;

	vector<Complex> ret;

	X.resize(n), Y.resize(n);
	X = fft(X, n, 1), Y = fft(Y, n, 1);

	for (int i = 0; i < n; i++) { ret.push_back(X[i] * Y[i]); }
	return inv_fft(ret, n);
}

signed main() {
	int n, m, k, l;
	cin >> n >> m >> k >> l;

	vector<string> b(n);
	rep(i, n) cin >> b[i];

	string s;
	cin >> s;

	vector<vector<int>> visited(m, vector<int>(m, 0));
	visited[0][0] = 0;
	int y = 0, x = 0;
	rep(i, s.size()) {
		if (s[i] == 'R') x++;
		if (s[i] == 'D') y++;
		if (s[i] == 'L') x--;
		if (s[i] == 'U') y--;
		visited[y][x]++;
	}

	vector<Complex> ca(m * m, Complex(0, 0)), cb;
	rep(i, n) rep(j, n) ca[i * m + j] = Complex(b[i][j] == 'X', 0);
	rep(i, m) rep(j, m) cb.emplace_back(visited[i][j]);

	int cnt = 0;
	auto ans = multiply(ca, cb);
	// show(ans.size())
	range(i, 0, m * m + 0) {
		// cout << ans[i] << endl;
		if (static_cast<int>(ans[i].real() + 0.5) >= k) cnt++;
	}
	cout << cnt << endl;
}



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

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

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    ll N, K;
    cin >> N >> K;
    int ans = 0;
    while (N) {
        ans += 1;
        N /= K;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007

using namespace std;


int main(void){
	int n;
	cin >> n;
	ll x[n],work[n];
	rep(i,n){
		cin >> x[i];
		work[i] = x[i];
	} 
	sort(work,work+n);
	rep(i,n){
		if(x[i] <= work[n/2-1]) cout << work[n/2] << endl;
		else cout << work[n/2-1] << endl;
	}

	return 0;

}


Measured memory_bytes: 5248
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    
    scanf("%d",&n);
    
    int count = 0;
    for(int i = 0; i < n && count < 3; i++)
    {
        int d1, d2;
        scanf("%d %d", &d1, &d2);
        
        if(d1==d2)
            count++;
        else
            count = 0;
            
        //printf("%d\n",count);
    }
    
    printf("%s\n", (count==3)? "Yes":"No");
}


Measured memory_bytes: 3760
/*
 *
 * Author: r3gz3n
 * 
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define rep(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)


#define endl '\n'


class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
		int x, r, d;
        in >> r >> d >> x;
        rep(i, 0, 10, 1) {
            x = r*x - d;
            out << x << endl;
        }
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    string l[36]={},m[36]={};
    for(int i = 0; i<n; i++){
      cin>>l[i];
      m[i]=l[i];
    }
    for(int i = 0; i < n-1; i++){
      for(int j = n-1; j > i; j--){
          if (l[j][1]<l[j-1][1]){
            swap(l[j],l[j-1]);
          }
      }
    }
    for(int i= 0; i < n-1; i++){
        cout<<l[i]<<" ";
    }
    cout<<l[n-1]<<endl;
    cout<<"Stable"<<endl;
    for(int i = 0; i<n-1; i++){
        int minj = i;
      for(int j = i; j<n; j++){
        if (m[j][1]<m[minj][1]) minj = j;
      }
      if(i!= minj) swap(m[minj],m[i]);
    }
    for(int i = 0; i < n-1; i++){
        cout<<m[i]<<" ";
    }
    cout<<m[n-1]<<endl;
    for(int i = 0 ; i<n ; i++){
        if(l[i]==m[i]){continue;
        }else{
          cout<<"Not stable"<<endl;
          return 0;
        }
    }
    cout<<"Stable"<<endl;
}


Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void input_query(int a, vector<int> &b)
{
    for (int i = 0; i < a; i++)
    {
        cin >> b[i];
    }
}

int main()
{
    int n, m;
    cin >> n;
    vector<int> A(n);
    input_query(n, A);
    cin >> m;
    vector<int> B(m);
    input_query(m, B);
    cout << lexicographical_compare(A.begin(), A.end(), B.begin(), B.end()) << endl;
}


Measured memory_bytes: 3120