akhauriyash/Code-Regression huggingface dataset:
///spaesk

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define pi acos(-1)
#define int long long int
#define ld long double
#define ar array
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<int> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const int ths = 1LL << 40;
const int NN = 5e3 + 6;

const int maxN = 1e7 + 2;

///
///

int spf[maxN] ;

void sieve()
{
    spf[1] = 1;
    for (int i=2; i<maxN; i++)
        spf[i] = i;
    for (int i=4; i<maxN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<maxN; i++)
    {
        if (spf[i] == i)
        {
            for (int j=i*i; j<maxN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}


void solve()
{

    sieve();
    int n;
    cin>>n;
    int ans = 0;
    for(int i = 1; i <= n; i ++) {
        int c = 0, p = 0;
        int x = i;
        p = spf[x];
        int t = 1;
        while(x != 1) {
            if(spf[x] == p)
                x /= spf[x], c ++;
            else
                t *= (c + 1), c = 0, p = spf[x];
        }
        t *= (c + 1);
//        cout<<i<<' '<<t<<endl;
        ans += (i * t);
    }
    cout<<ans;
    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 81772
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"input();a=b=0\n"
"for x in input():b+=x>'D'or-1;a=max(a,b)\n"
"print(a)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 7360
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};
 
 
int main(){
    int k;
    cin>>k;
    int cnt=7;
    rep(i,10000000){
        if(cnt%k==0){
            cout<<i+1<<endl;
            return 0;
        }
        cnt *=10;
        cnt +=7;
        cnt %=k;
    }
    cout<<-1<<endl;
}

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


using namespace std;

int main()
{
    string s;
    cin>>s;
    int a=0;
    for(auto i=1;i<=s.length();i++)
    {
        if(i%2==0)
            {
                if(s[i-1]=='R')
                a++;
            }
        else
            {
                if(s[i-1]=='L')
                a++;
            }
    }

    if(a==0)
        cout<<"Yes";
    else
        cout<<"No";

    return 0;
}


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

int i, j, k,l, m, n, cnt[200005];
pair<int, int> p[200005];
int main() {
	scanf("%d%d", &n, &k);
	for(i = 0; i < n; i++) {
		scanf("%d", &j);
		++cnt[j];
	}
	for(i = 1; i <= n; i++) if(cnt[i]) {
		p[m++] = make_pair(cnt[i], i);
	}
	sort(p, p + m);
	if(m <= k) printf("0\n");
	else {
		for(i = 0; i < m - k; i++) l += p[i].first;
		printf("%d\n", l);
	}
}

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

#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int main()
{
    int n, m;
    while (cin >> n >> m, n) {
        vector<int> v(n, 0); 
        v[0] = 1;
        vector<vector<int>> ps(m);
        loop(m ,i) {
            vector<int> tsd(3);
            cin >> tsd[0] >> tsd[1] >> tsd[2];
            ps[i] = tsd;
        }
        sort(all(ps));
        for(auto p : ps) {
            if(v[p[1]-1] == 1) v[p[2]-1] = 1; 
        }
        cout << accumulate(all(v), 0) << endl;
    }
}

Measured memory_bytes: 3952
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import itertools
import math
n,m,k = ma()
mod = 998244353
nmax = 10**6

fac = [1]*nmax
finv = [1]*nmax
inv = [1]*nmax
def ncr_pre():
    for i in range(2,nmax):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) %mod
        finv[i] = finv[i-1] * inv[i] %mod

def ncr(n,r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fac[n]* (finv[r] * finv[n-r] %mod) %mod

ncr_pre()
ans = 0
for i in range(k+1):
    ans = ans+ncr(n-1,i) * m*pow(m-1,n-i-1,mod)
    ans %=mod
print(ans)


Measured memory_bytes: 94792
s=input()
cnt=0

if s!='1': 
    for i in range(0,len(s),2):
        if s[i]=='0':
            cnt+=1
    for j in range(1,len(s),2):
        if s[j]=='1':
            cnt+=1
else:
    cnt=0

print(min(cnt,len(s)-cnt))

Measured memory_bytes: 3188
from collections import Counter

def main():
    N, K = map(int, input().split())
    A = tuple(map(int, input().split()))

    cnt = Counter(A).most_common()[::-1]
    l = len(cnt)
    if l <= K:
        print(0)
    else:
        x = l - K
        ball = 0
        for i, j in cnt[:x]:
            ball += j
        print(ball)

main()


Measured memory_bytes: 39348
/*
𝓐𝓾𝓽𝓱𝓸𝓻:-
𝓢𝓪𝓾𝓻𝓪𝓫𝓱𝓼𝓱𝓪𝓭𝓸𝔀
------------------------
*/
#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 loop(i,a,b) for(int i=a;i<b;i++)
#define loopb(i,a,b) for(int i=a;i>=b;i--)
#define fore(name)  for(auto it=name.begin();it!=name.end();it++)
#define w  int t;cin>>t;while(t--)
#define pb(x) push_back(x)
#define in(y) insert(y)
#define bitscount 32
#define make(x,y) make_pair(x,y)
#define LOAD_FACTOR_set(name) name.reserve(32768);name.max_load_factor(0.25);
#define LOAD_FACTOR_map(name) name.reserve(1024);name.max_load_factor(0.25);
#define lcm(a,b) ((a*b))/(__gcd(a,b))
#define int long long int
#define REDBULL ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define all(x) (x).begin(), (x).end()


typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ordered_justset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

struct HASH {
	size_t operator()(const pair<int, int>&x)const {
		return ((int)x.first) ^ (((int)x.second) << 32);
	}
};
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
typedef pair<int, int> pi;
#define UNMAP(name) unordered_map<int,int,custom_hash> name
#define MAX 10000000000000
int check(string str)
{
	// Compute sum of digits
	int n = str.length();
	int digitSum = 0;
	for (int i = 0; i < n; i++)
		digitSum += (str[i] - '0');

	// Check if sum of digits is divisible by 9.
	return (digitSum % 9 == 0);
}
void solve()
{
	string s;
	cin >> s;
	check(s) ?  cout << "Yes" : cout << "No ";

}
int32_t main()
{
	REDBULL
	// w
	solve();

	return 0;
}

Measured memory_bytes: 3732
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		for(int i = 0; i < t; i++){
			int h = sc.nextInt();
			int w = sc.nextInt();
			String[][] map = new String[h][w];
			int[] x = new int[2];
			sc.nextLine();
			for(int j = 0; j < h; j++){
				String s = sc.nextLine();
				for(int k = 0; k < w; k++){
					map[j][k] = String.valueOf(s.charAt(k));
					String _s = map[j][k];
					if(_s.equals("^") || _s.equals("v") || _s.equals("<") || _s.equals(">")){
						x[0] = j;
						x[1] = k;
					}
				}
			}
			int n = sc.nextInt();
			String[] command = new String[n];
			sc.nextLine();
			String s = sc.nextLine();
			for(int j = 0; j < n; j++){
				command[j] = String.valueOf(s.charAt(j));
			}
			play(map, x, command);
			if(i < t-1){
				System.out.println();
			}
		}
		sc.close();
	}
	static void play(String[][] map, int[] x, String[] command){
		for(int i = 0; i < command.length; i++){
			if(command[i].equals("S")){
				shoot(map, x);
			}else{
				move(map, x, command[i]);
			}
		}
		printMap(map);
	}
	static void move(String[][] map,int[] x, String s){
		int[] v = new int[2];
		if(s.equals("U")){
			v[0] = -1;
		}else if(s.equals("D")){
			v[0] = 1;
		}else if(s.equals("L")){
			v[1] = -1;
		}else{
			v[1] = 1;
		}
		int[] nx = {x[0]+v[0], x[1]+v[1]};
		if(isInMap(map, nx) && map[nx[0]][nx[1]].equals(".")){
			map[nx[0]][nx[1]] = v2p(v);
			map[x[0]][x[1]] = ".";
			x[0] = nx[0];
			x[1] = nx[1];
		}else{
			map[x[0]][x[1]] = v2p(v);
		}

	}
	static String v2p(int[] v){
		if(v[0] == 0){
			if(v[1] == 1){
				return ">";
			}else{
				return "<";
			}
		}else if(v[0] == -1){
			return "^";
		}else{
			return "v";
		}
	}
	static void shoot(String[][] map, int[] x){
		int[] v = new int[2];
		String s = map[x[0]][x[1]];
		if(s.equals("^")){
			v[0] = -1;
		}else if(s.equals("v")){
			v[0] = 1;
		}else if(s.equals("<")){
			v[1] = -1;
		}else{
			v[1] = 1;
		}
		int[] bx = {x[0], x[1]};
		while(isInMap(map, bx) && (!map[bx[0]][bx[1]].equals("*") && !map[bx[0]][bx[1]].equals("#"))){
			bx[0] += v[0];
			bx[1] += v[1];
		}
		if(isInMap(map, bx)){
			if(map[bx[0]][bx[1]].equals("*")){
				map[bx[0]][bx[1]] = ".";
			}
		}
	}
	static boolean isInMap(String[][] map, int[] x){
		return 0 <= x[0] && x[0] < map.length && 0 <= x[1] && x[1] < map[0].length;
	}
	static void printMap(String[][] map){
		for(int i = 0; i < map.length; i++){
			for(int j = 0; j < map[0].length; j++){
				System.out.print(map[i][j]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  
  string k = "MARCH";
  ll cnt[5];
  memset(cnt, 0, sizeof(cnt));
  
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < 5; j++) {
      if (s[0] == k[j]) {
        cnt[j]++;
      }
    }
  }
  
  ll sum = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++) {
        sum += cnt[i] * cnt[j] * cnt[k];
      }
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	int N;
	cin >> N;
	VI a(N + 1);

	FOR(i, 1, N)cin >> a[i];


	vector<bool> seen(N + 1, false);

	bool ok = true;


	int now = 1, cnt = 0;
	while (now != 2 && ok ) {

		if (seen[now]){ok = false; break;}

		seen[now]=true;
		now = a[now]; //次の
		cnt++;
		//cout<<0<<endl;

	}


	if (ok)cout << cnt << endl;
	else cout << -1 << endl;








	return 0;
}


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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define sec second
#define fir first
#define pb push_back



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
//const int inf = pow(2, 62);
//const int mod = 1e9 + 7;
const int mod = 100000;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};



/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




/* main */
int ceil(int a, int b){
    if(a % b == 0) return a /b;
    else return a /b + 1;
}

struct Union_Find{
    vector<int> par;
    vector<int> rank;

    Union_Find(int n){
        for(int i = 0; i < n; i++){
            par.push_back(i);
            rank.push_back(0);
        }
    }

    int root(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = root(par[x]);
        }
    }

    void merge(int x, int y){
        x = root(x);
        y = root(y);

        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }

};


signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int t = input() + input();

    if(t > 9){
        print("error");
    }else{
        print(t);
    }

    
    




    
    



    
    

    







   




    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










Measured memory_bytes: 256
n, m, x = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(n)]
price = []
for i in range(2 ** n):
    cnt = [0]*m
    price_temp = 0
    for j in range(n):
        if (i >> j) & 1:
            price_temp += c[j][0]
            for k in range(m):
                cnt[k] += c[j][k+1]
    if all(s >= x for s in cnt):
        price.append(price_temp)
print(min(price) if len(price) > 0 else -1)

Measured memory_bytes: 9220
#include<stdio.h>
void maxheap(int *a, int i,int n);
int main()
{
  int n,i;
  scanf("%d",&n);
  int a[n+1];
  //int *a;
  for(i=1;i<=n;i++)scanf("%d",&a[i]);
  for(i=n/2;i>0;i--)maxheap(a,i,n);
  for(i=1;i<=n;i++)printf(" %d",a[i]);
  printf("\n");
  return 0;
}
void maxheap(int *a, int i,int n){
  int r,l,larg,tmp;
  l=2*i;
  r=2*i+1;
  if(l<=n && a[l]>a[i])larg=l;
  else larg=i;
  if(r<=n && a[r]>a[larg])larg=r;
  if(larg!=i){
    tmp=a[larg];
    a[larg]=a[i];
    a[i]=tmp;
    maxheap(a,larg,n);
  }
}


