akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
int main()
{    
    string t;
    vector<string>ans;
    int H,W;
    cin >> H >> W;
    for(int i = 0;i < H;i++)
    {
        cin >> t;
        ans.push_back(t);
        ans.push_back(t);
    }
    for(int i = 0;i < ans.size();i++)
    {
        cout << ans[i] << '\n';
    }
}   



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

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

int main()
{
    long long int a, b, c, d, ans, temp1, temp2, temp3, temp4;
    cin>>a>>b>>c>>d;
    temp1=a*c;
    temp2=a*d;
    temp3=b*c;
    temp4=b*d;
    ans=max(temp1, max(temp2, max(temp3, temp4)));
    cout<<ans<<endl;

}


Measured memory_bytes: 3604
n = int(input())
alfabet = 'abcdefghijklmnopqrstuvwxyz'
name = ''
while True:
  if n <= 26:
    name = alfabet[n-1] + name
    break
  else:
    num = n % 26
    name = alfabet[num-1] + name
    if n%26 ==0:
      n = (n//26) -1
    else:
      n = n//26
print(name)

Measured memory_bytes: 9192
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = []
l = 0

for i in range(m):
    if l+2 <= m:
        b.append(int(abs(a[l] - a[l+1])))
        l += 1
    elif l+2>m:
        b.append(int(n-a[l]+a[0]))

b.pop(b.index(max(b)))
print(sum(b))
  
      

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long a, b, k;
  cin >> a >> b >> k;
  if (a > k){
    a = a - k;
  }
  else{
    k = k - a;
    a = 0;
    if (b > k){
      b = b - k;
    }
    else
      b = 0;
  }
  cout << a << ' ' << b << '\n';
  return 0;
}


Measured memory_bytes: 256
import copy
n,m = map(int,input().split())
a00 = 0
a0 = 1
if m > 0:
    ann = 0
    for i in range(m):
        an = int(input())
        if an != ann:
            for x in range(an-ann-1):
                ak = copy.copy(a00 + a0)
                a00 = copy.copy(a0)
                a0 = copy.copy(ak)
            ann = copy.copy(an)
            a00 = copy.copy(a0)
            a0 = 0
        else:
            ann = copy.copy(an)
    for j in range(n-an):
        ak = copy.copy(a00+a0)
        a00 = copy.copy(a0)
        a0 = copy.copy(ak)
else:
    for i in range(n):
        ak = copy.copy(a00 + a0)
        a00 = copy.copy(a0)
        a0 = copy.copy(ak)
