akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int T, X, Y, W, H;
int N;

int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d%d%d", &X, &Y, &W, &H);
    scanf("%d", &N);
    int cx, cy, ret = 0;
    rep(i,N) {
      scanf("%d%d", &cx, &cy);
      if (X <= cx && cx <= X + W &&
          Y <= cy && cy <= Y + H) ++ret;
    }
    printf("%d\n", ret);
  }
  return 0;
}

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

using namespace std;

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

    int flag = 0;
    for (int i=0; i<n; i++){
        if (arr[i]==arr[i+1]){
            flag = 1;
            break;
        }
    }
    
    if (flag) cout<<"NO";
    else cout<<"YES";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
long long N; string S;
 
int main() {
	cin >> N;
	if (N == 0) { cout << "0" << endl; return 0; }
	while (N != 0) {
		if (N % 2 == 1 || N % 2 == -1) { N--; S += "1"; }
		else { S += "0"; }
		N /= -2;
	}
	reverse(S.begin(), S.end());
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
  size_t N;
  std::cin >> N;
  int H[N];
  for(size_t i = 0;
      i < N;
      ++i)
    {
      std::cin >> H[i];
    }

  int ret = 1;

  for(size_t i = 1;
      i < N;
      ++i)
    {
      bool high = true;
      for(size_t j = 0;
          j < i;
          ++j)
        {
          if(H[i] < H[j])
            {
              high = false;
              break;
            }
        }
      if(high)
        {
          ++ret;
        }
    }
  std::cout << ret << std::endl;
  return 0;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  
  if(s[k-1] == 'A') s[k-1] = 'a';
  if(s[k-1] == 'B') s[k-1] = 'b';
  if(s[k-1] == 'C') s[k-1] = 'c';
  
  cout << s << endl;
}



