akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            int sheets = cin.ReadInt;
            int yen= cin.ReadInt;

            bool is_discover = false;
            for (int yukichi=0; yukichi<=sheets & is_discover == false; yukichi++)
            {

                for (int higuchi =0; higuchi<= sheets - yukichi & is_discover == false; higuchi++)
                {
                    int noguchi = sheets - yukichi - higuchi;
                    if (yukichi * 10000 + higuchi * 5000 + noguchi * 1000 == yen)
                    {
                            
                        WriteLine(yukichi.ToString() + ' ' + higuchi.ToString() + ' ' + noguchi.ToString());
                        is_discover = true;

                    }
                    
                }
            }
            if (!is_discover)
            {
                WriteLine("-1 -1 -1");
            }
            




        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
        

fast();
//ll t;cin>>t;while(t--)
{
   ll r,g,b,k,flag=0;
   cin>>r>>g>>b>>k;
   
   if(k>0&&r>=g)
   {
    while(g<=r&&k>0)
    {
        g*=2;
        k--;
    }
    if(g<=r)
        flag=1;
    //cout<<"G ="<<g<<" k ="<<k<<endl;

   }
    if(g>=b)
   {
    while(b<=g&&k>0)
    {
        b*=2;
        k--;
    }
    if(b<=g)
        flag=1;
    //cout<<"B ="<<b<<" k ="<<k<<endl;
   }
   //cerr<<b<<" "<<g<<" "<<r<<endl;
   if(flag)
    No
   else 
    Yes

}
return 0;
}

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

struct Card {char suit; char value;};

void trace(struct Card C[], int N) {
    for (int i = 0; i < N; i++){
        if (i > 0) cout << " ";
        cout << C[i].suit << C[i].value;
    }
    cout << endl;
}

void bubbleSort(struct Card A[], int N){
    int flag = 1;
    for(int i=0;flag;i++){
        flag = 0;
        for(int j= N-1; j >= i+1; j--){
            if (A[j].value < A[j-1].value) {
                swap(A[j], A[j-1]);
                flag = 1;
            }
        }
    }
}

void selectionSort(struct Card A[], int N) {
    for(int i=0; i<N; i++) {
        int minj = i;
        for(int j=i+1; j<N; j++) {
            if(A[j].value < A[minj].value) {
                minj = j;
            }
        }
        if(i != minj) {
            swap(A[i], A[minj]);
        }
    }
} 

