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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 2005, mod = 1000000007;
int n, m, u[MX], v[MX], w[MX], p[MX], q[MX], a, b;
ll x, res;

int parent (int a) {
	return a == p[a] ? a : p[a] = parent(p[a]);
}

bool join (int a, int b) {
	a = parent(a), b = parent(b);
	if (a == b) return 0;
	p[a] = b;
	return 1;
}

ll pot (ll b, int p) {
	ll res = 1;
	while (p) {
		if (p & 1) (res *= b) %= mod;
		(b *= b) %= mod;
		p /= 2;
	}
	return res;
}

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

	cin >> n >> m >> x;

	forn (i, m) {
		cin >> u[i] >> v[i] >> w[i];
		q[i] = i;
	}

	sort(q, q + m, [&] (int i, int j) {
		return w[i] < w[j];
	});

	for (int j = 1; j < m; j++) {
		iota(p + 1, p + n + 1, 1);
		ll s = w[q[0]] + w[q[j]];

		join(u[q[0]], v[q[0]]);
		join(u[q[j]], v[q[j]]);

		for (int _ = 1; _ < m; _++) if (_ != j) {
			int i = q[_];
			if (join(u[i], v[i]))
				s += w[i];
		}

		if (s == x) a++;
		if (s > x) b++; 
	}

	cout << MOD(2 * (pot(2, a) - 1) % mod * pot(2, b), mod) << endl;

	return 0;
}


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

int dx[2] = {0,1};
int dy[2] = {1,0};
int area[17][17]={0};
int x,y;
int xg,yg;
int ans=0;

int saiki(int a,int b){
  for(int i=0;i<2;i++){
    if(a+dx[i] > x || b+dy[i] > y || area[a+dx[i]][b+dy[i]] == -1);
    else if(area[a+dx[i]][b+dy[i]] == 2){
      ans++;
    }
    else{
      saiki(a+dx[i],b+dy[i]);
    }
  }
  return ans;
}