Measured memory_bytes: 256
def main():
    _ = input()
    lst_a = [int(v) for v in input().split(' ')]
    ans = int(1)
    for a in lst_a:
        if a == 0:
            print('0')
            return
    for a in lst_a:
        ans *= a
        if ans > 1e18:
            ans = -1
            break
    print(int(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 21576
using System;
using System.Linq;

namespace tst
{
    class Program
    {
        public static void Main()
        {
            string[] In1 = Console.ReadLine().Split(' ');
            int n = int.Parse(In1[0]);
            int m = int.Parse(In1[1]);
            int[] P = new int[m];
            string[] S = new string[m];
            for (int i = 0; i < m; i++)
            {
                string[] In2 = Console.ReadLine().Split(' ');
                P[i] = int.Parse(In2[0]);
                S[i] = In2[1];
            }
            int cnt = 0;//クリアした数
            int penalty = 0;//ペナルティ数
            //解き終わったindexの保存//defalutはfalse
            bool[] Q = Enumerable.Repeat<bool>(false,n).ToArray();
            //何回間違えたか//defalutは0
            int[] WA = new int[n];
            for (int i = 0; i < m; i++)
            {
                int index = P[i]-1;
                if (Q[index] == false)//正解してない
                {
                    if (S[i] == "AC")//正解
                    {
                        Q[index] = true;
                        cnt++;
                        penalty += WA[index];
                    }
                    else//失敗
                    {
                        WA[index]++;
                    }
                }
            }
            Console.WriteLine("{0} {1}", cnt, penalty);

        }

    }
}

Measured memory_bytes: 23628
#include<bits/stdc++.h>
using namespace std;
const int maxN=200;
int n,res,ans;
int arr[maxN];
int brr[maxN];
int main()
{
    res=ans=1;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        res*=3;
        if(!(arr[i]&1)){
            ans*=2;
        }
    }
    res-=ans;
    cout<<res<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

ll n, c, h[200001], dp[200001];

bool case1(int b, int a, int i) {
    return (dp[b] - dp[a] + h[b] * h[b] - h[a] * h[a] <
            2 * h[i] * (h[b] - h[a]));
}

bool case2(int a, int b, int c) {
    return ((dp[b] - dp[a] + h[b] * h[b] - h[a] * h[a]) * (h[c] - h[b]) >
            (dp[c] - dp[b] + h[c] * h[c] - h[b] * h[b]) * (h[b] - h[a]));
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> c;
    FOR(i, 1, n + 1) { cin >> h[i]; }

    deque<ll> q;
    q.push_back(1);
    dp[1] = 0;
    FOR(i, 2, n + 1) {
        while (q.size() > 1 && case1(q[1], q[0], i)) {
            q.pop_front();
        }

        int j = q.front();
        dp[i] = dp[j] + (h[i] - h[j]) * (h[i] - h[j]) + c;

        while (q.size() > 1 && case2(q[q.size() - 2], q[q.size() - 1], i)) {
            q.pop_back();
        }
        q.push_back(i);
    }

    cout << dp[n] << '\n';
    return 0;
}

Measured memory_bytes: 4480
#include <iostream>

using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if(b%2==0){
        int d = a*2;
        int c = a*4;
        if(b <= c & b >= d){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
//#include <bits/stdc++.h>
#include <limits>
#include <utility>
#include <bitset>
#include <functional>
#include <tuple>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <cmath>

#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
//#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e9;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}
int d[4]={10,50,100,500};

int main(){
  int n;
  int f=0;
  while(cin>>n,n){
    if(f)cout<<endl;
    f=1;
    vector<int> c(4);
    int sum=0;
    rep(i,4){
      cin>>c[i];
      sum+=d[i]*c[i];
    }
    sum-=n;
    vector<int> ret(4);
    ret[3]=sum/500;
    sum-=500*ret[3];
    ret[2]=sum/100;
    sum-=100*ret[2];
    ret[1]=sum/50;
    sum-=50*ret[1];
    ret[0]=sum/10;
    rep(i,4)if(c[i]-ret[i]>0)cout<<d[i]<<' '<<c[i]-ret[i]<<endl;
  }

 return 0;
}



Measured memory_bytes: 3008
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main(){
  int N,M,sum = 0,p,x;
  cin >> N;
  int T[N];
  for(int i = 0; i < N; i++){
    cin >> T[i];
    sum += T[i];
  }
  cin >> M;

  for(int i = 0; i < M; i++){
      cin >> p >> x;
      cout << sum - (T[p-1] - x) << endl;
  }
}


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

int main() {
  int d;
  cin >> d;
  vector<int> c(26), last(26);
  for (int i = 0; i < 26; i++) {
    cin >> c.at(i);
  }
  vector s(d, vector(26, 0));
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s.at(i).at(j);
    }
  }
  for (int i = 0; i < d; i++) {
    int vmax = -1e9, tmax = 0;
    for (int t = 0; t < 26; t++) {
      int v = 0;
      v += s.at(i).at(t);
      for (int j = 0; j < 26; j++) {
        if (j == t) continue;
        v -= c.at(j) * (i + 1 - last.at(j));
      }
      if (v > vmax) {
        vmax = v;
        tmax = t;
      }
    }
    last.at(tmax) = i + 1;
    cout << tmax + 1 << endl;
  }
}


Measured memory_bytes: 3692
import itertools

n,m,x = (int(i) for i in input().split())
A = []
for i in range(n):
    A.append([int(i) for i in input().split()])

ans = float('inf')

for p in itertools.product(range(2), repeat=n):
    knowledges = [0 for _ in range(m)]
    tmp = 0

    for i,a in zip(p,A):
        if i == 0: continue
        tmp += a[0]
        for j,anm in enumerate(a[1:]): knowledges[j] += anm
    
    if all([a >= x for a in knowledges]):
        ans = min(ans, tmp)

if ans == float('inf'):
    print(-1)
else:
    print(ans)


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(N, 0);
  for (int i = 0; i < M * 2; i++) {
    int j;
    cin >> j;
    vec.at(j - 1)++;
  }
  for (int i = 0; i < N; i++) {
    cout << vec.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



int main() {
	int n;
	string s, t;
	cin >> n >> s >> t;
	int cnt = 0;
	for (int i = 0;i < n; i++) {
		if(s[i] !=t[cnt]) {
		cnt = 0;
		}
		if (s[i] == t[cnt]) {
			cnt++;
		}
		
	}

	
	cout <<( 2 * n - cnt) << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,tot,ans,dp[N],sum[N],head[N],nex[N<<1],to[N<<1];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
void dfs(int u,int p)
{
    int tot=0;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==p) continue;
        dfs(v,u);
        dp[u]+=dp[v];
        tot++;
    }
    dp[u]+=tot/2;
    if(u==1) dp[u]+=tot%2;
}
int top,s[N];
bool dfs(int u,int p,int m)
{
    sum[u]=0;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==p) continue;
        if(!dfs(v,u,m)) return false;
    }
    top=0;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==p) continue;
        s[++top]=sum[v]+1;
    }
    if(u==1)
    {
        if(top&1) s[++top]=0;
        sort(s+1,s+1+top);
        for(int i=1,j=top;i<j;i++,j--)
            if(s[i]+s[j]>m) return false;
        return true;
    }
    if(top%2==0) s[++top]=0;
    sort(s+1,s+1+top);
    int l=1,r=top,ans=-1;
    while(l<=r)
    {
        int mid=l+r>>1;
        bool flag=true;
        for(int i=1,j=top;i<j;i++,j--)
        {
            if(i==mid) i++;
            if(j==mid) j--;
            if(i>j) break;
            if(s[i]+s[j]>m) {flag=false;break;}
        }
        if(flag) ans=s[mid],r=mid-1;
        else l=mid+1;
    }
    if(ans==-1) return false;
    sum[u]=ans;
    return true;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        int u,v;scanf("%d%d",&u,&v);
        add(u,v);add(v,u);
    }
    dfs(1,0);
    int l=1,r=n,ans;
    while(l<=r)
    {
        int m=l+r>>1;
        if(dfs(1,0,m)) ans=m,r=m-1;
        else l=m+1;
    }
    printf("%d %d\n",dp[1],ans);
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
    
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) FOR(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
    
using ll = long long;
const ll INF = LLONG_MAX / 40 - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
int ddx[] = {-1,0,1,-1,1,-1,0,1}, ddy[] = {1,1,1,0,0,-1,-1,-1};
vector<ll> prime;
    
class fact {
public:
    int fmod = 1e9+7;
    vector<int> fac, inv;
    fact (int n, int Mod = 1e9+7) {
        fmod = Mod;
        fac = vector<int>(n + 1,0);
        inv = vector<int>(n + 1,0);
        fac[0] = 1; for (int i = 1; i < n + 1; i++) fac[i] = fac[i-1] * i % fmod;
        for (int i = 0;i < n + 1;i++) inv[i] = fact::POW(fac[i],fmod-2);
    }
    ll nCr(ll n, ll r) {if (n<r) return 0; return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
    ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
    
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return (a / GCD(a,b)) * b;}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

long long mul(long long a, long long b, long long mod) {
    long long keta[20] = {};
    long long c = b;
    long long now = 0;
    while (c != 0ll) {
        keta[now] = c % 10; c /= 10; now++;
    }
    long long res = 0;
    for (int i = 19; i >= 0; --i) {
        res *= 10; res %= mod;
        res += keta[i] * a % mod;
    }
    return res % mod;
}

void solve() {
    int n, k; cin >> n >> k;
  	if (k * 2 - 1 <= n) cout << "YES" << endl;
    else cout << "NO" << endl;
    return;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define F first
#define S second
#define MP make_pair
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll arr[100005];
vector<ll> pos;

int main()
{jizz
	ll n,ans=0,nw;
	cin >> n;
	for(int i=0;i<n;++i)
		cin >> arr[i];
	sort(arr,arr+n);
	if(arr[0]>0)
	{
		ans=-arr[0];
		for(int i=1;i<n;++i)
			ans+=arr[i],pos.pb(arr[i]);
		cout << ans << "\n";
		nw=arr[0];
		for(int i=0;i<n-2;++i)
			cout << nw << " " << pos.back() << "\n",nw=nw-pos.back(),pos.pop_back();
		cout << pos.back() << " " << nw << "\n";
	}
	else if(arr[n-1]>=0)
	{
		for(int i=0;i<n;++i)
			ans+=abs(arr[i]);
		cout << ans << "\n";
		nw=arr[0];
		for(int i=n-2;i>0;--i)
			if(arr[i]<0) break;
			else cout << nw << " " << arr[i] << "\n",nw-=arr[i];
		cout << arr[n-1] << " " << nw << "\n",nw=arr[n-1]-nw;
		for(int i=1;i<n;++i)
			if(arr[i]>=0) break;
			else cout << nw << " " << arr[i] << "\n",nw-=arr[i];
	}
	else
	{
		ans=arr[n-1];
		for(int i=0;i+1<n;++i)
			ans-=arr[i];
		cout << ans << "\n",nw=arr[n-1];
		for(int i=0;i+1<n;++i)
			cout << nw << " " << arr[i] << "\n",nw-=arr[i];
	}
}

Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        char[][] c = new char[H+ 2][W + 2];
        for (int i = 0; i < H; i++) {
            String s = sc.next();
            for (int j = 0; j < W; j++) {
                c[i + 1][j + 1] = s.charAt(j);
            }
        }
        for (int i = 1 ; i <= H ; i++) {
            for (int j = 1 ; j <= W ; j++) {
                int count = 0;
                if (c[i][j] == '.') {
                    count += countBomb(i - 1, j - 1, c);
                    count += countBomb(i - 1 , j, c);
                    count += countBomb(i - 1, j + 1, c);
                    count += countBomb(i , j - 1 , c);
                    count += countBomb(i, j + 1, c);
                    count += countBomb(i + 1, j - 1, c);
                    count += countBomb(i + 1, j, c);
                    count += countBomb(i + 1, j + 1, c);
                    c[i][j] =  (char)('0' + count);
                }
                System.out.print(c[i][j]);
            }
            System.out.println("");
        }
    }

    static int countBomb (int i , int j, char [][] c ) {
        if (c[i][j] == '#') {
            return 1;
        } else {
            return 0;
        }
    }

}

Measured memory_bytes: 22612
#include<iostream>
using namespace std;
int main(){
	char l;
	cin >> l;
	if (l == 'a' || l == 'e' || l == 'o' || l == 'i' || l == 'u') {
		cout << "vowel";
	}
	else {
		cout << "consonant";
	}
	return 0;
}

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

int main(){
	int N;
	cin >> N;
	bool flag=false;
	
	for(int i=1;i<N*2;i*=2)if(N==i)flag=true;
	
	if(flag)cout << "No" << endl;
	else{
		cout << "Yes" << endl;
		cout << "1 2" << endl;
		cout << "2 3" << endl;
		cout << "3" << " " << 1+N << endl;
		cout << 1+N << " " << 2+N << endl;
		cout << 2+N << " " << 3+N << endl;
		
		for(int k=5;k<=N;k+=2){
			cout << "1" << " " << k-1 << endl;
			cout << k-1 << " " << k << endl;
			cout << "1" << " " << k+N << endl;
			cout << k+N << " " << k-1+N << endl;
		}
		
		if(N%2==0){
			int c=0,n=N;
			for(;n%2==0;c++)n/=2;
			int t=(1<<c);
			cout << N << " " << (N^t)+1+N << endl;
			cout << N*2 << " " << t << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2304
#include<stdio.h>


int main()
{
	int n, i;
	int e, p, q, cnt;
	long long num[4000] = { 0 };
	int flag[4000] = { 0 };
	//long long tmp;

	while (1) 
	{
		scanf("%d", &n);
		if (n == 0) 
		{
			break;
		}

		cnt = 1;
		for (i = 0; i < 4000; ++i) 
		{
			num[i] = 0;
			flag[i] = 0;
		}

		for (i = 0; i < n; ++i) 
		{
			scanf("%d %d %d", &e, &p, &q);
			num[e] += p * q;


			if (num[e] >= 1000000) 
			{
				cnt = 0;
				if (flag[e] == 0) 
				{
					printf("%d\n", e);
					flag[e] = 1;
				}
			}
		}
		if (cnt)
		{
			printf("NA\n");
		}
	}

	return 0;
}


Measured memory_bytes: 668
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    string s,t;
    cin>>s>>t;
    int ans = 0;
    rep(i,3)ans+=(s[i]==t[i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       int n=sc.nextInt();
       
       int s=n%60;
       int m=n/60;
       int h=m/60;
       m =m%60;
       System.out.printf("%d",h);
       System.out.printf(":%d",m);
       System.out.printf(":%d\n",s);
 }
   }

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

int main(){
	ios::sync_with_stdio(false);
	int N; cin>>N;
	vector<int> X(N); rep(i,N) cin>>X[i];

	int mimu = 1e9;
	for(int i=1; i<=100; i++){
		int sum=0;
		for(int j=0; j<X.size(); j++){
			sum += (i-X[j])*(i-X[j]);
		}
		mimu = min(mimu,sum);
	}
	cout << mimu << endl;
}


Measured memory_bytes: 3596
n = gets.to_i
as = gets.split.map(&:to_i)

cs = Hash.new(0)
as.each do |a|
  cs[a] += 1
end

ans = Array.new(cs.keys.count + 1, 0)

sum = cs.inject(0) do |r, (_k, v)|
  r + v * (v - 1) / 2
end

as.each do |a|
  puts sum - (cs[a] - 1)
end


Measured memory_bytes: 31144
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>


using namespace std;

const int MAX	= 1e5 + 5;
const int LIM	= 3e5 + 5;
const int MOD	= 1e9 + 7;
const long double  EPS	= 1e-10;
const double PI = acos(-1.0);

typedef long long LL; 
typedef long double LD;


#define uint64 unsigned long long
#define int64 long long


#define IOS  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

////////////////////////////////////////////////////////////////

int main()
{
    uint64 H{0},W{0};

    cin >> H >> W;

    if( H == 1 || W == 1) {
        cout << 1  << endl;
    }
    else {
       cout << (H * W + 1) / 2 << endl;
    }    
    return 0;
}




Measured memory_bytes: 3640
#######################################
def csi(s=gets,spst=" ")
  if s==nil
    return 0
  end
  return s.chomp.split(spst).map(&:to_i)
end
def css(s=gets,spst=" ")
  if s == nil
    raise "nil!"
  end
  return s.chomp.split(spst).map(&:to_s)
end
def ml(n,datatype=:int)
  t = []
  case datatype
  when :int
    n.times do
      t.push(gets.to_i)
    end
  when :str
    n.times do
      t.push(gets.chomp.to_s)
    end
  else
    raise "n!"
  end
end
#######################################

N = gets.to_i
P,Q = csi , csi

arr = []

puts ((1..N).to_a.permutation(N).to_a.index(P)-(1..N).to_a.permutation(N).to_a.index(Q)).abs


Measured memory_bytes: 8188
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

bool e[100000];
int main() {
	vector<int>v;
	int a;
	cin >> a;
	for (int b = 0; b < a; b++)scanf("%d", &e[b]);
	for (int c = 0; c < a; c++) {
		int d = c;
		for (; d < a - 1; d++) {
			if (e[d] == e[d+1])break;
		}
		v.push_back(d - c + 1);
		c = d;
	}
	switch (v.size()) {
	case 1:cout << v[0] << endl; break;
	case 2:cout << v[0] + v[1] << endl; break;
	default:int MAX = 0;
		for (int i = 1; i < v.size() - 1; i++)MAX = max(MAX, v[i - 1] + v[i] + v[i + 1]);
		cout << MAX << endl;
	}
}

Measured memory_bytes: 3412
#include <iostream>
#include <stdio.h>
#include <map>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
#define lowbit(k) k&-k
#define pi	3.1415926535
const int INF = 0x3f3f3f3f;
int main()
{
	int a, b;
	cin >> a >> b;
	int flag = 0;
	if (a > b)
		swap(a, b);
	for (int i = a; i <= b; i++)
	{
		int s = a * b*i;
		if (s % 2 == 1)
		{
			flag = 1;
			break;
		}
	}
	if (flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
object Main extends App {
 
  def safeDivide(l: Double, r: Double) = if (l == 0.0) 0.0 else l / r
  def format(x: Double) = {
    val s = (x * 1000).round formatted "%04d"
    s.dropRight(3) + "." + s.takeRight(3)
  }
 
  val sc = new java.util.Scanner(Console.in)
 
  while (sc.hasNextLine()) {
    val line = sc.nextLine()
    val Array(a, b, c, d, e, f) = line.split(' ').map(_.toDouble)
    val x = safeDivide(c*e - b*f, a*e - b*d)
    val y = safeDivide(c - a*x, b)
 
    println(format(x) + " " + format(y))
  }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 1000000000;
const ll M = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/*----------------------------------------------/
/- char         : %c  | char *       : %s  | short        : %hd
/- int          : %d  | long         : %ld | long long    : %lld
/- unsigned short:%hu | unsigned int : %u  | unsigned long: %lu
/- u_long long  : %llu| (octal)      : %o  | (hexadecimal): %x
/- float        : %f  | double       : %lf |
/----------------------------------------------*/

/*----------------------------------------------/
/- INT_MAX, LONG_MAX   : 1<<15 = 2.1*pow(10, 9)       (= 2147483647)
/- UINT_MAX, ULONG_MAX : 1<<16 = 4.2*pow(10, 9)       (= 4294967295)
/- LLONG_MAX           : 1<<63 = 9.2*pow(10, 18)      (= 9223372036854775807)
/- ULLONG_MAX          : 1<<64 = 1.8*pow(10, 19)      (= 18446744073709551615)
/----------------------------------------------*/

int main() {
    int k, t;
    int a[102];
    scanf("%d%d", &k, &t);
    rep(i, t) scanf("%d", &a[i]);

    int A = 0;
    rep(i, t) A = max(A, a[i]);

    if (A <= (k + 1) / 2)
        puts("0");
    else
        cout << (k - 1) - 2 * (k - A);

    /* ====================================== */
    cout << endl;
    return 0;
}

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

typedef long long int int64;

void run(void){
  char *s=(char *)malloc(sizeof(char)*200001);
  scanf("%s",s);
  int n=strlen(s);
  int64 ans=1;
  int cnt[26]={};
  int i;
  for(i=0;i<n;i++){
    ans+=i-cnt[s[i]-'a'];
    cnt[s[i]-'a']++;
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>

int main() {
	std::string a, b, c;

	std::cin >> a >> b >> c;

	auto aptr = a.begin();
	auto bptr = b.begin();
	auto cptr = c.begin();
	auto ptr = &aptr;

	while(true) {
		if(*ptr == a.end()) {
			std::cout << "A" << std::endl;
			return 0;
		}else if(*ptr == b.end()){
			std::cout << "B" << std::endl;
			return 0;
		}else if(*ptr == c.end()) {
			std::cout << "C" << std::endl;
			return 0;
		}

		if(*(*ptr) == 'a') {
			++(*ptr);
			ptr = &aptr;
		}else if(*(*ptr) == 'b') {
			++(*ptr);
			ptr = &bptr;
		}else if(*(*ptr) == 'c') {
			++(*ptr);
			ptr = &cptr;
		}
	}
}

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

int main(){
	int n;
	string s;
	cin>>n>>s;
	int x = 0;
	int ans = 0;
	for(int i = 0;i<s.size();i++){
		if(s[i]=='I'){
			x+=1;
			ans=max(ans,x);
		}else{
			x--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
while(True):
  m, f, r = map(int, input().split())
  mf = m + f
  if m == -1 and f == -1 and r == -1:
    break
  elif m == -1 or f == -1:
    print("F")
  elif 80 <= mf:
    print("A")
  elif 65 <= mf and mf < 80:
    print("B")
  elif 50 <= mf and mf < 65:
    print("C")
  elif 30 <= mf and mf < 50:
    if 50 <= r:
      print("C")
    else:
      print("D")
  elif mf < 30:
      print("F")



Measured memory_bytes: 5592
import math
import decimal
a,b,h,m = map(int,input().split())
long = m/60*360
short = h*30+(m/60*30)
kakudo = abs(long-short)
if kakudo > 180:
    kakudo = 360-kakudo
dum = kakudo/180*3.141592653589793238462643
radi = math.cos(dum)
ans = a**2 + b**2 - (2*a*b*radi)
ans = ans ** (1/2)
print(ans)


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

int n;

struct Node
{
  int key;
  Node *parent, *left, *right;
};

// rootの初期化はしなくていいの? <- ともに値が0になっている
Node *root, *NIL;

void insert(int key)
{
  // zの親を格納する
  Node *y = NIL;
  Node *x = root;

  // zの生成
  Node *z = (Node *)malloc(sizeof(Node));
  z->key = key;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL)
  {
    y = x;
    if (key < x->key)
    {
      x = x->left;
    }
    else
    {
      x = x->right;
    }
  }

  // yにはzの親が格納されている
  z->parent = y;

  if (y == NIL)
  {
    root = z;
  }
  else if (key < y->key)
  {
    y->left = z;
  }
  else
  {
    y->right = z;
  }
}

Node *find(int key)
{
  Node *x = root;
  while (x != NIL)
  {
    if (key == x->key)
    {
      return x;
    }
    else if (key < x->key)
    {
      x = x->left;
    }
    else
    {
      x = x->right;
    }
  }
  return NIL;
}

Node *get_min(Node *z)
{
  while (z->left != NIL)
  {
    z = z->left;
  }
  return z;
}

// zの次節点を返す
Node *find_next(Node *z)
{
  if (z->right != NIL)
  {
    return get_min(z->right);
  }
  Node *p = z->parent;
  while (p != NIL && z == p->right)
  {
    z = p;
    p = p->parent;
  }
  return p;
}

void del(Node *z)
{
  if (z->left == NIL && z->right == NIL)
  {
    // zがleafのとき
    if (z == root)
    {
      root = NIL;
      return;
    }
    // zの親pからzという存在を消す
    Node *p = z->parent;
    if (p->left == z)
    {
      // pの左の子がzのとき
      p->left = NIL;
    }
    else
    {
      // pの右の子がzのとき
      p->right = NIL;
    }
  }
  else if (z->left == NIL || z->right == NIL)
  {
    // zの子が1つのとき
    Node *c;
    if (z->left != NIL)
    {
      c = z->left;
    }
    else
    {
      c = z->right;
    }
    if (z == root)
    {
      root = c;
    }
    else
    {
      Node *p = z->parent;
      if (p->left == z)
      {
        p->left = c;
        c->parent = p;
      }
      else
      {
        p->right = c;
        c->parent = p;
      }
    }
  }
  else
  {
    // zの子が2つのとき
    Node *y = find_next(z);
    z->key = y->key;
    del(y);
  }
}

void inorder(Node *u)
{
  // ベースケース
  if (u == NIL)
  {
    return;
  }
  // 再帰ステップ
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u)
{
  // ベースケース
  if (u == NIL)
  {
    return;
  }
  // 再帰ステップ
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    string com;
    cin >> com;
    if (com.at(0) == 'i')
    {
      // 挿入
      int key;
      cin >> key;
      insert(key);
    }
    else if (com.at(0) == 'p')
    {
      // 出力
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if (com.at(0) == 'f')
    {
      // 探索
      int key;
      cin >> key;
      if (find(key) != NIL)
      {
        printf("yes\n");
      }
      else
      {
        printf("no\n");
      }
    }
    else if (com.at(0) == 'd')
    {
      // 削除
      int key;
      cin >> key;
      if (find(key) != NIL)
      {
        del(find(key));
      }
    }
  }
}


Measured memory_bytes: 21932
#include<iostream>
#include<cstdio>

using namespace std;
const int maxn = 2000000;
int pa[maxn];
int find(int x)
{
    if(pa[x] == x) return x;
    else return pa[x] = find(pa[x]);
}

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i = 1;i <= n;i++){
        pa[i] = i;
    }
    for(int i = 1;i <= m;i++){
        int x,y,k;
        scanf("%d%d%d",&x,&y,&k);
        int px = find(x);
        int py = find(y);
        pa[px] = py; 
    }
    int ans = 0;
    for(int i = 1;i <= n;i++){
        if(find(i) == i){
            ans ++ ;
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
template<class T> inline bool chmin(T& a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
int main(){
    ll k,a,b;cin>>k>>a>>b;
    int c=1;
    bool ok=false;
    while(k*c<=1000){
        if(k*c>=a&&k*c<=b){
            ok=true;
            break;
        }
        c++;
    }
    if(ok)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    double n=0,a=0,b=0,c=0,d=0,i=0,j=0;
    while(1){
        cin >> n;
        if(n==0)break;
        b=0;
        for(i=0;i<n;i+=4){
            cin >> a;
            b+=a;
        }
        cout << b << endl;
    }

}

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

#define INPUT freopen("input.txt", "r", stdin);

#define ll long long
#define ld long double

#define len(s) s.size()

#define fl(st, en, in) for (int i = st; i < en; i += in)
#define rfl(st, en, de) for (int i = st; i < en; i -= de)

#define cy cout << "Yes" << endl;
#define cn cout << "No" << endl;
#define ci(s) cin >> s
#define co(s) cout << s << endl

int main()
{
    //INPUT;

    ll n;
    cin >> n;
    ll ar[n];
    fl(0, n, 1)
    {
        cin >> ar[i];
    }
    ll ans = 0;
    ll tm = ar[0];
    fl(1, n, 1)
    {
        ans = ans + max((ll)0, tm - ar[i]);
        tm = max(tm, ar[i]);
    }
    co(ans);
}

Measured memory_bytes: 5152
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define filein freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);


void fun1(int* a,int* b){
    int sum=*a+*b;
    int dif=abs(*a-*b);
    //cout<<sum<<dif<<"\n";
    *a=sum;
    *b=dif;
}


int main() {


    int n,m;
    cin>>n>>m;
    int a[n];
    double d=(double)1/(4*m);
    //cout<<d<<endl;
    int sum=0;
    for (int i = 0; i <n ; ++i) {

        cin>>a[i];
        sum+=a[i];
    }
    int count=0;
    for (int j = 0; j <n; ++j) {
        double t=(double)a[j]/sum;
        //cout<<t<<endl;
        if (t>=d)
            count++;
    }
    if (count>=m)cout<<"Yes\n";
    else cout<<"No\n";




}


Measured memory_bytes: 3576
def f(w):
    if w <= 10:
        return 4280 - 1150
    elif w <= 20:
        return 4280 - (1150 + f1(w - 10))
    elif w <= 30:
        return 4280 - (1150 + f1(10) + f2(w - 20))
    else:
        return 4280 - (1150 + f1(10) + f2(10) + f3(w - 30))


def f1(x):
    return x * 125


def f2(x):
    return x * 140


def f3(x):
    return x * 160


while True:
    _w = int(input())
    if _w == -1:
        break
    print(f(_w))

Measured memory_bytes: 7652
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;
const ll INF = (ll)1e12;

int main() {
	int N;
	cin >> N;
	vector<vector<pair<int, ll>>> c(N + 1);
	REP(i,N - 1){
		int aa, bb;
		ll cc;
		cin >> aa >> bb >> cc;
		c[aa].push_back({ bb,cc });
		c[bb].push_back({ aa,cc });
	}

	int Q, K;
	cin >> Q >> K;
	VI x(Q), y(Q);
	REP(i, Q) cin >> x[i] >> y[i];

	VL dist(N + 1,0);
	VB node(N + 1,true);
	queue<pair<int,ll>> que;
	que.push({K,0});

	while(!que.empty()){
		int p = que.front().first;
		ll pdist = que.front().second;
		dist[p] = pdist;
		node[p] = false;

		que.pop();
		REP(i, c[p].size()){
			if(node[c[p][i].first]) que.push({ c[p][i].first, pdist + c[p][i].second });
		}	
	}
	
	REP(i, Q) cout << dist[x[i]] + dist[y[i]] << endl;
	return 0;
}


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

int main()
{
  long long N, K, Q, A, i;
  
  cin >> N >> K >> Q;
  long long pt[N] = {};
  for(i=0; i<Q; i++){
    cin >> A;
    pt[A-1] ++;
  }
  for(i=0; i<N; i++){
    if (pt[i] + K - Q > 0){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1408
h,w = map(int,input().split())
ls  = [[x for x in input()] for _ in range(h)]



for i in range(h):
    ls[i].append("#")
    ls[i].insert(0,"#")

a = [ "#" for _ in range(w+2)]

ls.append(a)
ls.insert(0,a)

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

Measured memory_bytes: 38640
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define endl "\n"
#define sz(u) (int)(u.size())
#define L(x)(2*x)
#define R(x)(2*x+1)
#define M(x,y)((x+y)/2)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int n,m,k,ans=0;
char t[7][7];
void dfs(int index,unordered_map<int,bool> removed_r,unordered_map<int,bool> removed_c){
    if(index==n+m){
            int cnt=0;
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
                if(t[i][j]=='#' && !removed_r[i] && !removed_c[j])
                    cnt++;
        if(cnt==k){
            ans++;
            /*
            cout<<"rows : ";
            for(int i=0;i<n;i++)
                if(removed_r[i])
                    cout<<i<<" ";
            cout<<endl;
            cout<<"columns : ";
            for(int i=0;i<m;i++)
                if(removed_c[i])
                    cout<<i<<" ";
            cout<<endl<<endl;
            */
        }

        return ;
    }
    else if(index<=n-1){
        dfs(index+1,removed_r,removed_c);
        removed_r[index]=1;
        dfs(index+1,removed_r,removed_c);
    }
    else if(index<=n+m-1 && index>n-1){
        dfs(index+1,removed_r,removed_c);
        removed_c[index-n]=1;
        dfs(index+1,removed_r,removed_c);
    }
}
void solve(){

    cin>>n>>m>>k;

    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>t[i][j];
    unordered_map<int,bool> tr;
    unordered_map<int,bool> tc;
    dfs(0,tr,tc);
    cout<<ans;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
}


Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
signed main() {
	for (int z = 0; z < 1000; z++) {
		int n, m, cnt = 0; cin >> n >> m;
		if (n == 0 && m == 0) { return 0; }
		for (int h = 1; h <= n; h++) {
			for (int i = h + 1; i <= n; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (h + i + j == m) { cnt++; }
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  int odd = 0;
  rep(i,N){
    if(v[i]%2==1) odd++;
  }

  if(odd%2==1) cout << "NO" << endl;
  else cout << "YES" << endl;
  
  return 0;
}



Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<stdio.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    vector<int> a(26,0),b(26,100);
    for(int i=0;i<n;i++){
        cin >> s;
        for(int j=0;j<s.size();j++) a[s[j]-'a']++;
        for(int j=0;j<26;j++){
            b[j]=min(a[j],b[j]);
            a[j]=0;
        }
    }
    for(int i=0;i<26;i++){
        for(int j=0;j<b[i];j++){
            printf("%c",'a'+i);
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long N,temp,sum;


int main(){
 cin >> N;
 vector<int> A(N);
 for(int i = 0; i <  N; i++){
   scanf("%d",&temp);
   A[i] = temp - (i + 1);
 }
 sort(A.begin(),A.end());

 if(N%2){
  temp = A[N / 2];//tempのにどめの使用
 } else{
  temp = (A[N / 2] + A[N / 2 - 1]) / 2;
 }

 for(int i = 0; i < N; i++) sum += abs(A[i] - temp);

 cout << sum << endl;
 return 0;
}


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

int main()
{
    int p1[2019];
    int p2[2019];
    for( int i = 0; i < 2019; i++) p1[i] = 0;
    for( int i = 0; i < 2019; i++) p2[i] = 0;
    int *current = p1;
    int *next = p2;
    int ans = 0;
    {
        char c = getchar();
        int n = c - '0';
        current[n] = 1;
    }

    while(true)
    {

        char c = getchar();
        if( c < '1' || c > '9' ) break;
        int n = c - '0';
        for( int i = 0; i < 2019; i++ ) next[i] = 0;
        next[n] = 1;
        for( int i = 0; i < 2019; i++ )
        {
            int nmod = (10 * i + n) % 2019;
            next[nmod] += current[i];
        }
        ans += next[0];

        if( current == p1 )
        {
            current = p2;
            next = p1;
        }
        else
        {
            current = p1;
            next = p2;
        }
    }

    cout << ans;

    return 0;    
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() { 
	int n;
	cin >> n;
	set<int> s;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		s.insert(x);
	}
	cout << (int)s.size();
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
 
typedef pair<int,int> P;
const int MAX=1000000000;
 
int main() {
  int L,n;
  cin >> L >> n;
  map<int,P> a;
  map<int,int> m;
  for(int i=0; i<n; i++) {
    int x,y,z;
    cin >> x >> y >> z;
    a[x].first=y;
    a[x].second=z;
    m[x]=MAX;
    m[x+y]=MAX;
  }
  m[L]=MAX;
  m[0]=0;
  map<int,int>::iterator it=m.begin();
  while(it!=m.end() && it->first<L) {
    map<int,int>::iterator now=it++;
    int i=now->first,j=it->first;
    m[j]=min(m[j],m[i]+(j-i));
    if(a[i].first) m[i+a[i].first]=min(m[i+a[i].first],now->second+a[i].second);
  }
  cout << m[L] << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#define n_MAX 20
#define q_MAX 200
int solve(int ,int,int);
int a[n_MAX];
int b[q_MAX];
int main(){
  int i,n,q;
  scanf("%d" ,&n);
  for(i = 0;i<n;i++){
    scanf("%d",&a[i]);    
  }
  scanf("%d" ,&q);
  for(i = 0;i<q;i++){
    scanf("%d",&b[i]);    
  }
  for(i =0;i<q;i++){
    if(solve(0,b[i],n)==0)
      printf("no\n");
      else printf("yes\n");
  }
  return 0;
}

int solve(int i,int m,int n){
  int res1,res2;
  if(m ==0)
    return 1;
  if(i>=n)
    return 0;
  if(solve(i+1,m-a[i],n) ==0 && solve(i+1,m,n) ==0){
    return 0;
  }
  else return 1;
}





Measured memory_bytes: 2108
import collections

S = list(input())
c = collections.Counter(S)
ans = 'NO'
ma = c.most_common()[0][1]
if (len(c) == 1):
  if (len(S) == 1):
    ans = 'YES'
elif (len(c) == 2):
  if (len(S) == 2):
    ans = 'YES'
else:
  if (c.most_common()[1][1] >= ma - 1) and (c.most_common()[2][1] >= ma - 1):
    ans = 'YES'
print(ans)

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

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

Measured memory_bytes: 256
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 t = sc.nextInt();
		sc.close();
		
		System.out.println(b*(t/a));
				
				

	}

}


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

int main() {
  string s;
  cin >> s;
  if (s.at(0)==s.at(1)) {
    cout << "Bad" << endl;
  }
  else if (s.at(1)==s.at(2)) {
    cout << "Bad" << endl;
  }
  else if (s.at(2)==s.at(3)) {
    cout << "Bad" << endl;
  }
  else {
    cout << "Good" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k,x;cin >> k >> x;
	for(int i = x - k + 1; i < x + k; i++){
		if(i == x + k - 1) cout << i << endl;
		else cout << i << " ";
	}
}


Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:1024000000,1024000000")
/* vim: set fdm=marker */
//{{{
#define __ return
int ATTENTION() {
	/* pls IGNORE this function and go down and HACK me
	 * read this AFTER contest
	 * this function is empty and it will not be called !
	 */

	http://codeforces.com/group/Pmz2A2x7ES
	/* I created a group there.
	 * I hope with the group, people can finish
	 * past contests, which is important for 
	 * increasing rating.
	 * I am still getting familiar with this function.
	 */
	 __ 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < 0) return gcd(-a, b);
	if(b < 0) return gcd( a,-b);
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}

ll qpow(ll a, ll n, ll mod) {
	a %= mod;
	ll ans = 1LL;
	while(n) {
		if(n & 1) ans = (ans*a % mod);
		a = (a*a % mod);
		n >>= 1;
	}
	return ans;
}

inline ll rev(ll a, ll p) {
	return qpow(a, p - 2, p);
}

#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define rep(x, st, en) for(int x = st; x < en; x++)
#define rer(x, st, en) for(int x = st; x >= en; x--)
#define pb push_back
#define mp make_pair
#define dbgm(msg, var) cerr<<#msg<<" "<<#var<<" = "<<var<<endl; 
#define dbg(var) cerr<<#var<<" = "<<var<<endl;
#define X first
#define Y second
// build prefix sum
template<typename T>
inline void BPS(T* DST, T* SRC, int N, int s = 0) {
	DST[s] = SRC[s];
	rep(i, 1, N) DST[s + i] = DST[s + i - 1] + SRC[s + i];
}
inline int in() { int x; cin>>x; return x; }
#ifdef ALNDBG
namespace alndbg {
	clock_t s, e;
}
#endif

inline void tic() {
#ifdef ALNDBG
	alndbg::s = clock();
#endif
}

inline void toc() {
#ifdef ALNDBG
	alndbg::e = clock();
	cerr<<1000.0 * (alndbg::e - alndbg::s) / CLOCKS_PER_SEC<<" ms"<<endl;
#endif
}



//}}}

// -------------------- Spliters ------------------------
// BFS求最短路小心vis可能访问过
const int maxn = 1000;

int A[maxn];

ll ans[2];

int main() {
	ios::sync_with_stdio(0);
  int N, P;
  cin>>N>>P;
  rep(i,0,N) cin>>A[i];
  ans[0] = 1; ans[1] = 0;
  ll tmp[2];
  rep(i,0,N) {
    int mod = A[i] % 2;
    if(mod == 0) {
      tmp[0] = ans[0] + ans[0];
      tmp[1] = ans[1] + ans[1];
    } else {
      tmp[0] = ans[0] + ans[1];
      tmp[1] = ans[1] + ans[0];
    }
    ans[0] = tmp[0];
    ans[1] = tmp[1];
  }
  cout<<ans[P]<<endl;
	return 0;
}
// --USE C++11
// *-USE O2


Measured memory_bytes: 256