print(a0 % 1000000007)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const int maxn = 2e5 + 5;
ll n, d, a;
ll A[maxn];
pii p[maxn];
int main() {
	ios::sync_with_stdio(false);
	cin >> n >> d >> a;
	cin.tie(nullptr);
	for(int i = 1; i <= n; ++i) {
		ll x, h;
		cin >> x >> h;
		p[i] = make_pair(x, h);
	}
	sort(p + 1, p + n + 1);
	ll ans = 0 , tmp = 0;
	for(int i = 1; i <= n; ++i) {
		p[i].second -= tmp;
		if(p[i].second > 0) {
			int l = i, r = n;
			ll c = p[i].first + 2ll * d;
			ll need = (p[i].second + a - 1) / a;
			tmp += need * a;
			ans += need;
			while(l <= r) {
				int mid = l + r >> 1;
				if(p[mid].first > c) r = mid - 1;
				else l = mid + 1;
			}
			A[r] += need * a;
		}
		tmp -= A[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <map>
using namespace std;
int main()
{
	long long n,i,result=2;
	cin >> n;
	for (i = 0; i < n; i++) {
		result = (result + 1) * 2;
	}
	cout << result << endl;

	return 0;
}

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

int main() {
    int a,b;
    string s;
    cin >> a >> b >> s;
    bool ans = true;
    if(s.size()!= a+b+1) ans = false;
    else if(s[a] != '-') ans = false;
    for(int i = 0; i < a; i++){
        if(!('0'<=s[i]&&s[i]<='9')) ans = false;
    }
    for(int i = a + 1; i <= a + b; i++){
        if(!('0'<=s[i]&&s[i]<='9')) ans = false;
    }
    if(ans) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
signed main(){
	int a;
	while( scanf("%d", &a) != EOF ){
		int ans = 0;
		for(int i=a;i<600;i+=a){
			ans += i*i*a;
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	int w,a, b, c, d;
	cin >> w >> a >> b;
	c = a + w;
	d = b + w;
	if (a < d&&b < c)cout << 0<<endl;
	else {
		if (a - d < 0)cout << b - c << endl;
		else cout << a - d<<endl;
	}
	return 0;
}

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

int main()
{
  int N, M;
  cin >> N >> M;
  string S(N, 'x');
  for (int m = 0; m < M; ++m)
  {
    int s;
    char c;
    cin >> s >> c;
    auto & digit = S[s - 1];
    if ((1 < N) && (1 == s) && ('0' == c))
    {
      cout << "-1";
      return 0;
    }
    else if ('x' == digit)
      digit = c;
    else if (digit != c)
    {
      cout << "-1";
      return 0;
    }
  }
  if (1 == N)
  {
    if ('x' == S[0])
      S[0] = '0';
  }
  else
  {
    if ('x' == S[0])
      S[0] = '1';
    for (int i = 1; i < N; ++i)
      if ('x' == S[i])
        S[i] = '0';
  }
  cout << stoi(S);
  return 0;
}


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

long long inf = 1 << 30;
long long mod = 1e9 + 7;

int main(){

    int N;
    cin >> N;

    vector<vector<vector<vector<int>>>> dp(N + 1, vector<vector<vector<int>>>(4, vector<vector<int>>(4, vector<int>(4, 0))));

    int A = 0, G = 1, C = 2, T = 3;
    // AGC, GAC, ACG, A*GC, AG*C => out

    for(int c3 = 0; c3 < 4; c3++){
        for(int c2 = 0; c2 < 4; c2++){
            for(int c1 = 0; c1 < 4; c1++){
                if(c3 == A && c2 == G && c1 == C) continue;
                if(c3 == G && c2 == A && c1 == C) continue;
                if(c3 == A && c2 == C && c1 == G) continue;
                dp[3][c3][c2][c1] = 1;
            }
        }
    }

    for(int n = 3; n < N; n++){
        for(int c3 = 0; c3 < 4; c3++){
            for(int c2 = 0; c2 < 4; c2++){
                for(int c1 = 0; c1 < 4; c1++){
                    for(int c0 = 0; c0 < 4; c0++){
                        if(c2 == A && c1 == G && c0 == C) continue;
                        if(c2 == G && c1 == A && c0 == C) continue;
                        if(c2 == A && c1 == C && c0 == G) continue;
                        if(c3 == A && c1 == G && c0 == C) continue;
                        if(c3 == A && c2 == G && c0 == C) continue;

                        dp[n + 1][c2][c1][c0] += dp[n][c3][c2][c1];
                        dp[n + 1][c2][c1][c0] %= mod;
                    }
                }
            }
        }
    }

    int ans = 0;
    for(int c3 = 0; c3 < 4; c3++){
        for(int c2 = 0; c2 < 4; c2++){
            for(int c1 = 0; c1 < 4; c1++){
                ans += dp[N][c3][c2][c1];
                ans %= mod;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
// Reads multiple ints in a line, separate by a space.
// It works even if the actual number of ints is smaller than n.
// WARNING: This function does not work for -2^63.
// NOTE: This function does not handle error cases.
// Verified: ARC096D
fun fastReadLongs(n: Int): LongArray {
  val xs = LongArray(n)
  val s = readLine()!!
  var currentValue = 0L
  var isNegative = false
  var currentIndex = 0
  for (c in s) {
    if (c == ' ') {
      xs[currentIndex] = currentValue * if (isNegative) -1L else 1L
      currentValue = 0
      isNegative = false
      currentIndex++
    } else if (c == '-') {
      isNegative = true
    } else {
      currentValue *= 10
      currentValue += c - '0'
    }
  }
  xs[currentIndex] = currentValue * if (isNegative) -1L else 1L
  return xs
}

// Returns a number of elements less than a specified value.
// The input array needs be sorted.
// Verified: ARC 092 D
fun countLessThan(xs: LongArray, v: Long): Int {
  var l  = 0
  var u = xs.size - 1
  while (l <= u) {
    val m = (l + u + 1) / 2
    if (xs[m] < v) {
      l = m + 1
    } else {
      u = m - 1
    }
  }
  return l
}

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val xs = fastReadLongs(n)

  // sums[i] = xs[0] + ... + xs[i]
  val sums = LongArray(n)
  sums[0] = xs[0]
  for (i in 1 until n) {
    sums[i] = sums[i - 1] + xs[i]
  }

  var ans = Long.MAX_VALUE
  for (p2 in 2..(n - 2)) {
    val s1 = sums[p2 - 1]
    val s2 = sums[n - 1] - s1

    // Find p1
    var p1 = countLessThan(sums, s1 / 2L)
    if (p1 == 0) p1++
    var t1 = sums[p1 - 1]
    var t2 = s1 - t1
    if (Math.abs(t1 - t2) > Math.abs((t1 + xs[p1]) - (t2 - xs[p1]))) {
      t1 += xs[p1]
      t2 -= xs[p1]
      p1++
    }

    // Find p3
    var p3 = countLessThan(sums, s1 + s2 / 2L)
    if (p3 == p2) p3++
    var t3 = sums[p3 - 1] - s1
    var t4 = s2 - t3
    if (Math.abs(t3 - t4) > Math.abs((t3 + xs[p3]) - (t4 - xs[p3]))) {
      t3 += xs[p3]
      t4 -= xs[p3]
      p3++
    }

//    println("p2: $p2 p1: $p1 p3: $p3")
//    println("s1: $s1 s2: $s2")
//    println("t1: $t1 t2: $t2 t3: $t3 t4: $t4")
    val tMax = listOf(t1, t2, t3, t4).max()!!
    val tMin = listOf(t1, t2, t3, t4).min()!!
    ans = Math.min(ans, tMax - tMin)
  }

  println(ans)
}


Measured memory_bytes: 76456
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0;true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}
int main() {
	int n;
	cin >> n;
	int a2 = 0;
	int a4 = 0;
	int hoka = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a % 4 == 0) {
			a4++;
		}
		else if (a % 2 == 0) {
			a2++;
		}
		else {
			hoka++;
		}
	}
	if (a2 > 0) hoka++;
	if (hoka - a4 <= 1) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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


int main()
{

	int a[3][3];
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> a[i][j];
		}
	}
	string ans = "No";
	for (int a1 = 0; a1 <=100; a1++)
	{
		for (int a2 = 0; a2 <= 100; a2++)
		{
			for (int a3 = 0; a3 <= 100; a3++)
			{
				int f = 0;
				if (a[0][0] - a1 == a[1][0]-a2 && a[1][0]-a2 == a[2][0]-a3)
				{
					f++;
				}
				if (a[0][1] - a1 == a[1][1]-a2 && a[1][1]-a2 == a[2][1]-a3)
				{
					f++;
				}
				if (a[0][2] - a1 == a[1][2]-a2 && a[1][2]-a2 == a[2][2]-a3)

				{
					f++;
				}
				if (f == 3)
				{
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
	

}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    string s, t;
    cin >> s;
    cin >> t;
    if (s == t)
    {
        cout << "No" << endl;
        return 0;
    }
    ll n = s.length(), m = t.length();
    sort(ALL(s));
    sort(ALL(t), greater<char>());
    if (n < m)
    {
        if (s.substr(0, n) == t.substr(0, n))
        {
            cout << "Yes" << endl;
            return 0;
        }
        REP(i, n)
        {
            if (s[i] < t[i])
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }
    else
    {
        REP(i, m)
        {
            if (s[i] < t[i])
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;

class Test
{
    static void Main()
    {
        string[] ss = Console.ReadLine().Split(' ');
        int a = Convert.ToInt32(ss[0]);
        int b = Convert.ToInt32(ss[1]);
        int c = Convert.ToInt32(ss[2]);

        string ans;

        if ((a < b) && ( b < c)) ans = "Yes";
        else ans = "No";

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 17996
import sys
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a = I()

print(a+a**2+a**3)

Measured memory_bytes: 71028
#include <bits/stdc++.h>
#define int long long
#define moder 1234567
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
int mypow(int x,int y){
	int res=1;
	rep(i,y)res*=x;
	return res;
}
signed main() {
	int x;
	cin>>x;
	int ans=0;
	for(int i=1;i<=1000;i++){
		for(int j=2;j<=30;j++){
			if(mypow(i,j)>x)break;
			ans=max(ans,mypow(i,j));
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long int64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 2e3+5;
int gcd(int a, int b) { return b?gcd(b, a%b):a; }
struct Edge
{
    int next, to;
    Edge(int next = 0, int to = 0):next(next), to(to) {};
}edge[N*N];
int tot, head[N];
int n, vis[N], f[N][N], deg[N], a[N];
void add(int x, int y) { edge[++tot] = Edge(head[x], y), head[x] = tot, ++deg[y]; } 
void dfs(int x)
{
    vis[x] = 1;
    for(int y = 1; y <= n; ++y)
        if(!vis[y]&&f[x][y])
            add(x, y), dfs(y);
}
int main()
{
    n = read();
    for(int i = 1; i <= n; ++i) a[i] = read();
    sort(a+1, a+1+n);
    for(int i = 1; i <= n; ++i) 
        for(int j = 1; j < i; ++j)
            if(gcd(a[i], a[j]) != 1) f[i][j] = f[j][i] = 1;
    for(int i = 1; i <= n; ++i) if(!vis[i]) dfs(i);
    priority_queue<int> q;
    for(int i = 1; i <= n; ++i) if(!deg[i]) q.push(i);
    while(q.size())
    {
        int x = q.top(); q.pop();
        printf("%d ", a[x]);
        for(int i = head[x]; i; i = edge[i].next) q.push(edge[i].to);
    }
    return 0;
}

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

using namespace std;
const int N = 1e5+5;
const int MOD = 1e9+7;
int dp[N],add[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin >> n >> k;
    dp[0] = 1;
    for (int i = 1; i<=n; i++)
    {
        int a;
        cin >> a;
        memset(add,0,sizeof(add));
        for (int j = k; j>=0; j--)
        {
            int L = j+1, R = j+min(a,k-j);
            if (L<=R)
            {
                add[L] = (add[L]+dp[j])%MOD;
                if (R+1<=k)
                    add[R+1] = ((add[R+1]-dp[j])%MOD+MOD)%MOD;
            }
        }
        int s = 0;
        for (int j = 1; j<=k; j++)
        {
            s = (s+add[j])%MOD;
            dp[j] = (dp[j]+s)%MOD;
        }
    }
    cout << dp[k];
}


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

using namespace std;

//const long long int MOD = 998244353;
const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

void Solve(long double &ans, int s, long double a, long double r) {
	ans += a + r * (s - 1) / 2;
	//cout << a << " " << r << endl;
	//cout << ans << endl;
	if (s == 2)return;
	Solve(ans, s - 2, a + a * 2 / s + r * 5 / s, r + r * 4 / s);
	return;
}

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

	cin >> N >> L >> R;
	long double ans = 0;
	Solve(ans, N * 2, L, R);
	cout << setprecision(15) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 3e5+10;
const ll mod =   1e9+7;

int main()
{  fast

ll n;
cin>>n;
string ans;
while(n){
	int x=n%26-1;
	if(x<0)
	 x+=26;
	 char ch='a'+x;
	ans+=ch;
	n=(n-1)/26;
	
}
reverse(ans.begin(),ans.end());
cout<<ans;
}

Measured memory_bytes: 3640
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXSIZE 10000000;

const int MAX = 510000;
const int MOD = 1000000007;
const long long INF = 1LL << 60;

const ll MAXINDx = 3000;
const ll MAXINDy = 3000;

double dp[MAXINDx][MAXINDy] = {0};

vector<vector<int>> edges;

ll R, B, x, y;

bool check(ll mid)
{
    if (mid > R || mid > B)
        return false;
    ll num = (R - mid) / (x - 1) + (B - mid) / (y - 1);
    return (num >= mid);
}

bool comp(const pair<int, int> a, const pair<int, int> b)
{
    return a.second < b.second;
}

int main()
{
    int N, M;
    map<string, int> bt;

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        string s;
        cin >> s;
        bt[s]++;
    }
    cin >> M;
    map<string, int> rt;
    for (int i = 0; i < M; i++)
    {
        string s;
        cin >> s;
        rt[s]++;
    }
    int ans = 0;
    for (auto ite = bt.begin(); ite != bt.end(); ++ite)
    {
        int num = (ite->second - rt[ite->first]);
        if (num < 0)
        {
            continue;
        }
        if (ans < num)
        {
            ans = num;
        }
    }

    cout << ans << endl;
    return 0;
}

/*Syakutori
cout << fixed << setprecision(10) << ans << endl;
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;



ll gcd(ll a,ll b){
  if(a%b == 0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
/*
int rec(int v){
    int res = 0;

    if(dp[v] > -1)return dp[v];

    for(auto nv: edges[v]){
        res = max(res, rec(nv) + 1);
    }
    return dp[v] = res;
}
*/


Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#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(int i = m; i < n; i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

//#define __DEBUG__
#ifdef  __DEBUG__
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    REP(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
// pair出力
template<typename T, typename U>
ostream& operator << (ostream& os, pair<T, U>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template<typename T, typename U>
ostream& operator << (ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template<typename T>
ostream& operator << (ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#endif

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    ll ans = 0;
    for (ll i = 1; i < N; i++) {
        if (i < sqrt(N)) {
            if (N % i == 0 && N / i - 1 > i) {
                ans += N / i - 1;
            }
        }
        else {
            break;
        }
    }
    cout << ans << endl;
    getchar(); getchar();
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
odd = []
even = []
ans = []

for i in range(n):
    if i % 2 == 0:
        odd.append(a[i])
    else:
        even.append(a[i])

if n == 1:
    print(a[0])
    exit()
else:
    if n % 2 == 0:
        even.reverse()
        ans = even + odd
    else:
        odd.reverse()
        ans = odd + even

print(" ".join(map(str,ans)))


Measured memory_bytes: 37144
#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    long long int n,sum=0;
    cin >> n;

   for(int i=1;i<=n;i++){
        if(i%3==0||i%5==0) continue;
        sum+=i;
   }
   cout<<sum;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int a[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  fill(a, a + n, false);
  int count = 0;
  int mcount = 0;
  REP(i, n) {
    int b;
    cin >> b;
    if(a[b]) {
      mcount++;
    } else {
      count++;
      a[b] = true;
    }
  }

  if(mcount % 2 == 0) cout << count << endl;
  else cout << count - 1 << endl;
}


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

int main()
{
	int n;
	cin>>n;
 string s;
  cin>>s;
  
  int length = s.length();
 
	for(int i=0;i<length;i++)
	{
		int pos = int(s[i]) - int('A') +1;
		if(pos+n>26)
		{
			s[i] = char(int(s[i])-26+n);
		}
		else
		s[i] = char(int(s[i])+n);
	}
	cout<<s;
  return 0;
}

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

using ll=long long; 

void solve(){
	int k,t;
	cin>>k>>t;
	vector<int>a(t);
	for(int i=0; i<t; i++){
		cin>>a[i];
	}
	int dif=k-*max_element(a.begin(), a.end());
	cout<<max(0, *max_element(a.begin(), a.end())-dif-1)<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int d, t, s;

int main() {
    cin >> d >> t >> s;
    if(s*t >= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3600
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S, W = il()
    print('unsafe' if S <= W else 'safe')


if __name__ == '__main__':
    main()


Measured memory_bytes: 10060
#include <iostream>
int main(int argc, char *argv[])
{
    using namespace std;
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b;
    cin >> a >> b;
    cout << (((a&b)&1)==1?"Odd\n":"Even\n");
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)

const int N_MAX = 100000;
const int H_MAX = 1000000000;

int N, H;
int a[N_MAX];
int b[N_MAX];

void solve() {
  sort(a, a + N, greater<int>());
  sort(b, b + N, greater<int>());
  int ax = a[0];
  int ans = 0;
  int sum = 0;
  REP(i, N) {
    if (sum >= H) break;
    if (b[i] <= ax) break;
    ans++;
    sum += b[i];
  }
  if (sum < H) {
    ans += (H - sum + ax - 1) / ax;
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &N, &H);
  REP(i, N) scanf("%d%d", a + i, b + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 896
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int a,b;
inline void solve(){
  IN2(a,b);
  OUT((a-1)+(a<=b));
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc103/tasks/abc103_d

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

    int a,b;
    P ps[M];
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        ps[i].first = b;
        ps[i].second = a;
    }

    sort(ps, ps + M);

    int ans = 0;
    int endtime = 0;
    for (P p : ps) {
        if (p.second >= endtime) {
            ans++;
            endtime = p.first;
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

 
void solve()
{
    int n;cin>>n;
    int h[n];
    REP(i,n) cin>>h[i];
    REP(i,n-1)if(h[i]>h[i+1])h[i+1]++;
    REP(i,n-1)if(h[i]>h[i+1]){cout<<"No"<<endl;return;}
    cout<<"Yes"<<endl;
}

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

Measured memory_bytes: 768
n,k,q = map(int,input().split())

pl = [0 for i in range(n)]

a = []
for i in range(q):
        aa = int(input())
        a.append(aa)

for i in range(q):
        pl[a[i]-1] += 1

#print(pl)

for i in range(n):
        if q-pl[i] >= k:
                print("No")
        else:
                print("Yes")


Measured memory_bytes: 8640
#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> x(N), y(N), perm(N);
    rep(i, N) {
        cin >> x[i] >> y[i];
        perm[i] = i;
    }
    
    double ans = 0;
    int count = 0;
    do {
        count++;
        int xx = 0, yy = 0;
        for (int i = 1; i < N; i++) {
            xx = x[perm[i]] - x[perm[i - 1]];
            yy = y[perm[i]] - y[perm[i - 1]];
            ans += sqrt(xx * xx + yy * yy);
        }
    } while (next_permutation(perm.begin(), perm.end()));

    printf("%.12f\n", ans / count);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        if(x == 1){
            System.out.println("0");
        }else{
            System.out.println("1");
        }
    }
}


Measured memory_bytes: 35680
using System;
using System.Collections.Generic;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            //int N, M, K;

            //string[] number = Console.ReadLine().Split(' ');

            //N = int.Parse(number[0]);
            //M = int.Parse(number[1]);
            //K = int.Parse(number[2]);

            //string[] number2 = Console.ReadLine().Split(' ');

            //var A = new List<int>();

            //for (int i = 0; i < N; i++)
            //{
            //    A.Add(int.Parse(number2[i]));
            //}

            //string[] number3 = Console.ReadLine().Split(' ');

            //var B = new List<int>();

            //for (int i = 0; i < M; i++)
            //{
            //    B.Add(int.Parse(number3[i]));
            //}


            ////A.Sort();
            ////B.Sort();





            //int readTime = 0;
            //int ans = 0;

            //while (readTime < K && (A.Count > 0 || B.Count > 0))
            //{
            //    if (A.Count == 0 || A[0] > B[0])
            //    {
            //        if (readTime + B[0] > K)
            //        {
            //            break;
            //        }
            //        else
            //        {
            //            readTime += B[0];
            //            B.RemoveAt(0);
            //            ans++;
            //        }
            //    }
            //    else
            //    {
            //        if (B.Count == 0 || readTime + A[0] > K)
            //        {
            //            break;
            //        }
            //        else
            //        {
            //            readTime += A[0];
            //            A.RemoveAt(0);
            //            ans++;
            //        }
            //    }
            //}

            //Console.WriteLine(ans);



            //var test = new List<int>();
            //test.Add(1);

            //test.RemoveAt(0);

            ////Console.WriteLine(test[0]);

            //if (test.Count == 0)
            //{
            //    Console.WriteLine("aa");
            //}
            //else
            //{
            //    Console.WriteLine("bb");
            //}


            int a = int.Parse(Console.ReadLine());

            Console.WriteLine(a + a*a + a*a*a);
        }
    }
}


Measured memory_bytes: 27524
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;


int main(){
    long long N;
    scanf("%lld", &N);
    vector<long long> A(3 * N);
    for(int i = 0; i < 3 * N; i++)scanf("%lld", &A[i]);
    sort(A.begin(), A.end());
    long long sum = 0;
    for(int i = N; i < 3 * N; i += 2)sum += A[i];
    printf("%lld\n", sum);
}

Measured memory_bytes: 2560
using System;
using System.Linq;

namespace ABC121A
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            string[] H_W= Console.ReadLine().Split(' ');
            string[] h_w=Console.ReadLine().Split(' ');
            int H = int.Parse(H_W[0]);
            int W = int.Parse(H_W[1]);
            int h = int.Parse(h_w[0]);
            int w = int.Parse(h_w[1]);
            int ans = (H-h)*(W-w);
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int ans = 1;
        if (n > 1) {
            for (int i = 0; i < n - 1; i++) {
                if (a[i + 1] > a[i]) {
                    ans++;
                }
            }
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s ^= a[i];
  }
  for(int i=0; i<n; i++)
    cout << (s^a[i])<<endl;
  return 0;
}

Measured memory_bytes: 4368
#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>
using namespace std;

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

    long long ans = 0;
    for(int i=0; i<n; ++i){
        ans += a[i] / 2;
        if(i < n - 1 && a[i] % 2 == 1 && a[i+1] > 0){
            -- a[i+1];
            ++ ans;
        }
    }
    cout << ans << endl;

    return 0;
}

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

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main() {
	int a, b;
	cin >> a >> b;
	
	ll ans = lcm(a, b);

	cout << ans << endl;	
}


Measured memory_bytes: 256
n = int(input())
n2 = int(n**0.5//1)

def div(n,p):
    cnt = 0
    a = 1
    while n%p == 0:
        n = n//p
        cnt += 1
        if cnt == a:
            cnt = 0
            a += 1
    return [n,a-1]

ans = 0
for z in range(2,n2):
    if n%z == 0:
        n,cur = div(n,z)
        ans += cur

if n != 1: ans += 1

print(ans)

Measured memory_bytes: 9468
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
P d[100005];
int main() {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  for (int i=0; i<N; i++) {
    cin >> d[i].first >> d[i].second;
  }
  sort(d, d+N);
  ll c = M;
  ll ret = 0;
  for (int i=0; i<N; i++) {
    if (d[i].second >= c) {
      ret += c * d[i].first;
      break;
    }
    ret += d[i].first * d[i].second;
    c -= d[i].second;
  }
  cout << ret << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define bit(n) (1LL << (n))
#define INF 1e11
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    lli A, B, Q;
    cin >> A >> B >> Q;
    vector<lli> S;
    vector<lli> T;
    vector<lli> x(Q);

    S.push_back(-INF);
    REP(i, A)
    {
        lli p;
        cin >> p;
        S.push_back(p);
    }
    S.push_back(INF);

    T.push_back(-INF);
    REP(i, B)
    {
        lli p;
        cin >> p;
        T.push_back(p);
    }
    T.push_back(INF);

    REP(i, Q)
    {
        lli x;
        cin >> x;
        auto t0 = lower_bound(ALL(T), x);
        auto s0 = lower_bound(ALL(S), x);
        auto t1 = prev(t0);
        auto s1 = prev(s0);
        lli ans = INF;
        for (lli T : {*t0, *t1})
        {
            for (lli S : {*s0, *s1})
            {
                // cout << T << " " << S << "\n";
                lli d1 = abs(T - x) + abs(S - T);
                lli d2 = abs(S - x) + abs(S - T);
                ans = min({ans, d1, d2});
            }
        }
        cout << ans << "\n";
    }
}

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

using namespace std;

int main(){
	int N;
	cin >> N;
	
	std::vector<int> a(N);
	
	for (int i=0; i<N; ++i) {
		cin >> a.at(i);
	}
	
	vector<int> n_balls(N);
	int sum_i = 0;
	int base, mul;
	int largest = -1;
	for (int i=N-1; i>=0; --i) {
		sum_i = 0;
		base = i+1;
		mul = 2;
		while (base * mul <= N) {
			sum_i += n_balls.at(base * mul - 1);
			mul++;
		}
		
		n_balls.at(i) = abs((a.at(i) - sum_i) % 2);
		
		if (largest == -1 && n_balls.at(i) != 0) {
			largest = i;
		}
	}
	
	int count = 0;
	for (int i=0; i<largest+1; ++i) {
		count += n_balls.at(i);
	}
	
	if (largest == -1) {
		cout << 0 << endl;
	} else {
		cout << count << endl;
		
		for (int i=0; i<=largest; ++i) {
			if (n_balls.at(i) == 1) {
				cout << i+1;
			}
			if (i != largest) {
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 2560
S=input()
Q=int(input())
A=[list(input().split()) for i in range(Q)]
c=0
R=""
L=""
for i in range(Q):
    if A[i][0]=="1":
        c+=1
        continue
    if c%2==1 and A[i][0]=="2":
        if A[i][1]=="1":
            R=R+A[i][2]
        elif A[i][1]=="2":
            L=A[i][2]+L
    elif c%2==0 and A[i][0]=="2":
        if A[i][1]=="1":
            L=A[i][2]+L
        elif A[i][1]=="2":
            R=R+A[i][2]
S=L+S+R
if c%2==1:
    S=S[::-1]
print(S)

Measured memory_bytes: 30652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc62
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int x = int.Parse(str[0]);
            int y = int.Parse(str[1]);
            x = group(x);
            y = group(y);
            if (x == y)
            {
                Console.WriteLine("Yes");
            }else
            {
                Console.WriteLine("No");
            }
        }

        static public int group(int x)
        {
            int ans = 0;
            if (x == 4 || x == 6 || x == 9 || x == 11)
            {
                ans = 1;
            }else if (x == 2)
            {
                ans = 2;
            }
            return ans;
        }
    }
}


Measured memory_bytes: 11092
import java.util.Arrays;

public class Main {

  private static void solve() {
    int n = ni();

    long[] dp = new long[n + 1];
    Arrays.fill(dp, Long.MAX_VALUE / 10);
    dp[0] = 0;

    for (int i = 0; i <= n; i++) {
      for (int j = 6; i + j <= n; j *= 6) {
        dp[i + j] = Math.min(dp[i + j], dp[i] + 1);
      }
    }

    for (int i = 0; i <= n; i++) {
      for (int j = 9; i + j <= n; j *= 9) {
        dp[i + j] = Math.min(dp[i + j], dp[i] + 1);
      }
    }

    long min = Long.MAX_VALUE;
    for (int i = 0; i <= n; i++) {
      min = Math.min(min, (n - i) + dp[i]);
    }
    System.out.println(min);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 23252
while True:
    a, op, b = input().split()
    aa = int(a)
    bb = int(b)
    if op == "?" :
        break
    if op == "+" :
        ans = aa + bb
    elif op == "-" :
        ans = aa - bb
    elif op == "*" :
        ans = aa * bb
    elif op == "/" :
        ans = aa // bb
    print(ans)


Measured memory_bytes: 5592
s=str(input())
s=list(s)
n=len(s)

point=[0]*n

cnt=1
for i in range(n-1):
  if s[i]=="R" and s[i+1]=="L":
    point[i]=cnt
    cnt=1
  elif s[i]=="R":
    cnt+=1
    
for i in reversed(range(1,n)):
  if s[i]=="L" and s[i-1]=="R":
    point[i]=cnt
    cnt=1
  elif s[i]=="L":
    cnt+=1
    
ans=[0]*n
for i in range(n-1):
  if point[i]!=0 and point[i+1]!=0:
    ans[i]+=(point[i]+1)//2+point[i+1]//2
    ans[i+1]+=(point[i+1]+1)//2+point[i]//2
    point[i+1]=0
    

for i in range(n):
  print(ans[i],end=" ")

Measured memory_bytes: 11484