Measured memory_bytes: 3640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;
    
    

    void calc()
    {
        cin = new Scanner();
        string S = cin.next();
        if(S.Replace("A", "")=="KIHBR" && S.IndexOf("KIH")!= -1 && S.IndexOf("AA") == -1)
        {
            Console.WriteLine("YES");
        }
        else Console.WriteLine("NO");
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int n, a, b;
    cin >> n >> a >> b;

    cout << min(n * a, b) << '\n';
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main(void){
     int n,a,min,max,i;
     long int sum;
     max=-1000000;
     min=1000000;
     sum=0;
     scanf("%d",&n);
     for (i=0;i<n;i++){
          scanf("%d",&a);
          if(a>max){
          max=a;
          }
          if(a<min){
          min=a;
          }
          sum+=a;
     }
     printf("%d %d %ld\n",min,max,sum);
     return 0;
}
     

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    map<string,ll>c;
    c["AC"]=0,c["WA"]=0,c["TLE"]=0,c["RE"]=0;
    rep(0,i,n){
        string s;
        cin>>s;
        ++c[s];
    }
    cout<<"AC x "<<c["AC"]<<endl;
    cout<<"WA x "<<c["WA"]<<endl;
    cout<<"TLE x "<<c["TLE"]<<endl;
    cout<<"RE x "<<c["RE"]<<endl;
}

