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

using namespace std;

int main(){
    int n, x, y;
    cin >> n >> x >> y;
    int mid = (y+x)/2;

    
    vector<int> count(n*n, 0);
    

    for(int i=1; i<n; i++){
        for(int j=i+1; j<=n; j++){
            int a = min(j-i, abs(x-i) + 1 + abs(y-j));
            count[a]++;
        }
    }

    for(int k=1; k<=n-1; k++){
        cout << count[k] << endl;
    }
    // for(int k=1; k<=n-1; k++){
    //     int ans = 0;
    //     for(int i=1; i<n; i++){
    //         for(int j=i+1; j<=n; j++){
    //             int res = min(j-i, abs(x-i) + 1 + abs(y-j));
    //             if(res == k) ans++;
    //         }
    //     }
    //     // ans += max(0, n - (y-x-1) - k);
    //     // cout << ans << "\t";
    //     // for(int i=max(1, x-k+1); i+k<=mid && i<x; i++) ans++;
    //     // cout << ans << "\t";
    //     // for(int i=x; i<=y; i++){
    //     //     if(i+k < y-x+1-k + i && i-k > x){
    //     //         ans++;
    //     //     }
    //     // }
    //     // cout << ans << "\t";
    //     // for(int i=x; i+k<=y; i++){
    //     //     if(i+k >= y-x+1-k + i){
    //     //         ans++;
    //     //     }
    //     // }
    //     // cout << ans << "\t";

    //     // for(int i=y-k+1; i<=y-1 && i+k<n; i++) ans++;
    
    //     cout << ans << endl;


    // }
}

Measured memory_bytes: 15872
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
int main()
{
	int n,k;
	read(n);read(k);
	puts(k*2>n+1?"NO":"YES");
	return 0;
}









Measured memory_bytes: 2304
use whiteread::parse_line;