int main(){
  while(1){
    int no;
    memset(area,0,sizeof(area));
    ans=0;
    cin >> x >> y;
    if(x == 0 && y == 0)break;
    area[x][y] = 2;
    cin >> no;
    for(int i=0;i<no;i++){
      cin >> xg >> yg;
      area[xg][yg] = -1;
    }
    ans = saiki(1,1);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int a[5];
int main(){
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	reverse(a,a+3);
	if(((a[0]-a[2])-(a[0]-a[1]))%2){
		a[0]++;
		a[1]++;
		cout<<(a[0]-a[1])+(a[0]-a[2]-(a[0]-a[1]))/2+1<<endl;
	}else {
		cout<<(a[0]-a[1])+(a[0]-a[2]-(a[0]-a[1]))/2<<endl;
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N,D,X;
vector<int> A;
int main() {
  cin >> N;
  cin >> D >> X;
  A.resize(N);
  for (auto &val : A){
    cin >> val;
  }
  sort(A.begin(), A.end());
  int sum = 0;
  for (int j = 0; j < A.size(); j++){
    int day = 1;
    while (day <= D){
      sum++;
      day += A[j];
    }
  }
  cout << sum + X << endl;
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n,k;cin>>n>>k;
  ll d=n/k;
  cout<<min(n-d*k,k*(d+1)-n)<<endl;
}

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

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<double> v(N);
	for (int i = 0; i < N ; ++i)
		cin >> v[i];

	double roll = 0;
	for (int i = 0; i < K; ++ i)
		roll += 0.5 * (1. + v[i]);

	double maxima = roll;

	for (int i = 0; i < v.size() - K; ++i)
	{
		// cout << "subtract " << i << " " << v[i] << " add " << i + K << " " << v[i + K] << "\n";
	       	roll = roll + 0.5 * (1 + v[i + K]) - 0.5 * (1 + v[i]); 	
		maxima = max(maxima, roll);
	}
	printf("%.12f", maxima);

	return 0;
}


Measured memory_bytes: 4768
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
typedef vector<pii> vp;
 
double to_rad(int angle){
    return angle*PI*2/360;
}
 
double dist(pii l,pii r){
    return sqrt(pow((double)l.second-r.second,2)+pow((double)l.first-r.first,2));
}
#define EQ(a,b) (abs((a)-(b))<EPS)
 
int main(){
    int n;
    while(cin>>n,n){
        vp coords;
        coords.push_back(make_pair(0,0));
        REP(i,n){
            int x,y;
            cin>>x>>y;
            coords.push_back(make_pair(x,y));
        }
 
        double res=0;
        int cur_index=0;
        double runner_angle=to_rad(90);
        while(coords.size()>1){
            pii cur=coords[cur_index];
            coords.erase(coords.begin()+cur_index,coords.begin()+cur_index+1);
            int best_index=0;
            double best_angle=1000;
			double best_abs_angle=0;
            REP(j,coords.size()){
				double abs_angle=atan2((double)(coords[j].second-cur.second),coords[j].first-cur.first);
				if(abs_angle<0){
					abs_angle+=to_rad(360);
				}
                double angle;
				//if(EQ(runner_angle,abs_angle)){
				//	angle=0;
				//}else{
					angle=runner_angle-abs_angle;
				//}
				if(angle<0){
					angle+=to_rad(360);
				}
                if(best_angle>angle||(EQ(angle,best_angle)&&dist(cur,coords[best_index])>dist(cur,coords[j]))){
                    best_index=j;
                    best_angle=angle;
					best_abs_angle=abs_angle;
                }
            }
            res+=dist(cur,coords[best_index]);
            cur_index=best_index;
            runner_angle=best_abs_angle;
        }
 
        printf("%.1f\n",res);
    }
}

Measured memory_bytes: 1320
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll aa[100000];
int main()
{
	ll a,b,c;
	string s;
	cin>>a>>b;
	if(a==2||b==2||a==11){
		cout<<"No";
	}else if(a==4||a==6||a==9){
		if(b==6||b==9||b==11){
			cout<<"Yes";
		}else{
			cout<<"No";
		}
	}else{
		if(b==3||b==5||b==7||b==8||b==10){
			cout<<"Yes";
		}else{
			cout<<"No";
		}
	}
}

Measured memory_bytes: 256
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i, n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i, a, b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i, a, b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a, b) a=min((a),(b))
#define CHMAX(a, b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a, b) (abs(a-b)<EPS)
typedef complex<Real> P;


int main() {
//    cin >> A >> B;
    double db = 2.9;
    string st; cin >> st; cin >> st;
//    int B; cin >> B;

    cout << "A" << st.at(0) << "C";
}


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

const int MAXN = 1e3 + 5;
const string five[] = {"eefll", "h.fmm", "hggnn", "ijk..", "ijk.."};
const string seven[] = {"a.bbc..", "a...c.d", "...feed", "gg.f.hh", "jkk..ii", "jlm....", ".lmnn.."};

int N;
char ans[MAXN][MAXN];

void fill_hor(int x, int y) {
	for (int i = 0; i < 2; i++)
		ans[2 * x + i][2 * y] = ans[2 * x + i][2 * y + 1] = "ab"[i];
}

void fill_ver(int x, int y) {
	for (int i = 0; i < 2; i++)
		ans[2 * x][2 * y + i] = ans[2 * x + 1][2 * y + i] = "cd"[i];
}

void solve_even(int n) {
	n /= 2;
	for (int i = 0; i < n; i++) {
		fill_hor(i, i);
		fill_ver(i, (i + 1) % n);
	}
}

void solve_odd() {
	if (N == 7) {
		for (int i = 0; i < N; i++)
			for (int j = 0; j < N; j++)
				ans[i][j] = seven[i][j];
		return;
	}
	for (int i = 0; i < 5; i++)
		for (int j = 0; j < 5; j++)
			ans[N - 5 + i][N - 5 + j] = five[i][j];
	solve_even(N - 5);
}

int main() {
	scanf("%d", &N);
	
	memset(ans, '.', sizeof ans);
	
	if (N == 2) {
		puts("-1");
		return 0;
	}
	
	if (N == 3) {
		puts("..a");
		puts("..a");
		puts("bb.");
		return 0;
	}
	
	if (N % 2)
		solve_odd();
	else
		solve_even(N);
		
	for (int i = 0; i < N; i++) {
		ans[i][N] = '\0';
		puts(ans[i]);
	}
	
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>

using namespace std;

const int Z = 1e9+7;

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

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

    int inv[n+1];
    for (int i = 1; i <= n; i++) {
        inv[i] = i == 1 ? 1 : 1ll * (Z - Z / i) * inv[Z%i] % Z;
    }

    int fac[n+1], ifac[n+1];
    for (int i = 0; i <= n; i++) {
        fac[i] = i == 0 ? 1 : 1ll * fac[i-1] * i % Z;
        ifac[i] = i == 0 ? 1 : 1ll * ifac[i-1] * inv[i] % Z;
    }

    int ans = 0;
    for (int i = 0; i <= n - k; i++) {
        ans = ((ans - 1ll * fac[n-i-1] * ifac[k-1] % Z * ifac[n-i-k] % Z * a[i]) % Z + Z) % Z;
    }
    for (int i = k - 1; i < n; i++) {
        ans = ((ans + 1ll * fac[i] * ifac[k-1] % Z * ifac[i+1-k] % Z * a[i]) % Z + Z) % Z;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,m;
vector<P> a;
int main() {
  cin >> n >> m;

  for(int i = 0; i < m; i++) {
    int A,B;
    cin >> A >> B;
    a.push_back(P(B,A));
  }
  sort(a.begin(),a.end());
  int tmp = 0;
  int ans = 0;
  for(int i = 0; i < m; i++) {
    if(a[i].second > tmp) {
      ans++;
      tmp = a[i].first - 1;
    }
  }
  cout << ans << endl;
  
  
}


Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/12/2018
 
 15:25-
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5+1;
int N;
LL A[MAX_N],T[MAX_N];
const LL MOD=1e9+7;
LL L[MAX_N],R[MAX_N];
void solve() {
  REP(i,N) {
    if(i==0||A[i-1]<A[i]) L[i]=R[i]=A[i];
    else L[i]=1,R[i]=A[i];
  }
  LL res=1;
  for(int i=N-1; i>=0; --i) {
    LL l,r;
    if(i==N-1||T[i]>T[i+1]) l=r=T[i];
    else l=1,r=T[i];
    LL d=min(r,R[i])-max(l,L[i])+1;
    d=max(d,0LL);
    if(d<0) res=0;
    dump2(i,d);
    res*=d,res%=MOD;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N;
  REP(i,N) cin>>A[i];
  REP(i,N) cin>>T[i];
  solve();
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>
using namespace std;
using ll = long long;
#define MAX 200005;

int main(){
    string s,t; cin >> s >> t;
    string ss = s;
    ll ans = 0;
    for(int i=0;i<t.size();i++){
        ll x = ss.find_first_of(t.at(i));
        ss.erase(ss.begin(),ss.begin()+x+1);
        if(ss.size() < s.size()) ss+=s;
        if(x>=0) ans += x+1;
        else{
            ans = -1;
            break;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 768
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();

		int cnt=0;
		for (int a=0;a<A+1;a++) {
			for (int b=0;b<B+1;b++) {
				for (int c=0;c<C+1;c++) {
					if(X==a*500+b*100+c*50) {
						cnt++;
					}
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 23124
import java.util.Scanner;
public class Main{
    public static void main(String[]args){

        Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a < b){
			if(b < c){
				System.out.println("Yes");
				}else{
		  		  	System.out.println("No");
				}
		}else{
			System.out.println("No");
		}
    }
}

Measured memory_bytes: 17352
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt();
		long[] sum = new long[N + 1];
		sum[0] = 0;
		for(int i = 1; i <= N; i++) sum[i] += sum[i - 1] + sc.nextLong();
		Arrays.sort(sum);
		long cnt = 0;
		for(int i = 0; i < N + 1; i++) {
			long tmp = i;
			while(i + 1 < N + 1 && sum[i] == sum[i + 1]) i++;
			cnt += (i - tmp) * (i - tmp + 1) / 2;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 82272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    string s;cin>>s;
    string t;cin>>t;
    ll a;cin>>a;
    ll b;cin>>b;
    string u;cin>>u;
    if(s==u) a--;
    else if(t==u) b--;
    cout<<a<<" "<<b<<endl;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 256
eval"N,K,S,T,*A="+`dd`.split*?,
A.select!{1>~_1&S|_1&~T}
c=[1]*-~N
c.map{$*<<c[K]-1
t=0
c.map!{t+t=_1}}
p (0..2**18).sum{|u|~u&S|u&~T<1?A.map{_1&u}.tally.sum{$*[_2]}*(1-('%b'%(u-S)).count(?1)%2*2):0}

Measured memory_bytes: 14520
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
typedef unsigned us;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

const int N=5005;
bool ans,o,be[5001];
int l,ne[N],son[N],ed[N],fa[N],a[N],f[N][2],x,n,w,ww;

void dfs(int x) {
	int l=son[x],y;
	while (l>0) {
		y=ed[l];
		if (x==fa[y]) dfs(y);
		if (ans) return;
		l=ne[l];
	}
	l=son[x];w=0;ww=0;memset(be,0,sizeof(be));
	while (l>0) {
		y=ed[l];
		if (x==fa[y]) {
			w+=f[y][0]+f[y][1];ww+=min(f[y][0],f[y][1]);
			for (int i=5000;i>=0;i--) {
				if ((i-f[y][0]>0 && be[i-f[y][0]]) || i-f[y][0]==0) be[i]=1;	
				if ((i-f[y][1]>0 && be[i-f[y][1]]) || i-f[y][1]==0) be[i]=1;
				}
		}
		l=ne[l];
	} 
	o=0;
	for (int i=a[x];i>=ww;i--) if (be[i]) {
		o=1;
		f[x][0]=a[x];
		f[x][1]=w-i;
		break;
	}
	if (w==0) {
		o=1;f[x][0]=a[x];
		f[x][1]=0;
	}
	if (!o) {ans=1;printf("IMPOSSIBLE");return;}
}


int main(){
	scanf("%d",&n);
	rep(i,2,n+1) {
		scanf("%d",&x);
		fa[i]=x;
		l++;ne[l]=son[x];son[x]=l;ed[l]=i;
		l++;ne[l]=son[i];son[i]=l;ed[l]=x;
	}
	rep(i,1,n+1) scanf("%d",&a[i]);
	dfs(1);
	if (!ans) printf("POSSIBLE");
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int k = sc.nextInt();
        long ans = 0L;
        int rl = 1;
        for(int i = 1, f = s.length; i < f; ++i) {
            if(s[i - 1] == s[i]) {
                ++rl;
            } else {
                ans += (rl / 2L);
                rl = 1;
            }
        }
        if(rl == s.length) {
            System.out.println(1L * s.length * k >> 1L);
            return;
        }
        
        ans += (rl / 2L);
        rl = 1;
        ans *= k;
        
        if(s[0] == s[s.length - 1]) {
            int a = 1;
            for(int i = 1, f = s.length; i < f; ++i) {
                if(s[i] != s[0]) break;
                ++a;
            }
            
            int b = 1;
            for(int i = s.length - 2; i >= 0; --i) {
                if(s[i] != s[s.length - 1]) break;
                ++b;
            }
            ans -= (a / 2L + b / 2L - (a + b) / 2L) * (k - 1L);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22740
import numpy as np
n = int(input())
j = np.array(list(map(int, input().split())))
minn = 999999999999999999
for i in range(min(j), max(j)+1):
    if minn > sum((j - i) ** 2):
        minn = sum((j - i) ** 2)
print(minn)

Measured memory_bytes: 21384
n = int(input())
a = sorted(list(map(int,input().split())))
m_a = a[-1]+1
dp = [0]*m_a

for i in a:
    dp[i] += 1
    if dp[i] == 1:
        for j in range(i*2, m_a, i):
            dp[j] += 2

print(dp.count(1))

Measured memory_bytes: 32064
import java.util.Scanner;

class Main{
  public static void main(String[] arg){
    Scanner scan=new Scanner(System.in);
    String[] week={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    String in=scan.next();
    int day=0, Ans=0;
    for(int a=0; a<7; a++){
      if(in.equals(week[a])){
        day=a;
      }
    }
    Ans=7-day;
    System.out.println(Ans);
  }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> 
#define ff first 
#define endl "\n"
#define ss second 
#define li list<int>
#define vi vector<int>
#define ll long long int
#define pii pair<int,int>
#define vii vector<pair<int,int> >
#define mp make_pair
#define pb push_back
#define setbits(x) __builtin_popcountll(x)
#define custom  pair<int,pair<int,int> >
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds; 
#define mod 1000000007
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    vi arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    bool dp[k+1];
    memset(dp,0,sizeof dp);
    for(int i=1;i<=k;i++){
        for(int move:arr){
            if(move>i)
            continue;
            if(dp[i-move]==0)
            dp[i]=1;
        }
    }
    if(dp[k]==1){
        cout<<"First";
    }
    else{
        cout<<"Second";
    }
    return 0;
}

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

int main() {
int n;
while(1){
	cin>>n;
	if(n==0){
		break;
	}
	int k=0,go=5;
	for(int jj=1;jj<=14;jj++){
		k=k+n/go;
		go=go*5;
	}
cout<<k<<endl;
}
return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()


const ll inf=4e18+5;

int main(){
    int n,k; cin>>n>>k;
    ll ans=-inf;
    vector<int> p(n); vector<ll> c(n), q;
    rep(i,n) cin>>p[i];
    rep(i,n) cin>>c[i];
    rep(i,n) p[i]--;
    rep(i,n){
        q.clear();
        int now=i;
        do{
            now=p[now];
            q.push_back(c[now]);
            //cout<<c[now]<<endl;
        }while(p[now]!=p[i]);
        ll karians=-inf, tot=0, kari=0;
        for(auto &v: q) tot+=v;
        rep(j,q.size()){
            if(j>=k) break;
            kari+=q[j];
            if(tot>0){
                ll aa=(k-j-1)/q.size();
                if(aa>0){
                    kari+=tot*aa;
                    karians=max(karians,kari);
                    kari-=tot*aa;
                }
            }
            karians=max(karians,kari);
        }
        ans=max(ans,karians);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3796
import java.util.*;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] list = new int[n];

        int sum = 0;
        for (int i = 0; i < n; i++) {
            int value = sc.nextInt();
            sum += value;
            list[i] = sum;
        }
        int min = Integer.MAX_VALUE;
        for (int value: list
             ) {
            int target = Math.abs(value - (sum - value));
            if (target < min) {
                min = target;
            }
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define reep(i,n) for(ll i = n; i >-1; i--)
#define deb(variable) cout<<#variable<<"="<<variable<<endl;
#define pb push_back
const ll INF=99999999999999999;
const ll MOD=1000000007;
const ll MAX_N=100010;
ll a,b,c,d,e,x,y,z,k,m,n,l,q,ans=0;
vl v;
string s;
int main(){
    cin>>n>>s;

    rep(i,n){
        if(s[i]=='#')v.push_back(0);
        else v.push_back(1);
    }

    a=0;
    rep(i,n){
        a+=v[i];
    }

	//cout<<a<<endl;
    ans=a;
    rep(i,n){
        if(s[i]=='#')a++;
        else a--;
        ans=fmin(ans,a);
    }

    cout<<ans<<endl;


}

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

void CountTriangles(vector <int> A){

	int n=A.size();

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

	int count = 0;

	for( int i = n-1; i >= 1; i--){
		int l = 0, r = i-1;
		while( l < r){
			if( A[l] + A[r] > A[i]){
				count += r - l ;
			r--;
			}
			else


				l++;
		}
	}
	cout<<count;
}
int main(){

	vector<int> v ;
    int n;cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
      v.push_back(a);
    }

	CountTriangles(v);

}


Measured memory_bytes: 256
#include<stdio.h>
 
main()
{
    char ch;
    int counter[26] = {0};
     
     
    while(scanf("%c",&ch) != EOF){
        if('a'<= ch && ch <= 'z'){
            counter[ch-'a']++;
        } else if('A'<=ch && ch <= 'Z'){
            counter[ch-'A']++;
        }
    }
     
     
    short i;
     
    for(i=0;i<26;i++){
        printf("%c : %d\n",'a'+i,counter[i]);
    }
    return 0;
}


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

int N;
vector<vector<int> > graph(N, vector<int>(0));
vector<vector<int> > children(N, vector<int>(0));
vector<long long> cnt(N, 0);


void child(int id, int parent)
{
    //cout << "child呼び出し: " << id << endl;
    for (int i=0; i<graph[id].size(); i++)
    {
        if (graph[id][i]!=parent)
        {
            children[id].push_back(graph[id][i]);
            child(graph[id][i], id);
        }
    }
}

void flow(int id)
{
    for (int i=0; i<children[id].size(); i++)
    {
        int child = children[id][i];
        cnt[child] += cnt[id];
        flow(child);
    }
}

int main()
{
    int Q;
    cin >> N >> Q;
    graph = vector<vector<int> > (N, vector<int>(0));
    children = vector<vector<int> > (N, vector<int>(0));
    cnt = vector<long long> (N, 0);
    for (int i=0; i<N-1; i++)
    {
        int a, b;
        cin >> a >> b;
        graph[a-1].push_back(b-1);
        graph[b-1].push_back(a-1);
    }

    child(0, -1);

    for (int i=0; i<Q; i++)
    {
        int p, x;
        cin >> p >> x;
        cnt[p-1] += x;
    }
    flow(0);
    for (int i=0; i<N; i++) cout << cnt[i] << " ";
    cout << endl;
}

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

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

int n, score[100];

void solve() {
  rep(i,n) cin>>score[i];

  sort(score, score+n);
  double sum = 0;
  REP(i,1,n-1) sum += score[i];
  
  cout<<(int)(sum/(n-2))<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 3e5+5;

const int mod = 1e9+7;

int n;
int a[N];
int b[N];

int main(){
    scanf("%d " , &n);
    long long ans = 0;
    for(int i = 1; i <= n + 1; i++){
        scanf("%d" , &a[i]);
    }
    for(int i = 1; i <= n; i++){
        scanf(" %d" , &b[i]);
        int dec = min(b[i] , a[i]);
        b[i] -= dec;
        a[i] -= dec;
        ans += dec;
        dec = min(b[i] , a[i + 1]);
        ans += dec;
        a[i + 1] -= dec;
    }
    printf("%lld\n" , ans);
}


Measured memory_bytes: 4460
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
int g[91][91],w,h;
int d[91][91];
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
int dfs(int y,int x){
  int ret = 0;
  
  for(int i=0;i<4;i++){
    int ty = y + dy[i];
    int tx = x + dx[i];
    if(g[ty][tx] == 1 && d[ty][tx] == 0){
      d[ty][tx] = 1;
      ret = max( ret , dfs( ty , tx ) + 1 );
      d[ty][tx] = 0;
    }
  }
  return ret;
}
int main(){
  while(1){
    cin >> w;
    cin >> h;
    if(!w && !h)break;
    memset( d , 0 , sizeof(d) );
    memset( g , 0 , sizeof(g) );
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> g[i][j];
      }
    }
    int ret = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(g[i][j] == 1)ret = max( ret , dfs( i , j ) );
      }
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
 vector<int> vi[maxii];
 vector<int>:: iterator child;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
bool check[maxii];

bool dfs(int node,int c)
{
    check[node]=true;
    arr2[node]=c;
    for(int child=0;child<vi[node].size();child++)
    {
        if(check[vi[node][child]]==false)
        {
            if(dfs(vi[node][child],c^1)==false)
            {
                return false;
            }
        }
        else if(arr2[node]==arr2[vi[node][child]])
        {
            return false;
        }
        //else if()
    }
    return true;
}

int main()
{
    string aarr[105];
    int n,l;
    cin>>n>>l;
    for(int i=0;i<n;i++)
    {
        cin>>aarr[i];
    }
    sort(aarr,aarr+n);
    for(int i=0;i<n;i++)
    {
        cout<<aarr[i];
    }
}






Measured memory_bytes: 5940
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    vector<int> vs(3);
    for (auto& v : vs)
    {
        cin >> v;
    }
    sort(vs.begin(), vs.end());
    if ((vs[0] == vs[1] && vs[1] != vs[2]) || (vs[0] != vs[1] && vs[1] == vs[2]))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
paySix = []
payNine = []
i = 0
while 6**i <= n:
   paySix.append(6**i)
   i += 1
i = 0
while 9**i <= n:
   payNine.append(9**i)
   i += 1

maxCount = n
sum = 0
for j in range(n+1):
    count = 0
    count6 = 0
    count9 = 0
    nine = j
    six = n - j
    for i in reversed(range(len(payNine))):
        count9 += int(nine/payNine[i])
        nine -= int(nine/payNine[i])*payNine[i]
    # print("\ndiv target:{} 9Count:{}".format(j, count9))
    for i in reversed(range(len(paySix))):
        count6 += int(six/paySix[i])
        six -= int(six/paySix[i])*paySix[i]
    # print("div target:{} 6Count:{}".format(n-j, count6))
    maxCount = min(maxCount, count9+count6)
print(maxCount)
"""
pay = [1]
i = 1
while 6**i <= n:
   pay.append(6**i)
   i += 1
i = 1
while 9**i <= n:
   pay.append(9**i)
print(i)
pay = sorted(pay)
print(len(pay))
count = 0
for i in reversed(range(len(pay))):
    # print(i)
    count += int(n/pay[i])
    n -= int(n/pay[i])*pay[i]
    if n == 0:
        print(count)
"""
""""
for i in range(1, 100000):
    if 9 ** i < n:
        nine.append(9 ** i)
    else:
        break
for i in range(1, 100000):
    if 6 ** i < n:
        six.append(6 ** i)
    else:
        break

count = 0
last = n
while last >= 9:
    if nine:
        while nine[-1] > last:
            nine.pop()
    if six:
        while six[-1] > last:
            six.pop()

    if nine:
        tmp9 = nine[-1]
        num9 = int(last / tmp9)
    if six:
        tmp6 = six[-1]
        num6 = int(last / tmp6)

    if num9 < num6:
        count += num9
        last %= tmp9
        nine.pop()
    elif num9 == num6 and last % tmp9 <= last % tmp6:
        count += num9
        last %= tmp9
        nine.pop()
    else:
        count += num6
        last %= tmp6
        six.pop()


count += int(last / 6)
last %= 6
print(count + last)
"""

Measured memory_bytes: 3064
#include <stdio.h>

int square(int a){
	return (a * a);
}

int main(void)
{
	int N;
	int i, j;
	int a[3] = {0};
	int x2[3];
	int max[3] = {0};
	int result[1000] = {0};
	
	scanf("%d", &N);
	
	for (i = 0; i < N; i++){
		scanf("%d %d %d", &a[0], &a[1], &a[2]);
		for (j = 0; j < 3; j++){
			x2[j] = square(a[j]);
		}
		for (j = 0; j < 3; j++){
			if (max[0] < x2[j]){
				max[2] = max[1];
	            max[1] = max[0]; 
	            max[0] = x2[j];
			}
			else if (max[1] < x2[j]){
				max[2] = max[1];
				max[1] = x2[j];
			}
			else {
				max[2] = x2[j];
			}
		}
		if ((max[1] + max[2])== max[0]){
			result[i] = 1;
		}
		else {
			result[i] = 2;
		}
		max[0] = 0;
		max[1] = 0;
		max[2] = 0;
	}
	
	for (i = 0; i < N; i++){
		if (result[i] == 1){
			printf("YES\n");
		}
		else if (result[i] == 2){
			printf("NO\n");
		}
		else {
			break;
		}
	}
	
    return (0);
}

Measured memory_bytes: 584
<?php
fscanf(STDIN, "%d %d", $N, $Y);

for($i = 0; $i <= $N; $i++) {

  for($j = 0; $j <= $N; $j++) {
    if(($i + $j) <= $N) {
      $k = $N - ($i + $j);

      $total = (10000 * $i) + (5000 * $j) + (1000 * $k);

      if($total == $Y) {
        echo "$i $j $k\n";
        exit;
      }
    }


  }
}

echo "-1 -1 -1\n";
exit;
?>


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll x; cin >> x;
	ll fx = 0, po = x;
	while(po){
		fx += po % 10;
		po /= 10;
	}
	cout << (x % fx ? "No\n" : "Yes\n"); 
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <ctype.h>
#include <algorithm>
using namespace std;
int gcd(int a, int b) {
    if(b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int main() {
    int x,y,ans;
    cin >> x >> y;
    ans = gcd(x,y);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=100005;
int x[maxn],w[maxn],n,l,t;
pin fin[maxn];
int ans[maxn];
int main(){
	read(n);read(l);read(t);
	rep(i,1,n)read(x[i]),read(w[i]);
	rep(i,1,n){
		if(w[i]==1){
			fin[i]=mk((x[i]+t)%l,i);
		}else{
			fin[i]=mk(((x[i]-t)%l+l)%l,i);
		}
	}
	sort(fin+1,fin+1+n);
	i64 tot=0;
	rep(i,2,n){
		if(w[i]==w[1])continue;tot%=n;
		int dis=0;
		if(w[1]==1)
			dis=x[i]-x[1];
		else
			dis=(l-(x[i]-x[1]))%l;
		tot+=(2ll*t+l-dis)/l;
	}i64 id;
	if(w[1]==1){
		id=(1+tot-1)%n+1;
	}else{
		id=((1-tot-1)%n+n)%n+1;
	}int gt=0;
	rep(i,1,n)if(fin[i].w2==1){
		if(fin[i+1].w1==fin[i].w1&&w[1]==1)gt=i+1;else
		gt=i;break;
	}
	rep(x,1,n){
		ans[id]=fin[gt].w1;
		id++;gt++;
		if(id>n)id-=n;
		if(gt>n)gt-=n;
	}
	rep(i,1,n)printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
using namespace std;
int main(){
   int n,i,x,a,b;
   char ch;
   cin>>n;
   int cards[5][14];
   for(a=1;a<=4;a++){
       for(b=1;b<=13;b++){
           cards[a][b]=0;
       }
   }
   for(i=1;i<=n;i++){
       cin>>ch>>x;
       if(ch=='S'){
           cards[1][x]=1;
       }
       else if(ch=='H'){
           cards[2][x]=1;
       }
       else if(ch=='C'){
           cards[3][x]=1;
       }
       else if(ch=='D'){
           cards[4][x]=1;
       }
   }
   for(a=1;a<=4;a++){
       for(b=1;b<=13;b++){
           if(cards[a][b]==0){
               if(a==1){
                   cout<<'S'<<" "<<b<<endl;
               }
               else if(a==2){
                   cout<<'H'<<" "<<b<<endl;
               }
               else if(a==3){
                   cout<<'C'<<" "<<b<<endl;
               }
               else if(a==4){
                   cout<<'D'<<" "<<b<<endl;
               }
           }
       }
   }
   return 0;
}


Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {

		int n = sc.nextInt();
		int m = sc.nextInt();
		int d = sc.nextInt();
		
		double ans = 0;
		if(d == 0){
			ans = n;
		}else{
			ans = (n-d)*2;
		}
		
		ans = ans*(m-1)/n/n;
		
		System.out.printf("%.10f", ans);
//		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int now = 1;
		int break_brock = 0;
		int a[] = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = scan.nextInt();
		}
		for(int i=0;i<n;i++) {
			if(a[i] != now) {
				break_brock += 1;
			}else {
				now += 1;
			}
		}
		if(break_brock == n) {
			System.out.println(-1);
		}else {
			System.out.println(break_brock);
		}
		
	}
}




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

using namespace std;

#ifdef LOCAL
  #include "debug.h"
#else
  #define debug(...) 42
#endif

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  auto check = [&](int x) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      cnt += (a[i] - 1) / x;
    }
    return cnt <= k;
  };
  int l = 1, r = *max_element(a.begin(), a.end());
  int answer = r;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (check(mid)) {
      answer = mid;
      r = mid - 1;
    }
    else {
      l = mid + 1;
    }
  }
  cout << answer << '\n';
}


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

  int main(){

int n;
cin>>n;

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


int mn = a[0], mx = a[0];
long long sum = 0;
for(int i=0;i<n;i++){
  mn = min(mn, a[i]);
mx = max(mx, a[i]);
sum += a[i];
}


cout<<mn<<" "<<mx<<" "<<sum<<endl;

return 0;
}


Measured memory_bytes: 3112
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int cnt = 0;
    REP(i,n){
        cin >> a[i];
        if(a[i]%2==1)cnt++;
    }
    if(cnt%2==1){
        put("NO");
    }else{
        put("YES");
    }
    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 1000;
const int MOD = 1000 * 1000 * 1000 + 7;
int nb[MAXN + 1][MAXN + 1];

bool libre[MAXN + 1][MAXN + 1];
int32_t main()
{
	int N , M;
	cin >> N >> M;
	for (int i = 0 ; i < N ; i++)
	{
		for (int j = 0 ; j < M ; j++)
		{
			char t;
			cin>>t;
			if (t=='.') libre[i][j] = true;
		}
	}
	nb[N][M - 1] = 1;
	for (int i = N - 1 ; i >= 0 ; i--)
	{
		for (int j = M - 1 ; j >= 0 ; j--)
		{
			if (libre[i][j])
			{
				nb[i][j] = (nb[i][j + 1] + nb[i + 1][j]) % MOD;
			}
		}
	}
	cout<<nb[0][0]<<endl;
}


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

#define int long long

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 2e5 + 5;

string S[101];
int s;

void f(int a, char x, char y){
    a--;
    int i;
    s++;
    for(i=1;i<=99;i++) S[s] += y;
    for(; a ;){
        s++; 
        if(a >= 49){
            for(i=1;i<=49;i++) S[s] += y, S[s] += x;
            S[s] += y;
            a -= 49;
        }
        else{
            for(i=1;i<=a;i++) S[s] += y, S[s] += x;
            for(i=a+a+1;i<=99; i++) S[s] += y;
            a = 0;
        }
        s++; for(i=1;i<=99;i++) S[s] += y;
    }
    
    s++; for(i=1;i<=99;i++) S[s] += y;
}

signed main(){
    int a,b;
    cin >> a >> b;
    f(a,'.','#');
    f(b,'#','.');
    if(s > 100) assert(0);
    cout << s << " 99\n";
    for(int i=1; i<=s; i++)
        cout << S[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;

int num[51];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1,now=1;
    long long int a,a1;
    //float f,g,h;
    //char now,pre;
    string s,s1;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        if(i==0)
        {
            for(j=0;j<m+2;j++) cout<<"#";
            puts("");
        }
        cin>>s;
        cout<<"#"<<s<<"#"<<endl;
        if(i==n-1)
        {
            for(j=0;j<m+2;j++) cout<<"#";
            puts("");
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;
	FOR(i,0,abs(sx-tx))cout<<'R';
	FOR(i,0,abs(sy-ty))cout<<'U';
	FOR(i,0,abs(sx-tx))cout<<'L';
	FOR(i,0,abs(sy-ty)+1)cout<<'D';
	FOR(i,0,abs(sx-tx)+1)cout<<'R';
	FOR(i,0,abs(sy-ty)+1)cout<<'U';
	cout << "LU";
	FOR(i,0,abs(sx-tx)+1)cout<<'L';
	FOR(i,0,abs(sy-ty)+1)cout<<'D';
	cout << 'R' << endl;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;
ll mod_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) return mod_pow(x * x % MOD, n / 2) % MOD;
    else return x * mod_pow(x, (n - 1)) % MOD;
}
ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;
    ll ret = 1;
    while (n) if (n & 1) ret = ret * x % MOD; x = x * x % MOD; n /= 2;
    return ret;
}
ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) ret *= (i + 1); ret %= MOD;
    return ret;
}
ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);
    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}

void solve() {
    ll a, b, n; cin >> a >> b >> n;
    ll ret = a * min(b - 1, n) / b;
    cout << ret;
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include<limits.h>
#include<algorithm>
#include<queue>
#include<set>
#include<math.h>
#include<random>

#define lli long long int
#define MOD 1000000007

using namespace std;

long long int modpow(long long int a, long long int n) {
	if (n == 0)return 1;
	if (n == 1)return (a % MOD);

	long long int hanbun = n / 2;
	long long int amari = n % 2;

	long long int ans = (a * a) % MOD;
	ans = modpow(ans, hanbun);

	if (amari == 1)ans *= a;

	ans %= MOD;

	return ans;

}

long long int gcd(long long int a, long long int b) {
	if (a < b) {
		long long int tmp = a;
		a = b;
		b = tmp;
	}

	long long int amari = a % b;

	if (amari == 0)return b;

	return gcd(b, amari);
}

long long int lcm(long long int a, long long int b) {
	long long int ans = (a * b) % MOD;
	long long int wari = modpow(gcd(a, b), MOD - 2);
	ans = (ans * wari) % MOD;
	return ans;
}

long long int factElement[10000] = { 0 };

long long int factrial(int n) {

	if (factElement[n] != 0)return factElement[n];

	if (n == 0) {
		factElement[0] = 1;
		return factElement[n];
	}

	long long int ans = n * factrial(n - 1);
	factElement[n] = ans;
	return factElement[n];

}

struct SegmentTree {
private:
	int n;
	vector<long long int> node;
	int TANNI;

	long long int Func(long long int a, long long int b) {
		return min(a,b);
	}

public:
	//元配列ｖをセグメント木で表現する。
	SegmentTree(vector<long long int> v, long long int tanni) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪→これをｎとおく。
		//セグメント木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1;
		while (n < sz)n *= 2;

		TANNI = tanni;
		node.resize(2 * n - 1, TANNI);

		//最下段に値を入れた後に、下の段から順番に値を入れる。
		//値を入れるには、自分の子の２値を参照すればよい。
		for (int i = 0; i < sz; i++)node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--)node[i] = Func(node[2 * i + 1], node[2 * i + 2]);
	}

	void update(long long int x, long long int val) {
		//最下段のノードにアクセスする。
		x += (n - 1);

		//最下段のノードを更新したら、あとは親に上って更新していく。
		node[x] = val;

		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = Func(node[2 * x + 1], node[2 * x + 2]);
		}
	}

	long long int getVal(int x) {
		x += (n - 1);
		return node[x];
	}

	long long int getAns(int a, int b, int k = 0, int l = 0, int r = -1) {
		//最初に呼び出された時の区間は[0,n)
		if (r < 0)r = n;

		//要求区間と対象区間が交わらない→単位元を返す。
		if (r <= a || b <= l) return TANNI;

		//要求区間が対象区間を完全に被覆する→対象区間を答えの計算に使う。
		if (a <= l && r <= b) return node[k];

		//要求区間が対象区間の一部を被覆→子をよびだす。
		//左の子をvl、右の子をvrとしている。
		//新しい対象区間は現在の対象区間を半分に割ったもの。
		int vl = getAns(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = getAns(a, b, 2 * k + 2, (l + r) / 2, r);
		return Func(vl, vr);


	}



};




int main()
{
	
	lli n;
	cin >> n;

	lli ans = 0;

	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0)ans += i;

	}
	
	cout << ans << endl;


	return 0;

}



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

int main() {
	int n;
	cin>>n;
	int A[100];
	for(int i=0;i<n;i++)
		cin>>A[i];
		
	for(int i=0;i<n;i++){
			cout<<A[i];
			if(i<n-1){
				cout<<' ';
			}else{
				cout<<endl;
			}
	}
	
	for(int i=1;i<n;i++){
		int v = A[i];
		int j=i-1;
		while(j>=0 && A[j]>v){
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=v;
		for(int i=0;i<n;i++){
			cout<<A[i];
			if(i<n-1){
				cout<<' ';
			}else{
				cout<<endl;
			}
		}
	}

	
	return 0;	
}

Measured memory_bytes: 1164