Measured memory_bytes: 3576
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }
  int c = 0;
  for(int i = 1; i < n-1; i++){
    if(p[i-1] < p[i] && p[i] < p[i+1]){
      c++;
    }
    else if(p[i+1] < p[i] && p[i] < p[i-1]){
      c++;
    }
  }
  cout << c;
  return 0;
}


Measured memory_bytes: 256
N, M, X = map(int, input().split())
a_list = list(map(int,input().split()))

to_0_count = 0
to_N_count = 0
for i in range(0, X):
    if i in a_list:
        to_0_count +=1
for i in range(X+1, N+1):
    if i in a_list:
        to_N_count +=1
print(min([to_0_count, to_N_count]))

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){

	int r,c,table[101][101];
	int i,j,k,sum;

	cin >> r >> c;

	table[r][c] = 0;
	for(i=0;i<r;i++){
		table[i][c] = 0;
		for(j=0;j<c;j++){
			table[r][j] = 0;
			cin >> table[i][j];
			table[r][c] += table[i][j];
		}
	}

	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			cout << table[i][j] << " ";
			table[i][c] += table[i][j];
			table[r][j] += table[i][j];
		}
		cout << table[i][c] << endl;
	}
	for(j=0;j<c;j++)
		cout << table[r][j] << " ";
	cout << table[r][c] << endl;

	return 0;
}


Measured memory_bytes: 3132
import sys
from collections import deque,defaultdict

def bfs(s):
    bfs_map = defaultdict(lambda : 1)
    bfs_map[s] = 0
    q = deque([s])
    b = defaultdict(lambda : 0)
    b[s[0]] = 1
    while q:
        x = q.popleft()
        for y in v[x]:
            if bfs_map[y]:
                bfs_map[y] = 0
                q.append(y)
                b[y[0]] = 1

    for i in range(n):
        if not b[i]:
            return 0
    return 1

while 1:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    T = [[] for i in range(30)]
    v = defaultdict(list)
    for i in range(n):
        s = list(map(int, sys.stdin.readline()[:-1].split()))
        t = s[1:]
        t.sort()
        for j in t:
            T[j-1].append(i)
        for j in range(1,s[0]):
            v[(i,t[j]-1)].append((i,t[j-1]-1))
    f = 1
    for t in range(30):
        for i in range(len(T[t])-1):
            x = T[t][i]
            y = T[t][i+1]
            v[(x,t)].append((y,t))
            v[(y,t)].append((x,t))

    for t in range(30):
        if T[t]:
            if bfs((T[t][0],t)):
                f = 0
                print(t+1)
                break
        if not f:
            break
    if f:
        print(-1)



