akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

    int n,k;
    cin >> n >>k;
    int a[n];
    for (int i=0;i<n;i++){
        int t;
        cin >> t;
        a[i] = t;
    }
    sort(a,a+n);
    int sum = 0;
    int count = 0;
    for (int j : a){
        if (count < k){
            sum += j;
        }
        count++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	string s,t;cin >> s >> t;
	set<int> st[26];
	rep(i,(int)s.size())st[s[i] - 'a'].insert(i);
	rep(i,(int)t.size()){
		if(st[t[i] - 'a'].size() == 0){
			cout << -1 << endl;
			return 0;
		}
	}
	int cur = 0;
	int T = 0;
	rep(i,(int)t.size()){
		auto tmp = st[t[i]- 'a'].lower_bound(cur);
		if(tmp == st[t[i] - 'a'].end()){
			T++;
			cur = 1+*st[t[i]-'a'].begin();
			continue;
		}
		cur = 1+*tmp;
	}
	int ret = T*(int)s.size() + cur;
	cout << ret << endl;
	return 0;
}	

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

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

const long long MOD = 1000000007;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  c=c-min(a-b,c);
  cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl


using namespace std;
using ll = long long;

ll a;
ll b;
ll f(ll x) {
    return -(((a * x) / b) - a * (x / b));
};


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

    ll left = 1;
    ll right = n;

    ll ans = 100100100100;
    while (right - left > 1){
        ll mid = (right + left) / 2;
        ll res = f(mid);
        if (res < ans) {
            ans = res;
            left = mid;
        } else {
            right = mid;
        }
    }

    ll res = f(n);
    if (res < ans) {
        ans = res;
    }


    cout << (ans * -1) << endl;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#define ll long long
#define rg register
struct ios{
	template<typename TP>
	inline ios operator >> (TP &x)
	{
		TP f=1;x=0;rg char c=getchar();
		for(;c>'9' || c<'0';c=getchar()) if(c=='-') f=-1;
		for(;c>='0' && c<='9';c=getchar()) x=(x<<3)+(x<<1)+(c^'0');
		x*=f;
		return *this;
	}
	template<typename TP>
	inline ios operator << (TP x)
	{
		int top=0,s[66];
		if(x<0) x=-x,putchar('-');
		if(!x) putchar ('0');
		while(x) s[++top]=x%10+'0',x/=10;
		while(top) putchar(s[top--]);
		return *this;
	}
	inline ios operator << (char s)
	{
		putchar(s);
		return *this;
	}
}io;
const int p=998244353;
const int N=3e5+5;
ll n,A,B,fac[N],inv[N];
ll k;
inline int pow(int a,int b)
{
	int ans=1;
	for(;b;b>>=1)
	{
		if(b&1) ans=(ll)ans*a%p;
		a=(ll)a*a%p;
	}
	return ans%p;
}
inline int C(int n,int m) {return (ll)fac[n]*inv[m]%p*inv[n-m]%p;}
int ans;
int main()
{
	io>>n>>A>>B>>k,inv[0]=fac[0]=1;
	if(!k) {io<<1;return 0;}
	for(rg int i=1;i<=n;++i) fac[i]=fac[i-1]*i%p;
	inv[n]=pow(fac[n],p-2);
	for(rg int i=n-1;i>=1;--i) inv[i]=inv[i+1]*(i+1)%p;
	for(rg int i=0;i<=n;++i)
	{
		ll tmp=k-(ll)i*A;
		if(tmp<0) break;
		if(tmp%B==0 && tmp/B<=n)
			ans=(ans+(ll)C(n,i)*C(n,tmp/B)%p)%p;
	}
	io<<ans;
	return 0;
} 

Measured memory_bytes: 4864
using System;

