akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define ll long long

const ll mod = 1e9 + 7;
const ll maxn = 2e5 + 5;
const double pi = 3.1415926535897932384626433832795028841971693993751058209749445923078;
//iostream::sync_with_stdio(false);

int main()
{
    int A, B, a, b;
    cin >> A >> B;
    for (int i = 1; i < 1010; i++)
    {
        a = i * 0.08;
        b = i * 0.1;
        if (A == a && B == b)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

int main()
{
	int k;
	while (scanf("%d", &k) != EOF)
	{
		if (k <= 500)
		{
			printf("%d\n", k);
			for (int i = 1; i <= k; ++i) for (int j = 1; j <= k; ++j)
				printf("%d%c", i, " \n"[j == k]);
		}
		else
		{
			int n = (k + 3) / 4 * 2;
			printf("%d\n", n);
			for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j)
			{
				int x;
				if (i & 1) x = (i + j) % n;
				else x = n + (i + j) % n;  
			    if (x >= k) x -= n; 	
				printf("%d%c", x + 1, " \n"[j == n]);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int x,a,b;
	cin>>x>>a>>b;
	if(abs(x-a)>=abs(x-b)){
		cout<<'B'<<endl;
	}
	else if(abs(x-a)<=abs(x-b)){
		cout<<'A'<<endl;
	}
	
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
   
   int N;
   scanf("%d",&N);
   
   int A[N+1];
   int B[N];
   int i;
   
   for (i = 0; i < N + 1; i++) {
      scanf("%d",&A[i]);
   }
   
   for (i = 0; i < N; i++) {
      scanf("%d",&B[i]);
   }
   
   long ans = 0;
   
   for (i = 0; i < N; i++) {
      
      //site i
      if (A[i] >= B[i]) {
         ans = ans + B[i];
         A[i] = A[i] - B[i];
         B[i] = 0;
      }
      else {
         ans = ans + A[i];
         B[i] = B[i] - A[i];
         A[i] = 0;
      }

      //site i + 1
      if (A[i + 1] >= B[i]) {
         ans = ans + B[i];
         A[i + 1] = A[i + 1] - B[i];
         B[i] = 0;
      }
      else {
         ans = ans + A[i + 1];
         B[i] = B[i] - A[i + 1];
         A[i + 1] = 0;
      }
   }
   
   printf("%ld\n",ans);
   
   
   return 0;
   
}


Measured memory_bytes: 896
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

int main(){
  int n,k,q;
  cin >> n >> k >> q;
  int a[q];
  int p[n+1];
  for(int i=0;i<q;i++){
    cin >> a[i];
  }
  for(int i=1;i<n+1;i++){
    p[i] = k-q;
  }
  for(int i=0;i<q;i++){
    p[a[i]] += 1;
  }

  for(int i=1;i<n+1;i++){
    if(p[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}


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

using namespace std;

int main() {
  vector<int> A(3);
  for (int i = 0; i < 3; ++i) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());

  int ans = 0;
  for (int i = 1; i < 3; ++i) {
    ans += abs(A[i - 1] - A[i]);
  }

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



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, z = 1;
    cin >> n;
    for (int i = 2; i <= 328; i++) {
        int c = i * i;
        while (c * i <= n) c *= i;
        if (c <= n) z = max(z, c);
    }
    cout << z;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn min_strength(x: Vec<i32>) -> i32 {
    let mut min = 100 * 100 * 100;
    for p in 0..100 {
        let mut sum_strength = 0;
        for i in 0..x.len() {
            sum_strength += (x[i] - p) * (x[i] - p);
        }
        min = if min > sum_strength { sum_strength } else { min }
    }
    min as i32
}

fn main() {
    input! {n: i32, x: [i32; n]}
    println!("{}", min_strength(x));
}


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

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n],ans=0;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n);
    for(int i=0;i<k;i++)
        ans+=arr[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    if (K  % 2 == 0) cout << A - B << endl;
    else cout << B - A << endl;
    return 0;
}

Measured memory_bytes: 3676
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pipii pair<int, pair<int, int> >
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;
#define N 3001
pipii dp[N][N];
// dp[i][j]: len(LCS(s[:i], t[:j]))
int main(){
    string ans = "";
    string s, t;
    cin >> s;
    cin >> t;
    rep(i, 0, N){
        dp[i][0] = pipii(0, pii(-1, -1));
        dp[0][i] = pipii(0, pii(-1, -1));
    }
    // どこから遷移したのか考える
    rep(i, 0, s.length()){
        rep(j, 0, t.length()){
            if(s[i] == t[j]){
                dp[i+1][j+1] = pipii(dp[i][j].first + 1, pii(i, j));
            } else {
                dp[i+1][j+1] = dp[i][j+1].first > dp[i+1][j].first ? 
                    dp[i][j+1] : dp[i+1][j];
                    /* pipii(dp[i][j+1].first, pii(i, j+1)) : */ 
                    /* pipii(dp[i+1][j].first, pii(i+1, j)); */
            }
        }
    }
    int i = dp[s.length()][t.length()].second.first;
    int j = dp[s.length()][t.length()].second.second;

    while (i >= 0 && j >= 0){
        ans += s[i];
        pipii tmp = dp[i][j];
        i = tmp.second.first;
        j = tmp.second.second;
    }
    /* rep(i, 0, s.length()+1){ */
    /*     rep(j, 0, t.length()+1){ */
    /*         cout << "(" << dp[i][j].second.first << ", " << dp[i][j].second.second << ") "; */
    /*     } */
    /*     cout << endl; */
    /* } */
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 105856
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node {int p, l, r;};
struct Node T[MAX];
int n;

void preParse(int u){
  if(u == NIL) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(){
  int i, v, l, r, root;

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    T[i].p = NIL;
  }

  for(i = 0 ; i < n ; i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }

  for(i = 0 ; i < n ; i++) if(T[i].p == NIL) root = i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



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


using namespace std;

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

	if (a.back() == b.front() && b.back() == c.front())
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
def getN():
    return int(input())

def getlist():
    return list(map(int, input().split()))

def solve(n,x):
    cnt = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k == x and i != j and i != k:
                    cnt += 1

    return cnt

while(True):
    n,x = getlist()
    if n == 0 and x == 0:
        break
    else:
        print(solve(n,x))


Measured memory_bytes: 5600
n = int(input())
A = list(map(int, input().split(' ')))
q = int(input())
M = list(map(int, input().split(' ')))

dp = {}

# Aの要素のうちp番目以降を組み合わせてtを作れるか?
def solve(p, t):
  if ((p, t) in dp):
    return dp[(p, t)]

  if (p == n):
    # 使う/使わないの枝をたどって0になったらOK
    return t == 0

  # p番目を使ったらtを引いて次へ, 使わなければtのまま次へ
  ans = solve(p+1, t-A[p]) or solve(p+1, t)
  dp[(p, t)] = ans
  return ans

for m in M:
  print("yes" if solve(0, m) else "no")



Measured memory_bytes: 9460
object Main {
  def main (args: Array[String]) {
    val input =  scala.io.StdIn.readLine().split(" ").map(_.toInt)
   
    List(input(0), input(1), input(2)) match{
      case l:List[Int] => println( l.sorted(Ordering[Int]).mkString(" ") )
      case _ => println("")
    }
  }
}

Measured memory_bytes: 43896
#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(){

string s,t;
cin >> s;
cin >> t;
int ans=0;
for(int i=0; i<s.size(); i++){
    if(s[i]!=t[i]) ans++;
}
cout << ans << endl;

}

Measured memory_bytes: 3884
from collections import deque
import heapq
N = int(input())
T = [[] for i in range(N)]
Edge = []
for i in range(N - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    T[a].append(b)
    T[b].append(a)
    Edge.append((a, b))
C = sorted(list(map(int, input().split())))

out = [(len(T[i]), i) for i in range(N)]
out.sort(reverse=True)

P = [-1] * N
que = [out[0]]
while que:
    u, n = heapq.heappop(que)
    P[n] = C.pop()
    for to in T[n]:
        if not P[to] < 0:
            continue
        heapq.heappush(que, [len(T[to]), to])

ans = 0
for a, b in Edge:
    ans += min(P[a], P[b])

print(ans)
print(*P, sep=' ')


Measured memory_bytes: 61016
import math
x,k,d = map(int,input().split())

def f( x, k, d, left):
	return abs(x + left*(-d) + (k-left)*d)


l = 0
r = k
res=10000000000000000;
while(r - l >2):
	
	m1 = l + (r - l) // 3
	m2 = r - (r - l) // 3
	
	f1 = f(x,k,d,m1)
	f2 = f(x,k,d,m2)
	
	res=min(res,f1)
	res=min(res,f2)
	
	if (f1 < f2):
		r = m2
	else:
		l = m1


for _i in range(l,r+1):
	cur = f(x,k,d,_i)
	res=min(res,cur)


print(res)

Measured memory_bytes: 62180
r, c = map(int, input().split())
h = [[0] * c for _ in range(r + 1)]
for i in range(r):
    h[i] = list(map(int, input().split()))
for i,j in enumerate(h):
    h[i].append(sum(j))
for i in range(c + 1):
    for j in range(r):
        h[r][i] += h[j][i]
for i in h:
    print(*i)


Measured memory_bytes: 6212
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	ll r, d, x;
	cin >> r >> d >> x;
	
	for(int i = 0; i < 10; ++i) {
		x = r * x - d;
		cout << x << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3572
open Batteries
let n = read_int ()
let h = Array.init n (fun a -> Scanf.scanf " %d" @@ fun b -> b)

let dp = Array.init 100010 @@ fun a -> max_int
let _ = dp.(0) <- 0

let change i w =
  if dp.(i) > dp.(i-w) + (abs @@ h.(i) - h.(i-w)) then dp.(i) <- dp.(i-w) + (abs @@ h.(i) - h.(i-w))


let rec loop i =
  if i >= n then dp.(n-1) else (
    change i 1; 
    if i > 1 then change i 2 else ();
    loop (i+1)
    )


let _ = Printf.printf "%d\n" @@ loop 1

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

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }



int main()
{
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    int N;
    cin >> N;
    cout << (int)ceil((double)N/2) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
constexpr int MOD = 1e9 + 7;
template <typename T>
std::vector<T> Vec(const std::size_t n, T v) { return std::vector<T>(n, v); }
template <class... Args>
auto Vec(const std::size_t n, Args... args) { return std::vector<decltype(Vec(args...))>(n, Vec(args...)); }
int main()
{
    std::string K;
    std::cin >> K;
    const int N = K.size();
    int D;
    std::cin >> D;
    auto dp = Vec(N + 1, D, 2, 0);
    dp[0][0][0] = 1;
    for (int i = 0; i < N; i++) {
        const int dig = K[i] - '0';
        for (int j = 0; j < D; j++) {
            for (int k = 0; k < 2; k++) {
                for (int d = 0; d <= (k ? 9 : dig); d++) {
                    const int nj = (j + d) % D;
                    const bool nk = k or d < dig;
                    (dp[i + 1][nj][nk] += dp[i][j][k]) %= MOD;
                }
            }
        }
    }
    std::cout << (dp[N][0][0] + dp[N][0][1] + MOD - 1) % MOD << std::endl;
    return 0;
}


Measured memory_bytes: 55296
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
int A,B;
int main()
{
	scanf("%d%d",&A,&B);
	int add=A+B;
	int jian=A-B;
	int times=A*B;
	printf("%d\n",max(times,max(add,jian)));
	return 0;
}

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

using namespace std;

#define en '\n'
#define ll long long
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pb push_back
#define mod 1000000007

int main()
{
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   ull n;
   cin>>n;
   string str;
   while(n)
   {
       ull ch = n%26;
       if(ch==0)ch = 26;
       str.push_back(char(ch+96));
       n/=26;
       if(ch==26)--n;
   }
   reverse(str.begin(),str.end());
   for(auto el : str)cout<<el;
}


Measured memory_bytes: 3656
S = input()
T = input()

max_count = 0
for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(len(T)):
        if T[j] == S[i+j]:
            count += 1
    max_count = max(max_count, count)

print(len(T)-max_count)

Measured memory_bytes: 9044
#include <stdio.h>
#include <stdlib.h>

int max(int a, int b){
    if(a > b){
        return a;
    }else{
        return b;
    }
}

int main(){
    int N,x;
    scanf("%d",&N);
    
    int hako[3] = {};
    hako[0]=N/100;
    hako[1]=(N%100)/10;
    hako[2]=N%10;

    if(hako[0] < hako[1]){
        int a = hako[0]+1;
        printf("%d", a*111);
    }else if(hako[0]>hako[1]){
        printf("%d", hako[0]*111);
    } else{
        if(hako[1]>=hako[2]){
            printf("%d", hako[0]*111);
        }else{
            printf("%d", (hako[0]+1)*111);
        }
    }

    return 0;
}



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

using namespace std;

#define ll long long 
#define REPL(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 10010;
static const ll INFTY = 1e12;
static const int NUMMAX = 300;
static const ll MOD = 1000000007;
 #define LOOP 10000000


int main() {

  int X;
  vector<int> shina{ 100, 101, 102, 103, 104, 105};
  cin >> X;

  int dp[100010] = {0,};
  dp[100] = 1;
  dp[101] = 1;
  dp[102] = 1;
  dp[103] = 1;
  dp[104] = 1;
  dp[105] = 1;

  REP(i, X+2){
    if( i >= 100 ) if( dp[i-100] == 1 ) dp[i] = 1;
    if( i >= 101 ) if( dp[i-101] == 1 ) dp[i] = 1;
    if( i >= 102 ) if( dp[i-102] == 1 ) dp[i] = 1;
    if( i >= 103 ) if( dp[i-103] == 1 ) dp[i] = 1;
    if( i >= 104 ) if( dp[i-104] == 1 ) dp[i] = 1;
    if( i >= 105 ) if( dp[i-105] == 1 ) dp[i] = 1;

      //cout << dp[i] << endl;
  }

  cout << dp[X] << endl;
  





  //cout << ans << endl;

  return 0;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main()
{
    char A[20], B[20], C[20];

    scanf("%s %s %s", A, B, C);

    int la = strlen(A), lb = strlen(B);

    if(A[la-1] == B[0] && B[lb-1] == C[0])
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
using namespace std;
typedef long long ll;

int main(){
  int n, k;
  cin >> n >> k;

  int a = (n-1);
  int b = (k-1);
  cout << (a + (b - 1)) / b << endl;
  return 0;
}


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

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static long mod = 998244353;
	static int inf = (int) 1e15;
	static ArrayList<Integer>[] ad;
	static int n, k;
	static long[][] memo;
	static char[][] g;
	static boolean[] vis;
	static long ans, tem;
	static long[] a;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		double l=sc.nextInt();
		l=l/3d;
	    double ans=l*l*l;
	    System.out.println(ans);
		out.close();
	}

	static long cal(int i, int u, int p) {
		if (memo[i][u] != -1)
			return memo[i][u];
		long ans = 1;
		for (int v : ad[i]) {
			if (v == p)
				continue;
			if (u == 0) {
				long tem = 0;
				tem = (2 * cal(v, 0, i)) % mod;
				tem = (tem + 2 * cal(v, 1, i)) % mod;
				tem = (tem - cal(v, 2, i) + mod) % mod;
				ans = ans * tem % mod;
			} else if (u == 1) {
				long tem = 0;
				tem = (2 * cal(v, 0, i)) % mod;
				tem = (tem + cal(v, 1, i)) % mod;
				tem = (tem - cal(v, 2, i) + mod) % mod;
				ans = ans * tem % mod;
			} else {
				long tem = 0;
				tem = cal(v, 0, i) % mod;
				tem = (tem + cal(v, 1, i)) % mod;
				tem = (tem - cal(v, 2, i) + mod) % mod;
				ans = ans * tem % mod;
			}
		}
		return memo[i][u] = ans;
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

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

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

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

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

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

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

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

Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
char s[N];
int n,m;
char x[N],y[N];
int main(){
    ios::sync_with_stdio(0);
    cin>>n>>m;
    cin>>(s+1);
    for(int i=0;i<m;i++) cin>>x[i]>>y[i];
    int l = 0, r = n + 1;
    for(int i=m-1;i>=0;i--){
        if(y[i]=='L'){
            if(x[i]==s[l+1]) l++;
            if(x[i]==s[r]) r++;
        }
        else{
            if(x[i]==s[r-1]) r--;
            if(x[i]==s[l]) l--;
        }
        if(l+1>=r) break;
//        cout<<l<<' '<<r<<endl;
    }
    cout<<max(r-l-1,0)<<endl;
}


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


int main() {
  int A, B; cin >> A >> B;
  string S; cin >> S;
  int cnt = 0;
  for(int i=0; i<S.size(); i++){
    if(isdigit(S[i])) cnt++;
  }

  if(S[A]=='-' && cnt==A+B) cout << "Yes" << endl;
  else cout << "No" << endl;


  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
    #include <iostream>
    #include <vector>
    #include <cassert>
    #include <algorithm>
    #include <cstdlib>
    #include <string>
    #include <math.h>
    #include <map>
    #include <set>
    #include <queue>
    #include <bitset>
    using namespace std;
     
    long long int n, k;
    long long int a[100001];
    long long int res = 0;
     
    int main()
    {
     
        cin >> n >> k;
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
     
        long long int tmp = k;
     
        for (int i = 1; i <= 50; i++)
        {
            long long int x, m;
     
            //mb~iビット目までkと共通
            m = (1ll << (i - 1)) - 1;
     
            m = ~m;
            x = k & m;
            //cout << x << endl;
            //i-1 ~ 1ビット目までを決定する
            for (int j = 1; j <= i - 1; j++)
            {
                int bit, ct = 0;
     
                //a[l]についてjビット目を調べる
                //0の出現回数をカウント
                for (int l = 0; l < n; l++)
                {
                    bit = (a[l] >> (j - 1)) & 1;
                    if (bit == 0)
                    {
                        ct++;
                    }
     
                    //cout << a[l] << " " << j << "bit=" << bit << endl;
                }
     
                //0の方が多い
                if (ct > n - ct)
                {
                    //jビット目を1にする
                    x += (1ll << (j - 1));
                }
            }
     
            if (x > k)
                continue;
     
            long long int tmp = 0;
            for (int j = 0; j < n; j++)
            {
                tmp += (a[j] ^ x);
            }
     
            res = max(res, tmp);
        }
     
        cout << res << endl;
        return 0;
    }

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        HashMap<String,Long> map =  new HashMap<>();
        
        for(int i = 0; i < a; i++){
            String s = sc.next();
            char[] c = s.toCharArray();
            Arrays.sort(c);
            s = new String(c);
            Long cnt = (map.containsKey(s) ? map.get(s) + 1 : 1);
			map.put(s, cnt);
        }

        long count = 0;
        for(Long l: map.values()){
            count = count + (l * (l -1) / 2);
        }
        
        System.out.print(count);
    }
}

Measured memory_bytes: 56376
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >>a ;
  if (a<1200) {
    std::cout << "ABC" << '\n';
  }
  else if (1200<=a and a<2800) {
    std::cout << "ARC" << '\n';
  }
  else {std::cout << "AGC" << '\n';}
  return 0;
}


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

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

int main()
{
    string s, p;

    cin >> s;
    cin >> p;

    s += s;

    if (s.find(p) == -1)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3216
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

N = int(input())
s = {}
for i in range(N):
    a = int(input())
    if s.get(a, False):
        s.pop(a)
    else:
        s[a] = True

print(len(s))

Measured memory_bytes: 15076
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector< int > h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        int cnt = 0;
        while (i < n - 1 && h[i] >= h[i + 1]) {
            cnt++;
            i++;
        }
        if (cnt)
            i--;
        ans = max(cnt, ans);
    }
    cout << ans << endl;
    return 0;
}

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

//create arrays outside of main()
int N = 10;
int a[3] = {};


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

    if(d==22){
        cout << "Christmas Eve Eve Eve";
    } 
    else if(d==23){
        cout << "Christmas Eve Eve";
    }
    else if(d==24){
        cout << "Christmas Eve";
    }
    else {
        cout << "Christmas";
    }

    return 0;
}

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


int main(){
  int n,k;
  cin>>n>>k;
  int x[k+1],y[k+1];
    int h=n/2+n%2;
  
  for(int i=1;i<=k;i++){
    cin>>x[i]>>y[i];
    if(x[i]>h){x[i]=n-x[i]+1;}
    if(y[i]>h){y[i]=n-y[i]+1;}
    x[i]=min(x[i],y[i]);
  }
  
  for(int i=1;i<=k;i++){
    int ans;
    ans=x[i]%3;
    if(ans==0){ans=3;}
    cout<<ans<<endl;
  }
  
  
  return 0;
}



Measured memory_bytes: 3088
s=input()
l=[]
i=0
while i<len(s):
  k=0
  while s[i]=='<' if i<len(s) else False:
    k+=1
    i+=1
  if k>0:
    l.append(k)
  k=0
  while s[i]=='>' if i<len(s) else False:
    k+=1
    i+=1
  if k>0:
    l.append(k)
sm=0
for i in l:
  sm+=(i*(i+1))//2
for i in range(0 if s[0]=='<' else 1,len(l)-1,2):
  sm-=min(l[i],l[i+1])
 
  
print(sm)

Measured memory_bytes: 11844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		sc.close();
		int r = 1;
		for(int i=0;i<n;i++){
			r = Math.min(r*2, r+k);
		}
		System.out.println(r);
	}
}

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

using namespace std;

int h[111111];
long d[111111];
int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		scanf("%d", h + i);
	for (int i = 1; i < n; i++) {
		d[i] = d[i - 1] + 100000;
		for (int j = 0; j < min(i, k); j++)
			d[i] = min(d[i], d[i - j - 1] + abs(h[i - j - 1] - h[i]));
	}
	cout << d[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 1408
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {

	in := nextInt
	n, m := in(), in()

	lp := make([][]int, m)
	for i := 0; i < m; i++ {
		c := in()
		lp[i] = make([]int, c)
		for j := 0; j < c; j++ {
			lp[i][j] = in()
		}
	}

	p := make([]int, m)
	for i := 0; i < m; i++ {
		p[i] = in()
	}

	res := 0
	for i := 0; i < (1 << uint(n)); i++ {
		on := 0
		for j := 0; j < m; j++ {
			cnt := 0
			for k := 0; k < len(lp[j]); k++ {
				d := uint(lp[j][k] - 1)
				if ((i >> d) & 1) == 1 {
					cnt++
				}
			}
			if (cnt % 2) == p[j] {
				on++
			}
		}
		if on == m {
			res++
		}
	}

	ans := res
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func anser(b bool, y string, n string) string {
	if b {
		return y
	}
	return n
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ld = long double;

// ========================================================================



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);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) {
	return (1 + n) * n / 2;
}
//1から整数nまでの合計を出す
ll mch(ll n) {
	if (n == 1) return 1;
	else return n * mch(n - 1);
}
//1から整数nまでの階乗を出す(INFで割っていない)
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定
ll modpow(ll a, ll n, ll mod) {
	ll hi = 1;
	while (n > 0) {
		if (n & 1) hi = hi * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return hi;
}
//いろいろやります（ただの前座）
ll mg(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}
//割り算の10^9+7等対策で逆元を出します 
ll e(string s) {
	ll n, m;
	n = m = 0;
	for (int i = 0; i < s.size(); i++) if (s[i] == '0') n++;
	for (int i = 0; i < s.size(); i++) if (s[i] == '1') m++;
	return 2 * min(n, m);
}
ll cnt = 0;


// ========================================================================


int main() {
	string a; cin >> a;
	cout << e(a) << endl;

	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=55;
using T = tuple<int,ll,ll>;
int n,m,s;
ll ctr[mxn],tsct[mxn],dist[mxn][5005];
vector<T>adj[mxn];

struct state{
	int u; ll c,t;
	state(int u, ll c, ll t):u(u),c(c),t(t){};
	bool operator>(const state &s)const{return t>s.t;}
};

void dij(){
	for(int i=0; i<n; i++)
		for(int j=0; j<5005; j++)
			dist[i][j]=INF;
	
	priority_queue<state,vector<state>,greater<state>>pq;
	dist[0][s]=0LL;
	pq.push(state(0,s,0));
	while(!pq.empty()){
		state cur = pq.top(); pq.pop();
		for(T x:adj[cur.u]){
			int v; ll c,w;
			tie(v,c,w)=x;
			if(cur.c-c<0)continue;
			if(dist[v][cur.c-c]>dist[cur.u][cur.c]+w){
				dist[v][cur.c-c]=dist[cur.u][cur.c]+w;
				pq.push(state(v,cur.c-c,dist[v][cur.c-c]));
			}
		}
		if(cur.c+ctr[cur.u]<=5000){
			if(dist[cur.u][cur.c+ctr[cur.u]]>dist[cur.u][cur.c]+tsct[cur.u]){
				dist[cur.u][cur.c+ctr[cur.u]]=dist[cur.u][cur.c]+tsct[cur.u];
				pq.push(state(cur.u,cur.c+ctr[cur.u],dist[cur.u][cur.c+ctr[cur.u]]));
			}
		}
	}
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	cin >> n >> m >> s;
	s=min(s,5000);
	int u,v,a,b;
	for(int i=0; i<m; i++){
		cin >> u >> v >> a >> b;
		u--; v--;
		adj[u].eb(v,a,b);
		adj[v].eb(u,a,b);
	}
	for(int i=0; i<n; i++)cin >> ctr[i] >> tsct[i];
	dij();
	vll ans(n,INF);
	for(int i=1; i<n; i++)
		for(int j=0; j<5005; j++)
			ans[i]=min(ans[i],dist[i][j]);
	for(int i=1; i<n; i++)
		cout << ans[i] << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 11492
from heapq import heappop, heappush
import numpy as np


def solve(n, a_list):
    h = []
    for i in range(n):
        heappush(h, (-a_list[i], i))
    # dp
    dp = (-10 ** 18) * np.ones((n + 1, n + 1), dtype=np.int)
    dp[0, 0] = 0
    for i in range(n):
        a, k = heappop(h)
        # add left
        dp[i + 1, 1:] = np.maximum(dp[i, :-1] + (-a) * np.abs(k - np.arange(n)), dp[i + 1, 1:])
        # add right
        # for j in range(n):
        #    dp[i + 1, j] = max(dp[i, j] + (-a) * abs(n - 1 - (i - j) - k), dp[i + 1, j])
        dp[i + 1, :-1] = np.maximum(dp[i, :-1] + (-a) * np.abs(k - np.arange(n - 1 - i, n + n - 1 - i)), dp[i + 1, :-1])

    # print(dp)
    res = dp[-1, :].max()
    return res


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    res = solve(n, a_list)
    print(res)


def test():
    assert solve(4, [1, 3, 4, 2]) == 20
    assert solve(6, [5, 5, 6, 1, 1, 1]) == 58
    assert solve(6, [8, 6, 9, 1, 2, 1]) == 85
    # print(solve(2000, [0] * 2000))


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 58736
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2444&lang=jp
typedef long long ll;
typedef unsigned long long ull;
const ull B = 100000007;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	string s; cin >> s;
	vector<ull> H(n + 1,0), b(n + 1, 1);
	set<ull> Ans;
	/*
		rolling-hash algorithm
		initialize 
			b[n] := B^n
			H[n] := s[0]*b^(n-1) + s[1]*b^(n-2) +... +s[n-1]*b^0
	*/
	for (int i = 0; i < n;i++) {
		b[i + 1] = b[i] * B;
		H[i + 1] = H[i] * B + s[i];
	}

	int l, r; l = r = 0;
	for (int k = 0; k < m;k++) {
		string q; cin >> q;
		if (q == "L++") l++;
		else if (q == "L--") l--;
		else if (q == "R++") r++;
		else r--;
		ull _hash = H[r + 1] - H[l] * b[r - l + 1];
		Ans.insert(_hash);
	}
	cout << Ans.size() << endl;
	return 0;
}

Measured memory_bytes: 22088
N = int(input())
ps = [1]

i6 = 1
while 6**i6 <=N:
  ps.append(6**i6)
  i6 += 1

i9 = 1
while 9**i9 <=N:
  ps.append(9**i9)
  i9 += 1

len_ps = len(ps)
dp = [float('inf') for _ in range(N+1)]
dp[0] = 0
for i in range(1,N+1):
  for j in range(len_ps):
    if i-ps[j]>=0:dp[i] = min(dp[i], 1+dp[i-ps[j]])

print(dp[-1])

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

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

  char last, current; 
  last = '_';
  string rest = "";
  for (int i = 0; i < N; i++) {
    current = S.at(i);
    
    if (last != current) {
      last = current;
      rest += current;
    }
  }

  cout << rest.size() << endl;
}


Measured memory_bytes: 512
/*                          The four Truths of Life

                                    CKMKB
                                    PKMKB

                                    CKMKC
                                    PKMKC
*/


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define ye cout<<"YES";
#define no cout<<"NO";
#define ln cout<<"\n";
// cout<<"Case #"<<ts<<": “;
//priority_queue < pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;




ll mod(ll x, ll m) {
	return (x % m + m) % m;
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t = 1, r, n, a, d, c, b, x, y, sum, cnt, i, j, k, m, l, q, maxx, minn, temp, ans, flag, g, ts;
	ll mod = 1000000007;
	char ch, chh;
	double dans;
	string str, ttr;

	//cin >> t;


	for (ts = 1; ts <= t; ts++)
	{
		flag = 0; sum = 0; cnt = 0; ans = 0; k = 0; maxx = 0; minn = 0; a = 0; b = 0; temp = 0;

		cin >> a >> b >> c >> k;
		//ll arr[n]; for (i = 0; i < n; i++) {cin >> arr[i];}

		while (b <= a && k > 0)
		{
			k--;
			b *= 2;
		}
		while (c <= b && k > 0)
		{
			k--;
			c *= 2;
		}

		if (b > a && c > b)
			cout << "Yes";
		else
			cout << "No";


		ln
	}
	return 0;
}


Measured memory_bytes: 3648
package main

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

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

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

	a := make([]int, n+1, n+1)
	for i := 1; i <= n; i++ {
		sc.Scan()
		tmp, _ := strconv.Atoi(sc.Text())
		a[i] = tmp
	}

	d := make([]int, n+1, n+1)
	for i := 1; i <= n; i++ {
		d[i] = 0
	}

	b := make([]int, 0, 0)

	for i := n; i >= 1; i-- {
		tmp := 0
		for j := i; j <= n; j += i {
			tmp ^= d[j]
		}
		d[i] = tmp ^ a[i]
		if d[i] == 1 {
			b = append(b, i)
		}
	}

	c := len(b)
	fmt.Println(c)
	for i := 0; i < c; i++ {
		if i == c-1 {
			fmt.Println(b[0])
		} else {
			fmt.Printf("%d ", b[c-1-i])
		}
	}
}


Measured memory_bytes: 9344
#include<iostream>
#include<sstream>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define each(i, c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

typedef pair<int, int> pi;

int t, p, r, wrong[100][100];
pair<int, pi> team[100];
bool ac[100][100];

int main(){
	while(cin >> t >> p >> r, t){
		rep(i, t) rep(j, p) wrong[i][j] = ac[i][j] = 0;
		memset(team, 0, sizeof(team));
		rep(i, t) team[i].second.second = i + 1;
		
		rep(i, r){
			int tid, pid, time;
			string msg;
			cin >> tid >> pid >> time >> msg;
			tid--; pid--;
			if(msg[0] == 'W') wrong[tid][pid]++;
			else{
				if(ac[tid][pid]) continue;
				ac[tid][pid] = 1;
				team[tid].first--;
				team[tid].second.first += 1200 * wrong[tid][pid] + time;
			}
		}
		sort(team, team + t);
		
		rep(i, t) cout << team[i].second.second << " " << -team[i].first
		<< " " << team[i].second.first << endl;
	}
	return 0;
}

Measured memory_bytes: 956
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, L, T[3000];
	double ANSX = 0, ANSY = 0, PI = 3.14159265358979323846;
	cin >> N >> L;
	L *= 2;
	for (int i = 0; i < N; i++) cin >> T[i], T[i] *= 2;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i == j) continue;
			if (i < j) {
				ANSX += cos(2 * PI * (((T[i] + T[j]) / 2) % L) / (double)L) * ((i - j - 1 + N) % N);
				ANSY += sin(2 * PI * (((T[i] + T[j]) / 2) % L) / (double)L) * ((i - j - 1 + N) % N);
			}
			else {
				ANSX += cos(2 * PI * (((T[i] + T[j] + L) / 2) % L) / (double)L) * ((i - j - 1 + N) % N);
				ANSY += sin(2 * PI * (((T[i] + T[j] + L) / 2) % L) / (double)L) * ((i - j - 1 + N) % N);
			}
		}
	}
	ANSX /= (double)(N * (N - 1) * (N - 2) / 6), ANSY /= (double)(N * (N - 1) * (N - 2) / 6);
	printf("%.12lf %.12lf\n", ANSX, ANSY);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}














string s;
int n;
ll ans=0;
void calc(ll x,ll y)
{
     if(x==n+1){
          ans+=y;
          return;
     }
     ll cur=0;
     for(int i=x;i<=n;i++){
          cur=cur*10+s[i]-'0';
          calc(i+1,y+cur);
     }
}
int main()
{
    cin>>s;
    int k;
    cin>>k;
    int left=k;
    for(int i=0;i<s.length();i++){
         if(s[i]!='a'){
              int t='z'-s[i]+1;
              if(t<=left){
                   left-=t;
                   s[i]='a';
              }
         }
    }
    if(left>0){
         int n=s.length()-1;
         int t=(s[n]-'a'+left)%26;
         s[n]='a'+t;
    }
    cout<<s;

}



















 
 
 
 
 

 
 
 
 
 
 
 
 
 
 
 
 
 



Measured memory_bytes: 512
S = input()
N = len(S)
dp = [[0]*(13) for _ in range(N+1)]
dp[0][0] = 1
mod = 10**9+7
for n in range(N):
    s = S[n]
    if s!='?':
        s = int(s)*pow(10, (N-n-1), 13)%13
        for i in range(13):
            idx = (s+i)%13
            dp[n+1][idx] = dp[n][i]%mod
    else:
        for i in range(10):
            s = i*pow(10, (N-n-1), 13)%13
            for j in range(13):
                idx = (s+j)%13
                dp[n+1][idx] += dp[n][j]%mod

print(dp[-1][5]%mod)

Measured memory_bytes: 61788
#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()
{
	string S;
	getline(cin, S);

	cout << "A" << S.at(8) << "C" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
using namespace std;

int main() {
	string s;
	cin >> s;
	int cnt = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '1')cnt++;
	}
	cout << cnt;
	return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<numeric>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int>PII;
typedef pair<ll,ll>PLL;
typedef long double ld;

//typedef acos(-1) PI;

#define PI acos(-1)

int main(){
	int n;
	cin>>n;
	ld ans=2*PI*n;
	printf("%.11Lf\n",ans);
	//cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3764
class Dice
	attr_accessor :t, :b, :n, :e, :s, :w
	def initialize(*labels)
		@t = labels[0]
		@s = labels[1]
		@e = labels[2]
		@w = labels[3]
		@n = labels[4]
		@b = labels[5]
	end
	def roll(dir)
		case dir
		when 'N'
			@t, @s, @b, @n = @s, @b, @n, @t
		when 'S'
			@s, @b, @n, @t = @t, @s, @b, @n
		when 'W'
			@t, @e, @b, @w = @e, @b, @w, @t
		when 'E'
			@e, @b, @w, @t = @t, @e, @b, @w
		end
	end
	def ==(other)
		dice1 = dup
		dice2 = other.dup
		dirs = 'EEEENEEEENEEEENEEENEEEENNEEEE'
		found = false
		dirs.chars{|d|
			if dice1.t == dice2.t && dice1.s == dice2.s && dice1.e == dice2.e && dice1.w == dice2.w && dice1.n == dice2.n && dice1.b == dice2.b
				found = true
				break
			else
				dice2.roll d
			end
		}
		found
	end
end

dices = []
gets.to_i.times{
	dices.push Dice.new(*gets.split)
}
puts dices.combination(2).any?{|a,b|
	a == b
} ? "No" : "Yes"

Measured memory_bytes: 9052
#include <bits/stdc++.h>
/*...
  ...
  author 
  @
  Aman Kothari
  .....
  .....*/
using namespace std;
#define ll long long
#define dl double

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,x,t;
    cin>>n>>x>>t;
    ll count=0;
    while(n>0){
    	n-=x;
    	count+=t;
    }
    cout<<count<<"\n";
    return 0;
}

Measured memory_bytes: 3612