akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] original_enemy = Console.ReadLine().Split();
            int enemy = int.Parse(original_enemy[0]);
            int special_attack = int.Parse(original_enemy[1]);
 
            string[] original_hp = Console.ReadLine().Split();
            long[] hp = original_hp.Select(long.Parse).ToArray();
            Array.Sort(hp);
            Array.Reverse(hp);
            if(special_attack > hp.Length)
            {
                special_attack = hp.Length;
            }
            for (int i = 0; i < special_attack; i++)
            {
                hp[i] = 0;
            }
            Console.WriteLine(hp.Sum());
            Console.Read();
        }
    }
}

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

int main() {
    string s;
    cin >> s;
    bool flag = false;
    int cnt = 0;
  	int cnt1 = 0;

    for(int i = 2; i < s.size()-1; i++) {
        if(s[i]=='C') cnt++;
      	if((s[i] == toupper(s[i]) && s[i] != 'C') || s[1] == toupper(s[1]) || s[s.size()-1] == toupper(s[s.size()-1])) cnt1++;
    }
    if(cnt == 1 && cnt1 == 0) flag = true;

    flag==true && s[0] == 'A'? 
    cout << "AC" << endl:
  	cout << "WA" << endl;
}

Measured memory_bytes: 256
# 入力
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n,m,d = li()

if d==0:
    print((m-1)/n)
else:
    print(2*(n-d)*(m-1)/(n**2))

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

#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define ll   long long 
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define S second
#define F first
#define die() return 0;
 
#define md          1000000007
#define fmd         998244353 
#define M           100011
#define N            18
ll exp(ll a,ll b){if(b<0)return 0;ll r=1;while(b){if(b&1)r=r*a%md,r%=md;a=a*a%md;b/=2;}return r;}

int solve(){
    ll n,i,j,k,m,x,y,z;
    string s1,s2;
    cin>>s1>>s2;
    n=s1.size();m=s2.size();
    vector<int> a(n+1),b(m+1);
    for(i=1;i<=n;++i){
    	if(s1[i-1]=='A')a[i]=a[i-1]+1;
    	else a[i]=a[i-1]+2;
    }
    for(i=1;i<=m;++i){
    	if(s2[i-1]=='A')b[i]=b[i-1]+1;
    	else b[i]=b[i-1]+2;
    }
    int q;
    cin>>q;
    while(q--){
    	int ai,bi,ci,di;
    	cin>>ai>>bi>>ci>>di;
    	x=a[bi]-a[ai-1];
    	y=b[di]-b[ci-1];
    	if(x%3!=y%3)cout<<"NO\n";
    	else cout<<"YES\n";
    }
    





    

    die();
}
 
 
int main(){
 
 
#ifndef ONLINE_JUDGE
    double _tBeg=clock();
#endif

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

    int t;
    t=1;;
    // prec();
    // cin>>t;
 
    while(t--){

        solve();
    }
 
 
 
 


#ifndef ONLINE_JUDGE
    double _tEnd=clock();
    // printf("\ntotal time %.6f\n",(_tEnd-_tBeg)/CLOCKS_PER_SEC);
#endif
 
    die();
}

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

int main(){
	int n,q;
	cin >> n >> q;
	vector<queue<int> > ans(n);
	for(int i=0;i<q;i++)
	{
		int a,t,x;
		cin >> a;
		if(a==0)
		{
			cin >> t >> x;
			ans[t].push(x);
		}else if(a==1)
		{
			cin >> t;
			if(!ans[t].empty())
				cout << ans[t].front() << endl;
		}else
		{
			cin >> t;
			if(!ans[t].empty())
				ans[t].pop();
		}
	}
}


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


def ceil(a, b):
    return (a+b-1)//b


def main():
    k, q = map(int, input().split())
    d = list(map(int, input().split()))
    for i in range(q):
        n, x, m = map(int, input().split())
        last = x
        eq = 0
        for j in range(k):
            num = ceil((n-1-j), k)
            last += (d[j] % m)*num
            if d[j] % m == 0:
                eq += num
        ans = (n-1) - (last//m - x//m) - eq
        print(ans)


main()


Measured memory_bytes: 45432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;

int main()
{
    int a, b;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}


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



int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,k;
    cin>>a>>b>>k;
    rep(i,k){
        if(i%2==0){
        if(a%1==1)a--;
        a/=2;
        b+=a;}
        else {
        if(b%1==1)b--;
        b/=2;
        a+=b;
        }
    }
    cout<<a<<' '<<b<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		if (A==0) {
			System.out.println(f(B));
		}else {
			System.out.println(f(B)^f(A-1));
		}
	}
	static long f(long x) {
		if (x%2==1) {
			if (x/2%2==1) {
				return (long)0;
			}else {
				return (long)1;
			}
		}else {
			if (x/2%2==0) {
				return (long)x;
			}else {
				return (long)x+1;
			}
		}
	}
}

