akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int a[12][12];
int main(){
  int n,m,x;cin>>n>>m>>x;
  vector<int>c(n);
  rep(i,n){
    cin>>c[i];
    rep(j,m)cin>>a[i][j];
  }
  int ans=INT_MAX;
  rep(s,1<<n){
    int cost=0;
    vector<int>d(m,0);
    rep(i,n){
      if(s>>i&1){
        cost+=c[i];
        rep(j,m){
          d[j]+=a[i][j];
        }
      }
      bool ok=true;
      rep(j,m)if(d[j]<x)ok=false;
      if(ok)ans=min(ans,cost);
    }
  }
      if(ans==INT_MAX)cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
  }


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    ll n,a,b;
    ll ablong;
    cin>>n>>a>>b;
    if(abs(a-b)%2==0){
        cout<<abs(a-b)/2<<endl;
    }
    else{
        ablong=min(n-a+n-b,a-1+b-1);
        cout<<(ablong+1)/2<<endl;
    }
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  // ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  int ans = 1;
  for (int i = 2; i * i <= n; i++) {
    int t = i * i;
    while (t * i <= n) t *= i;
    ans = max(ans, t);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 3636
/*

 Remember, Hope is a good thing... May be the best of things... and No Good thing ever Dies !!!

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cout.tie(0);
#define endl "\n"
#define MOD 1000000007
#define MOD1 1e18
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
typedef long double ld;
const ll inf=(1LL<<60)-1;
const ll mxn=1e5;
int dx[]= {-1,1,0,0};
int dy[]= {0,0,-1,1};
long long ans,a[100005];
ll mod(ll x)
{
    ll res=x%MOD;
    while(res<0)
        res+=MOD;
    return res;
}
ll bigmod(ll x,ll n)
{
    ll res=1;
    while(n>0)
    {
        if(n&1)
            res=(res*x)%MOD;
        x=(x*x)%MOD;
        n>>=1;
    }
    return res;
}
void solve()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
   string s;
   cin>>s;
   if(s[s.size()-1]!='s')
   {
       s.push_back('s');
       cout<<s<<endl;
   }
   else
   {
       s.push_back('e');
       s.push_back('s');
       cout<<s<<endl;
   }

}
int main()
{
    IOS;
    //ll t;
    //cin>>t;
    // while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main(void){
    int a[3][3]={};
    int c[3][3]={};
    rep(i, 3){
        rep(j, 3){
            cin >> a[i][j];
        }
    }
    
    int n;
    cin >> n;
    int b[n];
    rep(k, n){
        cin >> b[k];
        rep(i, 3){
            rep(j, 3){
                if(b[k] == a[i][j]){
                    c[i][j] = 1;
                }
            }
        }
    }
    
    int yoko=0;
    int tate=0;
    int naname1=c[0][0] + c[1][1] + c[2][2];
    int naname2=c[0][2] + c[1][1] + c[2][0];
    
    rep(i, 3){
        rep(j, 3){
            yoko += c[i][j];
        }
        if(yoko == 3){cout << "Yes" << endl; return 0;}
        else{yoko = 0;}
    }
    
    rep(i, 3){
        rep(j, 3){
            tate += c[j][i];
        }
        if(tate == 3){cout << "Yes" << endl; return 0;}
        else{tate = 0;}
    }
    
    if(naname1 == 3 or naname2 == 3){cout << "Yes" << endl; return 0;}
    
    cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3592
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   :
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cerr<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 3e5 + 5, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
ll a[N] = { };
vl v;
priority_queue<ll, vl, greater<ll>> pq;
unordered_map<ll, set<int>> pos;
set<int> st;
int main() {
#ifdef ONLINE_JUDGE
	   FAST;
#endif
	int n, R;
	ll sum = 0, sum2 = 0, ans = -1e15;
	cin >> n;
	R = n - 1;
	lp(i,0,n*3-1)
	{
		cin >> a[i];
		if (i >= n)
			v.pb(a[i]);
		else {
			pq.push(a[i]);
			sum += a[i];
		}
	}
	sort(all(v));
	lp(i,0,v.size()-1)
	{
		pos[v[i]].insert(i);
		if (i < n)
			sum2 += v[i];
		st.insert(i);
	}
	ans = max(ans, sum - sum2);
	lp(i,n,2*n-1)
	{
		ll x;
		if (a[i] > pq.top()) {
			x = pq.top();
			sum -= x;
			sum += a[i];
			pq.pop();
			pq.push(a[i]);
		}
		x = *pos[a[i]].rbegin();
		pos[a[i]].erase(x);
		st.erase(x);
		if (x <= R) {
			R++;
			sum2 -= a[i];
			x = *st.lower_bound(R);
			sum2 += v[x];
			R = x;
		}
		ans = max(ans, sum - sum2);
	}
	f(ans);
	return 0;
}

Measured memory_bytes: 41328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, t; cin >> n >> t;
    V<pair<ll,ll>> v(n);
    REP(i, n){
        ll a, b; cin >> a >> b;
        v[i] = {a, b};
    }
    sort(all(v));
    ll res = 0;
    V<> dp(t + 1, 0);
    REP(i, n) RREP(j, t) chmax(dp[min(j + v[i].first, t)], dp[j] + v[i].second);
    REP(j, t + 1) chmax(res, dp[j]);
    cout << res << '\n';
}

Measured memory_bytes: 3688
#include<stdio.h>

int main() {
    //変数の宣言
    char m1[101], m2[101];
    int i, j, n1=0, n2=0, t;
    
    //入力
    scanf("%s %s", m1, m2);
    
    //処理
    while (m1[n1] != '\0') {
        n1++;
    }
    while (m2[n2] != '\0') {
        n2++;
    }
    
    for (i=0; i<n1; i++) {
        t = 1;
        for (j=0; j<n2; j++) { //ここで回すのは２回目に入力した文字列の分だけ
            if (m1[(i+j)%n1] != m2[j]) {//１ずつズレてる
                t = 0;
            }
        }
        if (t) { //forで回した後でもt=1のままだったらyes
            printf("Yes\n");
            return 0;
        }
    }
    
    printf("No\n");
    
    return 0;
//    //変数の宣言
//    char m1[100], m2[100], tmp;
//    int a=0, b=0, i, j; //処理用
//    
//    //入力
//    while (1) {
//        scanf("%c", &m1[a]);
//        if (m1[a] == '\n') {
//            break;
//        }
//        a++;
//    }
//    
//    while (1) {
//        scanf("%c", &m2[b]);
//        if (m2[b] == '\n') {
//            break;
//        }
//        b++;
//    }
//    
//
//    //処理
//    for (i=0; i<a; i++) { //１回目に入力した文字数の数だけ
//        for (j=0; j<b; j++) { //2回目に入力した文字数の数だけ
//            if (m1[i] != m2[j]) {
//                break;
//            }
//            if (j == b-1 && m1[i] == m2[j]) {
//                printf("Yes\n");
//                return 0;
//            }
//        }
//        tmp = m1[a-1];
//        for (j=0; j<a; j++) { //１個づつずらす
//            if (j == 0) {
//                m1[a-1] = m1[0];
//            }else if (j == a-1) {
//                m1[j-1] = tmp;
//            }else{
//                m1[j-1] = m1[j];
//            }
//        }
//    }
//    
//    printf("No\n");
//    
//    
//    return 0;
}



Measured memory_bytes: 2108
def main():
    import sys
    input=sys.stdin.readline
    h,w,k=map(int,input().split())
    S=[]
    for _ in range(h):
        s=list(map(int,list(input().rstrip())))
        S.append(s)
    ans=10**5
    for i in range(2**(h-1)):
        l=[0]
        for j in range(h-1):
            if i&1<<j:
                l.append(l[-1]+1)
            else:
                l.append(l[-1]) 
        ans_=l[-1]
        ll=[0]*h
        j=0
        flag=0
        while j<w:
            for p in range(h):
                ll[l[p]]+=S[p][j]
            if max(ll)>k and flag==0:
                flag=1
                ans_+=1
                ll=[0]*h
            elif max(ll)>k and flag==1:
                ans_=10**5
                break
            else:
                j+=1
                flag=0
        ans=min(ans,ans_)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1234567;
const ll INF=1000000010;
const ll LINF=1000000000000000010LL;
const int MAX=500010;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
int main(){
    int n;cin>>n;
    cout<<800*n-200*(n/15)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef pair<int,int> P;
typedef pair<double,double> P_f;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define MAX 100100
#define MAX_N 200100
#define MAX_T 2001001
#define SENTINEL 20010010010
#define NIL -1
static const int INF = 1 << 29;
const ll INFTY = 1LL<<50;
int n,k;
int num[10]={0,1,2,3,4,5,6,7,8,9};

int main(){
    cin>>n>>k;
    bool D[10];
    rep(i,10)D[i]=false;
    int d;
    rep(i,k){
        cin>>d;
        D[d]=true;
    }
    bool check=true;
    for(int i=n;i<=10*n;i++){
        string S=to_string(i);
        check=true;
        rep(j,S.length()){
            if(D[S[j]-'0'])check=false;
        }
        if(check){cout<<i<<endl;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++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

#define N 10
int C[N][N];
int COST[N];

const int INF = 1<<30;


int main(){
    int h, w;
    cin >> h >> w;
    rep(i, N) rep(j, N) cin >> C[i][j];
    vector<vector<int>> A(h, vector<int>(w));
    rep(i, h) rep(j, w) cin >> A[i][j];

    rep(i, N) COST[i] = C[i][1];
    for(int k = 0; k < N; k++){
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                if (j == 1) continue;
                if (i == j) continue;
                COST[i] = min(COST[i], COST[j] + C[i][j]);
            }
        }
    }
    
    // 
    ll ans = 0;
    rep(i,h) rep(j,w){
        if (A[i][j] == -1) continue;
        ans += COST[A[i][j]];
    }
    cout << ans << endl;
}



Measured memory_bytes: 3820
s = [input() for _ in range(3)]
now = 0
count = len(s[0])+len(s[1])+len(s[2])
for _ in range(count):
    if len(s[now]) == 0:
        if now == 0:
            print('A')
        elif now == 1:
            print('B')
        else:
            print('C')
        exit()
    else:
        if s[now][0] == 'a':
            if now == 0:
                s[0] = s[0][1:]
            elif now == 1:
                s[1] = s[1][1:]
            else:
                s[2] = s[2][1:]
            now = 0
        elif s[now][0] == 'b':
            if now == 0:
                s[0] = s[0][1:]
            elif now == 1:
                s[1] = s[1][1:]
            else:
                s[2] = s[2][1:]
            now = 1
        else:
            if now == 0:
                s[0] = s[0][1:]
            elif now == 1:
                s[1] = s[1][1:]
            else:
                s[2] = s[2][1:]
            now = 2


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

N = int(input())
A = list(map(int, input().split()))

def calc(l):
    count = 0
    for i in range(len(l)-1):
        count += abs(l[i]-l[i+1])

    return count

# 0 3 5 -1 0 みたいに
L = [0] + A + [0]
max_L = calc(L)
#print(max_L)

# 左右引いて、左右通しで計算すればいい
for i in range(1, N+1):
    diff_minus = abs(L[i-1]-L[i])+abs(L[i]-L[i+1])
    diff_plus = abs(L[i-1]-L[i+1])
    print(max_L-diff_minus+diff_plus)


Measured memory_bytes: 14052
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	int k, A, B;
	cin >> k;
	cin >> A >> B;
	for (int i = A; i <= B; i++) {
		if (i % k == 0) {
			cout << "OK" << '\n'; return 0;
		}
	}
	cout << "NG" << '\n';



}

Measured memory_bytes: 3128
/*
गिरते हैं शहसवार ही मैदान-ए-जंग में ।
वो तिफ़्ल क्या गिरे जो घुटनों के बल चले ।।
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int     long long int
#define ull     unsigned int
#define ld      long double
#define pb      push_back
#define pa      pair<int,int>
#define ppa     pair<pair<int,int>,int>
#define pap     pair<int,pair<int,int>>
#define v1d     vector<int>
#define v2d     vector<vector<int> >
#define vpa     vector<pair<int,int>>
#define M       1000000007
#define MN      LLONG_MIN
#define MX      LLONG_MAX
#define ff      first
#define ss      second
#define endl    "\n"
#define v1s     vector<string>
#define all(v)  v.begin(),v.end()
#define S(v)    sort(v.begin(),v.end())
#define RS(v)   sort(v.rbegin(),v.rend())
#define R(v)    reverse(v.begin(),v.end())
#define mxpq(T)    priority_queue <T>
#define mnpq(T)    priority_queue<T,vector<T>,greater<T>>
#define T       int tc;cin>>tc;while(tc--)
#define p2d(v)     for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)      for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)      for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define sz(v)       (int)(v.size())
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define qqq 400005


void Weapons19(){
    int n,sum=0;cin>>n;
    for(int i=1;i<=n;i++){
        if(i%3==0);
        else if(i%5==0);
        else sum+=i;
    }
    cout<<sum;























}

int32_t main(){

    /*
    त्यक्तवाधर्मं च लोभं च
    मोहंचो द्यमास्थिता।
    युद्ध्यध्वमनहंकारा
    यतो धर्मस्ततो जयः।।
    */

    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

   

    Weapons19();
    
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int N, M;
    cin >> N >> M;
    vector <bool> T(N);
    while (M--) {
        int a;
        cin >> a;
        T[a - 1] = true;
    }
    vector <ll> dp(N + 1);
    dp[0] = 1;
    for (int i = 0; i < N; i++) {
        if (!T[i]) {
            dp[i + 1] = (dp[i] + (i >= 1 ? dp[i - 1] : 0)) % 1000000007;
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 3980
while True:
    vote_n = int(input())
    if vote_n == 0:
        break
    vote_lst = [v for v in input().split()]
    
    vote_cnt = {}
    for i, v in enumerate(vote_lst):
        if not v in vote_cnt:
            vote_cnt[v] = 1
        else:
            vote_cnt[v] += 1
        
        first = 0
        second = 0
        first_key = None
        for k in vote_cnt:
            if first < vote_cnt[k]:
                second = first
                first = vote_cnt[k]
                first_key = k
            elif second < vote_cnt[k]:
                second = vote_cnt[k]
        
        if first - second > vote_n - (i + 1):
            print(first_key, i + 1)
            break
    if first == second:    
        print('TIE')


Measured memory_bytes: 5620
#include<iostream>
#include<stack>
#include<string.h>
#include<stdlib.h>
#include<cstdio>
#define mod 1e9+7
#define ll long long
using namespace std;
int N;
int bitsum(int x)
{
    int ans=0;
    while(x)
    {
        ans+=x%10;
        x/=10;
    }
    return ans;
}
int main()
{
    cin>>N;
    int ans=1000000;
    for(int i=1;i<=N/2;i++)
        ans=min(ans,bitsum(i)+bitsum(N-i));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	bool azb[26];
	for( int i = 0; i < 26; ++i ){
		azb[i] = false;
	}
	string s;
	cin >> s;
	for( int i = 0; i < s.l_ength(); ++i ){
		if( azb[ s[i] - 'a' ]  ){
			cout << "no" << endl;
			return 0;
		}
		azb[ s[i] - 'a' ] = true;
	}
	cout << "yes" << endl;
	return 0;
}

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

int main() {
  int k;
  string s;
  cin >> k >> s;
  if(s.size() <= k)
    cout << s << endl;
  else{
    for(int i=0; i<k; i++)
      cout << s.at(i);
    cout << "..." << endl;
  }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
const ll LLMAX=9223372036854775807;

map<ll,ll> m;

ll dfs(ll value, ll a, ll b, ll c, ll d){
  if(m[value]!=0)
    return m[value];
  if(value==0)
    return 0;
  if(value==1)
    return d;

  ll res=LLINF;
  if(value<res/d)
    res=d*value;

  ll l2=value/2*2;
  ll r2=(value+1)/2*2;
  ll l3=value/3*3;
  ll r3=(value+2)/3*3;
  ll l5=value/5*5;
  ll r5=(value+4)/5*5;
  res=min(res,dfs(l2/2,a,b,c,d)+(value-l2)*d+a);
  res=min(res,dfs(r2/2,a,b,c,d)+(r2-value)*d+a);
  res=min(res,dfs(l3/3,a,b,c,d)+(value-l3)*d+b);
  res=min(res,dfs(r3/3,a,b,c,d)+(r3-value)*d+b);
  res=min(res,dfs(l5/5,a,b,c,d)+(value-l5)*d+c);
  res=min(res,dfs(r5/5,a,b,c,d)+(r5-value)*d+c);

  m[value]=res;
  return res;

}



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

  ll t;
  cin>>t;
  vll n(t),a(t),b(t),c(t),d(t);
  REP(i,t)cin>>n[i]>>a[i]>>b[i]>>c[i]>>d[i];

  REP(i,t){
    m.clear();
    ll ans=dfs(n[i],a[i],b[i],c[i],d[i]);
    cout<<ans<<endl;
  }
}



Measured memory_bytes: 4308
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    cin >> a;
    
    vector<ll> dp(n, 1000);
    rep3(i, 1, n) {
        chmax(dp[i], dp[i - 1]);
        rep(j, i) { // 株を買う
            ll cnt = dp[j] / a[j];
            chmax(dp[i], dp[j] - cnt * a[j] + cnt * a[i]);
        }
    }
    cout << dp[n - 1] << endl;
    // cerr << dp << endl;
}


Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;

public class Main{

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        char[] text = br.readLine().toCharArray();
        int n = Integer.parseInt(br.readLine());
        for (int i = 0; i < n; i++) {
            String[] command = br.readLine().split(" ");
            int s = Integer.parseInt(command[1]);
            int e = Integer.parseInt(command[2]);
            switch (command[0]) {
                case "replace":
                    char[] rArr = command[3].toCharArray();
                    for (int j = s, c = 0; j <= e; j++, c++) {
                        text[j] = rArr[c];
                    }
                    break;
                case "reverse":
                    String tmp = new String(text).substring(s, e + 1);
                    for (int j = s, c = (e - s); j <= e; j++, c--) {
                        text[j] = tmp.charAt(c);
                    }
                    break;
                case "print":
                    tmp = new String(text).substring(s, e + 1);
                    bw.append(tmp + "\n");
                    break;
            }
        }
        bw.flush();
    }
}


Measured memory_bytes: 24512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl
#define MAXSIZE 100005

vector<ll> udist(MAXSIZE, -1);
vector<ll> vdist(MAXSIZE, -1);
vector<ll> visited(MAXSIZE,-1);
vector<vector<ll>> g;
vector<ll> newdist(MAXSIZE, -1);


template<class T>
void show_1d_vector(const vector<T> &v){
    for(auto v1: v) {
        cout << v1 << " ";
    }
    cout << endl;
}

void dfs(ll now, ll depth, bool is_u){
    if(is_u){
        udist[now] = depth;
        for(int i = 0; i < g[now].size(); i++){
            if(udist[g[now][i]]==-1){
                dfs(g[now][i], depth+1, is_u);
            }

        }
    }else{
        vdist[now] = depth;
        for(int i = 0; i < g[now].size(); i++){
            if(vdist[g[now][i]]==-1){
                dfs(g[now][i], depth+1, is_u);
            }
        }
    }
}

vector<ll> path;
void dfs2(ll now, ll depth){
    path.push_back(now);
    if(depth == 0){
        return;
    }
    for(int i = 0; i < g[now].size(); i++){
        if(udist[g[now][i]]==depth-1){
            dfs2(g[now][i], depth-1);
        }
    }
}

bool flg = true;
ll bfs(ll st){
    queue<ll> q;
    ll start = st;
    q.push(start);
    visited[start] = 0;
    ll ret = 0;
    while(!q.empty()){
        ll now = q.front();
        q.pop();

        for(int i = 0; i < g[now].size(); i++){
            ll next = g[now][i];
            if(visited[next] == -1 && newdist[next] != 9999999){
                flg = false;
                q.push(next);
                visited[next] = visited[now] + 1;
                ret = max(ret, visited[now] + 1);
            }
        }
    }

    return ret;
}


int main(){
    ll n, u, v;
    cin >> n >> u >> v;
    u--; v--;
    g.resize(n);
    for(int i = 0; i < n-1; i++){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dfs(u, 0, true);
    dfs(v, 0, false);
    //show_1d_vector(udist);
    //show_1d_vector(vdist);

    ll dist1 = udist[v];
    //dbg(dist1);
    dfs2(v, dist1);
    //show_1d_vector(path);
    ll start;
    ll ans = 0;
    if(dist1<=2){
        start = u;
        if(dist1==2){

            for(int i = 0; i < MAXSIZE; i++){
                if(vdist[i]<=1){
                    newdist[i] = 9999999;
                }
            }
        }
        newdist[v] = 9999999;
    }else{
        if(path.size()%2==0){
            start = path[path.size()/2];
            ans += path.size()/2-1;
        }else{
            start = path[path.size()/2+1];
            ans += path.size()/2-1;
        }
        for(int i = 0; i < path.size()/2; i++){
            newdist[path[i]] = 9999999;
        }
    }

    //dbg(start);
    ll ret = bfs(start);
    //dbg(ret);
    ans += ret;
    if(path.size()%2==1){ans++;}

    if(dist1 == 2 && flg){
        cout << 1 << endl;
    }else if(dist1 == 1&&flg){
        cout << 0 << endl;
    }else{
        cout << ans << endl;

    }

    return 0;

}


Measured memory_bytes: 12144
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    char[] s = scanner.next().toCharArray();

    int min0 = s.length;
    int min1 = s.length;
    for (int i = 0; i < s.length; i++) {
      int l = s.length - i - 1;
      int r = i;
      int m = l == r ? l + 1 : Math.max(l, r);
      if (s[i] == '1') {
        if (m < min1) min1 = m;
      } else {
        if (m < min0) min0 = m;
        
      }
    }
    System.out.println(Math.max(min0, min1));
  }
}