Measured memory_bytes: 6664
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;
int n,a[100000+5],f,ans;
int main()
{
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
    scanf("%d",&a[i]);
  sort(a+1,a+1+n);
  for(int i=1;i<=n;i++)
  {
    f++;
    if(a[i]!=a[i+1])
    {
      if(f<a[i])ans+=f;
      if(f>a[i])ans+=f-a[i];
      f=0;
    }
  }
  printf("%d\n",ans);
  return 0;
}


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

using namespace std;

int main()
{

    int sum, a, b;

    std::scanf("%d %d %d", &a, &b, &sum);
    int times = 0;
    int div = 0;

    if (sum > a * 7 + b) {
        div = sum / (a * 7 + b);
        times += 7 * div;
        sum -= ((a * 7 + b) * div);
    }


    if (sum > 6 * a) times += 7;
    else {
        times += (sum % a == 0) ? sum / a : sum / a + 1;
    }
    std::printf("%d\n", times);

    return 0;
}



Measured memory_bytes: 3212
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product

def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m,v,p=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)

rui=[0]
for i in range(p,n):
   rui.append(rui[i-p]+(a[p-1]-a[i]))
# print(a)
# print(rui)
ans=p
tmp=0

for i in range(p,n):
    if a[p-1]<=a[i]+m:
        if n-i-1+p>=v:
            ans+=1
        else:
            mae=rui[i-p]+(a[i]+m-a[p-1])*(i-p+1)
            ushiro=(n-i-1)*m
            # print(mae,ushiro)
            if mae+p*m+ushiro>=m*v:
                ans+=1

print(ans)

Measured memory_bytes: 64356
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>

using namespace std;

int waru(int num){
    int count = 0;
    while(1){
            //printf("num/10 : %d\n",num%10);
            count += num%10;
            num = num/10;
            if(num == 0){
                break;
            }
        }
    return count;
}

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

    int count = 0;
    int result = 0;
    for(int i = 1; i <= N; i++){
        count = waru(i);
        if(A <= count and count <= B){
            //printf("count : %d, i : %d\n",count, i);
            result += i;
        }
    }
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
typedef long long ll;

int n,m;
string s,t;

int main() {
  cin >> n >> m;
  int x[n];
  rep(i,n){
   cin >> x[i]; x[i]-=m;
  }
  int d=abs(x[0]);
  rep(i,n) d=__gcd(d,abs(x[i]));
  cout << d << endl;
}

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

class Main {

    public static void main(String[] args) {

	Scanner stdin = new Scanner(System.in);

	while ( stdin.hasNextInt() ) {
	    final int no = ( stdin.nextInt() - 1 ) % 39 + 1;
		System.out.printf( "3C%02d\n", no );
	}	
    }
    
}

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()         

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q, sum, cnt, m, k;
int arr[N+2], brr;


void solve()
{
      string str;
      cin >> str;
      if( str[3-1] == str[4-1] and str[5-1] == str[6-1] ) cout << "Yes";
      else cout << "No";

}

int32_t main()
{
      ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);
      //INP(); 

      int test = 1;
      // cin >> test;

      // cout << setprecision(9) << fixed;
      // clock_t z = clock();
      while(test--)solve();
      // cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
}











inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //






Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

struct Dice
{
	int top, bottom;
	VI sides;

	Dice() : top( 1 ), bottom( 6 ), sides { 2, 3, 5, 4 }
	{
		return;
	}