Measured memory_bytes: 23892
#include "bits/stdc++.h"
using namespace std;
typedef int64_t ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
const int MAX = 300010;
const int MOD = 998244353;

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

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

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  ll n,a,b,k,n_copy,ans=0;
  cin>>n>>a>>b>>k;
  COMinit();
  FOR(i,1,n+1){
    if((k-a*i)%b==0){
      int j=(k-a*i)/b;
      if(0<=j&&j<=n){ans=(ans+COM(n,i)*COM(n,j))%MOD;}
    }
  }
  
  if(ans!=0){cout<<ans<<endl;}
  else{cout<<1<<endl;}
  
}  



Measured memory_bytes: 7296
#include <iostream>
using namespace std;
long long n[100000];
int main(){
    long long a=0;
    long long sum=0;
    long long min=1000001;
    long long max=-1000001;
    cin >> a;
    for(long long i = 1;i<=a;i++){
        cin >> n[i];
        
    }
    for(long long j = 1;j<=a;j++){
        sum += n[j];
        if(max<n[j]){
            max = n[j];
        }
        if(min>n[j]){
            min = n[j];
        }
    }
    cout << min <<" "<< max <<" "<< sum << endl;
}


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

using namespace std;

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

    while(true)
    {
        c = c - b;
        if (c <= 0)
        {
            cout << "Yes" << endl;
            break;
        }

        a = a - d;
        if (a <= 0)
        {
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll v = N - K + 1;
    if(K == 1){
        print(0);
    }else{
        print(v - 1);
    }

    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k;
int a;
bool f1=0,f2=0;
int g;
int gcd(int a,int b) {
	return a%b==0?b:gcd(b,a%b);
}
int main() {
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a);
		if(a>k&&!f2)
			f2=1;
		if(i==1) {
			g=a;
		}
		else {
			g=gcd(g,a);
		}
		if(a==k)
			f1=1;
	}
	if(f1) {
		puts("POSSIBLE");
		return 0;
	}
	if(!f2) {
		puts("IMPOSSIBLE");
		return 0;
	}
	if(g==1) {
		puts("POSSIBLE");
		return 0;
	}
	else {
		if(k%g==0) {
			puts("POSSIBLE");
			return 0;
		}
		else {
			puts("IMPOSSIBLE");
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall
import sys
sys.setrecursionlimit(10**8)

n=int(input())
arr=[input() for _ in range(n)]
g=[[] for _ in range(n)]
for i in range(n):
  for j in range(n):
    if i==j:
      continue
    if arr[i][j]=='1':
      g[i].append(j)
g2=[[0]*n for _ in range(n)]
for i in range(n):
  for j in range(n):
    g2[i][j]=int(arr[i][j])

colors=[0]*n

def dfs(v,color):
  colors[v]=color
  for u in g[v]:
    if colors[u]==color:
      return False
    if colors[u]==0 and not dfs(u,-color):
      return False
  return True

def is_bipartite():
  return dfs(0,1)

if is_bipartite()==False:
  print(-1)
  exit()

ans=0
d=floyd_warshall(g2)
for i in range(n):
  ans=max(ans,int(max(d[i])+1))
print(ans)

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

using pii = pair<int, int>;

constexpr int INF = 1e9;

int main() {
    int n;
    while(cin >> n, n) {
        n = 1000 - n;
        int res = n / 500;
        n %= 500;
        res += n / 100;
        n %= 100;
        res += n / 50;
        n %= 50;
        res += n / 10;
        n %= 10;
        res += n / 5;
        n %= 5;
        res += n;
        cout << res << endl;
    }
}


Measured memory_bytes: 3056
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int n,m,p,d[1145140],ans=1e9;
int main(){
    cin>>n>>m>>p;
    for(int i=0;i<m;i++){
        cin>>d[i];
        d[i]=(n+d[i]-p)%n;
    }
    sort(d,d+m);
    for(int i=0;i<m;i++){
        if(i==0){
            ans=min(ans,n-d[i]);
        }
        else{
            ans=min(ans,2*(n-d[i])+d[i-1]);
        }
        if(i==m-1){
            ans=min(ans,d[i]);
        }
        else{
            ans=min(ans,2*d[i]+n-d[i+1]);
        }
    }
    cout<<ans*100<<endl;
}

Measured memory_bytes: 1220
/*  Bismillahir Rahmanir Rahim  */

#include <bits/stdc++.h>

using namespace std;

typedef pair <long long, long long> pii;

const long long N = 100007;
const long long oo = 1e18;

struct data{
	long long st, en, extra;
	data () {}
	data (long long a, long long b, long long c){
		st = a;
		en = b;
		extra = c;
	}	
};

long long n, m, a[N];
vector <pii> add[N];


int main(){
	scanf("%lld %lld", &n, &m);
	for(long long i = 1; i <= n; ++i) scanf("%lld", &a[i]);
	long long sum = 0;
	for(long long i = 2; i <= n; ++i){
		if(a[i-1] <= a[i]){
			add[a[i-1] + 1].push_back({a[i-1], 0});
			add[a[i] + 1].push_back({-a[i-1], 0});
			sum += a[i] - a[i-1];
		}
		else{
			long long ex = m - a[i-1] + 1;
			add[1].push_back({1, ex});
			add[a[i] + 1].push_back({-1, -ex});
			add[a[i-1] + 1].push_back({a[i-1], 0});
			sum += ex;
			sum += a[i] - 1;
		}
	}
	long long ret = oo;
	long long cnt = 0;
	long long sub = 0;
	long long extra = 0;
	for(long long i = 1; i <= m; ++i){

		for(auto u : add[i]){
			if(u.first < 0) --cnt;
			else ++cnt;
			sub += u.first;
			extra += u.second;
		}

		long long ans = cnt * i - sub + extra;

		ret = min(ret, sum - ans + cnt);
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 9200
#include <iostream>

using namespace std;

int main() {
	
	int a, b;
	char op;
	
	while (true) {
		cin >> a >> op >> b;
		if (op == '?') break;
		
		switch (op)
		{
		case '+': cout << a + b << endl; break;
		case '-': cout << a - b << endl; break;
		case '*': cout << a * b << endl; break;
		case '/': cout << a / b << endl; break;
		default:
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3068
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto a=new int[][](n, 10);
  foreach(i; 0..n) a[i]=readln.split.to!(int[]);
  auto c=new int[][](n, 11);
  foreach(i; 0..n) c[i]=readln.split.to!(int[]);

  long sum=-10000000000;
  for(int bit=1; bit<(1<<10); bit++){
    auto cnt=new int[](n);
    foreach(j; 0..10)if(bit&(1<<j)){
      foreach(i; 0..n)if(a[i][j]) cnt[i]++;
    }
    long s=0;
    foreach(i; 0..n) s+=c[i][cnt[i]];
    sum=max(sum, s);
  }
  
  writeln(sum);
}


void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=2e5+20;
const int inf=0x3f3f3f3f;

inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=min((ll)ans*a,(ll)inf);
		b>>=1;
		a=min((ll)a*a,(ll)inf);
	}
	return ans;
}

int n,a[maxn];

inline void init()
{
	n=read();
	REP(i,1,n)a[i]=read();
}

#define pii pair<int,int>

inline bool check(int x)
{
	if(x==1)
	{
		REP(i,1,n-1)if(a[i]>a[i+1])return 0;
		return 1;
	}
	vector<pii>v;
	v.push_back(mkr(0,0));
	REP(i,1,n)
	{
			
		if(a[i]>v.back().fi)
		{
			v.push_back(mkr(a[i],0));
		}else
		{
			while(v.back().fi>a[i])v.pop_back();
			int ad=a[i];
			while(1)
			{
				if(ad!=v.back().fi)v.push_back(mkr(ad,0));
				if(v.back().fi==0)return 0;
				int len=SZ(v)-1;
				v[len].se++;
				if(v[len].se==x)
				{
					v[len].se=0; ad--;
					v.pop_back();
				}else
				{
					REP(j,ad+1,a[i])v.push_back(mkr(j,0));
					break;
				}
			}
		}
	}
	return 1;
}

inline void doing()
{
	int l=1,r=n;
	while(l<r)
	{
		int mid=l+r>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	printf("%d\n",l);
}

int main()
{
	init();
	doing();
	return 0;
}


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

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

    // vector<long long> a_li(N);
    int num_4 = 0;
    int num_2 = 0;
    int num_0 = 0;

    long long tmp_a;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp_a;
        if (tmp_a % 4 == 0)
            num_4++;
        else if (tmp_a % 2 == 0)
            num_2++;
        else
            num_0++;
    }

    if (num_0 <= num_4 || (num_0 == num_4 + 1 && num_2 == 0))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

using namespace std;

int main(void){
    int N;
    cin>>N;
    vector<int> d(N);
    for(int i=0;i<N;i++){
        cin>>d[i];
    }
    int sum=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            sum+=d[i]*d[j];
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
count = 0

for i in range(N):
  if B[i] - A[i] >= 0:
    count += A[i]
    B[i] -= A[i]
    if B[i] - A[i + 1] >= 0:
      count += A[i + 1]
      A[i + 1] = 0
    else:
      count += B[i]
      A[i + 1] -= B[i]
  else:
    count += B[i]
print(count)

Measured memory_bytes: 82148
#include <iostream>

using namespace std;

long long int N, sum = 0, a;

int main() {
	cin >> N;
	a = N;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	if (N%sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  if(N*A<B){
    cout << N*A << endl;
  }
  else if(N*A==B){
    cout << B << endl;
  }
  else if(N*A>B){
    cout << B << endl;
  }
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define EL '\n'
#define el '\n'
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define repd(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define large 1000000007
#define pb() push_back()
#define MAX 10e+7
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void helper(string s,string t)
{
int n=s.length();
int m=t.length();
int mat[n+1][m+1];
rep(i,0,n+1)
{
	rep(j,0,m+1)
	{
		if(i==0||j==0)
		mat[i][j]=0;
      else if(s[i-1]==t[j-1])
	  {
		  mat[i][j]=1+mat[i-1][j-1];
	  }
	  else
	  {
		  mat[i][j]=max(mat[i-1][j],mat[i][j-1]);
	  }
	}
}

	int index = mat[n][m]; 
  //cout<<index<<el;
   // Create a character array to store the lcs string 
   //char lcs[index+1]; 
   //lcs[index] = '\0'; // Set the terminating character 
  vector<char> vc;
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = n, j = m; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (s[i-1] == t[j-1]) 
      { 
		  vc.push_back(s[i-1]);
          //lcs[index-1] = s[i-1]; // Put current character in result 
          i--; j--;      // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (mat[i-1][j] > mat[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  reverse(vc.begin(),vc.end());
  rep(i,0,index)
  {
	  cout<<vc[i];
  }
  
   // Print the lcs 
//cout<<mat[n][m];
}
void solve()
{
string s;
string t;
cin>>s>>t;
//cout<<s<<el<<t;
helper(s,t);
//int ans=helper(s,t);
//cout<<ans<<el;

}
int main()
{
	
FASTIO
 long long int t;
solve();
  return 0;
}


Measured memory_bytes: 35456
let N =
    stdin.ReadLine()
    |> int
let A =
    stdin.ReadLine().Split()
    |> Array.map int

A
|> Array.fold (fun (sum,highest) item ->
    if item < highest then (sum+int64(highest-item),highest)
    else (sum, item)) (0L,0)
|> fun (sum,_) -> sum
|> stdout.WriteLine

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

public class Main {

	public static void main(String[] args) {
		Main answer = new Main();
		System.out.printf("%.10f\n",answer.solve());
	}

	private double solve() {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double [] array = new double[N+1];
		for(int i=1;i<=N;i++){
			array[i] = sc.nextDouble();			
		}
		//System.out.println(Arrays.toString(array));
		double [][] dp = new double[3001][3001];
		for(int i=0;i<dp.length;i++){
			Arrays.fill(dp[i], -1.0);
		}
		return solve(array, N, (N+1)/2, dp);
	}

	private double solve(double [] array, int i, int x, double[][] dp) {

		// prob of getting atleat 0 heads will be 1 if all are tails or 
		// even if some coins have >1 heads, then also prob of getting 
		// atleast 0 heads is 1
		if (x==0) return 1;

		// if there are 0 coins then zero prob of getting at least x heads
		// unless x is also 0 in which case prob is 1. (see reason above)
		// But this is taken care above
		if (i==0) return 0;

		// choosing 0.9 instead of -1 to account for double precision.
		if (dp[i][x]> -0.9) return dp[i][x];

		dp[i][x] = array[i]*solve(array, i-1, x-1, dp) + (1-array[i])*solve(array, i-1, x, dp);

		return dp[i][x];
  
	}
}


Measured memory_bytes: 118688
#include <iostream>
using namespace std;
int main()
{
	int n,m,c,s=0,total=0;
	cin>>n>>m>>c;
	int a[m+1],b[n+1][m+1];
	for(int i=1;i<=m;i++)cin>>a[i];
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	{
		cin>>b[i][j];
	}
	for(int i=1;i<=n;i++)
	{
		total=0;
		for(int j=1;j<=m;j++)
		{
			total+=b[i][j]*a[j];
		}
		if(total+c>0)
		{
			s++;
		}
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int n;
int a[100100];
int main(){
	cin >> n;
	bool flag = false;
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i]%2==1)flag = true;
	}
	if(flag)cout << "first" << endl;
	else cout << "second" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=3e5+5,mod=1e9+7;
bool cmp(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first!=b.first)return a.first<b.first;
    return a.second<b.second;
}
ll ans[N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;cin>>n;
    vector< pair<ll,ll> > a(n+1);
    for(ll i=1;i<=n;i++)cin>>a[i].first,a[i].second=i;
    sort(a.begin()+1,a.end(),cmp);
    ll cur=n;
    for(ll i=n;i>=1;i--){
        cur = min(cur,a[i].second);
        ans[cur]+=(a[i].first - a[i-1].first)*(n-(i-1));
    }
    for(ll i=1;i<=n;i++)cout<<ans[i]<<"\n";
}

Measured memory_bytes: 3456
s = gets.chomp

memo = Array.new(s.length + 1) { Array.new(4) { 0 } }

ABC = ['A', 'B', 'C']
MOD =  1_000_000_000 + 7

memo[s.length][0] = 0
memo[s.length][1] = 0
memo[s.length][2] = 0
memo[s.length][3] = 1

(s.length - 1).downto(0).each do |i|
  c = s[i]

  3.downto(0).each do |j|
    non_check = (c == '?' ? 3 : 1) * memo[i + 1][j]
    if j == 3
      memo[i][j] = non_check % MOD
    else
      do_check = ((c == '?' || c == ABC[j]) ? 1 : 0) * memo[i + 1][j + 1]
      memo[i][j] = (non_check + do_check) % MOD
    end
  end
end
puts memo[0][0]


Measured memory_bytes: 14844
h, w = map(int, input().split())
l = []
for i in range(h):
    l.append(list(str(input())))

for y in range(h):
    for x in range(w):
        if l[y][x] == ".":
            c = 0
            for ya in range(-1, 2):
                for xa in range(-1, 2):
                    if 0 <= y + ya < h and 0 <= x + xa < w:
                        p = y + ya
                        q = x + xa
                        if l[p][q] == "#":
                            c += 1
            l[y][x] = str(c)

for i in l:
    print("".join(i))


Measured memory_bytes: 3188
#include <stdio.h>

const int num[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

int sum_combination(int n, const int search, int start, int sum_previous) {
	int sum_true = 0;
	
	if(n == 1) {
		while(sum_previous + num[start] < search && start < 10)
			start++;
		if(sum_previous + num[start] == search)
			return 1;
		else
			return 0;
	}

	else {
		while(start < 11 - n) {
			if(sum_previous + num[start] >= search)
				break;
			sum_true += sum_combination(n - 1, search, start + 1, sum_previous + num[start]);
			start++;
		}
	}

	return sum_true;
}

int main() {
	int s, n;
	int num[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

	do {
		scanf("%d %d", &n, &s);
		if(!s && !n)
			break;

		printf("%d\n", sum_combination(n, s, 0,  0));
	} while(1);

	return 0;
}

Measured memory_bytes: 600
import java .util.*;

public class Main {
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int M = sc.nextInt();
	int useDays = 0;
	for (int i=0; i<M; i++) {
	    useDays += sc.nextInt();
	}
	if (useDays > N) System.out.print(-1);
	else { System.out.print(N-useDays); }
    }
}


Measured memory_bytes: 46276
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const int EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vvb B(N, vb(N, false));
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		B[a][b] = true;
		B[b][a] = true;
	}
	vi V(N);
	int ans = 0;
	REP(i, N)V[i] = i;
	do {
		if (V[0] != 0)break;
		bool b = true;
		REP(i, N - 1) {
			if (not B[V[i]][V[i + 1]])b = false;
		}
		if (b)ans++;
	} while (next_permutation(ALL(V)));
	cout << ans << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
#include <stdio.h>

int main() {
    char s[4];
    scanf("%s", s);
    // printf("%s\n", s);

    int ans=0, i;

    for(i=0; i<3; i++) {
        if(s[i]=='o') ans += 1;
    }

    printf("%d\n", ans*100+700);

    return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int N;
cin >> N;
ll ans = 0;
REP(i,N+1) {
  ans += i;
}
cout << ans << endl;
return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();

    int wlr = 0;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'W') {
            ans += i - wlr;
            wlr++;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	int sum = 0;
	for (auto&& vi : v)
	{
		cin >> vi;
		sum += vi;
	}
	if (sum % 10 == 0)
	{
		sort(v.begin(), v.end());
		for (auto&& vi : v)
			if (vi % 10 != 0)
			{
				sum -= vi;
				break;
			}
	}
	cout << (sum%10 == 0 ? 0 : sum) << endl;
	return 0;
}


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

using namespace std;

void a()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
}

int main()
{
    a();

    int h, w, inf = 1000000007;
    vector<vector<char>> grid(1000, vector<char>(1000));
    vector<vector<long long>> dp(1000, vector<long long>(1000));
    cin >> h >> w;

    for(int i = 0; i < h; i++){
       for(int j = 0; j < w; j++){
            cin >> grid[i][j];
       }
    }

    dp[0][0] = 1;
    for(int i = 0; i < h; i++){
       for(int j = 0; j < w; j++){
            if(i < h - 1 && grid[i+1][j] != '#'){
                dp[i + 1][j] += dp[i][j];
                if(dp[i + 1][j] >= inf){
                    dp[i + 1][j] -= inf;
                }
            }

            if(j < w - 1 && grid[i][j+1] != '#'){
                dp[i][j+1] += dp[i][j];
                if(dp[i][j+1] >= inf){
                    dp[i][j+1] -= inf;
                }
            }
       }
    }

    cout << dp[h-1][w-1];
}

Measured memory_bytes: 12100
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            final int d = in.nextInt();
            final int n = in.nextInt();
            int ans = n < 100 ? n : 101;
            if (d == 1) ans *= 100;
            else if (d == 2) ans *= 10000;
            out.println(ans);
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 23380
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll a=0,b=0,c=0,k=1,s=0,n,w,m,min=100000000000,ans=1,max=0;
    string s1,s2;
    cin >> a >> b >> c;
    for(int i=1;i<=b;i++){
        if (a*i%b==c){
            cout << "YES"<< endl;
            return 0;
       }
    }
    
    cout <<"NO"<< endl;
    return 0;
}

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

const int N = 2e5 + 10;

int n, T, ans, cur, x;

int main(){
    while(~scanf("%d %d", &n, &T)){
        ans = 0;
        cur = -1;
        for(int i=0; i<n; i++){
			scanf("%d", &x);
			if(x > cur){
				ans = ans + T;
			} else {
				ans = ans + (x + T - 1 - cur);
			}
			cur = x + T - 1;
        }
        printf("%d\n", ans);
    }
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;

char c;

int main(){
	cin>>c;
	if('A'<=c&&c<='Z') cout<<'A'<<endl;
	else cout<<'a'<<endl;
	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, C;
    cin >> N >> C;
    vector<vector<int>> D(C, vector<int>(C));
    vector<vector<int>> A(N, vector<int>(N));
    rep(i, C) rep(j, C) cin >> D[i][j];
    rep(i, N) rep(j, N) cin >> A[i][j];
    
    vector<vector<int>> B(3, vector<int>(C, 0));
    rep(i, 3) rep(c, C){
        rep(y, N) rep(x, N) {
            if((y + x) % 3 == i) {
                B[i][c] += D[A[y][x] - 1][c];
            }
        }
    }
    int ans = inf;
    rep(i, C) rep(j, C) rep(k, C) {
        if(i != j && j != k && k != i) {
            ans = min(ans, B[0][i] + B[1][j] + B[2][k]);
        }
    }
    output(ans);
    
    
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
const int N=110;
int n;
bool f[N];
int a[N],b[N];
int main() {
    cin>>n;
    for(int i=0;i<n;i++) {
        cin>>a[i]>>b[i];
        if(a[i]==b[i]) f[i]=1;
        else f[i]=0;
    }
    for(int i=0;i<n-2;i++) {
        if(f[i] && f[i+1] && f[i+2]) {
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		int n;
		TreeSet<String> ts = new TreeSet<>();
		Scanner scan = new Scanner(System.in);

		n = scan.nextInt();

		String[] array = new String[n];
		for(int i = 0; i < array.length; i++) {
			array[i] = scan.next();
		}

		for(int i = 0; i < array.length; i++) {
			ts.add(array[i]);
		}

		System.out.println(ts.size());
	}
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

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

  vi A(N), B(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }

  vpii v(N);
  for (ll i = 0; i < N; i++) {
    v[i] = make_pair(A[i] + B[i], i);
  }

  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());

  ll x = 0, y = 0;
  for (ll i = 0; i < N; i++) {
    if (i % 2 == 0) {
      x += A[v[i].second];
    } else {
      y += B[v[i].second];
    }
  }

  cout << x - y << endl;
}

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

using namespace std;

int n, a[100000];
int two, four, none;

int main(){
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		if(a[i] % 4 == 0) four++;
		else if(a[i] % 2 == 0) two++;
		else none++;
	}
	if(four+1 >= none && two == 0) cout << "Yes" << endl;
	else if(four >= none) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

int main(){
  	int n;cin>>n;
  	int cnt=0;
  	int temp;
  	for(int i=1;i<=n;i++){
      	cin>>temp;
      	if(temp!=i)cnt++;
    }
  	if(cnt==0||cnt==2)cout<<"YES\n";
  	else cout<<"NO\n";
  	return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  if (a == b) {
    cout << a+b << endl;
  }
  else
  {
    int max_num = max({a,b});
    cout <<  max_num * 2 - 1 << endl;
  }
}


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


int main() {
  string S;
  cin >> S;
  int N, W, E;
  N = S.size();
  W = 0;
  for(int i = 0; i < N; i++){
    E = S.at(i) - '0';
    W += E;
  }
  if(W % 9 == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;

#define mod 1000000007
// #define mod1 9982
#define int  long long int
#define pii pair<int,int>
#define vpii vector<pii>
#define vi vector<int>
#define fi first
#define se second
#define psb push_back
#define ppb pop_back
#define fio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define all(x) x.begin(),x.end()
#define endl "\n"

const int maxn=2e5+5;

void solve()
{
    int x;
    cin>>x;
    cout<<(x<30 ? "No":"Yes")<<endl;
}

int32_t main()
{
    fio;
    int t;
    // cin>>t;
    t=1;
    while(t--)
        solve(); 
}

/*
./a.out <input.txt > output.txt
*/


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

int main(){
        int a,b,c;
        while(1){
                scanf("%d %d %d",&a,&b,&c);
                if(a==-1 && b==-1 && c==-1) break;
                if(a==-1 || b==-1){
                        printf("F\n");
                }else if(a+b>=80){
                        printf("A\n");
                }else if(a+b>=65){
                        printf("B\n");
                }else if(a+b>=50 || (a+b>=30 && c>=50)){
                        printf("C\n");
                }else if(a+b>=30){
                        printf("D\n");
                }else{
                        printf("F\n");
                }
        }
        return 0;
}

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

using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  int num = stoi(a + b);
  for (int i = 0;; i++) {
    int work = i * i;
    if (num < work)
      break;
    else if (num == work) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long;
using ll = long long;
#define rep(i,n) for(lint (i) = 0;(i) < (lint)(n);(i)++)
#define repInRange(i,start,end) for(lint (i) = (start);(i) < (end);++(i))
#define pb push_back
using Vecint = vector<lint>;
using Llint = list<lint>;

ll pow(ll a,ll b) {
	ll ret = 1;
	rep(i,b) {
		ret *= a;
	}
	return ret;
}

void Main() {
	ll H;
	cin >> H;
	cout << (ll)(pow(2,(ll)(log2(H)+1)) - 1) << '\n';
}

signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	Main();
	return 0;
}

Measured memory_bytes: 512
using System;
class waterbottle{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    int a = int.Parse(str[0]);
    int b = int.Parse(str[1]);
    int x = int.Parse(str[2]);
    double s = Math.Atan((double)(2*a*a*b-2*x)/(a*a*a));
    if(b < a*Math.Tan(s)){
      s = Math.Atan((double)(b*b*a)/(2*x));
    }
    Console.WriteLine((180*s)/Math.PI);
  }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int N;
  cin>>N;
  vector<int> A(N+1);
  rep(i,N) cin>>A[i+1];
  int B[N+1]={};
  rep(i,N){
    if(N/(N-i)>1){
      ll tmp=0;
      rep(j,N/(N-i)-1) tmp^=B[(N-i)*(N/(N-i)-j)];
      if(tmp!=A[N-i]) B[N-i]=1;
    }else B[N-i]=A[N-i];
  }
  int ans=0;
  rep(i,N) ans+=B[i+1];
  cout<<ans<<endl;
  rep(i,N) if(B[i+1]) cout<<i+1<<endl;
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 200010
#define lim9 1000000010

#define deg(rad) (((rad)/2/M_PI)*360)
#define mid(min, max) ((min + max) / 2)

int main() {
    in(n);
    int a[lim5] = {};
    int cnt[lim5] = {};
    repp(i, n-1) {
        cin >> a[i];
        ++cnt[a[i]];
    }
    repp(i, n) {
        out(cnt[i]);
    }
    return 0;
}


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

int main() {
    vector<vector<int>> grid (3,vector<int>(3));
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> grid.at(i).at(j);
        }
    }
    string ans = "Yes";
    int judge = grid.at(0).at(0) - grid.at(0).at(1);
    for(int i=0; i<3; i++){
        if(grid.at(i).at(0) - grid.at(i).at(1) != judge) ans = "No";
    }
    judge = grid.at(0).at(1) - grid.at(0).at(2);
    for(int i=0; i<3; i++){
        if(grid.at(i).at(1) - grid.at(i).at(2) != judge) ans = "No";
    }
    judge = grid.at(0).at(0) - grid.at(1).at(0);
    for(int i=0; i<3; i++){
        if(grid.at(0).at(i) - grid.at(1).at(i) != judge) ans = "No";
    }
    judge = grid.at(1).at(0) - grid.at(2).at(0);
    for(int i=0; i<3; i++){
        if(grid.at(1).at(i) - grid.at(2).at(i) != judge) ans = "No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {

  int n,a[100];
  cin>>n;

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

  for (int i=n-1; i>=0; i--) {
    cout<<a[i];
    if (i!=0) {
      cout<<" ";
    }
  }
  cout<<"\n";

  return 0;
}

Measured memory_bytes: 1164
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, K = read_ints()
S = list(read()[:-1])

S[K - 1] = S[K - 1].lower()

print(*S, sep='')


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< ll > vll;
typedef vector< vll > vvll;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long mod = 1000000007;

template<typename T>
void max_self(T& a, T b)
{
	a = max(a, b);
}
template<typename T>
void add_self(T& a, T b)
{
	a += b;
	if (a >= mod)
		a -= mod;
}
template<typename T>
void sub_self(T& a, T b)
{
	a -= b;
	if (a < 0)
		a += mod;
}

// dp[i][j] - number of ways to distribute i candies to j kids

int main()
{ 
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int h, w, k;
	cin >> h >> w >> k;
	vs f(h);
	for (auto& s : f)
		cin >> s;
	vvi res(h, vi(w, 0));
	int cr = 1;
	vector<bool> empty(h, false);
	for (int i = 0; i < h; i++)
	{
		vi cp;
		for (int j = 0; j < w; j++)
			if (f[i][j] == '#')
				cp.push_back(j);
		if (cp.empty())
		{
			empty[i] = true;
		}
		else if (sz(cp) == 1)
		{
			for (int j = 0; j < w; j++)
				res[i][j] = cr;
			cr++;
		}
		else
		{
			for (int j = 0; j < cp[1]; j++)
				res[i][j] = cr;
			cr++;
			for (int k = 1; k < sz(cp) - 1; k++)
			{
				for (int j = cp[k]; j < cp[k + 1]; j++)
				{
					res[i][j] = cr;

				}
				cr++;
			}
			for (int j = cp[sz(cp) - 1]; j < w; j++)
				res[i][j] = cr;
			cr++;
		}
		
	}
	for (int i = 0; i < h; i++)
	{
		if (!empty[i])
		{
			for (int j = i - 1; j >= 0; j--)
			{
				if (empty[j])
				{
					empty[j] = false;
					res[j] = res[i];
				}
				else
					break;
			}
			for (int j = i + 1; j < h; j++)
			{
				if (empty[j])
				{
					empty[j] = false;
					res[j] = res[i];
				}
				else
					break;
			}
		}
	}
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
			cout << res[i][j] << " ";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main(){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    a*=100,b*=100;
    int ans1=0,ans2=0;
    for(int A=0;a*A<=f;A++){
        for(int B=0;a*A+b*B<=f;B++){
            for(int C=0;a*A+b*B+c*C<=f;C++){
                for(int D=0;a*A+b*B+c*C+d*D<=f;D++){
                    int water=a*A+b*B,salt=c*C+d*D;
                    if(salt>water/100*e) break;
                    if(ans2*(water+salt)<=ans1*salt){
                        ans1=water+salt;
                        ans2=salt;
                    }
                }
            }
        }
    }
    cout<<ans1<<" "<<ans2<<endl;
    return 0;
}

Measured memory_bytes: 256