Measured memory_bytes: 28808
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){
    llint n;
    cin >> n;
    DEFOR(i,n+1,0){
        if(__builtin_popcount(i)==1){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
n,d = gets.chomp.split(" ").map(&:to_i)
 x = Array.new(n).map{Array.new}
n.times do |i|
  x[i] = gets.chomp.split(" ").map(&:to_i)
end

c = x.combination(2)
ans = 0
c.each do |p|
  len = p[0].length
  sum = 0
  for i in 0..len-1
    sum += (p[0][i] - p[1][i])**2.0
  end
  d = sum ** 0.5
  if d.to_s =~ /^[0-9]+(\.0)?$/
    ans += 1
  end
end
puts ans

Measured memory_bytes: 3836
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    int t,s;
    int sum,i,j,k;
    cin>>t>>s;
    sum=0;
    for(i=0; i<=t; ++i)
    {
        for(j=i; j<=t; ++j)
        {
            for(k=j; k<=t; ++k)
            {
                if(i+j+k==s)
                {
                    if(i==j&&j==k)
                        sum+=1;
                    if((i==j&&i!=k)||(j==k&&j!=i)||(i==k&&j!=k))
                        sum+=3;
                    if(i!=j&&j!=k&&i!=k)
                        sum+=6;
                }
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int count = 0;
    for(int i=0; i<n; i++){
        int newnum;
        cin >> newnum;
        while(newnum%2 == 0){
            newnum /= 2;
            count ++;
        }
    }

    cout << count << '\n';
}

Measured memory_bytes: 256
'use strict';

function main(input) {
  let inputs = input.split('\n');
  let cards = inputs[1].split(' ').map(n => parseInt(n, 10));
  let alice_sum = 0;
  let bob_sum = 0;

  let sorted_cards = cards.sort(compareNumbers);

  sorted_cards.forEach((card, i) => {
    if (i === 0 || i % 2 === 0) {
      alice_sum += card;
    } else {
      bob_sum += card;
    }
  });

  console.log(alice_sum - bob_sum);
}

function compareNumbers(a, b) {
  return b - a;
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
# ABC066-B
S = input()
flag = False
for i in range(len(S)):
    L = len(S)
    S = S[0 : L-1]   # 末尾消去
    L = len(S)   
    if L % 2 == 0:
        short_L = int(L / 2)
        if S[0 : short_L] == S[short_L : L]:
            ans = L
            break
print(ans)

Measured memory_bytes: 3060
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

typedef vector<vector<P> > Graph;
vector<int> dijkstra(int s, Graph &G){
  priority_queue<P,vector<P>,greater<P>> que;
  int n = G.size();
  vector<int> dist(n);
  dist.assign(n,INF);
  dist[s] = 0;
  que.push(P(0,s));

  while(!que.empty()){
    P p = que.top();
    que.pop();
    int v = p.sc;
    REP(i,G[v].size()){
      if(dist[G[v][i].fs] > dist[v]+G[v][i].sc){
        dist[G[v][i].fs] = dist[v]+G[v][i].sc;
        que.push(P(dist[G[v][i].fs],G[v][i].fs));
      }
    }
  }
  return dist;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    pvvec G(n);
    rep(i,n-1){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        G[a].eb(b,c);
        G[b].eb(a,c);
    }
    int q,k;
    cin>>q>>k;
    k--;
    vec dist=dijkstra(k,G);
    rep(i,q){
        int x,y;
        cin>>x>>y;
        x--;y--;
        cout<<dist[x]+dist[y]<<endl;
    }
    
}

Measured memory_bytes: 11120
#include<stdio.h>
#include<stdlib.h>
#define abs(x) ((x>0) ? (x): (-(x)))

int main()
{
	int n,l,m,x,i,min=10000,ans=0;
	scanf("%d %d",&l,&n);
	for(i=0;i<l;i++)
	{
		m=n+i;
		ans+=m;
		//printf("%d",ans);
		if((abs(m))<min)
		{
			min=(abs(m));
			x=m;
		}
	}
	printf("%d",(ans-x));
}


Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))
 
ans = 0
l = [0]*N
u = [0]*N

for i in range(N):
  b = i - A[i]
  c = i + A[i]
  if 0 < b < N:
    l[b] += 1
  if 0 < c < N:
    u[c] += 1

for i in range(N):
  ans += l[i]*u[i]

print(ans)

Measured memory_bytes: 32288
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<random>
using namespace std;
int inf = 1e9;

int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
vector<string> g(8, "--------");

void dfs(int x, int y){
  g[y][x] = '0';
  for(int i=0; i<4; i++){
    int nx = x;
    int ny = y;
    for(int j=0; j<3; j++){
      nx += dx[i]; ny += dy[i];
      if( nx < 0 || nx >= 8 || ny < 0 || ny >= 8 ) break;

      if( g[ny][nx] == '1' ){
        g[ny][nx] = '0';
        dfs(nx, ny);
      }

    }
  }

}


int main() {

  int n; cin >> n;
  for(int i=0; i<n; i++){
    for(int j=0; j<8; j++) cin >> g[j];
    int x, y; cin >> x >> y;
    x--; y--;
    dfs(x, y);

    cout << "Data " << i+1 << ":" << endl;
    for(int j=0; j<8; j++){
      cout << g[j] << endl;
    }

  }

  return 0;
}




// EOF

Measured memory_bytes: 3044
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

int main()
{

    int K,N;
    cin >> N >> K;
    vector<int> p;
    rep(i,N){
        int t = 0;
        cin >> t;
        p.push_back(t);
    }
    sort(p.begin(),p.end());
    ll sum =0;
    rep(i,K){
        sum+=p[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3632
s = input()
if 0<int(s[:2])<=12 and 0<int(s[2:4])<=12:
    print('AMBIGUOUS')
elif 0<int(s[:2])<=12:
    print('MMYY')
elif 0<int(s[2:4])<=12:
    print('YYMM')
else:
    print('NA')    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  ll ans=0;
  rep(i,n){
    while(a[i]%2==0){
      ans++;
      a[i]/=2;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	string s , t; cin >> s >> t;
	t = t.substr(0,(int)s.size());
	if(s==t)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3632
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DPreparingBoxes solver = new DPreparingBoxes();
        solver.solve(1, in, out);
        out.close();
    }

    static class DPreparingBoxes {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n + 1];
            for (int i = 1; i <= n; i++) a[i] = in.nextInt();
            int b[] = new int[n + 1];
            int count = 0;
            for (int i = n; i >= 1; i--) {
                long sum = 0;
                for (int k = 2; ; k++) {
                    if (i * k <= n) {
                        sum += b[i * k];
                    } else {
                        break;
                    }
                }
                if (sum % 2 == a[i]) {
                    b[i] = 0;
                } else {
                    b[i] = 1;
                    count++;
                }
            }
            out.println(count);
            for (int i = 1; i <= n; i++) {
                if (b[i] == 1)
                    out.print(i + " ");
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 43644
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a;
  cin>>n>>a;
  cout<<n*n-a<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define Abs(_A) ((_A)>0?(_A):(-(_A)))
#define Max(_A,_B) ((_A)>(_B)?(_A):(_B))
#define Min(_A,_B) ((_A)<(_B)?(_A):(_B))
#define INF 0x3f3f3f3f3f3f3f3f
long long n,a[200005],sm[200005];
void init(){
    scanf("%lld",&n);
    sm[0]=0;
    for(long long i=1;i<=n;++i){
        scanf("%lld",&a[i]);
        sm[i]=sm[i-1]+a[i];
    }
    long long p=2,q=1;
    long long ans=INF;
    for(long long i=2;i<=n-2;++i){
        while(q+1<i&&Abs(sm[q]-(sm[i]-sm[q]))>=Abs(sm[q+1]-(sm[i]-sm[q+1]))){
            ++q;
        }
        while(p+1<n&&Abs((sm[p]-sm[i])-(sm[n]-sm[p]))>=Abs((sm[p+1]-sm[i])-(sm[n]-sm[p+1]))){
            ++p;
        }
        ans=Min(ans,Max(Max(sm[n]-sm[p],sm[p]-sm[i]),Max(sm[i]-sm[q],sm[q]))-Min(Min(sm[n]-sm[p],sm[p]-sm[i]),Min(sm[i]-sm[q],sm[q])));
    }
    printf("%lld",ans);
} 
int main(){
    init();
    return 0;
}

Measured memory_bytes: 3328
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto xs = readints;
    int a = xs[0], b = xs[1], c = xs[2], d = xs[3];

    if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
        writeln("Yes");
    }
    else writeln("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
int A[30][30];
int x,y;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int dfs(int x,int y){
    A[x][y]=1;
    int ans=0;
    REP(i,4){
        int xx=dx[i]+x;
        int yy=dy[i]+y;
        if(A[xx][yy]==0){
           ans+=dfs(xx,yy);
        }
    }
    return ans+1;
}

int main(){
    int W,H;
    while(cin>>W>>H,W+H){
        REP(i,30){
            REP(j,30){
                A[i][j]=1;
            }
        }
        REP(i,H){
            string s;
            cin>>s;
            REP(j,W){
                if(s[j]=='.')A[i+1][j+1]=0;
                if(s[j]=='@'){
                   A[i+1][j+1]=0;
                   x=i+1;
                   y=j+1;
                }
            }
        }
        cout<<dfs(x,y)<<endl;
    }
    return 0;
}

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

int main(){
	int n, k;
	cin >> n >>  k;
	
	vector<int> v(n);
	for ( int i= 0; i < n; i++)
		cin >> v[i];
	sort(v.begin() , v.end());
	
	int sum = 0;
	for ( int i = 0; i < k; i++)
		sum += v[i];
		
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3612
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 1200031;

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	int a,b;
	cin>>a>>b;
	if (max(a,b)<=8)
		cout<<"Yay!"<<endl;
	else
		cout<<":("<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 256
//
//  abc148_b.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll INF = 1000000007;
#define PI 3.14159265

const int MAX = 110000;

ll fac[MAX], finv[MAX], inv[MAX];

std::vector<int> permutations;

int gcd(int a, int b) {
   if (b == 0)
      return a;
   return gcd(b, a % b);
}

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

  for (int i = 0; i < n; i++) {
    std::cout << s[i] << t[i];
  }
  std::cout << std::endl;
  return 0;
}



Measured memory_bytes: 256