akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
int a,b,c,d,e,k;
cin>>a>>b>>c>>d>>e>>k;
if(abs(a-b)>k){
cout<<":("<<endl;
}
else if(abs(a-c)>k){
cout<<":("<<endl;
}
else if(abs(a-d)>k){
cout<<":("<<endl;
}
else if(abs(a-e)>k){
cout<<":("<<endl;
}
else if(abs(b-c)>k){
cout<<":("<<endl;
}
else if(abs(b-d)>k){
cout<<":("<<endl;
}
else if(abs(b-e)>k){
cout<<":("<<endl;
}
else if(abs(c-d)>k){
cout<<":("<<endl;
}
else if(abs(c-e)>k){
cout<<":("<<endl;
}
else if(abs(d-e)>k){
cout<<":("<<endl;
}
else{
cout<<"Yay!"<<endl;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++)
    cin>>h[i];
    long long a[n];
    a[0]=0;
    if(n>=2){
    a[1]=max(0,abs(h[1]-h[0]));
    }
    for(int i=2;i<n;i++){
        a[i]=min(a[i-1]+abs(h[i]-h[i-1]),a[i-2]+abs(h[i]-h[i-2]));
    }
    /*
    for(int i=0;i<n;i++)
    cout<<a[i]<<" ";
    cout<<endl;
    */
    cout<<a[n-1]<<endl;
    
}

Measured memory_bytes: 1408
// Ryo Kamoi
//#define DEBUG

#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>

using namespace std;

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

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

int INF = 1000000000;

vector<int> row[2010];
vector<int> col[2010];

int h, w;
string field[2010];

int bisearch(int idx, vector<int>& vec) {
  int l = -1, r = vec.size();
  int u = (l+r) / 2;
  while(1) {
    if (r - l == 1) break;

    if (vec[u] > idx) {
      r = u;
    } else {
      l = u;
    }
    u = (l+r) / 2;
  }

  return l;
}

int main(){
  cin >> h >> w;
  REP(i, h) {
    cin >> field[i];
  }

  REP(i, h) {
    REP(j, w) {
      if (field[i][j] == '#') {
        row[i].push_back(j);
        col[j].push_back(i);
      }
    }
  }

  int output = 0;
  REP(i, h) {
    REP(j, w) {
      if (field[i][j] == '#') continue;
      int cur = 0;

      int colidx = bisearch(i, col[j]);
      if (col[j].size() == 0) {
        cur += h;
      } else {
        int lb, ub;
        if (colidx == -1) {
          lb = 0;
        } else {
          lb = col[j][colidx]+1;
        }

        if (colidx+1 == col[j].size()) {
          ub = h;
        } else {
          ub = col[j][colidx+1];
        }
        cur += ub - lb;
#ifdef DEBUG
        cout << ub << " " << lb << endl;
#endif
      }

      int rowidx = bisearch(j, row[i]);
      if (row[i].size() == 0) {
        cur += w;
      } else {
        int lb, ub;
        if (rowidx==-1) {
          lb = 0;
        } else {
          lb = row[i][rowidx]+1;
        }

        if (rowidx+1==row[i].size()) {
          ub = w;
        } else {
          ub = row[i][rowidx+1];
        }
        cur += ub - lb;
#ifdef DEBUG
        cout << ub << " " << lb << endl;
#endif
      }

      cur--;
#ifdef DEBUG
      cout << i << " " << j << " " << colidx << " "
        << rowidx << " " << cur << endl;
#endif
      output = max(output, cur);
    }
  }
  cout << output << endl;
}


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

using namespace std;

const int MAXN = 1000;

int arr[MAXN+1];

int main()
{
	int n,m;
	
	scanf("%d%d",&n,&m);
	
	if(n>m)printf("%d",n-1);
	else printf("%d",n);
	
	for(int i=0;i<n;i++)
	{
		
	}
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n,l;cin>>n>>l;
    vector<int> v;
    int sum=0;
    rep(i,1,n+1){
        int now=l+i-1;
        sum+=now;
        v.push_back(now);
    }
    sort(v.begin(),v.end());
    int mi=1000000000;
    rep(i,0,v.size()){
        if(abs(v[i])<abs(mi))mi=v[i];
    }
    cout<<sum-mi<<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }



signed main(){

    int N; cin >> N;
    double ans = 0, x;
    string s;
    REP(i, N){
        cin >> x >> s;
        if(s == "JPY") ans += x;
        else ans += 380000 * x;
    }
    cout << setprecision(15) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll dp[101][101][505];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll W;
	cin >> n >> W;
	vector<ll> w(n), v(n);
	cin >> w[0] >> v[0];
	ll w0 = w[0];
	for(int i = 1; i < n; ++i){
		cin >> w[i] >> v[i];
		w[i] -= w0;
	}
	w[0] = 0;
	ll ans = 0;
	rep(i,n)rep(j,n)rep(k,501){
		if((j+1)*w0 + (k+w[i]) <= W){
			chmax(dp[i+1][j+1][k+w[i]], dp[i][j][k] + v[i]);
			chmax(ans, dp[i+1][j+1][k+w[i]]);
		}
		chmax(dp[i+1][j][k], dp[i][j][k]);
		chmax(ans, dp[i+1][j][k]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 40064
N = int(input())
A = list(map(int, input().split()))

a = [0]*N

sum_a=sum(A)
a[0]=sum_a
for i in range(1,N,2):
    a[0]-=2*A[i]
print(a[0],end=" ")

for i in range(1,N):
    a[i]=2*A[i-1]-a[i-1]
    print(a[i],end=" ")


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

int main(void)
{
    int n;
    cin >> n;
    float a[100];
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n-1;i++)
    {
        a[0] = (a[0] + a[i+1])/2;
    }
    cout << a[0];
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func isqrt(n int) int {
	if n < 0 {
		panic("isqrt argument must be nonnegative")
	}

	if n <= 1 {
		return n
	}

	ok := 0
	ng := 3037000500 // 3037000499 * 3037000499 < math.MaxInt64 < 3037000500 * 3037000500
	if n < ng {
		ng = n
	}
	for ng-ok > 1 {
		m := ok + (ng-ok)/2
		if m*m <= n {
			ok = m
		} else {
			ng = m
		}
	}
	return ok
}

func makeDivisorList(n int) []int {
	result := make([]int, 0)
	for i := 1; i <= isqrt(n); i++ {
		if n%i == 0 {
			result = append(result, i)
			result = append(result, n/i)
		}
	}
	return result
}

func calcMinOps(r []int, d int) int {
	i, j := 0, len(r)
	for i < j && r[i] == 0 {
		i++
	}
	i--
	a, b := 0, 0
	for j-i != 1 {
		if a <= b {
			i++
			a += r[i]
		} else {
			j--
			b += d - r[j]
		}
	}
	return a
}

func main() {
	defer flush()

	N := readInt()
	K := readInt()

	A := make([]int, N)
	c := 0
	for i := 0; i < N; i++ {
		A[i] = readInt()
		c += A[i]
	}
	r := make([]int, N)

	divisors := makeDivisorList(c)
	sort.Sort(sort.Reverse(sort.IntSlice(divisors)))
	for i := 0; i < len(divisors); i++ {
		d := divisors[i]
		for j := 0; j < N; j++ {
			r[j] = A[j] % d
		}
		sort.Ints(r)
		if calcMinOps(r, d) <= K {
			println(d)
			break
		}
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 2000
# -*- coding: utf-8 -*-

N, K = map(int, input().split())
S = list(str(input()))
K  -= 1

if S[K] == "A" :
  S[K] = "a"
elif S[K] == "B" :
  S[K] = "b"
else :
  S[K] = "c"
  
ans = "".join(S)
print(ans)

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main()
{
    long long int a, b;
    cin>>a>>b;
    
    long long int x = a*b;
    if(a<b){
       int tmp = a;
       a = b;
       b = tmp;
     }
     long long int r = a % b;
     while(r!=0){
       a = b;
       b = r;
       r = a % b;
     }
    cout << x/b << endl;
	return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
use std::cmp;
fn main() {
    input!{
        a: u8,
        b: u8,
    }
    for i in vec![cmp::min(a, b); cmp::max(a, b) as usize] {
        print!("{}", i);
    }
    println!();
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
 
#define lp(i, x, y) for(int i = x ; i < y ; i++)
#define lp_rev(i, x, y) for(int i = x ; i >= y ; i--)
#define ff first
#define ss second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(v)  v.begin(), v.end()
#define vll vector<long long int>
#define vi vector<int>
#define Fasttt ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
typedef unsigned long long ull;
typedef long long ll;
#define endl "\n"
ll mod = 1000000007;

int main()
{
	int n, wt;
	cin>> n>> wt;
	vll w(n), val(n);
	lp(i, 0, n)
		cin>> w[i]>> val[i];
	ll dp[n + 1][wt + 1];
	lp(i, 0, n + 1)
		dp[i][0] = 0;
	lp(i, 0, wt + 1)
		dp[0][i] = 0;
	lp(i, 1, n + 1)
	{
		lp(j, 1, wt + 1)
		{
			if(w[i - 1] > j)
			{
				dp[i][j] = dp[i - 1][j];
			}
			else
			{
				ll val1 = dp[i - 1][j];
				ll val2 = val[i - 1] + dp[i - 1][j - w[i - 1]];
				dp[i][j] = max(val1, val2); 
			}
		}
	}
	cout<< dp[n][wt];
	return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i ++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i --)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return 1;}return 0;}

constexpr ll INF = (1ll << 60);
constexpr ll MOD = 1000000007ll;


// べき乗を計算　指数を計算
ll llpow(ll a, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


int main(){
    ll n;
    cin >> n;
    vector<ll> a(n+10);
    PREP(i, 1, n+1){
        cin >> a[i];
    }

    vector<ll> p(n+10), q(n+10);
    PREP(i, 1, n+1){
        p[i] = i - a[i];
        q[i] = i + a[i];
    }

    map<ll, ll> mp, mq;
    PREP(i, 1, n+1){
        mp[p[i]]++;
        mq[q[i]]++;
    }

    ll ans = 0;
    MREP(i, n, 1){
        ll pp = i - a[i], qq = i + a[i];
        mq[qq]--;
        ans += mq[pp];
    }
    // PREP(i, 1, n+1){
    //     ll pp = i - a[i], qq = i + a[i];
    //     mp[pp]--;
    //     ans += mp[qq];
    // }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 42100
using System;
 
class main{
  public static void Main(string[] args){
    string[] s = Console.ReadLine().Split(" ");
    decimal a = decimal.Parse(s[0]);
    decimal b = decimal.Parse(s[1]);
    decimal ans = Math.Ceiling(a*b/2);
    
    if(a == 1 || b == 1)ans = 1;
    
    Console.WriteLine(ans);
  }
}

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

int main()
{
  int64_t N, Q, a, b, c, sum = 0;
  cin >> N;
  vector<int64_t> V(100010, 0);
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    sum += a;
    V.at(a)++;
  }

  cin >> Q;
  for (int i = 0; i < Q; i++)
  {
    cin >> b >> c;
    int64_t n = V[b];
    V[b] = 0;
    V[c] += n;
    sum = sum - (b * n) + (c * n);
    cout << sum << endl;
  }
}

Measured memory_bytes: 4000
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    
    int a[6], ans;
    for(int i = 0; i < 5; i++){
        cin >> a[i];
        if(a[i] == 0){
            ans = i + 1;
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3528
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int A, B;
  ci(A, B);
  co(max(A + B, max(A - B, A * B)));
}


Measured memory_bytes: 256
#138_E
from bisect import bisect_left, bisect_right
#leftはある数未満,rightはある数以下を返す
s = input()
t = input()
if set(s) >= set(t):
    al_idx = [[] for _ in range(26)]
    ss = s * 2
    alp = 'abcdefghijklmnopqrstuvwxyz'
    for i in range(len(ss)):
        al_idx[alp.index(ss[i])].append(i)
    
    tmp = -1
    ans = 0
    for j in range(len(t)):
        idx = alp.index(t[j])
        cur = bisect_right(al_idx[idx], tmp)
        ans += al_idx[idx][cur] - tmp
        tmp = al_idx[idx][cur] % len(s)
        
    print(ans)
else:
    print(-1)

Measured memory_bytes: 12020
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
int n,x,sum;
bitset<2000010>f;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
    cin>>n;f[0]=1;
    for(int i=1;i<=n;i++){
        cin>>x;
        f|=f<<x;
        sum+=x;
    }
    for(int i=(sum+1)/2;i<=sum;i++) if(f[i]) {cout<<i<<'\n';break;}
    return 0;
}

Measured memory_bytes: 1024
# - coding: utf-8 -*-

# 色を返却
def what_color(num):
    if num < 400: #灰色
        return 0
    elif num < 800: #茶色
        return 1
    elif num <1200 : #緑
        return 2
    elif num < 1600: #水色
        return 3
    elif num < 2000: #青
        return 4
    elif num < 2400: #黄色
        return 5
    elif num < 2800: #橙色
        return 6
    elif num < 3200: #赤色
        return 7
    else:
        return 8

n = raw_input()
a = map(int, raw_input().split())

colors = [0, 0, 0, 0, 0, 0, 0, 0]
god = 0
for rate in a:
    color = what_color(rate)
    if color == 8:
        god = god+1
    else:
        colors[color] = 1

sum_colors = sum(colors)

saidai = sum_colors + god
saisyo = sum_colors
if saisyo == 0:
    saisyo = 1

print '{0} {1}'.format(saisyo, saidai)


Measured memory_bytes: 2696
import numpy as np
N,M=map(int,input().split())
A=np.zeros(N)
ans=0
for i in range(M):
  s,t=map(int,input().split())
  if s==1 and t==0 and N!=1:
    ans=1
  elif t==0:
    A[s-1]=99
  else:
    if A[s-1]==0:
      A[s-1]=t
    elif A[s-1]==t:
      A[s-1]=t
    else:
      ans=1
if N!=1:      
  if A[0]==0:
    A[0]=1

if ans==1:
  print(-1)
else:
  for i in range(N):
    if A[i]==99:
      A[i]=0
    ans+=A[i]*(10**(N-i-1))
  print(int(ans))
  

Measured memory_bytes: 14428
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef pair<string, pair<int, int> > P1;
typedef pair<int, int> P2;
vector <pair<string, pair<int, int> > > V;
bool pairCompare(const P1& firstElof, const P1& secondElof)
{
    return (firstElof.first < secondElof.first);
}


bool pairCompare2(const P2& firstElof, const P2& secondElof)
{
    return (firstElof.second > secondElof.second);
}

int main(void){
    // Your code here!
    int N;
    cin >> N;
    string s;
    int p;
    for(int i = 0; i < N; i++){
        cin >> s >> p;
        V.push_back(make_pair(s, make_pair(i+1, p)));
    }
    
    sort(V.begin(), V.end(), pairCompare);
    string last = V[0].first;
    vector<pair<int, int> > sub;
    for(int i = 0; i < N; i++){
        
        if(last == V[i].first) sub.push_back(make_pair(V[i].second.first, V[i].second.second));
        else{
            sort(sub.begin(), sub.end(), pairCompare2);
            for(int j = 0; j < sub.size(); j++){
                cout << sub[j].first << endl;
            }
            sub.clear();
            last = V[i].first;
            sub.push_back(make_pair(V[i].second.first, V[i].second.second));
        }
    }
    
    sort(sub.begin(), sub.end(), pairCompare2);
    for(int j = 0; j < sub.size(); j++){
        cout << sub[j].first << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,1,-1,1,-1,-1,0};
int dy[]={0,1,1,-1,-1,1,0,-1};


vector<string> b3({
        "a..",
        "a..",
        ".aa"});


vector<string> b4({
        "aada",
        "bbda",
        "cacc",
        "cabb"});

vector<string> b5({
        "aabbc",
        "bc..c",
        "bc..a",
        "c.cca",
        "caabb"});

vector<string> b6({
        "aaca..",
        "bbca..",
        "ca..aa",
        "ca..cc",
        "..aaba",
        "..ccba"});

vector<string> b7({
        "aabcc..",
        "b.baa..",
        "bca....",
        "aca....",
        "abb..cc",
        "...acbb",
        "...acaa"});

void f(int k,vector<string> &a,vector<string> &base){
    int n = base.size();
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            a[k+i][k+j] = base[i][j];
        }
    }
}

int main(){
    int n;cin >> n;
    vector<string> ans(n,string(n,'.'));
    if(n==2){
        puts("-1");
        return 0;
    }
    else if(n==3) f(0,ans,b3);
    else if(n==11){
        f(0,ans,b4);
        f(4,ans,b7);
    }
    else{
        int k = 0;
        while(n){
            if(n==5){
                f(k,ans,b5);
                k += 5;
                n -= 5;
            }
            else if(n==6){
                f(k,ans,b6);
                k += 6;
                n -= 6;
            }
            else if(n==7){
                f(k,ans,b7);
                k += 7;
                n -= 7;
            }
            else{
                f(k,ans,b4);
                k += 4;
                n -= 4;
            }
        }
    }
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define rrepa(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define all(a) (a).begine(),(a).end()
#define MOD 1000000007

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main(){
   
    int h,w,a,b;
    cin >> h >> w >> a >> b;

    int f=0;
    rep(i,h){
        rep(j,w){
            if(j==0)f=(f+1)%2;
            if(j==a)f=(f+1)%2;
            if(i==b && j==0)f=(f+1)%2;
            cout << f;
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1280
#include <string.h>

int main(void)
{
    char str[20], num[20];
    int i, n;
    char t;

    scanf("%s", str);

    n = strlen(str);
    
    for (i = 0; i <= n; i++){
        num[i] = str[n - i];
    }

    //printf("%c\n", num[0]);

    for (i = 1; i <= n; i++){
        printf("%c", num[i]);
    }

    printf("\n");

    return (0);
}



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

using namespace std;

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

  cin >> N >> S;
  int cnt = 0;
  for ( int i = 0; i < N; i++ ) {
    if ( S[i] == 'x' ) cnt++;
    else cnt = 0;
    if ( cnt == 2 ) {
      cout << i << endl;
      return 0;
    }
  }

  cout << N << endl;
  
  return 0;
}

Measured memory_bytes: 3280
n, k = map(int, input().split())
a = list(map(int, input().split()))

lb, ub = 0, max(a)
while ub - lb > 1:
    mid = (ub + lb) // 2

    cnt = 0
    for i in range(n):
        cnt += a[i] // mid
        if a[i] % mid != 0:
            cnt += 1
        cnt -= 1

    if cnt <= k:
        ub = mid
    else:
        lb = mid

print(ub)


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

using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int dp1[2010][2010], dp2[2010][2010], dp3[2010][2010];
string s[2010];
int sx[200010], sy[200010], gx[200010], gy[200010];
signed main(void)
{
  int h, w, q;
  cin >> h >> w >> q;
  REP(i, h) cin >> s[i];
  REP(i, q) cin >> sy[i] >> sx[i] >> gy[i] >> gx[i], sx[i]--, sy[i]--;

  FOR(i, 1, h+1) FOR(j, 1, w+1) {
    dp1[i][j] = dp1[i-1][j] + dp1[i][j-1] - dp1[i-1][j-1] + (s[i-1][j-1] == '1');
  }
  REP(i, h) REP(j, w) {
    dp2[i+1][j+1] = (i>0&&s[i][j]=='1'&&s[i-1][j]=='1');
    dp3[i+1][j+1] = (j>0&&s[i][j]=='1'&&s[i][j-1]=='1');
  }
  FOR(i, 1, h+1) FOR(j, 1, w+1) {
    dp2[i][j] += dp2[i-1][j] + dp2[i][j-1] - dp2[i-1][j-1];
    dp3[i][j] += dp3[i-1][j] + dp3[i][j-1] - dp3[i-1][j-1];
  }

  // cout << endl;
  // REP(i, h) {
  //   REP(j, w) {
  //     cout << dp1[i+1][j+1] << " ";
  //   }
  //   cout << endl;
  // }
  // cout << endl;
  // REP(i, h) {
  //   REP(j, w) {
  //     cout << dp2[i+1][j+1] << " ";
  //   }
  //   cout << endl;
  // }
  // cout << endl;
  // REP(i, h) {
  //   REP(j, w) {
  //     cout << dp3[i+1][j+1] << " ";
  //   }
  //   cout << endl;
  // }
  // cout << endl;

  REP(i, q) {
    int v = dp1[gy[i]][gx[i]] - dp1[sy[i]][gx[i]] - dp1[gy[i]][sx[i]] + dp1[sy[i]][sx[i]];
    int e1 = dp2[gy[i]][gx[i]] - dp2[sy[i]+1][gx[i]] - dp2[gy[i]][sx[i]] + dp2[sy[i]+1][sx[i]];
    int e2 = dp3[gy[i]][gx[i]] - dp3[sy[i]][gx[i]] - dp3[gy[i]][sx[i]+1] + dp3[sy[i]][sx[i]+1];
    // cout << dp3[gy[i]][gx[i]] << " " << dp3[sy[i]+1][gx[i]] << " " << dp3[gy[i]][sx[i]] << " " <<  dp3[sy[i]+1][sx[i]] << endl;
    // cout << sx[i] << "," << sy[i] << "," << gx[i] << "," << gy[i] << endl;
    // cout << v << " " << e1 << " " << e2 << endl;
    cout << v - e1 - e2 << endl;
  }

  return 0;
}


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

int n,a[55];

int main() {
	cin>>n;
	a[0]=a[1]=1;
	for (int i=2;i<=n;i++) a[i]=a[i-1]+a[i-2];
	cout<<a[n]<<'\n';
}


Measured memory_bytes: 3080
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define IN cin >>
#define OUT cout <<


int main() {
	int D;
	IN D;
	if (D == 25)OUT "Christmas";
	if (D == 24)OUT "Christmas Eve";
	if (D == 23)OUT "Christmas Eve Eve";
	if (D == 22)OUT "Christmas Eve Eve Eve";
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        sc.close();
        String S1 = S.substring(0, 2);
        String S2 = S.substring(2, 4);
        if (isYYMM(S1, S2) && isMMYY(S1, S2)) {
            System.out.println("AMBIGUOUS");
        } else if (isYYMM(S1, S2)) {
            System.out.println("YYMM");
        } else if (isMMYY(S1, S2)) {
            System.out.println("MMYY");
        } else {
            System.out.println("NA");
        }
    }
    public static boolean isYear(String S) {
        int yy = Integer.valueOf(S);
        if (0 <= yy && yy <= 99) {
            return true;
        }
        return false;
    }
    public static boolean isMonth(String S) {
        int mm = Integer.valueOf(S);
        if (1 <= mm && mm <= 12) {
            return true;
        }
        return false;
    }
    public static boolean isYYMM(String S, String T) {
        if (isYear(S) && isMonth(T)) {
            return true;
        }
        return false;
    }
    public static boolean isMMYY(String S, String T) {
        if (isMonth(S) && isYear(T)) {
            return true;
        }
        return false;
    }
}


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

#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int N;
    int ans = 0;
    cin >> N;
    rep(i, N){
        int a, b;
        cin >> a >> b;
        ans += b-a+1;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long  ll;
#define endl '\n'


int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


const int MOD = 1000000007;

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

int N, M;

void Input() {

    cin >> N >> M;
}

void Solve() {


    int s[M][N];
    for(int i = 0; i < M; i++) {

        for(int j = 0; j < N; j++) {

            s[i][j] = 0;
        }
    }

    for(int i = 0; i < M; i++) {

        int t;
        cin >> t;

        for(int j = 0; j < t; j++) {

            int k;
            cin >> k;

            s[i][k-1] = 1;
        }
    }

    vector<int> p(M);

    for(int i = 0; i < M; i++) cin >> p.at(i);

    int bits = pow(2, N);

    int ans = 0;
    for(int i = 0; i < bits; i++) {

        int temp = i;

        vector<int> set_bits(N);

        for(int j = 0; j < N; j++) {

            if(temp & 1 == 1) set_bits.at(j) = 1;
            temp = temp >> 1;
        }

        int a = 0;
        for(int k = 0; k < M; k++) {

            int cnt = 0;
            for(int l = 0; l < N; l++) {

                if(s[k][l] == 1 && set_bits.at(l) == 1) cnt++;
            }
            if(cnt % 2 == p.at(k)) a++;
        }
        if(a == M) ans++;
    }

    cout << ans << endl;
}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();


  return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	for(auto &i:a) cin>>i;
	for(int i=0;i<n-1;i++) if(a[i]<0) a[i]*=-1,a[i+1]*=-1;
	ll sum=0;
	for(auto i:a) sum+=abs(i);
	if(a[n-1]>=0) cout<<sum<<endl;
	else{
		int m=inf;
		for(auto i:a) m=min(m,abs(i));
		cout<<sum-2*m<<endl;
	}
}

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

using namespace std;

constexpr int INF = 100000000;

using Weight=int;
struct Edge{
    int src,dst;
    Weight weight;
    Edge(int src,int dst,Weight weight):
    src(src),dst(dst),weight(weight){}
};

auto operator < (const Edge &e,const Edge &f){
    if(e.weight!=f.weight)return e.weight>f.weight;
    else if(e.src!=f.src)return e.src<f.src;
    else return e.dst<f.dst;
}

using Edges=vector<Edge>;
using Graph=vector<Edges>;

long long ChuLiu_Edmonds(const Graph &g,int root){
    const int V=g.size();
    Edges mins(V,Edge(-1,-1,INF));
    //????????????????????\??£?????????????°???????????????¶
    for(auto es:g){
        for(auto e:es){
            if(e.weight < mins[e.dst].weight){
                mins[e.dst]=e;
            }
        }
    }
    mins[root]=Edge(-1,-1,-1);
    /*for(auto e:mins){
        if(e.weight==INF)return -1;
    }*/
    vector<int>group(V,0);
    vector<bool>isCycle(V,false);
    int count=0;
    vector<bool>used(V,false);
    //??°???????????????
    for(int i=0;i<V;++i){
        if(used[i])continue;
        vector<int>chain;
        int cursor=i;
        //??????????????£?????????
        while(cursor != -1 && !used[cursor]){
            used[cursor]=true;
            chain.push_back(cursor);
            cursor=mins[cursor].src;
        }
        //?????????????????§??????
        if(cursor != -1){
            bool inCycle=false;
            for(int j=0;j<chain.size();++j){
                group[chain[j]]=count;
                if(chain[j]==cursor){
                    isCycle[count]=true;
                    inCycle=true;
                }
                if(!inCycle)++count;
            }
            if(inCycle)++count;
        }else{//????????§??????
            for(int j=0;j<chain.size();++j){
                group[chain[j]]=count++;
            }
        }
    }
    //??°?????????????????????
    //?????????????????¨???
    if(count==V){
        long long ans=1;
        for(int i=0;i<V;++i){
            ans+=mins[i].weight;
        }
        return ans;
    }
    //????´?????????????????????????????¨?
    long long res=0;
    for(int i=0;i<V;++i){
        if(i!=root && isCycle[group[i]]){
            res+=mins[i].weight;
        }
    }
    //???????????????????????????????????°????????????????????????
    Graph ng(count);
    for(auto es:g){
        for(auto e:es){
            int to=e.dst;
            int gfrom=group[e.src];
            int gto=group[e.dst];
            if(gfrom==gto){
                continue;
            }else if(isCycle[gto]){
                ng[gfrom].emplace_back(gfrom,gto,e.weight-mins[to].weight);
            }else{
                ng[gfrom].emplace_back(gfrom,gto,e.weight);
            }
        }
    }
    return res+ ChuLiu_Edmonds(ng,group[root]);
}

int main(){
    int v,e,r;cin>>v>>e>>r;
    Graph g(v);
    for(int i=0;i<e;++i){
        int s,t,w;cin>>s>>t>>w;
        g[s].emplace_back(s,t,w);
    }
    cout<<ChuLiu_Edmonds(g,r)<<endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  
  rep(i,n){
    cin >> A[i];
  }
  
  sort(all(A));
  
  double ans=A[0];
  rep(i,n){
    ans=(ans+A[i])/2.0;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
N, M, C = [ int(x) for x in input().split(' ')]
B = [ int(x) for x in input().split(' ')]
A = []
for i in range(N):
    A.append([ int(x) for x in input().split(' ')])

import numpy
count = 0
for i in range(N):
    if (numpy.dot(A[i], B) + C > 0):
        count += 1

print(count)


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

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

  long long ans = 1;
  int M = 1e9+7;

  for (int i = 1; i <= N; i++) {
    ans = ans * i % M;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <vector>
typedef long long ll;
using namespace std;

const int N=2e5+10;

ll cal(ll* s,int r,int cnt){
	return s[r]-s[r-cnt];
}

int x[N];
ll a[N],b[N];

void solve(){
	int L,n;
	scanf("%d%d",&L,&n);
	for(int i=1;i<=n;i++){
		scanf("%d",x+i);
		a[i]=a[i-1]+x[i];
	}
	for(int i=n;i>=1;i--){
		b[i]=b[i+1]+L-x[i];
	}
	reverse(b+1,b+n+1);
	ll ans=max(L-x[1],x[n]);
	for(int i=1;i<n;i++){
		int j=min(i,n-i);
		ll tans=2*cal(a,i,j)+2*cal(b,n-i,j)-min(x[i],L-x[i+1]);
		ans=max(ans,tans);
		if(i!=n-i){
			if(i<n-i){
				tans=2*cal(a,i,j)+2*cal(b,n-i,j+1)-(L-x[i+1]);
			}
			else{
				tans=2*cal(a,i,j+1)+2*cal(b,n-i,j)-x[i];
			}
			ans=max(ans,tans);
		}
	}
	printf("%lld\n",ans);
}

int main(){

	solve();
    return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int n,a=0,p[100000];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) {
		cin>>p[i];
		if(p[i]!=i) a++;
	}
	if(a<=2) cout<<"YES";
	else cout<<"NO";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int H, W;
	string S;
	cin >> H >> W;

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> S;
			if (S == "snuke")
			{
				cout << (char)(j + 'A') << i + 1 << endl;

				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

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

  ll n;
  cin >> n;
  ll ans = 0;
  for(ll i = 0; i < n; i++){
    ll a;
    cin >> a;
    ans ^= a;
  }
  if(ans == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
fun main( args : Array<String> ) {
  val (n, m) = readLine()!!.split(" ").map { it.toInt() }
  ( "#".repeat(m+2) + "\n" + (1..n).map {
    "#" + readLine()!! + "#"
  }.joinToString("\n") + "\n" + "#".repeat(m+2) ).let { println(it) }
}

Measured memory_bytes: 37860
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.begin(), c.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
#define Sort(a) sort(Range(a));
#define DeSort(a) sort(RevRange(a));

using namespace std;
using ll = long long;

int main(void){
    Cin(int, a);
    Cin(int, b);
    Cin(int, c);
    Cin(int, d);
    //Cout();
    //Cout(() ? "Yes" : "No");
    Cout((a < 1200) ? "ABC" : "ARC");
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

struct Article {
  double unit;
  int v, w;
  Article() {}
  Article(int v, int w): unit((double)v / (double)w), v(v), w(w) {}

  bool operator< (const Article &that) const noexcept { return unit < that.unit; }
  bool operator> (const Article &that) const noexcept { return unit > that.unit; }
};

Article a[100100];

signed main()
{
  int N, W;
  cin >> N >> W;
  for (int i = 0; i < N; i++) {
    int v, w;
    cin >> v >> w;
    a[i] = Article(v,w);
  }

  sort(a, a+N, greater<Article>());

  int rem = W;
  double ans = 0;

  for (int i = 0; i < N; ++i) {
    const Article &e = a[i];

    int take = min(e.w, rem);
    rem -= take;
    ans += e.unit * take;
  }

  cout << fixed << setprecision(9) <<  ans << endl;


  return 0;
}




Measured memory_bytes: 4768
h,w = map(int, input().split())
s = []
for i in range(h):
    row = list(input().strip())
    s.append(row)

flag = 'Yes'
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            if i != 0 and s[i-1][j] == '#':
                continue
            elif i != h-1 and s[i+1][j] == '#':
                continue
            elif j != 0 and s[i][j-1] == '#':
                continue
            elif j != w-1 and s[i][j+1] == '#':
                continue
            flag = 'No'
        else:
            continue

print(flag)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll k,ans1=0,ans2=0;
string s,t;
const ll MOD = 1000000007;
void Main(){    
    cin>>s>>k;
    t=s+s;
    ll num=1;
    bool flag=true;
    For(i,1,s.size()){
        if(s.at(i)==s.at(i-1)){
            continue;
        }
        else{
            flag=false;
            break;
        }
    }
    For(i,1,s.size()){
        if(s.at(i)==s.at(i-1)){
            num++;
        }
        else{
            ans1+=num/2;
            num=1;
        }
    }
    ans1+=num/2;
    num=1;
    For(i,1,t.size()){
        if(t.at(i)==t.at(i-1)){
            num++;
        }
        else{
            ans2+=num/2;
            num=1;
        }
    }
    ans2+=num/2;
    ll ansk=ans2*(k-1)-ans1*(k-2);
    if(s.size()==1) ansk=k/2;
    else if(flag) ansk=(k*s.size())/2;
    cout<<ansk<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
current_x = 0
current_y = 0
current_t = 0
flag = true

n.times do
  t, x, y = gets.split.map(&:to_i)
  distance = (current_x - x).abs + (current_y - y).abs
  if distance > (t - current_t)
    flag = false
    break
  elsif ((current_t - t) - distance).odd?
    flag = false
    break
  end
  current_t = t
  current_x = x
  current_y = y
end

puts flag ? "Yes" : "No"


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

using namespace std;

int main(int argc, char *argv[]) {
	int A, B;
	cin >> A >> B;

	bool can(false);
	if (A <= 8 && B <= 8) {
		can = true;
	}

	cout << ((can) ? "Yay!" : ":(") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;



signed main()
{
    string N;
    
    cin >> N;
    if (N[0] == N[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
program rotation_matching
  implicit none
  integer :: n, m, i = 0, j, cnt = 0, maxm, d
  read(*,*) n, m
  maxm = (n-1)/2
  d = mod(n,2)
  do
    write(*,'(i0,x,i0)') i+1, maxm+1-i
    cnt = cnt+1
    if (cnt == m) stop
    write(*,'(i0,x,i0)') maxm+3+i-d, n-i
    cnt = cnt+1
    if (cnt == m) stop
    i = i+1
  end do
end program rotation_matching

Measured memory_bytes: 2868
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K; cin>>N>>K;
  vector<long>H(N);
  for (int i=0; i<N; i++) cin>>H[i];
  long ans=0;
  
  if (N<=K) cout << 0 << endl;
  else{
    sort(H.begin(), H.end());
    for (int i=0; i<(N-K); i++){
      ans += H[i];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1920
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A,B;
  cin >> A >> B;
  cout << A*B-A-B+1 << endl;
}

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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

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

    string S,T; cin>>S>>T; S += S;
    Yes((int)S.find(T)>=0);
}


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

struct edge{
  int to, cost;
};
typedef vector< vector< edge > > Graph;
void add_edge(Graph& info, int u, int v, int cost, bool flag = true){
  info[u].push_back( (edge){ v, cost});
  if(flag) info[v].push_back( (edge){ u, cost});
}
int Dijkstra(Graph& info, int s, int g, vector< int >& min_cost, vector< int >& beg) { //sからgへの最短路
  typedef pair< int, int > Pi;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  min_cost.assign(info.size(), -1);
  for(int i = 0; i < beg.size(); i++){
    que.push( Pi( 0, beg[i]));
    min_cost[beg[i]] = 0;
  }
  while(!que.empty()){
    Pi p = que.top(); que.pop();
    if(p.second == g) return p.first;
    if(p.first > min_cost[p.second]) continue;
    for(int i = 0; i < info[p.second].size(); i++){
      edge& e = info[p.second][i];
      if(min_cost[e.to] == -1 || p.first + e.cost < min_cost[e.to]){
        min_cost[e.to] = p.first + e.cost;
        que.push( Pi( min_cost[e.to], e.to));
      }
    }
  }
  return -1;
}

int main(){
  int N, M, K;
  cin >> N >> M >> K;
  Graph graph(N);
  for(int i = 0; i < M; i++){
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    add_edge( graph, a, b, c);
  }
  vector< int > min_cost;
  vector< int > beg(K);
  for(int i = 0; i < K; i++){
    int a;
    cin >> a;
    --a;
    beg[i] = a;
  }

  Dijkstra( graph, -1, -1, min_cost, beg);

  int ret = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < graph[i].size(); j++){
      int dist = min_cost[i] - min_cost[graph[i][j].to];
      if(dist < 0) continue;
      ret = max( ret, min_cost[graph[i][j].to] + dist + (graph[i][j].cost - dist + 1)/ 2);
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 4196