bool judgeStable(Card C1[], Card C2[], int N) {
    for(int i=0; i<N; i++) {
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    int N;
    cin >> N;
    Card C1[100],C2[100];
    for (int i=0; i < N; i++) {
        cin >> C1[i].suit >> C1[i].value;
        C2[i] = C1[i]; 
    }

    bubbleSort(C1, N);
    selectionSort(C2, N);

    trace(C1, N);
    cout << "Stable" << endl;
    trace(C2, N);
    if(judgeStable(C1, C2, N)){
        cout << "Stable" << endl;;
    }
    else {
        cout << "Not stable" << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
n = int(input())
p_list = list(map(int, input().split()))
ans = 0
for i in range(1, n-1):
    if p_list[i] > p_list[i-1] and p_list[i] <= p_list[i+1]:
        ans += 1
    elif p_list[i] > p_list[i+1] and p_list[i] <= p_list[i-1]:
        ans += 1
    else:
        pass
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<numeric>
#include<climits>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

int main(void) {
	int n, m;
	cin >> n >> m;
	vector<vector<int> > swt(m);
	for (int i = 0; i < m; i++)
	{
		int k;
		cin >> k;
		for (int j = 0; j < k; j++)
		{
			int tmp;
			cin >> tmp;
			tmp--;
			swt[i].push_back(tmp);
		}
	}
	vector<int> p(m);
	for (int i = 0; i < m; i++)
	{
		cin >> p[i];
	}

	int count = 0;
	for (int i = 0; i < (int)pow(2, n); i++)
	{
		bitset<10> on_off(i);
		for (int j = 0; j < m; j++)
		{

			vector<int> tmp;
			for (int v : swt[j])
			{
				tmp.push_back(on_off[v]);
			}
			if (accumulate(ALL(tmp), 0) % 2 != p[j]) {
				break;
			}
			if (j == m - 1) {
				count++;
			}
		}
	}
	cout << count << endl;
	
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#include<climits>
#include<functional>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
#define MP make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define EPS 1e-9
#define PI 3.14159265359
const ll mod = 1000000007;
const ll OO = (ll)1e9;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
ll fast_power(ll base, ll power){
	if (power == 0)
		return 1;
	if (power == 1)
		return (base % mod);
	if (power % 2 == 0)
		return (fast_power(((base*base) % mod), power / 2LL) % mod);
	else return ((base*fast_power(((base*base) % mod) % mod, power / 2LL)) % mod);
}
//#pragma warning (disable : 4996)
void Qalbaz()
{

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(3);
}

int main(){

	Qalbaz();

	int x, y;
	cin >> x >> y;
	if (x == y)
		cout << "Draw";
	else if (x == 1)
		cout << "Alice";
	else if (y == 1)
		cout << "Bob";
	else if (x > y)
		cout << "Alice";
	else if (x < y)
		cout << "Bob";;

	return 0;
}

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

int main() {
  int N;
  int V[25] = {0};
  int C[25] = {0};

  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> V[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> C[i];
  }

  int result = 0;
  int temp = 0;
  for (int i = 0; i < N; i++) {
    temp = V[i] - C[i];
    if (temp > 0) {
      result += temp;
    }
  }

  cout << result << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+7;
const ll mod = 1e9 + 7;
#define afdafafafdafaf y1;
int ar[maxn], n, m, k;

int ar2[maxn];
int main()
{
    ll m;
    scanf("%d%lld", &n, &m);
    for(int i=1;i<=n;i++)scanf("%d", ar + i);
    for(int i=1;i<=n;i++)scanf("%d", ar2 + i);
    sort(ar+1, ar+n+1);
    sort(ar2+1, ar2+n+1);
    ll l = 0, r = 1LL * ar[n] * ar2[n];
    while(l < r){
        ll mid = l + r >> 1;
        ll res = m;
        for(int i=1;i<=n;i++){
            res -= max(0LL, ar[i] - mid / ar2[n - i + 1]);
            if(res < 0)break;
        }
        if(res >= 0)r = mid;
        else l = mid + 1;
    }
    printf("%lld\n", r);
 
    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
int mI(int a, int m)  {return power(a, m - 2, m);}
vector<vector<int>> dir = {{0, 1}, {0, -1}, {1, 0}, {-1, 0},{1,1},{1,-1},{-1,1},{-1,-1}};



void solve(){
    string s, t;
    cin >> s >> t;
    int n = s.size(), ans = 0;
    fo(i,n){
        if(s[i]!=t[i]){
            ans++;
        }
    }
    cout << ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3808
N, M = map(int, input().split())

try_flags = [True] * N  # まだacceptされてない=続けるフラグ
wa_list = [0] * N
ac_list = [0] * N

for _ in range(M):
    i, result = input().split()
    i = int(i) - 1
    if result == 'WA' and try_flags[i]:
        wa_list[i] += 1
    if result == 'AC' and try_flags[i]:
        ac_list[i] = 1
        try_flags[i] = False

ac_cnt = 0
wa_cnt = 0
for ac, wa in zip(ac_list, wa_list):
    if ac == 1:
        ac_cnt += ac
        wa_cnt += wa
print('{} {}'.format(ac_cnt, wa_cnt))


Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    string s,t;
    cin >> s >> t;
    char matuo;
    
    string mozi = s;
    bool hantei = true;
    while(mozi != t){
    
    matuo = mozi[mozi.size()-1];
    string a = mozi.substr(0,mozi.size()-1);
    mozi = matuo + a;
    if( mozi == s){
        hantei = false;
        break;
    }
    
}
if(hantei) cout << "Yes" <<endl;
else       cout << "No" <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a=1,b=1,i,j;
	for(i=0;i<9;i++){
		b=1;
		for(j=0;j<9;j++){
			printf("%dx%d=%d\n",a,b,a*b);
			b++;
		}a++;
	}
	return 0;
}

Measured memory_bytes: 520
N=int(input())
D,X=map(int,input().split())
a=list()
for i in range(N):
    a.append(int(input()))
total=0
for i in range(N):
    j=0
    while True:
        if  a[i]*j+1<=D:
            total+=1
            j+=1
        else:
            break
print(X+total)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, K;

	cin >> N >> K;

	if (K == 1) cout << 0 << endl;
	else cout << (N - (K - 1)) - (1) << endl;

	return 0;
}


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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 500005
#define all(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

int32_t main(){
	IOS;
	int tt = 1; 
	//cin >> tt;
	while(tt--){
		int n, d; cin >> n >> d;
		int cnt=  0;
		for(int i = 0; i < n; i++){
			int a, b; cin >> a >> b;
			if(a * a + b * b <= d * d) cnt++;
			
		}
		cout << cnt << endl;
	
	}
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;

using namespace std;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const int MOD = 998244353;

int n, q;

int main() {
    ios::sync_with_stdio(false);
    cin.tie();
    string s;
    cin >> n >> s >> q;
    vector<set<int>> cnt(26);
    for (int i = 0; i < n; i++){
        cnt[s[i]-'a'].insert(i);
    }
    while (q--){
        int t;
        cin >> t;
        if (t == 1){
            int i;
            char c;
            cin >> i >> c;
            i--;
            cnt[s[i]-'a'].erase(i);
            cnt[c-'a'].insert(i);
            s[i] = c;
        }
        if (t == 2){
            int ans = 0, l, r;
            cin >> l >> r;
            l--;
            r--;
            for (int j = 0; j < 26; j++){
                auto p = cnt[j].lower_bound(l);
                ans += p != cnt[j].end() && *p <= r;
            }
            cout << ans << '\n';
        }
    }
}

Measured memory_bytes: 24220
import math

q = int(input().strip())
count = {}
count['AC'] = 0
count['WA'] = 0
count['TLE'] = 0
count['RE'] = 0
for i in range(q):
    b = input().strip()
    count[b] += 1

print('AC x {}'.format(count['AC']))
print('WA x {}'.format(count['WA']))
print('TLE x {}'.format(count['TLE']))
print('RE x {}'.format(count['RE']))
    


Measured memory_bytes: 9200
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<f64>();
    let ans = 1.0 / a.iter().map(|&x| 1.0 / x).sum::<f64>();
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2136
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

#ifndef LOCAL
#define cerr _cer
struct _cert
{
    template <typename T> _cert& operator << (T) { return *this; }
};
_cert _cer;
#endif

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
		cerr << (*i) << " ";
    }
    cerr << "\n";
}
const int MX = 1200000;

int z[MX];
string s[2100];
string t;
string bs;
int av[MX];

void calcz() {
	z[0] = 0;
	int l = 0, r = 0;
	for (int i = 1; i < t.size(); ++i) {
		if (r > i)
			z[i] = min(r - i, z[i - l]);
		else
			z[i] = 0;
		while (i + z[i] < t.size() && t[z[i]] == t[i + z[i]])
			++z[i];
		if (i + z[i] > r)
			r = i + z[i], l = i;
	}
	z[t.size()] = 0;
}

int n, k;
char buf[MX];
int dp[2100][11000];

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i) {
		scanf(" %s", buf);
		s[i] = buf;
	}
	dp[n][0] = 1;
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j <= k; ++j)
			dp[i][j] = dp[i + 1][j];
		for (int j = 0; j + s[i].size() <= k; ++j)
			dp[i][j + s[i].size()] |= dp[i + 1][j];
	}
	av[0] = 1;
	for (int i = 0; i < n; ++i) {
		int bstp = -1;
		pair<int, char> bst = make_pair(k + 1, 0);
		t = s[i] + "$" + bs;
		calcz();
		int len = s[i].size();
		for (int j = 0; j <= bs.size(); ++j) {
			if (av[j] && (j + len <= k) && dp[i + 1][k - j - len]) {
				int cm = z[len + 1 + j];
				if (cm < len && j + cm < bs.size() && s[i][cm] < bs[j + cm]) {
					if (make_pair(j + cm, s[i][cm]) < bst)
						bst = make_pair(j + cm, s[i][cm]), bstp = j;
				}
			}
		}
		if (bstp != -1) {
			for (int i = bst.first + 1; i <= bs.size(); ++i)
				av[i] = 0;
			bs.resize(bstp);
			bs += s[i];
			av[bs.size()] = 1;
		}
		else {
			int lst = -1;
			for (int j = 0; j <= bs.size(); ++j) {
				if (av[j] && (j + len) <= k && dp[i + 1][k - j - len]) {
					int cm = z[len + 1 + j];
					if (j + cm == bs.size()) {
						if (lst == -1)
							lst = j;
						else {
							int cm = z[j - lst];
							if (j - lst + cm == s[i].size() || s[i][cm] < s[i][j - lst +cm])
								lst = j;
						}
					}
				}
			}
			if (lst != -1) {
				bs.resize(lst);
				bs += s[i];
				av[bs.size()] = 1;
			}
		}
		t = s[i] + "$" + bs;
		calcz();
		for (int j = (int)bs.size() - 1; j >= 0; --j) {
			if (av[j] && (j + len <= k) && dp[i + 1][k - j - len]) {
				int cm = z[len + 1 + j];
				if (cm == len) {
					av[j + len] = 1;
				}
			}
		}
	}
	cout << bs << "\n";
	return 0;
}