fn main() {
    let (n, k, q): (usize, isize, isize) = parse_line().unwrap();
    let mut a: Vec<isize> = vec![0; n];
    for _ in 0..q {
        let ai: usize = parse_line().unwrap();
        a[ai - 1] += 1;
    }
    for ai in a {
        if q - ai < k {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 2868
import sys
input = sys.stdin.readline

#########
class UnionFind():
    """
    parents : 親要素(findしない場合は根ではないことの注意)，根の場合は"-(要素数）"
    find(x):要素xの属するグループの根を返す
    size(x):要素xの属するグループの要素数を返す
    same(x,y):x,yが同じグループに属しているか返す
    members(x):要素xが属するグループに属する要素をリストで返す
    roots(x):全ての根の要素を返す
    group_counte():グループの数を返す
    all_group_members():{根要素：[そのグループに含まれる要素のリスト]}の辞書を返す
    """
    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 Kruskal(V,edges):
        """
        V:node数
        edges:[u,v,cost]の辺のリスト
        
        return: 最小全域木のコストの和
        """
        #edges = sorted(edges, key=lambda x: x[2])  # costでself.edgesをソートする
        res = 0
        uf=UnionFind(V)
        for e in edges:
            if not uf.same(e[0], e[1]):
                uf.union(e[0], e[1])
                res += e[2]
        return res

############

N,M=map(int,input().split())
edges=[]

for i in range(M):
    x,y,z=map(int,input().split())
    edges.append((x-1,y-1,1))
    
E=Kruskal(N,edges)
print(N-E)






Measured memory_bytes: 83164
#include<stdio.h>
int main(void)
{
	int N,R,a,B;
	scanf("%d %d",&N,&R);
	if(N<10){
		a=100*(10-N);
		B=a+R;
		printf("%d\n",B);
	}
	if(N>=10){
		printf("%d\n",R);
	}
	return 0;
}

Measured memory_bytes: 1724
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;

typedef long long LL;
typedef long double LD;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    LL ans = 0;
    for(int i = 1;i <= n; i++){
        if(i % 3 == 0 && i % 5 == 0);
        else if(i % 3 == 0);
        else if(i % 5 == 0);
        else ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
from bisect import bisect_right
import sys
input = sys.stdin.readline

N = int(input())
x = list(map(int, input().split()))
L = int(input())
log = 1
while 1 << log < N:
    log += 1
doubling = [[0] * (log + 1) for _ in range(N)]
for i in range(N):
    j = bisect_right(x, x[i] + L) - 1
    doubling[i][0] = j
for l in range(1, log + 1):
    for i in range(N):
        doubling[i][l] = doubling[doubling[i][l-1]][l-1]
Q = int(input())
for _ in range(Q):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a > b:
        a, b = b, a
    ans = 0
    for l in range(log, -1, -1):
        if doubling[a][l] < b:
            ans += 1 << l
            a = doubling[a][l]
    print(ans + 1)


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

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

  int ans{};
  for (int i{}; i < 1000; ++i) {
    stringstream ss;
    ss << setw(3) << setfill('0') << i;
    string digits{ss.str()};
    int cur{};
    for (int j{}; j < N; ++j) {
      if (S[j] == digits[cur]) {
        if (++cur == 3) {
          ++ans;
          break;
        }
      }
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int sum[5],in[5];
int main()
{
	int a,b;
	for(int i=1;i<=3;i++)
	{
		cin>>a>>b;
		sum[a]++;
		sum[b]++;
	}
	for(int i=1;i<=4;i++)
		in[sum[i]]++;
	if(!in[3])
		puts("YES");
	else
		puts("NO");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) rep2(i,0,n)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
string s;
int a=0;
int main()
{
	cin>>s;
	rep(i,s.size())
	{
		a+=s[i]-'0';
	}
	if(a%9==0) re("Yes")
	re("No")
	return 0;}

Measured memory_bytes: 3636
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
MAX = 2 * 10 ** 5 + 5
MOD = 10 ** 9 + 7

fac = [0 for i in range(MAX)]
finv = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]

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


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

def p(n, r, mod):
    return fac[n] * finv[n - r] % mod
    
comInit(MOD)

S = int(input())
l = S // 3
ans = 0
for i in range(1, l + 1):
    now = S - i * 3
    ans += com(now + i - 1, i - 1, MOD) % MOD
print(ans % MOD)

Measured memory_bytes: 108644
# ARC059D - アンバランス / Unbalanced (ABC043D)
def main():
    # more than half -> 2/3 in a 3-length partial string
    S = input().rstrip()
    N = len(S)
    if N == 2:  # e.g. "aa", "ab"
        ans = (1, 2) if S[0] == S[1] else (-1, -1)
        print(*ans)
        return
    for i in range(N - 2):
        if len(set(S[i : i + 3])) == 2:
            print(i + 1, i + 3)
            return
    print(-1, -1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<math.h>
using namespace std;

int main()
{
	
	int a,b;
	cin>>a>>b;
	
	cout<<a*b<<endl;
	return 0;
	
}


Measured memory_bytes: 3632
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
	let n = read_line().parse::<i64>().unwrap();
	let k = read_line().parse::<i64>().unwrap();
	let x = read_line().parse::<i64>().unwrap();
	let y = read_line().parse::<i64>().unwrap();

	if n >= k {
		let c = n - k;
		println!("{}",(k*x)+(c*y));
	}else{
		println!("{}",n*x);
	}
}


Measured memory_bytes: 4352
def resolve():
    from collections import deque
    n, Q = [int(i) for i in input().split()]
    ans = [deque() for _ in range(n)]
    for _ in range(Q):
        q = [int(i) for i in input().split()]
        if q[0] == 0:
            ans[q[1]].append(q[2])
        elif q[0] == 1:
            if len(ans[q[1]]) > 0:
                print(ans[q[1]][0])
        else:
            if len(ans[q[1]]) > 0:
                ans[q[1]].popleft()


resolve()



Measured memory_bytes: 14540
package main
 
import (
	"fmt"
)
 
func findSumOfDigits(n int) int {
	sum := 0
	for n > 0 {
		sum += n % 10
		n /= 10
	}
	return sum
}
 
func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)
 
	total := 0
	for i := 0; i <= n; i++ {
		if findSumOfDigits(i) >= a && findSumOfDigits(i) <= b {
			total += i
		}
	}
	fmt.Println(total)
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    if (n == 1) {
        cout << "Yes" << endl;
        cout << 1 << endl;
    }
    else if (n == 2) {
        if (x == 2) {
            cout << "Yes" << endl;
            for (int i = 1; i <= 2 * n - 1; i++)
                cout << i << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else {
        if (x > 2 && x < 2 * n - 2) {
            vector <int> a;
            for (int i = 1; i <= 2 * n - 1; i++)
                if (i < x - 2 || i > x + 2)
                    a.push_back(i);
            int cur = 0;
            cout << "Yes" << endl;
            for (int i = 0; i < n - 3; i++)
                cout << a[cur++] << endl;
            for (int diff : {2, -1, 0, 1, -2})
                cout << x + diff << endl;
            for (int i = 0; i < n - 3; i++)
                cout << a[cur++] << endl;
        }
        else if (x == 2 || x == 2 * n - 2) {
            cout << "Yes" << endl;
            int add = (x == 2 ? n : (n - 1));
            for (int i = 1; i <= 2 * n - 1; i++) {
                int j = i + add;
                if (j > 2 * n - 1)
                    j -= (2 * n - 1);
                cout << j << endl;
            }
        }
        else {
            cout << "No" << endl;
        }
    }
}


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

int main(){
  int ans =0;
  int N;
  cin>> N;
  
  for(int i=0;i<N;i++){
    int L, R;
    cin>> L>> R;
    ans += R-L+1;
  }
  cout<< ans;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100000000000000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;
int main(){
   string S;
   ll K;
   cin >> S >> K;
   ll ans = 0;
   vector<ll> B(1,1);
   rep(i,S.size()-1){
       if(S[i] == S[i+1]) B.back()++;
       else B.push_back(1);
   }
   if(S[0] != S.back()){
       rep(i,B.size()){
           ans += B[i] / 2;
       }
       cout << ans * K << endl;
   }else{
       rep(i,B.size()){
           ans += B[i] / 2;
       }
       if(B.size() == 1){
           cout << S.size() * K / 2 << endl;
           return 0;
       }else{
           cout << ans * K - (K-1) * (B[0]/2+B.back()/2-(B[0]+B.back()) / 2) << endl;
       }
   }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int data[3],n,a;
	while(1){
		for(int i=0;i<3;i++){
			cin>>data[i];
		}
		if(data[0]==0)break;
		cin>>n;
		sort(data,data+3);
		for(int i=0;i<n;i++){
			cin>>a;
			if(2*a*2*a>data[0]*data[0]+data[1]*data[1]){
				cout<<"OK"<<endl;
			}else{
				cout<<"NA"<<endl;
			}
		}
	}
}

Measured memory_bytes: 1172
n=int(input())
a=list(map(int,input().split()))
if a[0]:
  if n==0 and a[0]==1:
    print(1)
  else:
    print(-1)
  exit()
b=[0]*n
b.append(a[-1])
for i in range(n)[::-1]:
  b[i]=b[i+1]+a[i]
ro=1
ans=1
for i in range(1,n+1):
  t=min(ro*2,b[i])
  ans+=t
  ro=t-a[i]
  if ro<0:
    print(-1)
    exit()
print(ans)


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

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

using namespace std;

const int INF=1<<29;

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<int> G[100000];
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		G[u].emplace_back(v);
	}
	int s,t; scanf("%d%d",&s,&t); s--; t--;

	int d[100000][3];
	rep(u,n) rep(k,3) d[u][k]=INF;
	d[s][0]=0;
	queue<pair<int,int>> Q;
	Q.emplace(s,0);
	while(!Q.empty()){
		auto a=Q.front(); Q.pop();
		int u=a.first,k=a.second;

		if(u==t && k==0){ printf("%d\n",d[u][k]/3); return 0; }

		for(int v:G[u]) if(d[v][(k+1)%3]==INF) {
			d[v][(k+1)%3]=d[u][k]+1;
			Q.emplace(v,(k+1)%3);
		}
	}

	puts("-1");

	return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;
  bool flg = false;

  for(int i = 1; i <= 9; i++){
    if(N%i == 0){
      int j = N / i;
      if(j <= 9 && j >= 1){
        flg = true;
        break;
      }
    }
  }

  if(flg){
    cout << "Yes" << endl;
  } else { 
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3604
/* ex 7_3
   TakayukiY*/

#include<stdio.h>
#include<stdlib.h>

int main(void){
    //indexと行列の要素数と空行チェック用の配列のポインタの定義
    int i,j,row,column,*chkrow,*chkcol;
    //aijの格納配列の定義
    char **ptr;

    //要素数を代入して各行のメモリ確保、エラーチェック
    scanf("%d%d\n",&row,&column);
    ptr=(char**)calloc(row,sizeof(char*));
    if(ptr==NULL) exit(1);

    for(i=0;i<row;i++){
        //各列のメモリ確保、エラーチェック
        ptr[i]=(char*)calloc(column,sizeof(char));
        if(ptr==NULL) exit(1);
        
        //各要素を代入
        for(j=0;j<column;j++){
            scanf("%c",&ptr[i][j]);
        }
        //末尾の改行をスキップ
        getchar();
    }

    //空行チェック用の配列のメモリ確保
    chkrow=(int*)calloc(row,sizeof(int));
    if(chkrow==NULL) exit(1);
    chkcol=(int*)calloc(column,sizeof(int));
    if(chkcol==NULL) exit(1);

    //行列の各要素のいずれかが空白でないならチェック用配列に1を代入
    for(i=0;i<row;i++){
        for(j=0;j<column;j++){
            if(ptr[i][j]=='#'){
                *(chkrow+i)=1;
                *(chkcol+j)=1;
            }
        }
    }

    //空白でない行・列に対して出力→圧縮
    for(i=0;i<row;i++){
        if(chkrow[i]==1){
            for(j=0;j<column;j++){
                if(chkcol[j]==1){
                    printf("%c",ptr[i][j]);
                }
            }
            printf("\n");
        }
    }

    //メモリの解放
    for(i=0;i<row;i++){
        free(ptr[i]);
    }
    free(ptr);
    free(chkrow);
    free(chkcol);

    return 0;
}


Measured memory_bytes: 1656
#include<iostream>
#include<map>
using namespace std;
int main(){
  map<int,int> n;
  int a,b,c;cin>>a>>b>>c;
  n[a]+=1;n[b]+=1;n[c]+=1;
  for(auto& it:n){
    if(it.second==1)cout<<it.first<<endl;
  }
  return 0;
}

Measured memory_bytes: 3584
N = int( input())
A = [ int( input()) for _ in range(N)]
now = 0
ans = 0
for i in range(N):
    a = A[i]
    if now == 1:
        if a >= 1:
            ans += 1
            a -= 1
    now = 0
    ans += a//2
    a = a - a//2*2
    if a == 1:
        now = 1
print( ans)

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

using namespace std;

int main(){
    int k;
    cin >> k;
    if(k%2==0 || k%5==0){
        cout << -1 << endl;
        return 0;
    }

    int ans=1;
    int l;
    if(k%7==0){
        l=9*k/7;
    }else{
        l=9*k;
    }

    int ten=10;
    while (1) {
        if(ten%l==1){
            cout << ans << endl;
            return 0;
        }else{
            ten=(ten%l)*10;
            ans++;
        }
    }

    return 0;
}


Measured memory_bytes: 3612
n, m, c = map(int,input().split())
bList = list(map(int,input().split()))
aList = []
for i in range(n):
  aList.append(list(map(int,input().split())))

sorce = 0
for i in range(len(aList)):
  result = 0
  for j in range(m):
   result += aList[i][j]*bList[j]
  if result+c > 0:
    sorce += 1 

print(sorce)
 

Measured memory_bytes: 3060
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair< int, int> P;
struct edge{ll to, cost; };

static const double EPS = 1e-8;
static const double PI = 3.141592653589;
static ll INF = 999999999999;
int mod = 1000000007;

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define MIN(a,b)    (a) < (b) ? (a):(b)
#define MAX(a,b)    (a) > (b) ? (a):(b)
#define debug(x) cerr << #x << " = " << x << endl;
int dx[] = {1,-1,0,0,1,-1,1,-1};
int dy[] = {0,0,1,-1,-1,1,1,-1};

using namespace std;




int main() {

    int ans[27] = {0};
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        ans[s[i] - 'a']++;
    }
    int flag = 0;
    for(int i = 0; i < 26; i++){
        if(ans[i] % 2 == 1)flag = 1;
    }
    if(flag == 1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INF 999999999
using namespace std;

int main(){
          int h,w;
          cin >> h >> w;
          string s[h][w];
          REP(i,h)  REP(j,w)  cin >> s[i][j];
          REP(i,h)  REP(j,w){
                    if(s[i][j]=="snuke"){
                              cout << char(j+'A') <<  i+1 << endl;
                    }
          }
          return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,nForS,nForT,q,left,right,mid,count;
  int S[100000];
  scanf("%d",&nForS);
  for(i=0;i<nForS;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&nForT);
  count = 0;
  for(i=0;i<nForT;i++){
    scanf("%d",&q);
    left = 0;
    right = nForS;
    while(left < right){
      mid = (left+right)/2;
      if( S[mid] == q ){
	count++;
	break;
      }
      if( q < S[mid]){
	right = mid;
      }
      else if( S[mid] < q){
	left = mid + 1;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 988
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, M = map(int, input().split())
mod = 10 ** 9 + 7
a = [0] * M
dp = [0] * (N + 2)
dp[0] = 1
dp[1] = 1

for i in range(M):
	a[i] = int(input())
	
now = 0
next = 0

for i in a:
	next = i
	for j in range(now + 1, next + 1):
		if j == i:
			dp[i] = 0
		else:
			dp[j] = (dp[j - 1] + dp[j - 2]) % mod
	
	now = next

next = N
for j in range(now + 1, next + 1):
		dp[j] = (dp[j - 1] + dp[j - 2]) % mod
print(dp[N])

Measured memory_bytes: 42076
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;



signed main(){
	int N;
	cin>>N;
	vector<pair<int,int>>v(N);
	int ma=0;
	int id=-1;
	REP(i,N){
		cin>>v[i].second>>v[i].first;
		if(CHMAX(ma,v[i].first-v[i].second+1))id=i;
	}
	int add=0;
	pair<int,int>p={-1,INF};
	REP(i,N)if(id!=i){
		CHMIN(p.second,v[i].first);
		CHMAX(p.first,v[i].second);
	}
	if(p.second>=p.first)add+=p.second-p.first+1;
	sort(ALL(v));
	vector<pair<int,int>>lrange(N,{-1,INF});
	lrange[0]={v[0].second,v[0].first};
	FOR(i,1,N){
		lrange[i].first=max(v[i].second,lrange[i-1].first);
		lrange[i].second=min(v[i].first,lrange[i-1].second);
	}
	vector<pair<int,int>>rrange(N,{-1,INF});
	rrange[0]={v[N-1].second,v[N-1].first};
	FOR(i,1,N){
		rrange[i].first=max(v[N-i-1].second,rrange[i-1].first);
		rrange[i].second=min(v[N-i-1].first,rrange[i-1].second);
	}
	int ans = 0;
	REP(i,N-1){
		int ll = lrange[i].first,lr = lrange[i].second;
		int rl = rrange[N-i-2].first,rr = rrange[N-i-2].second;
		//cout<<ll<<" "<<lr<<" "<<rl<<" "<<rr<<endl;
		int tmp=0;
		if(lr>=ll)tmp+=lr-ll+1;
		if(rr>=rl)tmp+=rr-rl+1;
		CHMAX(ans,tmp);
	}
	
	
	cout<<max(add+ma,ans)<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    map<ll,ll> mp;
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        mp[a]++;
    }
    ll ans = 0;
    ll m1 = 0,m2 = 0;
    for(auto& x:mp){
        if(x.second>=4){
            ans = max(ans,x.first*x.first);
        }
        if(x.second>=2){
            if(m1<x.first){
                m2 = m1;
                m1 = x.first;
            }else if(m2<x.first){
                m2 = x.first;
            }
        }
    }
    ans = max(ans,m1*m2);
    cout << ans << "\n";
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 1000005

int main()
{
   string s;
   cin>>s;
   int k=0;
   for(int i=0;i<s.size();i++)
    if(s[i]=='o')
        k++;
   puts((15-s.size()+k)>=8?"YES":"NO");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string w;
  cin >>w;
  vector<char> result;
  for (int i=0;i<w.size();i++){
    if (w.at(i)=='B'){
      if (result.size() != 0){
        result.pop_back();
      }
    }
    else{
      result.push_back(w.at(i));
    }
  }
  for (char &x:result){
    cout<<x;
  }
  cout <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll S, W;
    cin >> S >> W;

    if(S<=W) cout << "unsafe" << endl;
    else cout << "safe" << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main(){
	int n,m;
	cin >> n >> m;	
	int l_max = 0;
	int r_min = n;
	int ans = 0;
	
	for(int i = 0; i < m; i++){
		int l,r;
		cin >> l >> r;
		if(r < l_max) {ans = 0; break;}
		if(l > r_min) {ans = 0; break;}
		
		l_max = (l>l_max)?l:l_max;
		r_min = (r<r_min)?r:r_min;
		ans = r_min - l_max + 1;
	}
	
	cout << ans << endl;
	return 0;
	
}

Measured memory_bytes: 3648
//PKMKB
#include <bits/stdc++.h>
#define ll long long int
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define scanarr(a,b,c) for( i=b;i<c;i++)cin>>a[i]
#define showarr(a,b,c) for( i=b;i<c;i++)cout<<a[i]<<' '
#define ln cout<<'\n'
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define MAX 100005
using namespace std;
////////////////////////////////////////////////////////////////CODE STARTS HERE////////////////////////////////////////////////////////////////

void solve(){
	
	int n, a, i;
	cin >> n;
	int ans = 0;

	for(i = 1; i <= n; i++){
		cin >> a;
		if(i&1 && a&1)
			ans++;
	}
	cout << ans <<endl;
}
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	#endif
	

		solve();
}

Measured memory_bytes: 3592
#!/usr/bin/python
# -*- coding: utf-8 -*-

N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = []
for i in range(M):
    AB.append(list(map(int,input().split())))

Kouho = [1]*N

for AiBi in AB:
    if H[AiBi[0]-1] > H[AiBi[1]-1]:
        Kouho[AiBi[1]-1] = 0
    elif H[AiBi[0]-1] < H[AiBi[1]-1]:
        Kouho[AiBi[0]-1] = 0
    else:
        Kouho[AiBi[0]-1] = 0
        Kouho[AiBi[1]-1] = 0

print(sum(Kouho))

Measured memory_bytes: 31764
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

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

	int x, y;
	cin >> x >> y;
	bool f = false;
	REP(i, x + 1) {
		if (2 * i + 4 * (x-i) == y) {
			f = true;
			break;
		}
	}

	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3636
N = int(input())
a = [0]
b = [0]
c = [0]
for i in range(N):
    a_i, b_i, c_i = map(int, input().split())
    a.append(a_i)
    b.append(b_i)
    c.append(c_i)


dp = [[0, 0, 0] for _ in range(N + 1)]
for i in range(1, N + 1):
    for j in range(3):
        l = [a[i], b[i], c[i]]
        for k in range(3):
            if k == j:
                continue
            dp[i][j] = max(dp[i][j], dp[i - 1][k] + l[k])

print(max(dp[N]))

Measured memory_bytes: 34656
//@author KhaledAlam.net
#include <bits/stdc++.h>
using namespace std;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	long long n,t,cnt=0,tmp,prev;
	cin>>n>>t;
	for (int i = 0; i < n; ++i) {
		cin>>tmp;
		if(!i){
			prev = tmp;
			continue;
		}
		cnt += min(t, tmp - prev);
		prev = tmp;
	}
	cout<<cnt+t;
}


Measured memory_bytes: 256
/* nothing is impossible */
#include <bits/stdc++.h> 
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;                                                                                                 
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}             
void no()
{
  cout<<"WA";
  exit(0);
}
int main()
{ 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 // freopen("input.txt", "r", stdin);
  st s;
  cin>>s;
  ll n=s.length();
  if(s[0]!='A'){
    no();
  }
  ll cnt=0;
  for(ll i=2;i<n-1;i++) if(s[i]=='C') cnt++;
  if(cnt!=1) no();
  forn(i,n)
  {
    if(isupper(s[i]))
    {
      if(s[i]!='A'&&s[i]!='C') no();
    }
  }
  cout<<"AC";
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void solve();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("error.txt", "w", stderr);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1;
    //cin>>t;
    while (t--)
    {
        solve();
        cout << "\n";
    }

    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
    return 0;
}
void solve()
{
    int n;
    cin >> n;
    int a[n + 1];
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    long long int comfort = 0;

    for (int i = 1; i <= n - 1; i++)
    {
        int k = floor(float(i) / 2);
        comfort += a[n - k];
    }

    cout << comfort;
}


Measured memory_bytes: 4616
import sys
N=int(input())
A=sorted([int(input()) for _ in range(N)])

tot=sum(A)
if tot%10 != 0:
    print(tot)
    sys.exit()
else:
    for i in range(N):
        if A[i]%10 != 0:
            print(tot-A[i])
            sys.exit()
print(0)



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

typedef long long ll;
typedef long double ld;
const ll M=1e9+7;
const ll MAXN=1e6+7;
const ld pi=acos(-1);

#define gi(n) ll n=read()
#define endl '\n'
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define per(i,a,b) for(ll i=b-1; i>=a; --i)

typedef vector<ll> V;
typedef vector<V> VV;
typedef set<ll> S;
typedef pair<ll,ll> pl;
typedef vector<pl> Vp;

#define all(v) v.begin(),v.end()
#define pb push_back
#define fs first
#define sc second

inline ll read(){
	ll x=0,ff=1;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
	while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*ff;
}

ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll pow1(ll p,ll d, ll P){return d?(pow1(p*p%P,d>>1,P)*(d&1?p%P:1))%P:1;}
ll mul(ll a,ll b,ll P){return b?(mul(a*2%P,b>>1,P)+(b&1?a:0))%P:0;}
ll pow1(ll p,ll d, ll P){return d?mul(pow1(mul(p,p,P),d>>1,P),(d&1?p%P:1),P):1;}

V prime;
bool is_composite[MAXN];
void sieve (ll n){
	std::fill (is_composite, is_composite + n, false);
	rep(i,2,n){
		if(!is_composite[i]) prime.pb(i);
		for(ll j = 0; j < prime.size() && i*prime[j] < n; ++j){
			is_composite[i*prime[j]] = true;
			if(i % prime[j] == 0) break;
		}
	}
}
ll modInverse(ll a, ll m){
	ll m0=m,y=0,x=1;
	if(m==1) return 0;
	while(a>1){
		ll q=a/m,t=m;
		m=a%m;
		a=t; 
		t=y;

		y = x-q*y; 
		x = t;
	}
	if(x<0) x += m0;
	return x; 
}

void doit(){
	gi(x);
	gi(k);
	gi(d);
	if(x<0) x=-x;
	if((ld)x/d>k) cout<<x-k*d;
	else{
		ll a=x/d;
		if(abs(k-a)&1){
			cout<<d-x%d;
		}
		else cout<<x%d;
//		cout<<min(x%d,d-x%d);
	}
	
}

int main(){
//	for(gi(t);t--;cout<<endl)
		doit();
	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
using namespace std;
int main(){
	int c1,c5,c10,c50,c100,c500;
	cin>>c1>>c5>>c10>>c50>>c100>>c500;
	if(c1*1+c5*5+c10*10+c50*50+c100*100+c500*500>=1000){
		cout<<"1"<<endl;
	}
	else{
		cout<<"0"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007ll
using namespace std;
int ara[200005];
ll bigmod(ll b, ll p)
{
    if(!p)return 1ll;
    ll ret= bigmod(b, p>>1);
    ret= (ret*ret)%mod;
    if(p&1ll)ret= (ret*b)%mod;
    return ret;
}
int main()
{
    int n, k, res= 1;
    scanf("%d %d", &n, &k);
    int neg= 0, z= 0;
    for(int i=1; i<=n; i++)
    scanf("%d", &ara[i]), z+= (ara[i]==0), neg+= (ara[i]<0);
    if(k==n || (neg==n && k&1))
    {
        sort(ara+1, ara+1+n, greater<int>());
        for(int i=1; i<=k; i++)
        res= (1LL*res*ara[i])%mod;
        if(res<0)res+= mod;
        printf("%d\n", res);
    }
    else if((n-z)<k || (z && (n-z)==k && (neg&1)) || (z && !(n-z-neg) && (k&1)))puts("0");
    else
    {
        vector<int>vp, vn;
        for(int i=1; i<=n; i++)
        if(ara[i]!=0)
        {
            if(ara[i]>0)vp.push_back(ara[i]);
            else vn.push_back(-ara[i]);
        }
        sort(vp.begin(), vp.end());
        sort(vn.begin(), vn.end());
        int lp= 0, ln= 0, c= 0;
        for(int i=1; i<=k; i++)
        {
            if(!vp.empty() && (vn.empty() || vp.back()>vn.back()))
            lp= vp.back(), vp.pop_back(), res= (1LL*res*lp)%mod;
            else ln= vn.back(), vn.pop_back(), res= (1LL*res*ln)%mod, c++;
        }
        if(c&1)
        {
            if(!vp.empty() && !vn.empty())
            {
                if(!lp)res= ((1LL*res*bigmod(ln, mod-2))%mod * 1LL*vp.back())%mod;
                else if((1LL*ln*vn.back())>(1LL*lp*vp.back()))
                res= ((1LL*res*bigmod(lp, mod-2))%mod * 1LL*vn.back())%mod;
                else res= ((1LL*res*bigmod(ln, mod-2))%mod * 1LL*vp.back())%mod;
            }
            else
            {
                if(vp.empty())res= ((1LL*res*bigmod(lp, mod-2))%mod * 1LL*vn.back())%mod;
                else res= ((1LL*res*bigmod(ln, mod-2))%mod * 1LL*vp.back())%mod;
            }
        }
        printf("%d\n", res);
    }
    return 0;
}


Measured memory_bytes: 5020
n=int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
total = 0
former = -2
for i in range(n):
  total += B[A[i]-1]
  if i != 0:
    if A[i] == A[i-1]+1:
      total += C[A[i-1]-1]
print(total)

Measured memory_bytes: 3064
number = input().split(" ")
N = int(number[0])
B = int(number[1])
R = int(number[2])

a = int(B+R)
b = int(N/a)
c = int(N%a)

if b <= 0:
    if R ==0:
        print(N)
    else:
        if B > N:
            print(N)
        else:
            print(B)
else:
    if R == 0:
        print(N)
    else:
        if B == 0:
            print(0)
        else:
            if c > B:
                print((b*B)+B)
            else:
                print((b*B)+c)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std; 
#define all(c) c.begin(),c.end()
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define tr(container,it) \
for(auto it=container.begin();it!=container.end();++it)
typedef long long ll ; 
typedef vector<int> vi;
#define mod 1000000007

int main()
{
 //freopen("input.txt","r",stdin);
 //freopen("output.txt","w",stdout);
 //  ios::sync_with_stdio(0);
// cin.tie(0);
ll n,w;
cin>>n>>w;
vi a(n),b(n);
for(ll i=0;i<n;++i)
cin>>a[i]>>b[i];
ll sum_value=accumulate(all(b),0);
vector<ll>dp(sum_value+1,1e18+5);
dp[0]=0;

for(int i=0;i<n;++i){
    for(int value_taken=sum_value-b[i];value_taken>=0;--value_taken)
    {
        dp[value_taken+b[i]]=min(dp[value_taken+b[i]],dp[value_taken]+a[i]);
    }
}
ll best=0;
for(int i=0;i<=sum_value;++i)
if(dp[i]<=w)
best=max(best,(ll)i);


cout<<best;
    return 0;
}

Measured memory_bytes: 4048
import numpy as np
n = int(input())
min = float("inf")
m = int(n/2 + 1)
for i in range(1,m):
    a = np.array([int(j) for j in list(str(i))])
    b = np.array([int(j) for j in list(str(n-i))])
    tmp = np.sum(a) + np.sum(b)
    if(tmp < min):
        min = tmp

print(min)

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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<double> v(N);
  double ans=0;
  for(double& a : v){
    cin >> a;
  }
  sort(v.begin(),v.end());
  ans=v.at(0);
  for(int i=1;i<N;i++){
    ans=(ans+v.at(i))/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<cstring>
#include<math.h>
#include<string>
#include<vector>
#include<map>
#include<numeric>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
ll a[101000];
ll ans[101000];
int main()
{
   int n;
   cin>>n;
   ll sum=0;
   for(int i=1;i<=n;i++)
   {
       scanf("%lld",&a[i]);
       sum+=a[i];
       a[i]*=2;
       ans[i]=a[i]-ans[i-1];
       sum-=ans[i];
   }
   ans[1]=-sum;
//   cout<<sum<<endl;
   for(int i=2;i<=n;i++)
    ans[i]=a[i-1]-ans[i-1];
   for(int i=1;i<=n;i++)
    cout<<ans[i]<<" ";
   cout<<endl;

}


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


int main (){
    int n ;
    cin >> n ;
    vector<ll> a (n) ;
    rep(i, n){
        cin >> a[i] ;
    }
    sort(a.rbegin(), a.rend()) ;
    ll ans = 0;
    ll t = n - 1 ;
    rep(i, n){
        int lim = 2 ;
        if(i == 0){
            lim = 1 ;
        }
        rep(j, lim){
            if(t > 0){
                ans += a[i] ;
                t-- ; 
            }
            
        }
    }
    cout << ans << endl ;
    return 0 ;
}

Measured memory_bytes: 4740
#include <iostream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

int main(){
    long long N,K,sum=0;
    cin >> N >> K;
    auto f = [](long long n, long long first){
        return (2* first + n-1)*n/2;
    };
    rep(i,N-K+2){
        long long min = f(K+i,0), max=f(K+i,N-K-i+1);
        sum+=max-min+1;
    }
    
    cout <<sum%(1000000007)<< endl;

    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void){

	int N;
	int x[200];
	int y[200];
	int i,n,d,max,min;
	while(scanf("%d",&N),N){
		x[0]=0;
		y[0]=0;
		for(i=1;i<N;i++){
			scanf("%d %d",&n,&d);
			switch(d){
				case 0:
					x[i]=x[n]-1;
					y[i]=y[n];
					break;
				case 1:
					x[i]=x[n];
					y[i]=y[n]-1;
					break;
				case 2:
					x[i]=x[n]+1;
					y[i]=y[n];
					break;
				case 3:
					x[i]=x[n];
					y[i]=y[n]+1;
					break;
			}
		}
		max=min=0;
		for(i=0;i<N;i++){
			if(x[i]>max)max=x[i];
			if(x[i]<min)min=x[i];
		}
		printf("%d ", max-min+1);
		max=min=0;
		for(i=0;i<N;i++){
			if(y[i]>max)max=y[i];
			if(y[i]<min)min=y[i];
		}
		printf("%d\n", max-min+1);
	}
	return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a == 1){
    a += 13;
  }
  if(b == 1){
    b += 13;
  }
  if(a == b){
    cout << "Draw" << endl;
  }
  else if(a > b){
    cout << "Alice" << endl;
  }else{
    cout << "Bob" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#define MAX 200002

using namespace std;

int main(){
  long long N,A[MAX];
  cin >> N;
  long long MAX_id=0,MAX2_id=0;
  A[MAX_id]= -1;
  A[MAX2_id]= -1;
  for(long long i = 1; i <= N;i++){
    cin >> A[i];
    if(A[MAX_id] <= A[i]){
      MAX2_id = MAX_id;
      MAX_id = i;
    }
    else if(A[MAX2_id] <= A[i]){
      MAX2_id = i;
    }
  }

  for(long long i = 1;i <= N;i++){
    if(i == MAX_id) cout << A[MAX2_id] << endl;
    else cout << A[MAX_id] << endl;
  }
}


Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
/*
*/
int main() {
  int n, m;
  cin >> n >> m;
  int a[51], b[51];
  int r[51] = {0};
  for(int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
    r[a[i]]++;
    r[b[i]]++;
  }
  for(int i = 1; i <= n; i++) cout << r[i] << endl;
  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define foro(i, n) for(i=0; i<n; i++)
#define forl(i, n) for(i=1; i<=n; i++)
#define x first
#define y second
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 1e18 + 1;

int main()
{
	int i, j, k, l, tmp;
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m;
	scanf("%d %d", &n, &m);
	int a[n];
	ll sum=0;
	foro(i, n){
		scanf("%d", a+i);
		sum += a[i];
	}
	double d = sum/(4.0 * m);
	sort(a, a+n);
	reverse(a, a+n);
	int sel=0;
	foro(i, n){
		if(a[i] >= d){
			sel++;
		}
	}
	sel >= m ? printf("Yes\n") : printf("No\n");
}


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

//mod逆元を使ったnCkの計算(速)
const int64_t MAX = 510000;
const int64_t MOD = 1000000007;

int64_t 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;
  }
}

// 二項係数計算
int64_t COM(int64_t n, int64_t 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(){
  int N, K;
  cin >> N >> K;
  int64_t ans = 0;
  COMinit();
  if(K == 1){
    ans = N*(N-1);
    ans %= MOD;
  }
  else if(K >= N-1){
    ans = COM(2*N-1,N);
  }
  else{
    for(int i=K+1; i<N; i++){
      ans += COM(N,i)*COM(N-1,N-i-1);
      ans %= MOD;
    }
    ans = COM(2*N-1,N) - ans;
    if(ans < 0){
      ans += MOD;
    }
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc140/abc140_c.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<int> b(N - 1);
  rep(i, N - 1) { cin >> b[i]; }

  ll ans = b[0];
  repi(i, 1, N - 1) { ans += min(b[i], b[i - 1]); }
  ans += b[b.size() - 1];

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{
    int N,K;
    cin >> N >> K;
    vl x(N),y(N);
    ve<pair<ll,ll>> A(N);
    rep(i,N){
        ll a,b;
        cin >> a >> b;
        x[i] = a,y[i] = b;
        A[i] = {a,b};
    }
    sor(A);
    //rep(i,N) cout << A[i].fi  << " " << A[i].se << endl;
    ll ans = 9000000000000000000;
    rep(i,N){
        vl B = {};
        ll sq_x = 0,sq_y = 0;
        reps(j,i,i+K-1) B.push_back(A[j].se);
        reps(j,i+K-1,N){
            sq_x = A[j].fi - A[i].fi;
            B.push_back(A[j].se);
            sort(all(B));
            //rep(p,N) cout << B[p]<< " ";
            //cout << endl;
            rep(k,int(B.size())){
                if(k+K-1 >= int(B.size())) break;
                sq_y = B[k+K-1]-B[k];
                //cout << sq_x << " " << sq_y << endl;
                ans = min(sq_x*sq_y,ans);
            }
        }
    }
    out(ans);
    
    



    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n=int(input())
a=list(map(int,input().split()))
ans=0
for j in range(1000):
    for i in range(n):
        if a[i]%2==0:
            a[i]=a[i]//2
        else:
            break
        if i==n-1:
            ans+=1
print(ans)

Measured memory_bytes: 3060