namespace ABC091_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);
            int c = int.Parse(array[2]);
            if(a + b >= c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
use std::io;
use std::collections::HashMap;
use std::cmp;

fn main() {
    let n = read_one::<usize>();
    let vn = read::<usize>();
    let mut odd = HashMap::new();
    let mut even = HashMap::new();

    for i in 0..n {
        if i % 2 == 0 {
            *even.entry(vn[i]).or_insert(0) += 1;
        } else {
            *odd.entry(vn[i]).or_insert(0) += 1;
        }
    }
    let mut even_key = 0;
    let mut odd_key = 0;
    let mut even_max = 0;
    let mut even_2nd = 0;
    let mut odd_max = 0;
    let mut odd_2nd = 0;
    for (k, v) in even.iter() {
        if *v >= even_2nd {
            if *v >= even_max {
                even_key = *k;
                even_2nd = even_max;
                even_max = *v;
            } else {
                even_2nd = *v;
            }
        }
    }

    for (k, v) in odd.iter() {
        if *v >= odd_2nd {
            if *v >= odd_max {
                odd_key = *k;
                odd_2nd = odd_max;
                odd_max = *v;
            } else {
                odd_2nd = *v;
            }
        }
    }

    let diff = if odd_key == even_key {
        cmp::max(odd_2nd + even_max, odd_max + even_2nd)
    } else {
        odd_max + even_max
    };

    let cnt = n - diff;
    println!("{}", cnt);
}


#[allow(unused)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}


#[allow(unused)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 11372
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;

int main(void){
   int64_t n;
   int64_t sum = 0;
   cin >> n;
   int64_t a[n], acc[n+1];
   for(int i=0; i<n+1; i++)
   {
        acc[i] = 0;
   }
   for(int i=0; i<n; i++)
   {
        cin >> a[i];
        a[i] %= mod;
        acc[i+1] += acc[i] + a[i];
   }
   
   for(int i=0; i<n; i++)
   {
        sum += a[i] * ((acc[n]-acc[i+1]) % mod);
        sum %= mod;
   }
   
   cout << sum << endl;
}


Measured memory_bytes: 6764
#include<bits/stdc++.h>
using namespace std;
const int maxm=4;
int f[2][maxm],N,a,b,c;
int main()
{
	memset(f,0,sizeof(f));
	cin>>N;
	for(int i=1;i<=N;++i)
	{
		cin>>a>>b>>c;
		f[i%2][1]=max(f[(i-1)%2][2],f[(i-1)%2][3])+a;
		f[i%2][2]=max(f[(i-1)%2][1],f[(i-1)%2][3])+b;
		f[i%2][3]=max(f[(i-1)%2][1],f[(i-1)%2][2])+c;
	}
	cout<<max(f[N%2][1],max(f[N%2][2],f[N%2][3]));
	return 0;
 } 

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int n;
double sin60, cos60;

void fractal(double x1, double y1, double x2, double y2, int d) {
	if (d == n) {
		cout << x2 << " " << y2 << endl;
		return;
	}
	
	double sx, sy, tx, ty, ux, uy;
	sx = (2 * x1 + x2) / 3;
	sy = (2 * y1 + y2) / 3;
	tx = (x1 + 2 * x2) / 3;
	ty = (y1 + 2 * y2) / 3;
	ux = (tx - sx) * cos60 - (ty - sy) * sin60 + sx;
	uy = (tx - sx) * sin60 + (ty - sy) * cos60 + sy;

	fractal(x1, y1, sx, sy, d + 1);
	fractal(sx, sy, ux, uy, d + 1);
	fractal(ux, uy, tx, ty, d + 1);
	fractal(tx, ty, x2, y2, d + 1);
}

int main() {
	sin60 = sin(M_PI / 3);
	cos60 = cos(M_PI / 3);
	cin >> n;

	cout << "0 0" << endl;
	fractal(0, 0, 100, 0, 0);

	return 0;
}

Measured memory_bytes: 1248
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	static final int INF = 1000000000;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		Node[] inn = new Node[101];
		int[][] dp = new int[101][101];
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int l = sc.nextInt();
			if(n == 0 && m == 0 & l == 0){
				break;
			}
			for(int i = 1; i <= n; i++){
				inn[i] = new Node(i);
			}
			Node start = inn[1];
			Node goal = inn[n];
			for(int i = 0; i < m; i++){
				int a = sc.nextInt();
				int b = sc.nextInt();
				int d = sc.nextInt();
				int e = sc.nextInt();
				
				inn[a].edges.add(new Edge(e, d, inn[b]));
				inn[b].edges.add(new Edge(e, d, inn[a]));
			}
			boolean[] flg = new boolean[n + 1];
			for(int i = 0; i <= n; i++){
				flg[i] = false;
			}
			for(int i = 1; i <= n; i++){
				for(int j = 0; j <= l; j++){
					dp[i][j] = INF;
				}
			}
			PriorityQueue<Node> q = new PriorityQueue<Node>();
			int len = 0;
			dp[1][0] = 0;
			q.add(inn[1]);
			while(!q.isEmpty()){
				Node node = q.poll();
				len = node.c;
				for(Edge e : node.edges){
					// ???????????£????????????
					if(len + e.d <= l){ // ?????¨??????????????????
						// ?????¨?????£?????´???????\???????????????°????°???????????????????
						if(dp[e.t.n][len + e.d] > dp[node.n][len]){
							Node nnode = new Node(e.t.n);
							nnode.edges = e.t.edges;
							nnode.c = len + e.d;
							q.add(nnode);
							dp[e.t.n][len + e.d] = dp[node.n][len] ;
						}
					}
					// ????????£???????????????
					// ?????¨??????????????´???????\???????????????°????????????
					if(dp[e.t.n][len] > dp[node.n][len] + e.e){
						Node nnode = new Node(e.t.n);
						nnode.edges = e.t.edges;
						nnode.c = len;
						q.add(nnode);
						dp[e.t.n][len] = dp[node.n][len] + e.e;
					}
				}
			}
			
			int min = INF;
			for(int i = 0; i <= l; i++){
				min = Math.min(min, dp[n][i]);
			}
			System.out.println(min);
//			System.out.println(func(start, l, goal, flg));
			
		}
		
		
		sc.close();
	}
	static int func(Node node, int cap, Node goal, boolean[] flg){
		int res = 1000000000;
		if(node.equals(goal)){
			return 0;
		}
		for(Edge e : node.edges){
			if(!flg[e.t.n]){
				if(e.d > cap){
					flg[node.n] = true;
					res = Math.min(res, func(e.t, cap, goal, flg) + e.e);
					flg[node.n] = false;
				}else{
					flg[node.n] = true;
					res = Math.min(res, Math.min(func(e.t, cap - e.d, goal, flg), func(e.t, cap, goal, flg) + e.e));
					flg[node.n] = false;
				}
			}
		}
		
		return res;
	}

}
class Node implements Comparable<Node>{
	int n;
	int c;
	LinkedList<Edge> edges;
	Node(int number){
		edges = new LinkedList<Edge>();
		n = number;
		c = 0;
	}
	@Override
	public int compareTo(Node o) {
		// TODO Auto-generated method stub
		return n - o.n;
	}
}
class Edge{
	boolean flg;
	int e;
	int d;
	Node t;
	Edge(int enemy, int dist, Node to){
		e = enemy;
		d = dist;
		t = to;
		flg = false;
	}
}