Measured memory_bytes: 91520
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()
{
    fast;
    ll a, b, c, x;
    cin>>a;
    cin>>b;
    cin>>c;
    
    x=min(c, b-1);
    cout<<floor((a*x)/b)-(a*floor(x/b));
    
    return 0;
}

Measured memory_bytes: 3808
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;

#define REP(i, n) for (int (i) = 0; (i) < (int)(n); ++(i))
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) {
    return s << '<' << P.first << ", " << P.second << '>';
}
template<class T> ostream& operator << (ostream &s, vector<T> P) {
    for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl;
}
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) {
    EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl;
}
template<class T> void print(T a, T b) { 
    for (T i = a; i != b; ++i) { if (i != a) { cout << " "; } cout << *i; } cout << endl; 
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }




const int MAX = 400;
int dp[MAX];
int s[MAX], l[MAX], p[MAX], w[MAX];

int n, m;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> s[i] >> l[i] >> p[i];
    cin >> m;
    for (int i = 0; i < m; ++i) cin >> w[i];
        
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < MAX; ++j) {
            for (int k = s[i]; k <= l[i]; ++k) {
                if (j + k < MAX) chmax(dp[j+k], dp[j] + p[i]);
            }
        }
    }

    vint res; 
    bool valid = true;
    for (int i = 0; i < m; ++i) {
        res.push_back(dp[w[i]]);
        if (dp[w[i]] == -1) valid = false;
    }
    if (valid) for (int i = 0; i < m; ++i) cout << res[i] << endl;
    else puts("-1");
    
    return 0;
}