	void rotate( string direction )
	{
		if ( direction == "North" )
		{
			int ntop = sides[0], nbottom = sides[2], nfront = bottom, nback = top;
			top = ntop;
			bottom = nbottom;
			sides[0] = nfront;
			sides[2] = nback;
		}
		else if ( direction == "East" )
		{
			int ntop = sides[3], nbottom = sides[1], nleft = bottom, nright = top;
			top = ntop;
			bottom = nbottom;
			sides[3] = nleft;
			sides[1] = nright;
		}
		else if ( direction == "South" )
		{
			int ntop = sides[2], nbottom = sides[0], nfront = top, nback = bottom;
			top = ntop;
			bottom = nbottom;
			sides[0] = nfront;
			sides[2] = nback;
		}
		else if ( direction == "West" )
		{
			int ntop = sides[1], nbottom = sides[3], nleft = top, nright = bottom;
			top = ntop;
			bottom = nbottom;
			sides[3] = nleft;
			sides[1] = nright;
		}
		else if ( direction == "Right" )
		{
			std::rotate( sides.begin(), sides.begin() + 1, sides.end() );
		}
		else
		{
			std::rotate( sides.begin(), sides.begin() + 3, sides.end() );
		}
	}
};

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

	while ( true )
	{
		int n;
		cin >> n;

		if ( !n )
		{
			break;
		}

		Dice d;
		int res = 1;
		REP( i, 0, n )
		{
			string str;
			cin >> str;
			d.rotate( str );
			res += d.top;
		}

		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 1240
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2369

#include <iostream>
#include <string>
using namespace std;

string A[4] = { "mew", "mXew", "meXw", "mXeXw" };

int main() {
  string S;
  cin >> S;
  if (S == "") S = "X";
  for (int s = S.size(); true; s = S.size()) {
    int i;
    for (int j=0; j<4; j++) {
      if ((i = S.find(A[j])) != -1) {
	S.replace(i, A[j].size(), "X");
      }
    }
    if (s == S.size()) break;
  }
  if (S == "X") {
    cout << "Cat" << endl;
  } else {
    cout << "Rabbit" << endl;
  }
}

Measured memory_bytes: 1212
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <sstream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define F first
#define S second
using namespace std;
using ll = long long;
using P = pair<int,int>;

vector<int> f(const vector<vector<P> >& m, int src) {
  vector<int> d(m.size(), 1<<30);
  queue<P> q;
  q.push(P(src, 0));

  while(!q.empty()) {
    P t = q.front();
    q.pop();

    int dst = t.F;
    int c = t.S;
    if (d[dst] > c) {
      d[dst] = c;
      rep(i, m[dst].size()) {
        P n = m[dst][i];
        q.push(P(n.F, c + n.S));
      }
    }
  }

  return d;
}

int main() {
  int n, x, y;
  cin >> n >> x >> y;

  vector<vector<P> > m(n);
  rep(i, n-1) {
    m[i].push_back(P(i+1, 1));
    m[i+1].push_back(P(i, 1));
  }
  m[x-1].push_back(P(y-1, 1));
  m[y-1].push_back(P(x-1, 1));

  vector<int> v(n, 0);
  rep(i, n-1) {
    vector<int> d = f(m, i);
    for(int j = i+1; j < d.size(); j++) {
      v[d[j]]++;
    }
  }

  for(int i = 1; i < n; i++) {
    cout << v[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 384
n = int(input())

R = []

for i in range(0,n):
    R.insert(i, int(input()))

m = min(R[0:2])
MAX = R[1] - R[0]
for r in range(2, n):
    if(R[r-1] < m):
        m = R[r-1]
    MAX2 = R[r] - m
    if(MAX2 > MAX):
        MAX = MAX2

print(MAX)

Measured memory_bytes: 15604
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=100005;
const double EPS=1e-6;

int x[SIZE];

int main(){
    /*main function start*/
    int n,k,c;
    bool ok=true;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
		scanf("%d",x+i);
	}
	long long ans=(long long)1e20;
    for(int i=1;i+k-1<=n;i++){
    	long long now;
    	if(x[i]<=0 && x[i+k-1]<=0){
    		now=-x[i];
		}
		else if(x[i]>=0 && x[i+k-1]>=0){
			now=x[i+k-1];
		}
		else{
			now=min((-x[i])*2+x[i+k-1],x[i+k-1]*2-x[i]);
		}
		ans=min(ans,now);
//		cout<<now<<endl;
	}
    printf("%I64d\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int n;
  cin >> n;
  mint ans = 0;
  combination comb(100000);
  for (int i = 1; i <= n; ++i) {
    int cur = n - i * 3;
    if (cur < 0) break;
    ans += comb(cur + i - 1, i - 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4840
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean ok = (s.charAt(2)==s.charAt(3))&&(s.charAt(4)==s.charAt(5));
        
        System.out.println(ok?"Yes":"No");
    }
}

Measured memory_bytes: 21972
import string

N = int(input())
alphabet = list(string.ascii_lowercase)
num2alphabet = {i + 1: a for i, a in enumerate(alphabet)}
num2alphabet[0] = "z"
ans = ""

while N > 0:
    num = N % 26
    ans += num2alphabet[num]
    if N <= 26:
        break

    if num == 0:
        N -= 1

    N = N // 26

print(''.join(list(reversed(ans))))


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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            String st = br.readLine();
            while(st!=null){
            String[] s = st.split(" ",0);
            double a = Double.parseDouble(s[0]);
            double b = Double.parseDouble(s[1]);
            double c = Double.parseDouble(s[2]);
            double d = Double.parseDouble(s[3]);
            double e = Double.parseDouble(s[4]);
            double f = Double.parseDouble(s[5]);
            double x = (c*e-b*f)/(a*e-b*d);
            double y = (c*d-a*f)/(b*d-a*e);
            if(x==-0){
                x=0;
            }
            if(y==0){
                y=0;
            }
            System.out.printf("%.3f %.3f\n",x,y);
            st = br.readLine();
            }
        }catch (Exception ex){
            System.exit(0);
        }
    }
}

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

int main()
{
ll n , x ;
cin >> n >> x ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
sort(a.begin(),a.end());
rep(i,n){
  if(x>=a[i]){
    ans++;
    x-=a[i];
  }
  else x=0;
}
if(x!=0)ans--;
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ull unsigned long long


using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int s, w; cin >> s >> w;
    cout << (w >= s ? "unsafe" : "safe") << endl;
    
    return 0;
}

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

namespace ABC103C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

            int ans = 0;
            foreach (var a in A)
            {
                ans += a - 1;
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13376
#include<bits/stdc++.h>
using namespace std;
struct UnionFind{
    vector<int>par;

    UnionFind(int n):par(n){
        for(int i=0;i<n;i++)par[i] = i;
    }
    int find(int x){
        if(par[x] == x)return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x,int y){
        int rx = find(x);
        int ry = find(y);
        if(rx != ry)par[rx] = ry;
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
};
int main(){
    long n,m;
    cin >> n >> m;
    long x[m];
    long y[m];
    long z[m];
    for(int i=0;i<m;i++){
        cin >>  x[i] >> y[i] >> z[i];
        x[i]--;
        y[i]--;
    }

    UnionFind unif(n);

    for(int i=0;i<m;i++){
        unif.unite(x[i],y[i]);
    }
    set<int>s;
    for(int i=0;i<n;i++){
        s.insert(unif.find(i));
    }
    cout << s.size() << endl;
    


}

Measured memory_bytes: 7680
A, B, K = list(map(int, input().split()))
if A+K-1 < B-K+1:
    for i in range(A, A+K):
        print(i)
    for i in range(B-K+1, B+1):
        print(i)
else:
    for i in range(A, B+1):
        print(i)

Measured memory_bytes: 3060
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string w;
  cin >> w;
  map<char,int>m;
  int n= w.size();
  int flag = 0;
  rep(i,n){
    m[w.at(i)]++;
  }
  for(auto p:m){
    if(p.second %2 != 0)flag=1;
  }
  if(flag==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

int main()
{
	int n;
	cin>>n;
	int f=n/100,s=n%100;
	if(f>12||f==0)
	{
		if(s>12||s==0)
		{
			cout<<"NA";
			return 0;
		}
		cout<<"YYMM";
		return 0;
	}
	if(s<=12&&s>0)
	{
		cout<<"AMBIGUOUS";
		return 0;
	}
	cout<<"MMYY";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
#define P pair<int,int>
typedef long long ll;
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> a(n+1);
    vector<int> now(n+1);
    vector<int> ans;
    rep(i,n) cin >> a[i+1];
    for(int i=n; i>=1; i--){
        int tmp=0;
        for(int j=i+i; j<=n; j=j+i) tmp+=now[j];
        //cout << i << ' ' << tmp << endl;
        if(a[i]%2!=tmp%2){
            ans.push_back(i);
            now[i]=1;
        }
        else now[i]=0;
    }
    cout << ans.size() << endl;
    rep(i,ans.size()) printf("%d ",ans[i]);
return 0;
}


Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int p = sc.nextInt();
		long[] arrEV = new long[n + 1];
		long[] arrOD = new long[n + 1];
		arrEV[0] = 1;
		arrOD[0] = 0;
		for (int i = 1; i <= n; i++) {
			int a = sc.nextInt();
			arrEV[i] = arrEV[i - 1];
			arrOD[i] = arrOD[i - 1];
			if (a % 2 == 0) {
				arrEV[i] += arrEV[i - 1];
				arrOD[i] += arrOD[i - 1];
			} else {
				arrEV[i] += arrOD[i - 1];
				arrOD[i] += arrEV[i - 1];
			}
		}
		if (p == 0) {
			System.out.println(arrEV[n]);
		} else {
			System.out.println(arrOD[n]);
		}
	}
			
}


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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    int rootNum;

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
        rootNum = N;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    int getRootNum() {
        return rootNum;
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        rootNum--;
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    UnionFind un(N);
    rep(i, M) {
        int x, y, z;
        cin >> x >> y >> z;
        un.unite(x-1, y-1);
    }

    cout << un.getRootNum() << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int r, g, b;
    cin >> r >> g >> b;
    if ((r * 100 + g * 10 + b) % 4 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 3608
/*;

THE BEST IS YET TO COME

*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define r(i, s, l) for (int i = s; i < l; i++)
#define rr(i,s,l) for(int i=s;i>=l;i--)
#define mod 1000000007
#define INT_BITS 32
#define ld long double
#define pp pair<int,int>
#define ss second
#define ff first
#define INF 1e18
#define N 2000005
#define all(a) a.begin(), a.end()
#define pb push_back
#define vi vector<int>
#define vip vector<pair<int,int> >
#define endl "\n"
#define ln length()
#define sz size()
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
signed main()
{

    int n,k;
    cin>>n>>k;
    int sum =0;
    vector<int> a(n);

    r(i,0,n)
    cin>>a[i];

    sort(all(a));

    r(i,0,k)
    sum += a[i];

    cout<<sum;

	return 0;
}




Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#define INF 1000000009
#define LINF 1000000000000000009
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmax(T &a, const T&b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T&b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (int i = 0; i < b; i++) ans *= a;
	return ans;
}

int main() {
	ll n;
	cin >> n;
	ll ans = 0;
	ll m = n;
	ll dig = 1;
	while (m >= 10) {
		m /= 10;
		dig++;
	}
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			ll x = 0, y = 0;
			for (int k = 1; k < 8; k++) {
				if (k == 1) {
					if (i == j && i <= n) {
						x++; y++;
					}
				}
				else if (k < dig) {
					x += mpow(10, k - 2);
					y += mpow(10, k - 2);
				}
				else if (k == dig) {
					if (i < m) {
						x += mpow(10, k - 2);
					}
					if (i == m) {
						ll ni = n - m * mpow(10, k - 1) - j;
						x += (ni + 10) / 10;
					}
					if (j < m) {
						y += mpow(10, k - 2);
					}
					if (j == m) {
						ll nj = n - m * mpow(10, k - 1) - i;
						y += (nj + 10) / 10;
					}
				}
				//if (i == 1 && j == 9) cout << x << ' ' << y << endl;
			}
			ans += x * y;
			//cout << i << ' ' << j << ' ' << x << ' ' << y << endl;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	vector<int> a;
	for (int i = 0; i < 3; i++)
	{
		int v;
		cin >> v;

		a.push_back(v);
	}

	sort(a.begin(), a.end());

	int result = a[2] * 10 + a[1] + a[0];
	cout << result;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
#include <complex>
using namespace std;
int main()
{
    string s;
    int i;
    cin>>s;
    for(i=0;i<s.size();i++) if((i%2)==0) cout<<s[i];
    system ("pause"); 
    return 0;
}


Measured memory_bytes: 756