akhauriyash/Code-Regression huggingface dataset:
#include <cstdint>
#include <iostream>

using namespace std;
#define MAX_N 40
#define MAX_A 10
#define MAX_B 10
#define MAX_C 100
#define COST_MAX (MAX_N * MAX_C + 1)

struct cost {
  int32_t a;
  int32_t b;
  int32_t c;
};

static int32_t costs[MAX_N + 1][MAX_N * MAX_A + 1][MAX_N * MAX_B + 1];
static cost inputs[MAX_N];

void init_costs()
{
  for (int32_t j = 0; j <= MAX_N * MAX_A; j++) {
    for (int32_t k = 0; k <= MAX_N * MAX_B; k++) {
      costs[0][j][k] = COST_MAX;
    }
  }
  costs[0][0][0] = 0;
}

int32_t main()
{
  int32_t N, Ma, Mb;
  cin >> N >> Ma >> Mb;

  for (int32_t i = 0; i < N; i++) {
    cin >> inputs[i].a >> inputs[i].b >> inputs[i].c;
  }

  init_costs();
  for (int32_t i = 1; i <= N; i++) {
    for (int32_t a = 0; a <= N * MAX_A; a++) {
      for (int32_t b = 0; b <= N * MAX_B; b++) {
        costs[i][a][b] = costs[i - 1][a][b];
        if ((a - inputs[i - 1].a) >= 0 && (b - inputs[i - 1].b) >= 0) {
          costs[i][a][b] = min(costs[i - 1][a][b], costs[i - 1][a - inputs[i - 1].a][b - inputs[i - 1].b] + inputs[i - 1].c);
        }
      }
    }
  }

  int32_t cost = COST_MAX;
  for (int32_t a = 1; a <= N * MAX_A; a++) {
    for (int32_t b = 1; b <= N * MAX_B; b++) {
      if (a * Mb == b * Ma) {
        cost = min(cost, costs[N][a][b]);
      }
    }
  }

  if (cost == COST_MAX) {
    cout << "-1" << endl;
  } else {
    cout << cost << endl;
  }

  return 0;
}


Measured memory_bytes: 25984
#include<stdio.h>
#include<algorithm>
using namespace std;
int UF[110];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;
	UF[a]+=UF[b];UF[b]=a;
}
pair<int,pair<int,int> > edge[50000];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a+b){
		for(int i=0;i<a+b;i++)UF[i]=-1;
		int sz=0;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			int p;scanf("%d",&p);
			if(p==0)continue;
			edge[sz++]=make_pair(p,make_pair(i,j+a));
		}
		for(int i=0;i<b;i++)for(int j=i+1;j<b;j++){
			int p;scanf("%d",&p);
			if(p==0)continue;
			edge[sz++]=make_pair(p,make_pair(i+a,j+a));
		}
		std::sort(edge,edge+sz);
		int ret=0;
		for(int i=0;i<sz;i++){
			bool ok=true;
			int s=-1;
			int t=-1;
			for(int j=0;j<a;j++){
				if(FIND(edge[i].second.first)==FIND(j))s=j;
				if(FIND(j)==FIND(edge[i].second.second))t=j;
			}
			if(~s&&~t)continue;
			if(!ok)continue;
			if(FIND(edge[i].second.first)!=FIND(edge[i].second.second)){
				ret+=edge[i].first;
				UNION(edge[i].second.first,edge[i].second.second);
			}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1616
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h, w ;
  cin >> h >> w ;
  if(h==1 || w==1){
    cout << 1 <<endl ;
    return 0 ;
  }
  if(h%2==0 || w%2==0){
    cout << h*w/2 <<endl ;
  }
  else{
    cout << h*w/2+1 <<endl ;
  }
  
  
  
  return 0 ;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
// constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

constexpr ll MOD = 998244353;


int N;
int D[112345];
int cnt[112345];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", D + i);
	
	if (D[0] != 0) {
		puts("0");
		return 0;
	}
	
	sort(D, D + N);

	REP(i, N) cnt[D[i]]++;
	ll ans = D[0] == 0;
	FOR(i, 1, N) {
		if (D[i] == 0) {
			ans = 0;
			break;
		}
		ans = ans * cnt[D[i] - 1] % MOD;
		
	}
	
	cout << ans << endl;
	
	return 0;
}



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