Measured memory_bytes: 1228
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};
  
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
using namespace std;
using mat = vector<bitset<100>>;

mat matMul(const mat& a, const mat& b) {
    const int n = a.size();
    mat c(n, bitset<100>(0));
    for(int i : in(n))
        for(int k : in(n))
            for(int j : in(n))
                c[i][j] = c[i][j] | (a[i][k] & b[k][j]);
    return c;
}
mat matPow(mat a, int k) {
    const int n = a.size();
    mat b(n, bitset<100>(0));
    for(int i : in(n)) b[i][i] = 1;
    while(k > 0) {
        if(k & 1) b = matMul(b, a);
        a = matMul(a, a);
        k >>= 1;
    }
    return b;
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m, k;
    while(cin >> n >> m >> k && n) {
        vector<pair<int, int>> edge;
        for(int _ : in(m)) {
            int u, v;
            cin >> u >> v;
            edge.emplace_back(u, v);
            edge.emplace_back(v, u);
        }
        m *= 2;
        vector<int> start, goal;
        mat e(m, bitset<100>(0));
        for(int i : in(m)) {
            int cur = edge[i].first, nxt = edge[i].second;
            if(cur == 1) start.emplace_back(i);
            if(nxt == n) goal.emplace_back(i);
            for(int j : in(m))
                if(edge[j].first == nxt && edge[j].second != cur)
                    e[i][j] = 1;
        }
        e = matPow(e, k - 1);
        bool ok = false;
        for(int s : start)
            for(int g : goal)
                ok |= (e[s][g] == 1);
        cout << (ok ? "yes" : "no") << endl;
    }
    return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
	if(a==0)
		return b;
	if(b==0)
		return a;
	if(a%b==0)
		return b;
	return gcd(b,a%b);
}
int main(){
	int a,b,k;
	cin>>a>>b>>k;
	int max_val=gcd(a,b);
	for(int i=max_val;i>0;i--){
		if(max_val%i==0)
			k--;
		if(k==0){
			cout<<i;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n;

int main(){
	cin >> n;
	
	ll pos=1;
	REP(i,1,n+1) (pos*=i)%=MOD;
	
	cout << pos << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int h,w;
  cin >> h >> w;
  
  char c[h+2][w+2] = {};
  
  REP(i,h){
    REP(j,w){
      cin >> c[i+1][j+1];
    }
  }
  
  int vx[8] = {1,1,1,0,0,-1,-1,-1};
  int vy[8] = {1,0,-1,1,-1,1,0,-1};
  
  char ans[h][w];
  REP(i,h){
    REP(j,w){
      if(c[i+1][j+1] == '#') ans[i][j] = '#';
      else{
        int cnt = 0;
      REP(k,8){
      if(c[i+1+vx[k]][j+1+vy[k]] == '#') cnt++;
      }
        ans[i][j] = (char)cnt + '0';
      }
    }
  }

  REP(i,h){
    REP(j,w){
      cout << ans[i][j];
    }
    cout << endl;
  }

 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<int, int>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

// 二分累乗 O(funcの計算量*logE)
template<typename T=ll>
T binpow(T x, int e, function<T(T,T)> func=[](T a, T b){return a*b%MOD;}, T d=1) {
  T ret = d, p = x;
  while(e > 0) {
    if(e%2 == 0) {p = func(p, p); e /= 2;}
    else {ret = func(ret, p); e--;}
  }
  return ret;
};

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  cin >> a;
  
  // i番目がカウントされる回数
  // = sum_{j=1}^N (j番目を取り除く時にi番目と連結なパターン数)
  // = sum_{j=1}^N N! / (abs(j-i)+1)
  // この和は前計算しておけばO(1)で求まるのでi番目がカウントされる回数がO(1)で求まる
  // 全体ではO(N)

  ll frac = 1;
  REP(i, n) (frac *= i+1) %= MOD;
  vector<ll> dp(n);
  REP(i, n) dp[i] = frac * binpow(i+1, MOD-2) % MOD;
  FOR(i, 1, n) (dp[i] += dp[i-1]) %= MOD;

  ll ret = 0;
  REP(i, n) {
    // [0, i] と [1, n-i]
    ll tmp = ((dp[i] + dp[n-i-1]) % MOD - dp[0]) % MOD;
    (tmp += MOD) %= MOD;
    (ret += a[i] * tmp % MOD) %= MOD;
  }
  cout << ret << endl;

  return 0;
}


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

int main()
{
    char S[10000];
    cin>>S;
    for(int i=0;i<strlen(S);i++){
    	if(S[i]=='C') {
    		for(int j=i;j<strlen(S);j++) 
    		    if(S[j]=='F'){
    		    	cout<<"Yes"<<endl;
    		    	return 0;
				}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {


	ll m,t,b;

	cin>>m>>t>>b;


	if((m+t)<b){
		cout<<"NA"<<endl;
	}else if(m<b){
		cout<<b-m<<endl;
	}else if(m>=b){
		cout<<"0"<<endl;
	}




}

Measured memory_bytes: 3096
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	int A,B;
	cin >> A >> B;
	cout << max({A+B,A-B,A*B}) << endl;
	return 0;
}

Measured memory_bytes: 256
public class Main {
    public static void main(String args[]) {
        java.util.Scanner sc = new java.util.Scanner(System.in);
        int num = sc.nextInt();
        int[] A = new int[4];
        for (int i = 0; i < 4; i++) {
            A[3-i] = num % 10;
            num /= 10;
        }

        for (int i = 0; i < 8; i++) {
            int tmp = i + 1;
            int ans = A[0];
            for (int j = 1; j < 4; j++) {
                if (tmp % 2 == 0) ans += A[j];
                else ans -= A[j];
                tmp /= 2;
            }
            if (ans == 7) {
                tmp = i + 1;
                System.out.print(A[0]);
                for (int j = 1; j < 4; j++) {
                    if (tmp % 2 == 0) 
                        System.out.print("+");
                    else System.out.print("-");
                    System.out.print(A[j]);
                    tmp /= 2;
                }
                System.out.println("=7");
                return;
            }
        }
    }
}

Measured memory_bytes: 23892
/* Code by Saborit */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast") 
#define MX 100005
#define INF (1<<30)
#define EPS 1e-9
#define MOD 1000000007
#define mid (x+xend)/2
#define izq nod*2
#define der nod*2+1
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define unique(X) (X).resize(unique(all(X)) - (X).begin())
#ifdef LOCAL 
	#include "debug.h"
#endif
using namespace std;
using namespace __gnu_pbds;
typedef long long int64;
typedef unsigned long long unt64;

int N, K;
char S[MX];

int main(void){
    //~ freopen("a.in", "r", stdin);
    //~ freopen("a.out", "w", stdout);
    
    scanf("%d %s", &K, &S);
    N = strlen(S);
    
    for(int i=0; i < N; i++)
		S[i] = 'A' + (S[i] - 'A' + K) %26; 
    
    printf("%s\n", S);
    
   return 0;
}


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

using namespace std;

int main(){
    int A, B;
    cin >> A >> B;

    for(int i = 0; i < 1000; ++i){
        if(A*i - (i-1) >= B){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
memo = {}

def fib(n) :
    if n in memo.keys() :
        return memo[n]
    else :
        if n == 0 :
            return 1
        elif n == 1 :
            return 1 
        else :
            memo[n] = fib(n - 1) + fib(n - 2)
            return memo[n]
    
print(fib(int(input())))


Measured memory_bytes: 5600
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    for (int i = 1; i < n; i++){
        int cnt = 0;
        for (char c = 'a'; c <= 'z'; c++){
            bool left = false, right = false;

            for (int j = 0; j < i; j++){
                if (s[j] == c)   left = true;
            }
            for (int j = i; j < n; j++){
                if (s[j] == c)   right = true;
            }
            if (left && right) cnt++;
        }
        ans = max (ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <cstring>
#include <set>
#include <map>
using namespace std;
#define ld long double
#define F first
#define S second
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define p1 1000000007
#define p 998244353
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int ll
const int N=1e5+10;
const int inf=1e17+10;
 int dp[N];
int h[N];
 int n;
 int k;
int rec(int i)
{
    if(i<=1) return 0;
    if(dp[i]!=inf) return dp[i];
   // cerr<<i<<" "<<dp[i]<<endl;
    int ans1=inf;
    for(int j=1;j<=k;j++)
    if(i-j>=1)
    ans1=min(ans1,rec(i-j)+abs(h[i]-h[i-j]));
    dp[i]=ans1;
    return ans1;

   
}
int32_t main()
{
   
    cin>>n>>k;
    
     
    for(int i=1;i<=n;i++){
        cin>>h[i];
        dp[i]=inf;
    }
   
    int  ans=rec(n);
    cout<<ans;
}


Measured memory_bytes: 6528
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int INF=1e9+7;
int main(){
  string s;cin>>s;
  
  vvll dp(s.size()+1,vll(4));
  dp[s.size()][3]=1;
  for(int j=s.size()-1;j>=0;j--){
    dp[j][3]=(s[j]=='?')?3*dp[j+1][3]:dp[j+1][3];
    dp[j][3]%=INF;
  }
  for(int i=2;i>=0;i--){
    dp[s.size()][i]=0;
    for(int j=s.size()-1;j>=0;j--){
      dp[j][i]=(s[j]=='?')?3*dp[j+1][i]:dp[j+1][i];
      if(s[j]=='?'||s[j]=='A'+i){dp[j][i]+=dp[j+1][i+1];}
      dp[j][i]%=INF;
    }
  }
  cout<<dp[0][0]%INF<<endl;
}

Measured memory_bytes: 7424
#include<set>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
LL read(){
	LL f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
#define MAXN 200
#define INF 0x3f3f3f3f
LL gcd(LL a,LL b){return !b?a:gcd(b,a%b);}
int main(){
	LL A=read(),B=read(),C=read(),D=read();
	printf("%lld\n",B-A+1-(B/C-(A-1)/C)-(B/D-(A-1)/D)+(B/(C/gcd(C,D)*D)-(A-1)/(C/gcd(C,D)*D)));
	return 0;
}


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

int main(){
  int a,b,c,d;
  cin>>a;
  if(a==1||a==4||a==7||a==9){
    cin>>b;
    if((b==1||b==4||b==7||b==9)&&b!=a){
      cin>>c;
      if((c==1||c==4||c==7||c==9)&&c!=a&&c!=b){
        cin>>d;
        if((d==1||d==4||d==7||d==9)&&d!=a&d!=b&&d!=c){
          cout<<"YES"<<endl;
          a=-1;
        }
      }
    }
  }
  if(a!=-1)cout<<"NO"<<endl;
  
}

Measured memory_bytes: 256
#include <cstdio>

int N, T;
int A[100100];

void solve()
{
	int i;
	int num = 0;
	int mn=A[0], mx=A[0];
	int diff=0;
	for(i=1; i<N; i++){
		if(A[i]>mx){
			mx = A[i];
			if(diff < mx-mn){
				diff = mx-mn;
				num = 1;
			}
			else if(diff == mx-mn){
				num ++;
			}
		}
		else if(A[i]<mn){
			mn = A[i];
			mx = A[i];
		}
	}
	printf("%d\n", num);
}

int main()
{
	int i;
	scanf("%d%d", &N, &T);
	for(i=0; i<N; i++)
		scanf("%d", &A[i]);
	solve();
	return 0;	
}

Measured memory_bytes: 512
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

H=[]
for j in range(10):
    H+=[j]*(j+1)

N=int(input())
S=0

if N!=1:
    L=factorization(N)
    S=0
    for (x,a) in L:
        S+=H[a]

print(S)


Measured memory_bytes: 63352
#include <iostream>

using namespace std;


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

    int kougo[3];
    int prev=0,now,len=1,ans=0,ind=0;

    kougo[0]=0; kougo[1]=0; kougo[2]=0;

    cin >> prev;

    for(int i=1; i<N; ++i) {
        cin >> now;
        if(prev==now) {
            kougo[(ind++)%3]=len;
            ans=max(ans,kougo[0]+kougo[1]+kougo[2]);
            len=0;
        }
        ++len;
        prev=now;
    }
    kougo[ind%3]=len;
    ans=max(ans,kougo[0]+kougo[1]+kougo[2]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3084
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ok(A, B, S):
    if len(S) != A + B + 1:
        return False
    if S.count("-") != 1:
        return False

    a, b = S.split("-")
    if len(a) != A or len(b) != B:
        return False

    return True


def main():
    A, B = map(int, input().split())
    S = input()
    if ok(A, B, S):
        print(Yes)
    else:
        print(No)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
#include <bits/stdc++.h>
#define salma ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef long double ld;
using namespace std;
const int N=1e5 + 5;


int main( )
{
salma
int n ;
cin>>n;
int arr[n+1];
for (int i=1 ; i<=n ;i++)
    cin>>arr[i];

ll dp[n+1];
dp[1]=0;
dp[2]=abs(arr[1]-arr[2]);

for (int i=3;i<=n;i++ )
{
    dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1] ,abs(arr[i]-arr[i-2] )+dp[i-2] );
}

cout<<dp[n];



    return 0;
}

Measured memory_bytes: 1408
n = list(reversed([0]+list(map(int, input()))))
ans = 0
for i in range(len(n)):
    if n[i] < 5 or (n[i]==5 and n[i+1]<5):
        ans += n[i]
    else:
        ans += 10 - n[i]
        n[i+1] += 1
print(ans)

Measured memory_bytes: 21352
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val txy = (0, 0, 0) :: List.fill(n)((sc.nextInt(), sc.nextInt(), sc.nextInt()))
  val ok = txy.sliding(2).forall{ case List((t1, x1, y1), (t2, x2, y2)) =>
    val t = t2 - t1
    val d = (x2 - x1).abs + (y2 - y1).abs
    d <= t && (t - d) % 2 == 0
  }
  println(if (ok) "Yes" else "No")
}


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

using ll = long long;

int main() {
  int n;
  cin >> n;
  set<int> s;
  
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (s.find(a) != s.end()) s.erase(a);
    else s.insert(a);
  }
  cout << s.size() << endl;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<int> a(n+1),b(n+1,0);//b[i]:=i番目の箱のボールの有無
  vector<int> ans;
  for(int i=1; i<=n; i++) cin >> a[i];

  for(int i=n; i>=1; i--){
    int sum=a[i];
    for(int j=i+i; j<=n; j+=i){//i以外の倍数を見る
      sum+=b[j];
    }
    b[i]=sum%2;
    if(b[i]) ans.pb(i);
  }

  cout << sz(ans) << endl;
  rep(i,sz(ans)){
    if(i)cout << " " ;
    cout << ans[i];
  }
  cout  << endl;

  return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

int main(){
    ll a,b,k;
    cin >> a >> b >> k;
    ll a_remain;
    ll b_remain;
    if(a >= k){
        a_remain = a - k;
        b_remain = b;
    }else if(a + b > k){
        a_remain = 0;
        b_remain = a + b -k;
    }else{
        a_remain = 0;
        b_remain = 0;
    }
    cout << a_remain << " " << b_remain << endl;
    return 0;
}

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

void fnBubbleSort(vector<string> &rvsSortBbl)
{
  int nSorting = 0;
  bool bSorting = true;

  while (bSorting)
  {
    bSorting = false;
    for (int j = rvsSortBbl.size() - 1; j > nSorting; j--)
    {
      if (rvsSortBbl[j].at(1) < rvsSortBbl[j - 1].at(1))
      {
        swap(rvsSortBbl[j], rvsSortBbl[j - 1]);
        bSorting = true;
      }
    }
    nSorting++;
  }
}

void fnOutputBbl(const vector<string> &cnrvsSortBbl)
{
  for (int i = 0; i < cnrvsSortBbl.size(); i++)
  {
    if (i) cout << " ";
    cout << cnrvsSortBbl[i];
  }
  cout << endl;
  cout << "Stable" << endl;
}

void fnSelectionSort(vector<string> &rvsSortSel)
{
  for (int nSorting = 0; nSorting < rvsSortSel.size() - 1; nSorting++)
  {
    int nMin = nSorting;
    bool bSorting = false;
    for (int j = nSorting + 1; j < rvsSortSel.size(); j++)
    {
      if (rvsSortSel[j].at(1) < rvsSortSel[nMin].at(1))
      {
        nMin = j;
        bSorting = true;
      }
    }
    if (bSorting == true)  swap(rvsSortSel[nSorting], rvsSortSel[nMin]);
  }
}

void fnOutputSel(const vector<string> &cnrvsSortSel, const vector<string> &cnrvsSortBbl)
{
  string sSortEnd = "Stable";

  for (int i = 0; i < cnrvsSortSel.size(); i++)
  {
    if (i) cout << " ";
    cout << cnrvsSortSel[i];
    
    if (cnrvsSortSel[i] != cnrvsSortBbl[i]) sSortEnd = "Not stable";
  }
  cout << endl;
  cout << sSortEnd << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  vector<string> vsSortBbl, vsSortSel;
  int nMaxSiz;
  
  cin >> nMaxSiz;
  for (int i = 0; i < nMaxSiz; i++)
  {
    string sCard;
    cin >> sCard;
    vsSortBbl.push_back(sCard);
    vsSortSel.push_back(sCard);
  }

  fnBubbleSort(vsSortBbl);
  fnOutputBbl(vsSortBbl); 

  fnSelectionSort(vsSortSel);
  fnOutputSel(vsSortSel, vsSortBbl);

  return 0;
}

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

int main(){
  vector<vector<int>> a(3, vector<int>(3));
  for(int i=0; i<3; ++i){
    for(int j=0; j<3; ++j){
      cin >> a[i][j];
    }
  }
  int n; cin >> n;
  vector<int> b(n);
  for(int i=0; i<n; ++i) cin >> b[i];
  
  vector<vector<bool>> buf(3, vector<bool>(3, false));
  for(int i=0; i<3; ++i){
    for(int j=0; j<3; ++j){
      for(int x : b){
        if(a[i][j] == x) buf[i][j] = true;
      }
    }
  }
  
  bool isBingo = 
    (buf[0][0] && buf[0][1] && buf[0][2]) ||
    (buf[1][0] && buf[1][1] && buf[1][2]) ||
    (buf[2][0] && buf[2][1] && buf[2][2]) ||
    (buf[0][0] && buf[1][0] && buf[2][0]) ||
    (buf[0][1] && buf[1][1] && buf[2][1]) ||
    (buf[0][2] && buf[1][2] && buf[2][2]) ||
    (buf[0][0] && buf[1][1] && buf[2][2]) ||
    (buf[2][0] && buf[1][1] && buf[0][2]);
  if(isBingo) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


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

int main(void){

  int sum;
  char m;

  while(1){
    sum = 0;
    scanf("%c", &m);
    if(m=='0') break;
    while(m != '\n'){
      sum += m-48;
      scanf("%c", &m);
    }
    printf("%d\n", sum);
  }

  return 0;
}



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

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N;
string s, t;

int main(){
  cin >> N;
  cin >> s >> t;
  REP(i, N) {
    int l = N - i;
    if(s.substr(i, l) == t.substr(0, l)) {
      cout << 2 * N - l << endl;
      return 0;
    }
  }
  cout << 2 * N << endl;
  return 0;
}


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

int main() {
  int D,N,x;
  N=0;
  x=0;
  cin >> D;
  vector<int> c(26);
  vector<int> last(26);
  for (int i=0;i<26;i++) {
    cin >> c.at(i);
  }
  vector<vector<int>> s(D,vector<int>(26));
  for (int i=0;i<D;i++) {
    for (int j=0;j<26;j++) {
      cin >> s.at(i).at(j);
    }
  }
  for (int i=0;i<D;i++) {
    cout << i%26+1 << endl;
  }
}


Measured memory_bytes: 3664