Measured memory_bytes: 81832
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using v = vector<ll>;
using p = pair<ll,ll>;

void a(){
    ll h,a;
    cin >> h >> a;
    cout << (h%a==0? h/a:h/a+1);
}

int main(){
    a();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int l, r, d, ctr = 0;
  scanf("%d %d %d", &l, &r, &d);

  for (int i = l; i <= r; i++)
  {
    if (i % d == 0)
    {
      ctr++;
    }
  }
  printf("%d\n", ctr);
  return 0;
}


Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;

int main(){
  /*
  int tt; cin >> tt;
  vector<string> ans = {};
  while(tt--){
    
  }
  rep(i,ans.size()) cout << ans[i] << "\n";
  */
  int n; cin >> n;
  int f[1001] = {};
  for(int i = 2; i <= n; i++){
    int p = i;
    for(int j = 2; j*j <= i; j++){
      while(p % j == 0 && p > 1){
        f[j]++;
        p /= j;
      }
    }
    if(p!=1) f[p]++;
  }

  ll ans = 1;
  rep(i,n+1){
    ans = (ans*(f[i]+1))%MOD;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n[50]={0},m,i,j,k,l,c=0;
	while(scanf("%d",&m)!=-1){
		for(i=0;i<10;i++){
			for(j=0;j<10;j++){
				for(k=0;k<10;k++){
					for(l=0;l<10;l++){
						if (i+j+k+l==m)n[c]++;
					}
				}
			}
		}
		c++;
	}
	for(i=0;i<c;i++)printf("%d\n",n[i]);
	return 0;
}

Measured memory_bytes: 592
import math
n = int(input())

inter = int(math.sqrt(n))

count = (inter)**2
if n / inter == inter:
  count -= 1

for a in range(1, inter+2):
  for b in range(inter+1, n):
    if a*b < n:
      count += 2
    else:
      break
      
print(count)


Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int N;
    cin >> N;
    vector<int> C(N-1), S(N-1), F(N-1);
    REP(i, N-1) cin >> C[i] >> S[i] >> F[i];
    REP(i, N) {
        int t = 0;
        for (int j = i; j < N - 1; j++) {
            if (t < S[j]) t = S[j];
            else t = (t + F[j] - 1) / F[j] * F[j];
            t += C[j];
        }
        cout << t << endl;
    }
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vector<pair<int, int>> p(n);
  for(int i=0;i<n;++i) {
    cin >> p[i].second >> p[i].first;
  }
  sort(p.begin(), p.end());
  int now = 0;
  bool ok = true;
  for(int i=0;i<n;++i) {
    now += p[i].second;
    if(now > p[i].first) {
      ok = false;
      break;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  ll k;
  cin >> k;
  ll cnt = 0;
  while(a >= b){
    b *= 2;
    cnt++;
  }
  while(b >= c){
    c *= 2;
    cnt++;
  }
  if(k >= cnt){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3608
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#include <bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
bitset<5000000> bit;
int main(){
    int n;
    cin >> n;
    int sum = 0;
    bit[0] = 1;
    while(n--){
        int a;
        cin >> a;
        sum += a;
        bit |= bit<<a;
    }
    for(int i = (sum+1)/2;i <= sum ; i++){
        if(bit[i]){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

void shot(int &p, int d, int l){ //点pから点dへ距離lだけ進んだ点を返す,p=dの時は正方向移動
  if (p==d){ p+=l; return;}
  p+=(d-p)/abs(d-p)*l;
  return;
}

int main(){
  int k,x,y;
  cin>> k >> x >> y;
  
  if (k%2==0 && (abs(x)+abs(y))%2==1){ //不可能
    cout<< -1 << endl;
    return 0;
  }
  
  int nx,ny; nx=ny=0;
  vector<pair<int,int>> v;
  while (abs(x-nx)+abs(y-ny)>=2*k){ //最終調整の前まで単純に近づく
    if (abs(x-nx)>=k){
      shot(nx,x,k);
      v.push_back(make_pair(nx,ny));
      continue;
    }
    if (abs(y-ny)>=k){
      shot(ny,y,k);
      v.push_back(make_pair(nx,ny));
      continue;
    }
  }
  
  int k2=abs(x-nx)+abs(y-ny);
  if (k2%k==0){ //残りの合計距離がkで割り切れる(上記whileの条件上k2=kしかない）
    v.push_back(make_pair(x,y));
  }
  else{
    if (k2%2==1){ //残りの合計距離を偶数にする
      if (abs(x-nx)>abs(y-ny)) shot(nx,x,k); //残り距離の長い方を移動させて調整
      else shot(ny,y,k);
      v.push_back(make_pair(nx,ny));
      k2=abs(x-nx)+abs(y-ny);
    }
    k2/=2; //残り2回のうち一回でゴールに近づく距離。k-k2は調整のため行って戻って0にする距離
    
    if (abs(x-nx)>abs(y-ny)){
      shot(nx,x,k2-abs(y-ny));
      shot(ny,y,k-k2+abs(y-ny)); //符号のことを忘れていた。結局shot()の方を直した
    }
    else{
      shot(ny,y,k2-abs(x-nx));
      shot(nx,x,k-k2+abs(x-nx));
    }
    v.push_back(make_pair(nx,ny));
    v.push_back(make_pair(x,y));
  }
 
  cout<< v.size() <<endl;
  for (auto p: v) cout<< p.first <<" "<< p.second <<endl;
  return 0;
}

Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	int n,k;
  	cin>>n>>k;
  	if(k==1 || n==k)
    {
      	cout<<0;
    }
  	else
    {
      	cout<<n-k;
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(ll i = 0;i < (n); ++i)
typedef long long ll;
typedef long double la;
using namespace std;
 
int main(){
    int n,m;
    cin >> n >> m;
    int ACnum=0,WAnum=0;
    vector<int> WA(n);
    vector<int> AC(n);
    rep(i,n){
        WA[i] = 0;
        AC[i] = false;
    }
    pair<int, string> p[m];
    rep(i,m){
        int p;
        string s;
        cin >> p >> s;
        if(AC[p]) continue;
        if(s == "AC"){
            AC[p] = true;
            ACnum++;
            WAnum += WA[p];
        }else{
            WA[p]++;
        }
    }
    cout << ACnum << ' ' << WAnum << endl;
} 

Measured memory_bytes: 2560
#include <functional>
#include <stdexcept>
#include <streambuf>
#include <exception>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <typeinfo>
#include <utility>
#include <complex>
#include <numeric>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <locale>
#include <memory>
#include <iosfwd>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <ios>
#include <new>
#include <set>
 
#define int long long
#define ll long long 
#define F first
#define S second
#define make make_pair
#define pb push_back
#define sz(x) (ll)(x.size()) 
#define all(x) x.begin (), x.end ()

using namespace std;

typedef long double ld;

const int MOD = (int)1e9 + 7;
const int N = (int)1e6+ 222;
const ll INF = (ll)1e18;
const double eps = (double)1e-6;

int n, a[N];

void solve () { 
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        a[i] %= 2;
    }
    for (int i = 1; i <= n; ++i) {
        if (a[i] == 1) cnt++;
    }
    if (cnt % 2 == 1) {
        cout << "NO";
        return;
    }
    cout << "YES";
}


signed main () {
    #ifdef Maga
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int t = 1;
    while (t --) {
        solve ();
    }
    return 0;
}





Measured memory_bytes: 1024
#include "bits/stdc++.h"
 
using namespace std;
 
 
const int N = 100100;
const long long inf = 1e9;
#define ll long long
#define fr(i,a,n) for (int i=a;i<n;i++)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vipb(v) int x;cin>>x;v.pb(x);
#define vllpb(v) ll x;cin>>x;v.pb(x);
#define in(x) cin>>x;
#define in2(x,y) cin >> x >> y;
#define in3(x,y,z) cin>>x>>y>>z;
#define in4(a,x,y,z) cin>>a>>x>>y>>z;
#define in5(a,b,x,y,z) cin>>a>>b>>x>>y>>z;
 
 
typedef vector<int> VI;
typedef vector<ll> VL;
 
ll n, m, k;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	ll ans = (n / 500) * 1000;
	n %= 500;
	ans += (n / 5) * 5;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int A,B;
int p[4010];
bool ans[4010];
queue<int> Q[2];

bool query(int x , int y){
	char c;
	printf("? %d %d\n" , x , y);
	fflush(stdout);
	scanf(" %c" , &c);
	return c == 'Y';
}

int main(){
	scanf("%d%d" , &A , &B);
	if(A <= B){
		printf("Impossible\n");
		return 0;
	}
	int N = A+B;
	repp(i,0,N){
		Q[0].push(i);
	}
	int x = 0 , t = 0;
	while(!Q[t%2].empty()){
		while(!Q[t%2].empty()){
			int u = Q[t%2].front(); Q[t%2].pop();
			if(Q[t%2].empty()){
				x = u;
				p[u] = -1;
				break;
			}
			int v = Q[t%2].front(); Q[t%2].pop();
			if(query(u,v) && query(v,u)){
				p[v] = u;
				Q[(t+1)%2].push(u);
			} else {
				p[u] = p[v] = -1;
			}
		}
		++t;
	}
	ans[x] = 1;
	p[x] = x;
	repp(i,0,N){
		if(p[i] < 0){
			ans[i] = query(x,i);
		} else {
			ans[i] = ans[p[i]];
		}
	}
	printf("! ");
	repp(i,0,N){
		printf("%d" , ans[i] ? 1 : 0);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 848
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    REP(i, n + 1) {
        string digit = to_string(i);
        int digit_sum = 0;
        REP(j, digit.size()) digit_sum += digit[j] - '0';
        if(a <= digit_sum and digit_sum <= b) ans += i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Sat Jun  9 15:28:55 2018
//
package main

import "fmt"

var N, M, K int

func main() {
	fmt.Scan(&N, &M, &K)
	for i := 0; i <= M; i++ {
		for j := 0; j <= N; j++ {
			if K == i*N+j*M-2*i*j {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  explicit FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  double H, d, X;
  cin >> d >> H >> X;
  double h = X / (d * d);
  if(h < H / 2) cout << 90.0 - atan(2.0 * d * h / H / H) / acos(-1) * 180.0 << endl;
  else cout << 90.0 - atan(d / (2 * (H - h))) / acos(-1) * 180.0 << endl;
}





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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

int lpf[10000009];

void sieve()
{
	int i,j;
	for(i=1;i<=10000000;i+=2) lpf[i]=i;
	for(i=2;i<=10000000;i+=2) lpf[i]=2;
	for(i=3;i*i<=10000000;i++)
	if(lpf[i]==i)
	{
		for(j=i*i;j<=10000000;j+=i)
		if(lpf[j]==j)
		lpf[j]=i;
	}
}

int dp[10000000];

void solve()
{
	sieve();
	int n,i;
	cin>>n;
	dp[1]=1;
	for(i=2;i<=n;i++)
	{
		dp[i]=dp[i/lpf[i]];
		int temp=i;
		int cnt=0;
		while(temp%lpf[i]==0)
		{
			temp/=lpf[i];
			cnt++;
		}
		dp[i] = 1LL*dp[i]*(cnt+1)/cnt;
	}
	ll sum=0;
	for(i=1;i<=n;i++)
	sum += 1LL*dp[i]*i;
	cout<<sum<<'\n';
}

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


Measured memory_bytes: 81772
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL<<60;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

class unionfind {
	VI par, rank;
public:
	void init(int N) {
		par.clear();
		rank.clear();
		for (int i = 0; i < N; i++) par.push_back(i);
		for (int i = 0; i < N; i++) rank.push_back(1);
	}
	int root(int x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	int size(int x) {
		if (par[x] == x)return rank[x];
		return size(par[x]);
	}
	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;
		if (rank[rx] < rank[ry]) {
			par[rx] = ry;
			rank[ry] += rank[rx];
		}
		else {
			par[ry] = rx;
			rank[rx] += rank[ry];
		}
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	VI a(m), b(m);
	FOR(i, m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}

	unionfind uf;
	int ans = 0;
	FOR(i, m) {
		uf.init(n);
		FOR(j, m) {
			if (i != j)uf.unite(a[j], b[j]);
		}
		if (uf.size(0) != n)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())

MOD = 10**9 + 7
N = pow(2,n,MOD)

def com(n,r):
    s = 1
    for i in range(n-r+1, n+1):
        s *= i
        s %= MOD

    t = 1
    for j in range(1,r+1):
        t *= j
        t %= MOD


    return s * pow(t,MOD-2, MOD) % MOD

print((N - com(n, a) - com(n, b) - 1) % (MOD))

Measured memory_bytes: 9192
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int N=gi();
	    int[] D=new int[N];
	    int s=0;
	  for (int i=0; i<N;i++) {
	    	D[i]=gi();
	    }  
      
      for (int i=0; i<N;i++) {
	    	for (int j=i+1; j<N;j++) {
		    	s+=D[i]*D[j];
		    }
	    }



        System.out.print(s);

//        if (m%2==0) {
//        	System.out.println(m/2);
//        }else{
//        	System.out.println((m+1)/2);
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int x, a, b;
    cin >> x >> a >> b;

    // 処理
    // 出力
    cout << (abs(x - a) < abs(x - b) ? "A" : "B") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
using ll = long long;

const int N = 2005;
const int MOD = 1e9 + 7;

int dp[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    dp[0] = 1;
    for (int i = 1; i <= n; i++) {
    	for (int j = 3; j <= i; j++) {
    		dp[i] = (dp[i] + dp[i - j]) % MOD;
    	}
    }
    cout << dp[n] << '\n';
    return 0;
}

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

const long long INF = 1e9;
const int n_MAX = 100010;

int main() {
  int n;
  int dp[n_MAX] = {INF};

  cin >> n;

  dp[0] = 0;

  for (int i = 1; i <= n; ++i) {
    int rep = dp[i - 1] + 1;

    for (int j = 6; j <= i; j *= 6) {
      rep = min(rep, dp[i - j] + 1);
    }

    for (int j = 9; j <= i; j *= 9) {
      rep = min(rep, dp[i - j] + 1);
    }

    dp[i] = rep;
  }

  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 768
open Batteries
let x, n = Scanf.sscanf (read_line()) "%d %d" (fun  x n-> x ,n)
let p_ = read_line ()
let p = (if p_ = "" then [] else p_ |> String.split_on_char ' ' |> List.map int_of_string)
let rec loop i =
  if List.mem (x - i) p then 
  if List.mem (x + i) p then (loop (i+1))
  else (x + i)
  else (x - i)
let _ = Printf.printf "%d\n" @@ loop 0

Measured memory_bytes: 5432
#include<bits/stdc++.h>
using namespace std;
int n,p;
string s;
int d[200];
char c[200];
 
int solve(){
  if('0'<=c[p]&&c[p]<='9')return c[p++]-'0';
  int k=p++,res=(c[k]=='*'?1:0);
  while(d[p]==d[k]+1){
    if(c[k]=='+')res+=solve();
    if(c[k]=='*')res*=solve();
  }
  return res;
}
 
int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    d[n]=0;
    for(int i=0;i<n;i++){
      cin>>s;
      d[i]=s.size();
      c[i]=s[s.size()-1];
    }
    p=0;
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3156
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	vector<char>al(26);
	al = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
	vector<char>AL(26);
	AL = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
	vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
	int H, W;
	cin >> H >> W;
	vector<vector<string>>V(H, vector<string>(W));
	rep(i, H) {
		rep(j, W) {
			cin >> V[i][j];
		}
	}
	rep(i, H) {
		rep(j, W) {
			if (V[i][j] == "snuke") {
				cout << AL[j] << i+1 << endl;
			}
		}
	}
}


Measured memory_bytes: 256
#include <stdio.h>

void dfs(int*,int*,int);
void visit(int*,int*,int*,int,int*,int);
void push(int *S,int *p,int key){
  (*p)++;
  S[*p]=key;
}
  
int pop(int *S,int *p){
  (*p)--;
  return S[*p+1];
}

int graph[101][101];
  

int main(){
  int i,j,key1,key2,roop,n,d[101],f[101];

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      graph[i][j]=0;
    }
  }
 

  for(i=1;i<=n;i++){
    scanf("%d%d",&key1,&roop);

    for(j=1;j<=roop;j++){
      scanf("%d",&key2);

      graph[key1][key2]=1;
    }
  }

  /*
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      printf(" %d",graph[i][j]);
    }
    printf("\n");
  }
  */
  

  dfs(d,f,n);

  for(i=1;i<=n;i++){
    printf("%d %d %d\n",i,d[i],f[i]);
  }
  
  return 0;
}

void dfs(int *d,int *f,int n){
  int u,color[101],time=0;

  for(u=1;u<=n;u++) color[u]=1;

  for(u=1;u<=n;u++){
    
    if(color[u]) visit(d,f,color,n,&time,u);
  }
  
}

void visit(int *d,int *f,int *color,int n,int *time,int key){
  int i,j,S[101],p=-1,u,v;
  
  push(S,&p,key);
  color[key]=0;
  d[key]= ++(*time);

  
  while(p!=-1){
    //u=pop(S,&p);
    u=S[p];
    
    
    v=0;
    for(i=1;i<=n;i++){
      if(graph[u][i]==1 && color[i]==1){//ここが違う！
	v=i;
	break;
      }
    }
    
    if(v){
      push(S,&p,v);
      color[v]=0;
      d[v]=++(*time);
    }
    else{
      pop(S,&p);
      f[u]=++(*time);
    }

  }

}



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

#define min(x,y) (x>y)?y:x

int main() {
	int i, N;
	int A[100010];
	long long P=0, T;
	scanf("%d", &N);
	for (i=0;i<N;i++) scanf("%d", &A[i]);
	for (i=0;i<N;i++) {
		if (i==N-1) {
			P += A[N-1]/2;
		}/* else if (A[i+1]==0) {
			T = A[i]/2;
			P += T;
			A[i] -= 2*T;
		}*/ else if (A[i]==0) continue;
		else {
			P += A[i]/2;
			A[i] %= 2;
			T = min(A[i], A[i+1]);
			P += T;
			A[i] -= T;
			A[i+1] -= T;
		}
	}

	printf("%lld\n", P);

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
using namespace std;

int N;
long long W;
vector<long long> vec[5];
long long sum[5][210];

int main() {
    while (cin >> N >> W) {
        for (int i = 0; i < 5; ++i) vec[i].clear();
        long long w0, w, v;
        cin >> w0 >> v;
        vec[0].push_back(v);
        for (int i = 1; i < N; ++i) {
            cin >> w >> v;
            vec[w-w0].push_back(v);
        }
        for (int i = 0; i < 4; ++i) sort(vec[i].begin(), vec[i].end(), greater<long long>());
        
        for (int it = 0; it < 4; ++it) {
            sum[it][0] = 0;
            for (int i = 0; i < 110; ++i) {
                sum[it][i+1] = sum[it][i] + (i < vec[it].size() ? vec[it][i] : 0);
            }
        }
        
        long long res = 0;
        for (int a = 0; a <= N  && w0*a <= W; ++a) {
            for (int b = 0; b+a <= N && w0*a + (w0+1)*b <= W; ++b) {
                for (int c = 0; c+a+b <= N && w0*a + (w0+1)*b + (w0+2)*c <= W; ++c) {
                    long long d = min((long long)N-a-b-c, (W-w0*a-(w0+1)*b-(w0+2)*c)/(w0+3));
                    if (d < 0) continue;
                    long long val = sum[0][a] + sum[1][b] + sum[2][c] + sum[3][d];
                    
                    //cout << a << ", " << b << ", " << c << ", " << d << ": " << sum[0][a] << ", " << sum[1][b] << ", " << sum[2][c] << ", " << sum[3][d] << endl;
                    
                    if (res < val) res = val;
                }
            }
        }
        
        cout << res << endl;
    }
}



Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]

dp = [0]*n
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
    dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]), dp[i-1] + abs(h[i]-h[i-1]))

print(dp[-1])


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

const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n; cin >> n;
	int ans;
	
	vector<int> h(n); rep(i,n) cin >> h[i];
	vector<int> dp(n+1,INT_MAX);
	
	dp[0]=0; dp[1]=abs(h[1]-h[0]);
	
	for(int i=0;i<n-1;i++){
		
		int d1=h[i]-h[i+1]; d1=abs(d1);
		int d2=h[i]-h[i+2]; d2=abs(d2);
		
		chmin(dp[i+1],dp[i]+d1);
		chmin(dp[i+2],dp[i]+d2);
	}
	
	ans=dp[n-1];
	
	cout << ans << "\n";
	
	return 0;
}


//vector<int> a(n);  sort(a.begin(),a.end());
//cout << "test" << "\n";


//g++ -o a a.cpp


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

#define inf 0x3f3f3f3f3f3f3f3f
#define ll long long

// Knapsack - O(n*MAXV)

// Bruxaria do Errichto
int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, W;
	scanf("%d%d",&n,&W);
	vector<ll> val(n),weight(n);
	for(int i=0;i<n;i++)
		scanf("%lld %lld",&weight[i],&val[i]);
	ll sum = 0;
	for(int x: val) sum+=x;
	vector<ll> dp (sum + 1,inf);
	dp[0]=0;
	for(int i=0;i<n;i++)
		for(int value= sum-val[i];value>=0;value--)
			dp[value+val[i]] = min(dp[value+val[i]],dp[value]+weight[i]);
	int ans = 0;
	for(int i = 0;i<=sum;i++)
		if(dp[i]<=W)
			ans = max(ans,i);
	printf("%d\n",ans);
}

Measured memory_bytes: 1024
import numpy as np
from scipy.spatial import distance

d = list(map(int, input().split()))
N = d[0]
D = d[1]

l = [0]*N

for i in range(N):
    l[i] = list(map(int, input().split()))

dist_M = distance.cdist(l, l, metric='euclidean')

count = 0

for i in range(N):
    for j in range(i+1,N):
        if dist_M[i][j] %1 == 0 :
            count += 1

print(count)

Measured memory_bytes: 19588
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n;
string s[10100];
int as=0;
int bs=0;
int absa=0;
int ans=0;

int main(){
	cin>>n;
	REP(i,n){
		cin>>s[i];
		for(int j=0;j<s[i].size()-1;j++){
			if(s[i][j]=='A'&&s[i][j+1]=='B'){
				ans++;
			}
		}
		if(s[i][0]=='B'&&s[i][s[i].size()-1]=='A'){
			absa++;
		}else if(s[i][0]=='B'){
			bs++;
		}else if(s[i][s[i].size()-1]=='A'){
			as++;
		}
	}
	
	if(as==0&&bs==0){
		if(absa>=1){
			cout<<absa-1+ans<<endl;
			return 0;
		}else{
			cout<<ans<<endl;
			return 0;
		}
	}
	as+=absa;
	bs+=absa;
	cout<<min(as,bs)+ans<<endl;
	return 0;
}
	
	

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

const int mod = 1e9 + 7;
vector<ll> fact;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * x % mod;
            x = x * x % mod;
            n >>= 1;
    }
    return res;
}
    
void init() {
    fact.resize(10000);
    fact[0] = 1;
    for (ll i = 1; i < 10000; i++) {
        fact[i] = fact[i - 1] * i;
        fact[i] %= mod;
    }
}

ll inv(ll x) {
    return mod_pow(x, mod - 2, mod);
}

ll comb(ll n, ll k) {
    if (k < 0 || k > n) return 0;
    return ((fact[n] * inv(fact[k])) % mod * inv(fact[n - k])) % mod;
}

void solve() {
    int N, K;
    cin >> N >> K;
    init();

    for (int k = 1; k <= K; k++) {
        cout << comb(K - 1, k - 1) * comb(N - K + 1, k) % mod << endl;
    }
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 384
using System;
class Aoj
{
    public static void Main()
    {
        String[] st = Console.ReadLine().Split(' ');
        int a = int.Parse(st[0]);
        int b = int.Parse(st[1]);
        int d = a / b;
        int r = a % b;
        double f =Math.Round( (double)a / b,6);
        Console.WriteLine(d + " " + r + " " + f);

    }

}

Measured memory_bytes: 9408
#include <stdio.h>

int main () {
	char str[11] = {0};
	char modstr[11] = {0};
	scanf("%s", str);
	
	int j = 0;
	for (int i = 0; i < 10; i++) {
		if (str[i] == '0') {
			modstr[j] = '0';				
			j++;
		}
		else if (str[i] == '1') {
			modstr[j] = '1';
			j++; 
		}
		else if (str[i] == 'B') {
			if (j != 0) {
				j--;
				modstr[j] = '\0';
			}
		}
	}
	printf("%s", modstr);
	
	return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int n;
    float x;
    string u;

    cin >> n;

    float c = 0.0;
    float bit = 380000.0;
    for (int i=0; i<n; i++) {

        cin >> x >> u;
        if (u[0] == 'J') c += x;
        else c +=x*bit;
    }

    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
AB=[]
for i in range(N):
    ab=list(map(int,input().split()))
    AB.append(ab)
AB=sorted(AB)
c=-1
while M>0:
    M-=AB[c+1][1]
    c+=1
S=[(AB[c][1]+M)*AB[c][0]]
for k in range(c):
    S.append(AB[k][0]*AB[k][1])
print(sum(S))


Measured memory_bytes: 28880
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(){
    int n;
    cin >> n;
    if(n ==1||n ==2||n ==3||n ==5||n ==6||n ==9||n ==10||n ==13||n ==17){
      cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }

  return 0;
  }

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main(void)
{
    int64_t N;
    cin >> N;

    map<string, int> m;

    for (int i = 0; i < N; ++i)
    {
        string s;
        cin >> s;
        if (m[s]) ++m[s];
        else m[s] = 1;
    }

    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
    
    return 0;
}


Measured memory_bytes: 3232
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<int> l(n+1, 0), r(n+1, 0);
    for(int i = 1; i <= n; i++){
        int a;
        cin >> a;
        if(i-a >= 1) l[i-a]++;
        if(i+a <= n) r[i+a]++;
    }

    ll ans = 0;
    for(int i = 1; i <= n; i++){
        ans += (ll)l[i] * r[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 4844