int main(){
	int n;
	cin >> n;
	char x = ' ';
	vector<string> v;
	bool flag = false;
	for( int i = 0; i < n; ++i ){
		string temp;
		cin >> temp;
		if( find( v.begin(), v.end(), temp ) != v.end() ){
			cout << "No" << endl;
			return 0;
		} 
		v.push_back(temp);
		if( flag == true ){
			if( x == temp[0] ){
				x = temp[temp.l_ength()-1];
			} else {
				cout << "No" << endl;
				return 0;
			}
		} else {
			flag = true;
			x = temp[temp.l_ength()-1];
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){

    string s, t;
    cin >> t >> s;
    int s_len = s.length(),t_len=t.length();
    int i, j;
    for (i = t_len - s_len; i >= 0;i--){
        for (j = 0; j < s_len;j++){
            if(t[i+j]!='?'&&s[j]!=t[i+j]){
                break;
            }
        }

        if(j==s_len){
            FOR(k,0,i){
                if(t[k]=='?'){
                    cout << 'a';
                }else{
                    cout << t[k];
                }
            }
            cout << s;
            FOR(k,i+s_len,t_len){
                if(t[k]=='?'){
                    cout << 'a';
                }else{
                    cout << t[k];
                }
            }
            cout << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    
    ll n;
    cin>>n;
    ll i,j;
    string s[n];
    for(i=0;i<n;i++) cin>>s[i];
    vector<vector<ll>> c(n, vector<ll>(26,0));
    for(i=0;i<n;i++)
    {
        for(j=0;j<sz(s[i]);j++)
        {
            c[i][s[i][j]-'a']++;
        }
    }
    vector<ll> ans(26,0);
    for(i=0;i<26;i++)
    {
        ll mn = 1e18;
        for(j=0;j<n;j++)
        {
          mn = min(mn, c[j][i]);
        }
        ans[i] = mn;
    }
    for(i=0;i<26;i++)
    {
        for(j=0;j<ans[i];j++)
        {
            cout<<(char)('a'+i);
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

signed main(){
	int n;
	scanf("%lld", &n);
	rep(i,n){
		int x, y;
		scanf("%lld%lld", &x, &y);
		printf("%lld\n", x%y == 0 ? y : x%y);
	}
	return 0;
}








Measured memory_bytes: 3212
import sys
input=sys.stdin.readline
def main():
    n=int(input())
    #H=[list(map(int,input().split())) for _ in range(n)]
    dp=[[-10**9]*3 for _ in range(n)]
    
    for i in range(n):
        a,b,c=map(int,input().split())
        t=[a,b,c]
        if i==0:
            dp[0][0],dp[0][1],dp[0][2]=a,b,c 
        else:
            for j in range(3):
                dp[i][j]=max(dp[i-1][j-1]+t[j],dp[i-1][j-2]+t[j])
    #print(dp)

    print(max(dp[-1]))
main()

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

int main() {
    double a,b,x;
    cin>>a>>b>>x;
    double s=x/a;
    double rad;
    if(s>=a*b/2){
      double h=(a*b-s)*2/a;
      rad = atan(h/a);
    }else{
      double w =s*2/b;
      rad = atan(b/w);
    }
    double PI = acos(-1);
    double deg = rad/(2*PI)*360;
    printf("%.10f\n",deg);
}

Measured memory_bytes: 4096
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = False
show_flg = True

class UnionFind(object):
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots()),


def main():
    N, M = MI()
    a = [0] * M
    b = [0] * M
    ans = 0

    for i in range(M):
        _a, _b = MI()
        a[i], b[i] = _a - 1, _b - 1

    for i in range(M):
        uf = UnionFind(N)
        for j in range(M):
            if i == j:
                continue
            uf.union(a[j], b[j])
        if len(uf.roots()) != 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67180
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{

    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] a = new int[n];
        String[] t = br.readLine().split(" ");
        for(int i = 0; i < n; i++){
            a[i] = Integer.parseInt(t[i]);
        }
        insertionSort(a, n);
    }

    public static void insertionSort(int[] a, int n){
        int i, j, v;
        StringBuilder sb = new StringBuilder();
        for(i = 0; i < n; i++){
            sb.append(a[i]);
            if(i != n-1)sb.append(" ");
            if(i == n-1)sb.append("\n");
        }
        for(i = 1; i < n; i++){
            v = a[i];
            j = i - 1;
            while(j >= 0 && a[j] > v){
                a[j+1] = a[j];
                j--;
            }
            a[j+1] = v;
            for(int k = 0; k < n; k++){
                sb.append(a[k]);
                if(k != n-1) sb.append(" ");
                //System.out.println(sb);                                           
                //sb.delete(0, sb.length());                                        
                if(k == n-1) sb.append("\n");
            }
        }
        System.out.print(sb);
    }

}

Measured memory_bytes: 25256
// in the name of Allah

#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define MP make_pair
#define pii pair<int, int>
#define p push_back

using namespace std;

const ll mx=2e5+5, inf=1e16;

ll n, k, s[mx], minn=inf;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	sort(s, s+n);
	for(int i=0;i<=n-k;i++){
		if(s[i+k-1]-s[i]<minn){
			minn=s[i+k-1]-s[i];
		}
	}
	cout<<minn;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    string S;
    cin >> S;
    rep(i, S.size()) {
        char c = S.at(i);
        if (c == '1') cout << '9';
        else if (c == '9') cout << '1';
        else cout << c;
    }
    cout << endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::cmp;
use std::collections::HashMap;
use std::collections::HashSet;
use std::char;
use std::cmp::min;
use itertools::Itertools;
use num_integer::div_floor;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_tuple2<T: FromStr, S: FromStr>() -> (T, S) {
    let a = read();
    let b = read();
    (a, b)
}

fn read_tuple3<T: FromStr, S: FromStr, R: FromStr >() -> (T, S, R) {
    let a = read();
    let b = read();
    let c = read();
    (a, b, c)
}

fn main() {
    let n:u64 = read();
    let alist:Vec<u64> = (0..n).map(|_|read()).collect();
    let mut counter = HashMap::new();
    for a in alist {
        let e = counter.entry(a).or_insert(0);
        *e += 1;
    }
    let ans:u64 = counter.iter()
        .map(|(k, v)| if v >= k { v - k } else { *v })
        .sum();
    println!("{}", ans);
}



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

    int n,m,c;
    cin>>n>>m>>c;
    int b[m];
    for (int i = 0; i < m; i++)
    {
        cin>>b[i];
    }
    int count =0;
    for (int  i = 0; i < n; i++)
    {
        int sum=0;
        for (int j = 0; j < m; j++)
        {
            int x;
            cin>>x;
            sum+=x*b[j];
        }
        if (sum+c>0)
        {
            count++;
        }
        
    }

    cout<<count <<endl;
    
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int A, B, C, K;

  scanf("%d %d %d %d", &A, &B, &C, &K);
  if(A>=K) printf("%d\n", K);
  else{
    if(A+B>=K)
      printf("%d\n", A);
    else
      printf("%d\n", A-(K-A-B));
  }
    return 0;
}


Measured memory_bytes: 1736
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())


ans = []
of = 0


if N < 0:
    N = -N
    s = "0000" + bin(N)[2:]
    l = len(s)
    for i in range(l):
        # 1010 = N + 0101
        of, b = of, int(s[l - i - 1])
        if i % 2 == 0:
            if (of, b) == (0, 0):
                ans.append(0)
                of = 0
            elif (of, b) == (0, 1):
                ans.append(1)
                of = 1
            elif (of, b) == (1, 0):
                ans.append(1)
                of = 1
            else:
                ans.append(0)
                of = 1
        else:
            if (of, b) == (0, 0):
                ans.append(0)
                of = 0
            elif (of, b) == (0, 1):
                ans.append(1)
                of = 0
            elif (of, b) == (1, 0):
                ans.append(1)
                of = 0
            else:
                ans.append(0)
                of = 1
    ans.reverse()
    pre_ans = "".join(list(map(str, ans)))
    print(pre_ans[pre_ans.find("1"):])

elif N > 0:
    s = "0000" + bin(N)[2:]
    l = len(s)

    for i in range(l):
        # 10101 = N + 01010
        of, b = of, int(s[l - i - 1])
        if i % 2 == 0:
            if (of, b) == (0, 0):
                ans.append(0)
                of = 0
            elif (of, b) == (0, 1):
                ans.append(1)
                of = 0
            elif (of, b) == (1, 0):
                ans.append(1)
                of = 0
            else:
                ans.append(0)
                of = 1
        else:
            if (of, b) == (0, 0):
                ans.append(0)
                of = 0
            elif (of, b) == (0, 1):
                ans.append(1)
                of = 1
            elif (of, b) == (1, 0):
                ans.append(1)
                of = 1
            else:
                ans.append(0)
                of = 1
    ans.reverse()
    pre_ans = "".join(list(map(str, ans)))
    print(pre_ans[pre_ans.find("1"):])
else:
    print(0)


Measured memory_bytes: 3700
#include <algorithm>
#include <iostream>
#include <string>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T> using vv=vector<vector<T>>;
typedef deque<int> di;
typedef deque<deque<int>> ddi;


int main() {
    bool f = true;
    while(1) {
        int m;
        cin >> m;
        if(m == 0) {
            break;
        }
        if(!f) cout << endl;
        f=false;
        int t[4] = {10,50,100,500};
        int c[4]= {},k[4] = {}; 
        rep(i,4) { //10,50,100,500
            cin >> c[i];
        }
        int sum = 0; 
        rep(i,4) {
            sum += c[i] * t[i];
        }
        sum -= m ;
        for(int i = 3;i >= 0;i--) {
            k[i] = sum /t[i];
            sum %= t[i];
        }
        
        rep(i,4) {
            if(c[i]-k[i] > 0) {
                cout << t[i] << " " << c[i] - k[i] << endl;
            }
        }
    }
    return 0;

}

Measured memory_bytes: 3080
from collections import Counter
n = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
c = Counter(A)
flg = True
for k,v in c.items():
    if k==0:
        if v!=1:
            flg = False
    else:
        if v!=2:
            flg = False
if flg is False:
    print(0)
else:
    print(pow(2, n//2, mod))

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

#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;

const double PI = acos(-1.0);

// long long積のオーバーフロー検出
bool detect_mul_overflow(ll a, ll b)
{
    return a >= LONG_MAX / b;
}

int lcm(int a, int b)
{
    //最小公倍数
    return a / __gcd(a, b) * b;
}

struct edge
{
    int from, to, cost;
};

// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));

int N;


int main()
{
    cin>>N;
    int a;
    int ans=0;
    for(int i=1;i<=N;i++){
        cin>>a;
        if(i%2==1){
            if(a%2==1){
                ans++;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int n;
bool isPallindrome(string s){
	for(int i = 0 ;i  < n/2; i++){
		if(s[i] != s[s.length()-1-i])return false;
	}
 
	return true;
}
int main(){
 
      string s;
      cin >> s;
      n = s.length();
      if(isPallindrome(s) && n%2 == 1){
          string str = "";
          for(int i =1; i <= (n-1)/2;i++){
          	str+=s[i-1];
          }
          string str1 ="";
          for(int i = (n+3)/2; i<=n ;i++){
          	str1 += s[i-1];
          }
          if(isPallindrome(str) && isPallindrome(str1))cout<<"Yes\n";
          else cout<<"No\n";
      }
      else cout<<"No\n";
 
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
 
ball = [0] * N
 
 
if a[-1] == 1:
        ball[-1] = 1
 
for i in reversed(range(N-1)):
        tmp = 0
        if i != 0:
                for j in range(i + (i + 1), N, i + 1):
                        #print("i j ", i , j)
                        if (j + 1) % (i + 1) == 0:
                                tmp += ball[j]
        else:
                tmp = sum(ball[1:])
        #print(i+1, tmp, a[i])
        if tmp % 2 != a[i]:
                ball[i] = 1
 
#print(ball)
 
print(sum(ball))
for i in range(N):
        if ball[i] == 1:
                print(i+1, end = " ")

Measured memory_bytes: 66144
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n, m;
    cin >> n >> m;

    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << "\n";

    return 0;
}



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

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

	if (a*n < b)
		cout << a * n << endl;
	else
		cout << b << endl;
	return (0);
}


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

void Main(void) {
  int n;

  cin >> n;

  n = n % 10;

  switch (n) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    case 3:
      cout << "bon" << endl;
      break;
  }

  return;
}

int main() {
  Main();

  return 0;
}

Measured memory_bytes: 3648
import math
#import fractions as math
a,b,c = map(int,input().split())
list1 = []
def insu(a,b):
    global list1
    for i in range(1,min(a,b)+1):
        if a%i==0 and b%i==0:
            list1.append(i)

if __name__ == "__main__":
    insu(a,b)
    print(list1[-c])


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto&& i : a){
        cin >> i;
    }
    vector<bool> check(n, false);
    check[0] = true;
    int cnt = 1;
    for(int i = 1; i < n; i++){
        check[i] = a[i - 1] <= a[i];
        cnt += check[i];
    }
    if(cnt == n){
        cout << 0 << "\n";
        return 0;
    }
    int q;
    cin >> q;
    for(int i = 1; i <= q; i++){
        int x, y;
        cin >> x >> y;
        if(y < x) swap(x, y);
        swap(a[x - 1], a[y - 1]);
        if(1 < x){
            if(check[x - 1]) cnt--;
            cnt += check[x - 1] = a[x - 2] <= a[x - 1];
        }
        if(check[x]) cnt--;
        cnt += check[x] = a[x - 1] <= a[x];
        if(check[y - 1]) cnt--;
        cnt += check[y - 1] = a[y - 2] <= a[y - 1];
        if(y < n){
            if(check[y]) cnt--;
            cnt += check[y] = a[y - 1] <= a[y];
        }
        if(cnt == n){
            cout << i << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

signed main(){

	lli n;
	
	cin>>n;

	map<lli,vector<pair<lli,lli>>> d;

	REP(i,0,n){
		lli a;
		cin>>a;
		REP(j,0,a){
			lli x,y;
			cin>>x>>y;
			x--;
			d[i].push_back(make_pair(x,y));
		}
	}

	//search
	lli ans=0;
	for(lli bit=0;bit<(1LL<<n);bit++){
		if(DEBUG)cout<<endl;

		set<lli> now;
		bool outFlag=false;
		REP(i,0,n){
			if(bit&(1LL<<i)){
				now.insert(i);
				if(DEBUG)cout<<"i="<<i<<endl;
			}
		}

		for(auto target:now){
			if(DEBUG)cout<<" now="<<target<<endl;
			REP(j,0,d[target].size()){
				pair<lli,lli> &test = d[target].at(j);
				if(test.second==0){
					if(now.find(test.first)!=now.end()){
						if(DEBUG)cout<<"out!!"<<" first="<<test.first<<" second="<<test.second<<endl;
						outFlag=true;
						break;
					}
				}
				else{
					if(now.find(test.first)==now.end()){
						if(DEBUG)cout<<"out!!"<<" first="<<test.first<<" second="<<test.second<<endl;
						outFlag=true;
						break;
					}
				}
			}
			if(outFlag)break;
		}
		if(!outFlag){
			ans = max(ans,(lli)now.size());
		}

	}
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 256
k = gets.strip.to_i 

a = 1.upto(9).map { |i| i }

loop do 
  if k <= a.size
    puts a[k-1]
    exit
  end
  k -= a.size
  old = Array.new

  # swap a, old array
  a, old = old, a

  old.each do |x|
    -1.step(1) do |i|
      d = x%10 + i 
      next if (d < 0 || d > 9) 
      a.push(x*10 + d)
    end
  end
end


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

int main(){
  int N;
  cin>>N;
  vector<pair<int,int>> V;
  for(int i=0; i<=100000; ++i){
    V.push_back(make_pair(0,i));
  }
  
  vector<pair<int,int>> U;
  for(int i=0; i<=100000; ++i){
    U.push_back(make_pair(0,i));
  }
  
  for(int i=1; i<=N; ++i){
    int a;
    cin>>a;
    if(i%2==1) V[a].first += 1;
    else U[a].first += 1;
  }
  
  sort(V.begin(),V.end());
  reverse(V.begin(),V.end());
  
  sort(U.begin(),U.end());
  reverse(U.begin(),U.end());
  
  if(V[0].second==U[0].second) cout<<N-max(V[0].first+U[1].first,V[1].first+U[0].first)<<endl;
  else cout<<N-V[0].first-U[0].first<<endl;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

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

    int n;cin>>n;
    int x=floor(sqrt(n));
    cout<<x*x;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
#define MOD 1000000007

ll modpow(ll x, ll n) { 
  ll ans = 1;
  while(n > 0){
    if(n % 2 == 1){
      ans *= x;
      ans %= MOD;
    }
    x *= x;
    x %= MOD;
    n >>= 1;
  }
  return ans;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

int main(){
  int n;
  cin >> n;
  map<ll,ll> x;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    ll tmp = a[i];
    ll div = 2;
    while(div * div <= tmp) {
      ll cnt = 0;
      while(tmp % div == 0) {
        tmp /= div;
        cnt++;
      }
      if(cnt > 0){
        x[div] = max(x[div], cnt);
      }
      div++;
      if(div >= 4){
        div++;
      }
    }
    if(tmp != 1){
      x[tmp] = max(x[tmp], (ll)1);
    }
  }
  ll ans = 0;
  ll maxi = 1;
  for(auto p : x){
    maxi *= modpow(p.first, p.second);
    maxi %= MOD;
  }
  vector<ll> b(n, maxi);
  
  for(int i = 0; i < n; i++) {
    b[i] *= modinv(a[i], MOD);
    b[i] %= MOD;
  }
  for(int i = 0; i < n; i++){
    ans += b[i];
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
package main

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

type Pair struct {
	p int
	s int
}

func main() {

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	in := scanner.Text()

	a := []int{}
	b := []Pair{}

	area := 0
	for i, v := range in {
		if v == '\\' {
			a = append(a, i)
		} else if v == '/' {
			if len(a) < 1 {
				continue
			}
			var j int
			a, j = a[:len(a)-1], a[len(a)-1]
			s := i - j
			area += s
			for len(b) > 0 && b[len(b)-1].p > j {
				s += b[len(b)-1].s
				b = b[:len(b)-1]
			}
			b = append(b, Pair{j, s})
		}
	}
	fmt.Println(area)
	fmt.Printf("%d", len(b))
	for _, p := range b {
		fmt.Printf(" %d", p.s)
	}
	fmt.Println()
}



Measured memory_bytes: 2024
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
#define mp(x,y) make_pair(x,y)
const int MAXN=2e5+5;
int n,r1,r2,ecnt;
int ans[MAXN],siz[MAXN],ban[MAXN*4];
int head[MAXN],cnt;
struct node{
    int v,id,nxt;
}E[MAXN*4];
void addedge(int u,int v,int id){
    E[++cnt]=(node){v,id,head[u]};
    head[u]=cnt;
}

void dfs(int u,int fa=0){
    for(int i=head[u];i;i=E[i].nxt){
        int v=E[i].v;
        if(v==fa) continue;
        dfs(v,u);
        siz[u]++;
    }
}
void sol(int u){
    for(int &i=head[u];i;i=E[i].nxt){
        int v=E[i].v,id=E[i].id;
        if(ban[id]) continue;
        ban[id]=1;
        if(v==u-n) ans[v]=-1;
        else if(v==u+n) ans[u]=1;
        sol(v);
    }
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        if(x==-1) r1=i;
        else{
            addedge(x,i,++ecnt);
            addedge(i,x,ecnt);
        }
    }
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        if(x==-1) r2=i+n;
        else{
            addedge(x+n,i+n,++ecnt);
            addedge(i+n,x+n,ecnt);
        }
    }
    dfs(r1);
    dfs(r2);
    for(int i=1;i<=n;i++){
        if((siz[i]&1)!=(siz[i+n]&1)) return puts("IMPOSSIBLE"),0;
        if(!(siz[i]&1)){
            addedge(i,i+n,++ecnt);
            addedge(i+n,i,ecnt);
        }
    }
    addedge(r1,2*n+1,++ecnt),addedge(2*n+1,r1,ecnt);
    addedge(r2,2*n+1,++ecnt),addedge(2*n+1,r2,ecnt);
    sol(2*n+1);
    puts("POSSIBLE");
    for(int i=1;i<=n;i++)
        printf("%d ",ans[i]);
}

Measured memory_bytes: 24192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  string S,T;
  cin >> S;
  cin >> T;
  
  int Sum = 0;
  for(int i=0;i<S.size();i++){
    if(S[i]!=T[i]){ Sum++; }
  }
  
  printf("%d\n", Sum);

  return 0;
}

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

typedef long long ll;
const ll MOD=1000000007;

int main(){
	int n;
	string s[2];
	cin>>n>>s[0]>>s[1];
	
	ll ret=1;
	ll t=0;
	for(int i=0;i<n;i++){
		if(t==0){
			if(s[0][i]==s[1][i]){
				ret=3;
				t=1;
			}
			else {
				ret=6;
				t=2;
				i++;
			}
		}
		else if(t==1){
			if(s[0][i]==s[1][i]){
				ret*=2;
				t=1;
			}
			else {
				ret*=2;
				t=2;
				i++;
			}
		}
		else {
			if(s[0][i]==s[1][i]){
				t=1;
			}
			else {
				ret*=3;
				t=2;
				i++;
			}
		}
		ret%=MOD;
	}
	cout<<ret<<endl;
}



Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
    int n, k, ans;
    string s;
    cin >> n >> k >> s;
    ans = n-1;
    for(int i=1;i<n;i++){
        if(s[i] != s[i-1])ans--;
    }
    ans += k*2;
    ans = min(ans, n-1);
    cout << ans << endl;
}


Measured memory_bytes: 512
# N, M = map(int, input().split())
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    H, N = map(int, input().split())
    As = list(map(int, input().split()))

    if sum(As) < H:
        print("No")
    else:
        print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 13964
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, S[1000];

void push(int x) {
  S[++top] = x;
}

int pop() {
  return S[top--];
}

int main() {
  int a,b;
  top = 0;
  char s[100];
  while (scanf("%s", s) != EOF) {
    if (s[0] == '+') {
      a = pop();
      b = pop();
      push(a+b);
    } else if (s[0] == '-') {
      a = pop();
      b = pop();
      push(b-a);
    } else if (s[0] == '*') {
      a = pop();
      b = pop();
      push(a*b);
    } else {
      push(atoi(s));
    }
  }
  printf("%d\n", pop());
  return 0;
}



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

int main()
{
  int N, K;
  cin >> N >> K;
  auto a = vector<int>(N, 0);
  auto b = vector<int>(N, 0);

  int count = 0;
  for (int i = 0; i < N; ++ i) {
    cin >> a[i];
    if (b[a[i] - 1] == 0) count ++;
    b[a[i] - 1] ++;
  }
  if (count <= K) cout << 0 << endl;
  else {
    for (int i = 0; i < N; ++ i) {
      a[i] = i; 
    }
    sort(a.begin(), a.end(), [&] (int i, int j) -> bool { return b[i] < b[j]; });
    int ans = 0;
    for (int i = 0; i < N; ++ i) {
      if (count <= K) break;
      if (b[a[i]]) {
        ans += b[a[i]];
        count --;
      } 
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
using namespace std;
int main(){
  long int a,b;
  cin >>a >>b;
  long int x = a*a-b*b;
  long int y = a-b;
  y *=2;
  if(x%y==0){
    cout <<(x/y);
  }else{
    cout <<"IMPOSSIBLE";
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
#include<string>
#include<cmath>
#include<tuple>
#include <algorithm>
#define INF 1111111111
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> tup;
typedef long long ll;
vector<int> vec(100100);
vector<int> passed(100100);
vector<int> dx = {-1,1};
int n,k;

int main() {
  int n;
  cin >> n;
  
  vector<ll> a(n+1);
  vector<ll> b(n);
  int min = INF;
  
  
  cin >> a.at(0);
  for(int i=1;i<=n;i++)
    cin >> a.at(i);
  sort(a.begin(), a.end());
    for(int i=0;i<n;i++){
      b.at(i) = a.at(i+1) - a.at(i);
        if(b.at(i) < min)
          min = b.at(i);
    }
  
  
  ll ans = min;
  
  for(int i=1;i<=min;i++){
    bool flag = true;
    if(min%i == 0){
      for(int j=0;j<n;j++){
        if(b.at(j)%(min/i) != 0){
          flag = false;
          break;
        }
      }
      if(flag){
      ans = min/i;
      break;
      }
    }
  }
  cout << ans << endl;
  
}

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

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

    int N, n;
    cin>>N;  //入力
    int count = N;

    for(int i = 0; i < N; i++) {
        cin>>n;

        for(int j = 2; j <= n/2  && j < 10000; j++) {
            if(n%j == 0) {
                count--;
                break;
            }
        }
    }
    cout<<count<<endl; //出力
    return 0;
}



Measured memory_bytes: 3224
using System;
using System.Linq;
class program {
	public static void Main() {
		string str;
		double[] vals;
		while((str = Console.ReadLine()) != null) {
			vals = str.Split().Take(8).Select(s => double.Parse(s)).ToArray();
			Console.WriteLine((vals[0] <= vals[6] && vals[4] <= vals[2] && vals[1] <= vals[7] && vals[5] <= vals[3]) ? "YES" : "NO");
		}
	}
}

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

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

    if(s.at(s.length()-1)=='s') cout << s << "es" << endl;
    if(s.at(s.length()-1)!='s') cout << s << 's' << endl;


}

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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;

int mod_pow(int a, int b) {
	if (!b) return 1;
	if (b % 2) return a * mod_pow(a, b - 1) % MOD;
	int q = mod_pow(a, b / 2);
	return q * q % MOD;
}

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(rall(a));

	vector<int> fact(n + 1);
	fact[0] = 1;
	for (int i = 1; i <= n; i++) {
		fact[i] = fact[i - 1] * i % MOD;
	}

	vector<int> inv(n + 1);
	for (int i = 0; i <= n; i++) {
		inv[i] = mod_pow(fact[i], MOD - 2);
	}

	vector<int> pw(n + 1);
	pw[0] = 1;
	for (int i = 1; i <= n; i++) {
		pw[i] = pw[i - 1] * 2 % MOD;
	}


	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = (ans + a[i - 1] * (i + 1) % MOD) % MOD;
	}
	ans = ans * mod_pow(4, n - 1) % MOD;
	cout << ans;
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int x;
cin >> x;
int sosu = 0;
for (int i = x;i < INF;i++) {
    if (i ==2) sosu = 2;
    for (int j = 2;j < i;j++) {
        
        if (i%j == 0) break;
        else if (j == i-1) sosu = i;
        
    }
    if (sosu > 0) break; 
}

cout << sosu << endl;

return 0;
}

Measured memory_bytes: 256
import time
_s = time.time()

import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

from numba import njit


def getInputs():
    D = int(readline())
    CS = np.array(read().split(), np.int32)
    C = CS[:26]
    S = CS[26:].reshape((-1, 26))
    return D, C, S


@njit('Tuple((i4[:], i8))(i8, i4[:], i4[:, :], i4[:], )', cache=True)
def _compute_score1(D, C, S, out):
    score = 0
    last = np.zeros(26, np.int32)
    for d in range(len(out)):
        i = out[d]
        score += S[d, i]
        last[i] = d + 1
        score -= np.sum(C * (d + 1 - last))
    return last, score


def _update_score():
    pass

@njit('Tuple((i4[:], i8))(i8, i4[:], i4[:, :], i4[:], i8, )', cache=True)
def _random_update(D, C, S, out, score):
    d = np.random.randint(0, D)
    q = np.random.randint(0, 26)
    p = out[d]

    if p == q:
        return out, score

    out[d] = q
    _, new_score = _compute_score1(D, C, S, out)
    if score < new_score:
        score = new_score
    else:
        out[d] = p

    return out, score


@njit('Tuple((i4[:], i8))(i8, i4[:], i4[:, :], i4[:], i8, i8, )', cache=True)
def _random_swap(D, C, S, out, score, delta):
    d1 = np.random.randint(0, D)
    d2 = np.random.randint(max(0, d1 - delta), min(D, d1 + delta))
    #p, q = out[[d1, d2]]
    p = out[d1]
    q = out[d2]

    if d1 == d2 or p == q:
        return out, score

    #out[[d1, d2]] = (q, p)
    out[d1] = q
    out[d2] = p
    _, new_score = _compute_score1(D, C, S, out)
    if score < new_score:
        score = new_score
    else:
        #out[[d1, d2]] = (p, q)
        out[d1] = p
        out[d2] = q

    return out, score



def step1(D, C, S):
    out = []
    LAST = 0
    for d in range(D):
        max_score = -10000000
        best_i = 0
        
        for i in range(26):
            out.append(i)
            last, score = _compute_score1(D, C, S, np.array(out, np.int32))
            if max_score < score:
                max_score = score
                LAST = last
                best_i = i
            out.pop()

        out.append(best_i)

    return np.array(out), LAST, max_score


def step2(D, C, S, out, score):
    while time.time() - _s <= 1.9:
        flag = np.random.rand() >= 0.5
        out = out.astype(np.int32)

        if flag:
            out, score = _random_update(D, C, S, out, score)
        else:
            out, score = _random_swap(D, C, S, out, score, 13)

    return out, score


def output(out):
    out += 1
    print('\n'.join(out.astype(str).tolist()))


D, C, S = getInputs()
out, _, score = step1(D, C, S)
#print(score)
out, score = step2(D, C, S, out, score)
output(out)
#print(score)

Measured memory_bytes: 108080
#include <stdio.h>
#include <math.h>

int main(){
  long long n;
  int count = 0;
  int count_r = 0;
  
  scanf("%lld", &n);
  
  for(int i = 2; i <= sqrt(n); i++){
    if(i > n)
      break;
    
    while(n % i == 0){
      n /= i;
      count++;
    }
    
    int j = 1;
    
    while(count >= j){
      count -= j;
      count_r++;
      j++;
    }
    
    count = 0;
  }
  
  if(n > sqrt(n))
    count_r++;
  
  printf("%lld\n", count_r);
  return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
int N, H[101010], dp[101010];
int main()
{
    cin >> N;
    rep(i, N)
    {
        cin >> H[i];
    }
    rep(i, N)
    {
        dp[i] = INFINITY;
    }
    dp[0] = 0;
    for (int i = 0; i < N; ++i)
    {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]));
    }
    cout
        << dp[N - 1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int H, W, N;
    cin >> H >> W >> N;

    vector <int> C;
    for (int i = 1; i <= N; i++){
        int a;
        cin >> a;
        
        for (int j = 0; j < a; j++){
            C.push_back(i);
        }
    }

    vector <vector <int> > c(H);
    
    for (int i = 0; i < H * W; i++){
        int a = i / W;

        c[a].push_back(C[i]);
    }
    
    vector <vector <int> > ans(H);
    for (int i = 0; i < H; i++){
        if (i % 2 == 0){
            for (int j = 0; j < W; j++){
                ans[i].push_back(c[i][j]);
            }
        }else{
            for (int j = 0; j < W; j++){
                ans[i].push_back(c[i][W - j - 1]);
            }
        }
    }
    
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    
    return 0;
}

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

int N = 100001;
bool is_prime[100001];
int s[100001];

int main() {

    int Q;
    cin >> Q;
    vector<int> l(Q), r(Q);
    for(int i = 0; i < Q; i++) cin >> l[i] >> r[i];

    for(int i = 0; i < N; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i < N; i++) {
        if(is_prime[i]) {
            for(int j = 2 * i; j < N; j += i) is_prime[j] = false;
        }
    }

    for(int i = 3; i < N; i+=2) {
        if(is_prime[i] && is_prime[(i+1)/2]) s[i]++;
    }

    for(int i = 1; i < N; i++) {
        s[i] += s[i-1];
    }

    for(int i = 0; i < Q; i++) {
        cout << s[r[i]] - s[l[i]-1] << endl;
    }

    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,ans=0;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  int a_max=a[n-1];
  for(int i=1;i<a_max+1;i++){
    int ite=lower_bound(a.begin(),a.end(),i)-a.begin();
    if(ite==n/2) ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
    int D[10];
    char cmd[100];
    int cp;
    scanf("%d %d %d %d %d %d",&D[1],&D[2],&D[3],&D[4],&D[5],&D[6]);
    scanf("%s",cmd);
    
    for(int i=0;;i++){
        if(cmd[i]=='\0')
            break;
        if(cmd[i]=='N'){
            cp=D[5];
            D[5]=D[1];
            D[1]=D[2];
            D[2]=D[6];
            D[6]=cp;
        }
        if(cmd[i]=='S'){
            cp=D[2];
            D[2]=D[1];
            D[1]=D[5];
            D[5]=D[6];
            D[6]=cp;
        }
        if(cmd[i]=='E'){
            cp=D[3];
            D[3]=D[1];
            D[1]=D[4];
            D[4]=D[6];
            D[6]=cp;
        }
        if(cmd[i]=='W'){
            cp=D[4];
            D[4]=D[1];
            D[1]=D[3];
            D[3]=D[6];
            D[6]=cp;
        }
    }
    printf("%d\n",D[1]);
}


Measured memory_bytes: 2100
N = int(input())
list = input().split()

odd = []
even = []
four = []

for i in range(0, N):
	if int(list[i]) % 2 != 0:
		odd.append(list[i])
	elif int(list[i]) % 2 == 0 and int(list[i]) % 4 != 0:
		even.append(list[i])
	elif int(list[i]) % 4 == 0:
		four.append(list[i])

odd_num = len(odd)
even_num = len(even)
four_num = len(four)

if four_num >= odd_num - 1 and even_num == 0:
	print('Yes')
elif four_num >= odd_num:
	print('Yes')
else:
	print('No')


Measured memory_bytes: 11436
#include<stdio.h>

int main(){
  int num; //出場回数
  int Irate; //内部レーティング
  int Drate; //表示レーティング
  
  scanf("%d %d",&num,&Drate);
  
  if(num < 10)
    Irate = Drate + 100*(10 - num);
  
  else 
    Irate = Drate;
  
  printf("%d",Irate);
  
  return 0;
}

Measured memory_bytes: 128
n = int(input())
if n <= 9:
    print(n)
else:
    y = 9
    z = 9
    for i in range(11,n+1):
        p = str(i)
        if p[0] == p[len(p)-1]:
            y += 2
            z += 1
            if len(p) >= 4:
                for j in range(3, len(p)):
                    y += 10 ** (j-2)
            if len(p) >= 3:
                y += int(p[1:len(p)-1])+1
        elif int(p[0]) > int(p[len(p)-1]) > 0:
            for j in range(2, len(p)+1):
                y += 10 ** (j-2)
        elif len(p) >= 3 and not i%10 == 0: 
            for j in range(2, len(p)):
                y += 10 ** (j-2)
    print(2*y-z)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,i,sum=0,max,e;
  cin>>n;
  long long int a[n];
  for(i=0;i<n;i++)
  {
   	cin>>e;
    a[i]=e;
    sum+=e;
  }
  max=a[0];
  for(i=0;i<n;i++)
  {
    if(a[i]>max)
      max=a[i];
  }
  if(max<sum-max)
    cout<<"Yes"<<endl;
  else 
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()

#西に向いている人の累計と、東に向いている人の累計を計算
wsuml = [0]*n
esuml = [0]*n
for i in range(n):
  esuml[i] = esuml[i-1]
  wsuml[i] = wsuml[i-1]
  if s[i] == 'E':
    esuml[i] += 1
  else:
    wsuml[i] += 1
#コスト計算用のリストを準備
costl = [0]*n
#両端は考えるの面倒なので手動で。
costl[0] = esuml[-1] - esuml[0]
costl[-1] = wsuml[-2]
#あとはO(n)のループをまわす。自分より左でWの人と、自分より右でEの人の和がコスト
for i in range(1,n-1):
  costl[i] = wsuml[i-1] + esuml[-1]-esuml[i]
print(min(costl))


Measured memory_bytes: 29472