akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

typedef struct RMQandRAQ {
  i64 *add;
  i64 *max;
  i32 bit;
  i32 size;
} RMQandRAQ;

RMQandRAQ* new_RMQandRAQ (const i32 n) {
  i32 k = 0;
  while ((1 << k) < n) ++k;
  RMQandRAQ *s = (RMQandRAQ *) calloc (1, sizeof (RMQandRAQ));
  s->add = (i64 *) calloc (2 << k, sizeof (i64));
  s->max = (i64 *) calloc (2 << k, sizeof (i64));
  s->bit = k;
  s->size = 1 << k;
  return s;
}

static inline i64 max (i64 a, i64 b) {
  return a > b ? a : b;
}

static inline i64 eval (RMQandRAQ *s, i32 k) {
  return s->add[k] + s->max[k];
}

void propagate (RMQandRAQ *s, i32 x) {
  x += s->size;
  for (i32 bit = s->bit; bit > 0; bit--) {
    i32 k = x >> bit;
    s->add[2 * k] += s->add[k];
    s->add[2 * k + 1] += s->add[k];
    s->add[k] = 0;
    s->max[k] = max (eval (s, 2 * k), eval (s, 2 * k + 1));
  }
}

void save (RMQandRAQ *s, i32 x) {
  for (i32 k = (x + s->size) >> 1; k >= 1; k >>= 1) {
    s->max[k] = max (eval (s, 2 * k), eval (s, 2 * k + 1));
  }
}

void add (RMQandRAQ *s, i32 l, i32 r, i64 v) {
  for (i32 x = l + s->size, y = r + s->size; x < y; x >>= 1, y >>= 1) {
    if (x & 1) s->add[x++] += v;
    if (y & 1) s->add[--y] += v;
  }
  save (s, l);
  save (s, r - 1);
}

i64 find (RMQandRAQ *s, i32 l, i32 r) {
  //propagate (s, l);
  //propagate (s, r - 1);
  i64 ans = 0;
  for (l += s->size, r += s->size; l < r; l >>= 1, r >>= 1) {
    if (l & 1) ans = max (ans, eval (s, l++));
    if (r & 1) ans = max (ans, eval (s, --r));
  }
  return ans;
}

typedef struct node {
  i32 l, v;
} node;

void run (void) {
  i32 n, m;
  scanf ("%" SCNi32 "%" SCNi32, &n, &m);
  node **p = (node **) calloc (n + 1, sizeof (node *));
  i32 *len = (i32 *) calloc (n + 1, sizeof (i32));
  i32 *max_len = (i32 *) calloc (n + 1, sizeof (node));
  for (i32 i = 0; i < m; ++i) {
    i32 l, r, v;
    scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &l, &r, &v);
    if (len[r] == max_len[r]) {
      max_len[r] = 2 * max_len[r] + 1;
      p[r] = (node *) realloc (p[r], sizeof (node) * max_len[r]);
    }
    p[r][len[r]++] = (node) {l, v};
  }
  RMQandRAQ *s = new_RMQandRAQ (n + 1);
  for (i32 i = 1; i <= n; ++i) {
    i64 v = find (s, 0, i);
    add (s, i, i + 1, v);
    for (i32 j = 0; j < len[i]; ++j) {
      add (s, p[i][j].l, i + 1, p[i][j].v);
    }
  }
  printf ("%" PRIi64 "\n", find (s, 0, n + 1));
}

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


Measured memory_bytes: 15232
#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<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

ll n,a,b;
vector<ll> h(n);

bool search(ll x){
	ll c = a - b;
	auto index = upper_bound(ALL(h),x * b);
	ll cnt = 0LL;
	if (index == h.end())return true;
	for(auto i = index; i != h.end(); i++) {	
		cnt += (((*i - x * b) + c - 1LL) / c);
	}
	if (cnt <= x){
		return true;
	}
	else{
		return false;
	}
}
int main(){
	cin>>n>>a>>b;
	h.resize(n);
	for(ll i = 0; i < n; i++) {
		cin>>h[i];	
	}
	sort(ALL(h));
	ll ok = 10000000000;
	ll ng = -1LL;
	while(abs(ok - ng) > 1LL){
		ll mid = (ok + ng) / 2LL;
		if (search(mid)){
			ok = mid;
		}
		else{
			ng = mid;
		}
	}
	cout << ok << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <complex>

using namespace std;
typedef long long ll;


typedef complex<double> xy_t;
double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }

typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

vector<int> G[100005];
std::vector<P> tree[100010];

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

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define re(i,a,b) for(i=a;i<=b;i++)
#define pb push_back
#define lb lower_bound
#define ub upper_bound

ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans=0;
ll a,b,c,d,e,h,w;

ll x[500005],y[500005],z[500005];
string s,t;
bool flag;
bool check[100005];


int main(){
    cin>>n>>m;
    for(i=0;i<m;i++){
        cin>>a>>b;
        x[i] = b*1000000+a;
    }
    sort(x,x+m);
    for(i=0;i<m;i++){
        a = x[i]%1000000;
        b = x[i]/1000000;
        if(a>=num){
            num = b;
            ans++;
        }
    }
    p(ans);
    
    return 0;
}


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

int countBomb(vector<vector<char>> &v, int H, int W);
char itoc(int i);

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char>>v(H,vector<char>(W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> v.at(i).at(j);
        }
    }

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(v.at(i).at(j)!='#')v.at(i).at(j)=itoc(countBomb(v,i+1,j+1));
        }
    }

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cout << v.at(i).at(j);
        }
        cout << endl;
    }
    return 0;
}

int countBomb(vector<vector<char>> &v, int H, int W){
    int count = 0;
    for(int i = -1; i <= 1; i++){
        if((H-1)+i<0||(H-1)+i>=v.size())continue;
        for(int j = -1; j <= 1; j++){
            if((W-1)+j<0||(W-1)+j>=v.at((H-1)+i).size())continue;
            if(v.at((H-1)+i).at((W-1)+j)=='#')count++;
        }
    }
    return count;
}

char itoc(int i){
    return to_string(i).at(0);
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define LL long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define I insert
#define bull bool
#define Max(a,b) ((b<a)?a:b)
#define Min(a,b) ((a<b)?a:b)

const LL N = 100005, mod = 1000000007;

using namespace std;

LL n, m, i, j, k, l, r, t, ans;
string s;

LL getint(){
	char c = getchar();
	LL t = 0;
	while(!isdigit(c)) c = getchar();
	while(isdigit(c)){
		t = (t << 3) + (t << 1);
		t += c - '0';
		c = getchar();
	}
	return t;
}

int main(){
	/*/
	freopen ( "detectivein.txt", "r", stdin);
	freopen ( "detectiveout.txt", "w", stdout);
	/**/
	cin >> s;
	for ( i = 1; i < s.size(); ++i ){
		if ( s[i] == s[i-1] ){
			cout << "Bad\n";
			return 0;
		}
	}
	cout << "Good\n";
	
	
	return 0;
}
/**/
//      IIIIIIIII      OOOOO             A          NN        N    EEEEEEEEEE
//          I         O     O           A A         N N       N    E
//          I        O       O         A   A        N  N      N    E
//          I        O       O        A     A       N   N     N    E
//          I        O       O       AAAAAAAAA      N    N    N    EEEEEEEE
//          I        O       O      A         A     N     N   N    E
//          I        O       O     A           A    N      N  N    E
//          I         O     O     A             A   N       N N    E
//      IIIIIIIII      OOOOO     A               A  N        NN    EEEEEEEEEE ___ KAPANADZE

Measured memory_bytes: 764
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())

sys.setrecursionlimit(10 ** 9)


def main():
    H, W = MAP()
    A = [INPUT() for _ in range(H)]

    ans_H = []
    for y in range(H):
        for x in range(W):
            if A[y][x] == '#':
                ans_H.append(y)
                break

    ans_W = []
    for x in range(W):
        for y in range(H):
            if A[y][x] == '#':
                ans_W.append(x)
                break

    ans = ["" for _ in range(len(ans_H))]
    for i, h in enumerate(ans_H):
        for w in ans_W: ans[i] += A[h][w]

    for a in ans: print(a)


if __name__ == '__main__':
    main()

Measured memory_bytes: 39280
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll x , N; cin >> x >> N;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  ll ans = 1e9;
  SORT(a);
  rep(i , 500){
    if(!binary_search(a.begin(), a.end(), i)){
      if( abs(ans - x) > abs(x - i) ){
        ans = i;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
import itertools
import numpy as np
from scipy.sparse.csgraph import floyd_warshall


def main():
    N = int(input())
    matr = np.array([tuple(map(int, input().split())) for _ in range(N)], dtype=np.int64)
    way = floyd_warshall(matr).astype(int)
    if np.any(way < matr):
        print(-1)
        exit()

    ans = 0
    for a, b in itertools.combinations(range(N), 2):
        eq = (matr[a, b] == (matr[a] + matr[:, b]))
        eq[a] = eq[b] = False
        if not np.any(eq):
            ans += matr[a, b]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 21308
#include <bits/stdc++.h>
using namespace std;
// #define LOCAL // 提出時はコメントアウト
#define DEBUG_

typedef long long ll;
const double EPS = 1e-9;
const ll INF = ((1LL<<62)-(1LL<<31));
typedef vector<ll> vecl;
typedef pair<ll, ll> pairl;
template<typename T, typename U> using mapv = map<T,vector<U>>;

#define ALL(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define contains(S,x) find(ALL(S),x) != S.end()
ll llceil(ll a,ll b) { return (a+b-1)/b; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> vector<vector<T>> genarr(ll n, ll m, T init) { return vector<vector<T>>(n,vector<T>(m,init)); }

///// DEBUG
#define DUMPOUT cerr
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
template<typename T>istream&operator>>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<typename T,typename U>ostream&operator<<(ostream&os,pair<T,U>&pair_var){os<<"("<<pair_var.first<<", "<<pair_var.second<<")";return os;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&vec){os<<"{";for(int i=0;i<vec.size();i++){os<<vec[i]<<(i+1==vec.size()?"":", ");}
os<<"}";return os;}
template<typename T,typename U>ostream&operator<<(ostream&os,map<T,U>&map_var){os<<"{";repi(itr,map_var){os<<*itr;itr++;if(itr!=map_var.end())os<<", ";itr--;}
os<<"}";return os;}
template<typename T>ostream&operator<<(ostream&os,set<T>&set_var){os<<"{";repi(itr,set_var){os<<*itr;itr++;if(itr!=set_var.end())os<<", ";itr--;}
os<<"}";return os;}
void dump_func(){DUMPOUT<<endl;}
template<class Head,class...Tail>void dump_func(Head&&head,Tail&&...tail){DUMPOUT<<head;if(sizeof...(Tail)>0){DUMPOUT<<", ";}
dump_func(std::move(tail)...);}
#ifndef LOCAL
#undef DEBUG_
#endif
#ifdef DEBUG_
#define DEB
#define dump(...)                                                          \
DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
        << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
        << endl                                                            \
        << "    ",                                                         \
    dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif

//////////

#include <atcoder/all>
using namespace atcoder;

int main() {
    #ifdef LOCAL
    ifstream in("../../Atcoder/input.txt");
    cin.rdbuf(in.rdbuf());
    #endif

    ll N,M;
    cin>>N>>M;

    scc_graph G(N);
    rep(i,M) {
        ll a,b;
        cin>>a>>b;
        a--;b--;
        G.add_edge(a,b);
        G.add_edge(b,a);
    }

    auto scc = G.scc();

    dump(scc);

    cout << scc.size() - 1 << endl;



    return 0;
}


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

int main() {
	int H;
	int W;
	int a;
	int b;
	int H3;
	int W3;
	int H2;
	int W2;

	cin >> H >> W;

	H2=H%2;
	W2=W%2;
	H3=H%3;
	W3=W%3;

	if(H3==0){
		cout << 0 << endl;
		return 0;
	}
	if(W3==0){
		cout << 0 << endl;
		return 0;
	}
		if(W2==1){
			a=min(max(W/2+H/3+1,H/3+H/3+1),W/2+W/2+1);
		} else {
			a=W/2;
		}
		if(H2==1){
			b=min(max(H/2+W/3+1,W/3+W/3+1),H/2+H/2+1);
		} else {
			b=H/2;
		}
	cout << min(a,b) << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int ans=0;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        while(a%2==0){
            ans++;
            a /= 2;
        }
    }
    cout << ans << endl;
}

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

import sys
from collections import Counter

INF = 2**62-1

buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))

def slv(N, A):

    c = Counter()
    ans = 0
    for i, a in enumerate(A):
        ans += c[a-i]
        c[-i-a] += 1
    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define mod 1000000007
#define ll long long int
#define mk make_pair
#define pb push_back
#define xx first
#define yy second


double pi=3.141592653589793238;
const int M = 1e9+7;
const int Nmax=5005;
const int MM = 1e7+1;
const int N=200010;

int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T=1;
//cin>>T;
while(T--){
ll n,ww;
cin>>n>>ww;
ll w[n+1],v[n+1];
for(int i=1;i<=n;i++)cin>>w[i]>>v[i];
vector<vector<ll> > dp(n+1,vector<ll>(ww+1,0));
for(int i=1;i<=n;i++){
    for(int j=0;j<=ww;j++){
        dp[i][j]=dp[i-1][j];
        if(j-w[i]>=0)dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
    }
}
cout<<dp[n][ww]<<"\n";
}
return 0;
}



Measured memory_bytes: 83144
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

int main() {
    string s;
    cin >> s;
    
    ll ans = 1;
    static int cnt[256];
    
    for ( int i = 0; i < s.size(); i++ ) {
        ans += i - cnt[s[i]];
        cnt[s[i]]++;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 644
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,f,n) for(int i=f;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;


signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    string s, t;
    cin >> s >> t;

    if(s == t.substr(0, s.size())){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstring>
using namespace std;
int a[16][16];
int main()
{
  int n;
  cin >> n;
  for(int i = 0; i < n; i++)
  {
    int d;
    cin >> d;
    for(int j = 0; j < d; j++)
    {
      int x, val;
      cin >> x >> val;
      if(val == 0) val--;
      a[i][x-1] = val;
    }
  }
  int ans = 0;
  for(int i = 0; i < (1<<n); i++)
  {
    int ok = 1;
    for(int j = 0; j < n; j++)
    {
      if((i&(1<<j)) == 0) continue;
      for(int k = 0; k < n; k++)
      {
        if(a[j][k] == 1)
        {
          if(((1<<k)&i) == 0) ok = 0;
        }
        else if(a[j][k] == -1)
        {
          if((1<<k)&i) ok = 0;
        }
      }
    }
    if(ok)
    {
      int cnt = 0;
      for(int j = 0; j < n; j++)
        if(i&(1<<j))cnt++;
      ans = max(ans,cnt);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]

for i in range(n):
  a.append(a[i] + A[i])
  
for i in range(m):
  b.append(b[i] + B[i])
  
ans, j = 0, m

for i in range(n+1):
  if a[i] > k:
    break
  while a[i] + b[j] > k:
    j -= 1
  ans = max(ans, i+j)

print(ans)

Measured memory_bytes: 134252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod = 1e9+7;

int d;
vector<int> c;
vector<vector<int>> s;

vector<int> argsort(vector<int> v) {
    vector<int> indices(v.size());
    iota(indices.begin(), indices.end(), 0);
    // ソートする。
    sort(indices.begin(), indices.end(), [&v](int i1, int i2) {
        return v[i1] < v[i2];
    });
    return indices;
}

int greedy(int date) {
    vector<int> score(26, 0);
    rep (i, 26) {
        score[i] = s[date][i] + c[i];
    }
    vector<int> indices = argsort(score);
    return indices[25];
}

int main() {
    cin >> d;
    c.resize(26);
    rep (i, c.size()) {
        scanf("%d", &c[i]);
    }
    s.resize(d, vector<int>(26));
    rep (i, d) {
        rep (j, c.size()) {
            cin >> s[i][j];
        }
    }
    rep (i, d) {
        cout << 1 << endl;
    }
}




Measured memory_bytes: 3704
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;


ll n;
int main()
{
        cin >> n;
        ll ans = 0;
        for(ll i=1;i<=n;i++) {
                ll x;
                cin >> x;
                ans ^= x;
        }
        if(ans == 0){
                cout << "Yes\n";
        }else cout << "No\n";
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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 long long INF = 1000000000000000;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n, m,k,l; string s;
char maze[60][60];
int dis[101][101];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main() {
	string o, e;
	cin >> o >> e;
	for (ll i = 0,on = 0,om = 0; i < o.size() + e.size();i++) {
		if (i % 2==0) {
			if (i == o.size() + e.size() - 1) {
				cout << o[on] << endl;
				return 0;
			}
			cout << o[on]; on++;
		}
		else if(i%2==1) {
			if (i == o.size() + e.size() - 1) {
				cout << e[om] << endl;
				return 0;
			}
			cout << e[om]; om++;
		}
	}
}

Measured memory_bytes: 256
def f(n):
    if n%2==0:
        return n//2
    else:
        return 3*n+1

a = [0]
a.append(int(input()))
for i in range(2,1000001):
    tmp = f(a[i-1])
    if tmp in a:
        break
    a.append(tmp)
#print(a)
print(i)

Measured memory_bytes: 9136
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

const ll mod = static_cast<ll>(1e9) + 7;

int main()
{
    ll H, W;
    cin >> H >> W;

    if (W == 1 || H == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    const ll x = (H * W) / 2;
    const ll y = (H % 2 == 0) || (W % 2 == 0) ? 0 : 1;

    const ll ans = x + y;
    cout << 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>;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int cnt = 0;
    rep(i,s.size()) {
        if (s[i] == 'R') cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = abc[0];
            var b = abc[1];
            var c = abc[2];

            var d = b / a;
            Console.WriteLine(d <= c ? d : c);
        }
    }
}


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

using namespace std;

const long long MOD = 1000000007;
int main() {
    long long N;
    cin>>N;
    double ans=-1;
    for(double i=0;(long long)i<=N;i=i+1){
        if((long long)(i*1.08)==N){
            ans=i;
        }
    }
    if((long long)ans!=-1){
        cout<<ans<<endl;
    }else{
        cout<<":("<<endl;
    }




}











Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.stream.Stream;

public class Main {
    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static PrintWriter pw = new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {
        func();
        pw.flush();
        return;
    }

    static void func() throws IOException {
        int N = nextInt();
        int[] x = new int[100];
        int[] y = new int[100];
        int[] h = new int[100];

        // 入力を処理
        for(int i = 0;i < N;i++){
            int[] input = arrayOfInt();
            x[i] = input[0];
            y[i] = input[1];
            h[i] = input[2];
        }

        // 全ての座標が頂点だった場合を探索する
        for(int posX = 0;posX <= 100;posX++){
            for(int posY = 0;posY <= 100;posY++){
                int top = 0;
                // posX,posYが頂点だった場合に、N個の入力が矛盾しないかを確かめる
                for(int i = 0;i < N;i++){
                    // 高さが0の入力は一旦無視する
                    if(h[i] > 0) {
                        int tmpH = h[i] + Math.abs(posX - x[i]) + Math.abs(posY - y[i]);
                        if(top == 0){
                            top = tmpH;
                        }else{
                            if(top != tmpH){
                                top = -1;
                                break;
                            }
                        }
                    }
                }

                for(int i = 0;i < N;i++){
                    if(h[i] == 0) {
                        int tmpH = h[i] + Math.abs(posX - x[i]) + Math.abs(posY - y[i]);
                        if(top > tmpH){
                            top = -1;
                            break;
                        }
                    }
                }

                if(top > 0){
                    println(posX + " " + posY + " " + top);
                    return;
                }
            }
        }
        return;
    }
    // 入力受け取り
    static String next() throws IOException {return br.readLine();}
    static int nextInt() throws IOException{return getInt(br.readLine());}
    static long nextLong() throws IOException{return getLong(br.readLine());}
    static String[] arrayOfString() throws IOException{return br.readLine().split(" ");}
    static int[] arrayOfInt() throws IOException{return toIntArray(arrayOfString());}
    // 変換
    static long getLong(String val) {return Long.parseLong(val);}
    static int getInt(String val) {return Integer.parseInt(val);}
    static int[] toIntArray(String[] array) {return Stream.of(array.clone()).mapToInt(Integer::parseInt).toArray();}
    static String joinToString(String[] array) {
        StringBuilder sb = new StringBuilder();
        for(int i = 0;i < array.length;i++) sb.append(array[i]);
        return sb.toString();
    }

    // 出力
    static void println(Object val){pw.println(val);}
}


Measured memory_bytes: 27476
#define s(p)!strstr(a,"th"#p)&&
char*c;main(i,a){for(;~scanf("%[^\n] ",a);!puts(a))for(;s(is)s(at)s(e)1;)for(c=a;*c;c++)*c=*c<97?*c:(*c+8)%26+97;}

Measured memory_bytes: 0
// #define _GLIBCXX_DEBUG
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vb = vector<bool>; using vvb = vector<vb>;
#define rep0(TMS) for (int CNT = 0; CNT < (int)(TMS); CNT++)
#define rep(CNT, GOAL) for (int CNT = 0; CNT < (int)(GOAL); CNT++)
#define rep2(CNT, START, GOAL) for (int CNT = (int)(START); CNT < (int)(GOAL); CNT++)
#define rep3(CNT, START, GOAL) for (int CNT = (int)(START); CNT > (int)(GOAL); CNT--)
#define all(CONT) begin(CONT), end(CONT)
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
void prec(const int &DIG) { cout << fixed << setprecision(DIG); cerr << fixed << setprecision(DIG); }
template <typename T> void CERR(const T &ELEM) { cerr << ELEM; }
#define dbl(OBJ) cerr << #OBJ << ": "; CERR(OBJ); cerr << "\n"
template <typename T, typename ...Ts> void CERR(const T &FIRST, const Ts &...REST) { CERR(FIRST); cerr << ", "; CERR(REST...); }
#define dbs(...) cerr << "(" << #__VA_ARGS__ << "): ("; CERR(__VA_ARGS__); cerr << ")\n"
#define itrep(ITR, CONT) for (auto ITR = begin(CONT); ITR != end(CONT); ITR++)
template <typename T> void CERR(const vector<T> &VEC) { cerr << "{ "; itrep(ITR, VEC) { CERR(*ITR); cerr << ", "; } cerr << "}"; }
#define YN(FLG) cout << (FLG ? "YES" : "NO") << "\n"
#define Yn(FLG) cout << (FLG ? "Yes" : "No") << "\n"
#define yn(FLG) cout << (FLG ? "yes" : "no") << "\n"
const ll INF = 1e18; // LONG_LONG_MAX;
// const int INF = INT_MAX;
const ll MOD = 1000000007; // 998244353;



int main() {
	int x; cin >> x;
	cout << 1 - x << endl;
}

Measured memory_bytes: 3628
// #define rep(i, n) for(int i = 0; i < (int)(n); i++)
// #define all(x) (x).begin(),(x).end()
// typedef long long ll;
// // #include<C:\Users\J\Desktop\AC\athead.h>
// #define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
// #define show(iiii) cout << iiii << endl; 
// #define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
using namespace std;

int main(){
    string s;
    cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy";

        return 0;
    }
        if(s == "Cloudy"){
            cout << "Rainy";
        return 0;
    }
        if(s == "Rainy"){
        cout << "Sunny";
        return 0;
    }
}

Measured memory_bytes: 256
n,m=map(int,input().split())
indegree=[0]*(n+1)
adj=[0]*(n+1)
for i in range(n+1):
	adj[i]=[]
for i in range(m):
	x,y=map(int,input().split())
	adj[x].append(y)
	indegree[y]+=1
stk=[]
for i in range(n+1):
	if indegree[i]==0 and len(adj[i])>0:
		stk.append(i)
path_length=[0]*(n+1)
while len(stk)>0:
	s=stk[-1]
	stk.pop()
	for i in range(len(adj[s])):
		indegree[adj[s][i]]-=1
		path_length[adj[s][i]]=max(path_length[adj[s][i]],path_length[s]+1)
		if indegree[adj[s][i]]==0:
			stk.append(adj[s][i])
print(max(path_length))

Measured memory_bytes: 61068
from itertools import accumulate
def main():
	n, k, *a = map(int, open(0).read().split())
	p = [x if x > 0 else 0 for x in a]
	acc = [0] + list(accumulate(a))
	p_acc = [0] + list(accumulate(p))
	rev_p_acc = [0] + list(accumulate(p[::-1]))
	print(max(max(0, acc[k + i] - acc[i]) + p_acc[i] + rev_p_acc[n - k - i] for i in range(n - k + 1)))
	
if __name__=="__main__":
	main()

Measured memory_bytes: 23308
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb emplace_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) sort(all(v)),v.erase(unique(all(v)), v.end());
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
#define deb(x) cout<<"\n["<<#x<<" = "<<x<<"]\n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int n,z,cnt;double tmp;
void solve(){
	cin>>n;map<pii,int>m;
	rep(i,1,n){
		cin>>tmp;int c1=0,c2=0;
		z=llround(tmp*1e9);
		while((z%2)==0)z/=2,c1++;
		while((z%5)==0)z/=5,c2++;
		m[mp(c1,c2)]++;
	}
	for(auto i:m)
		for(auto j:m){
			if(i<j){
				if(i.F.F+j.F.F>=18 and i.F.S+j.F.S>=18)cnt+=i.S*j.S;
			}
			if(i==j){
				if(i.F.F+j.F.F>=18 and i.F.S+j.F.S>=18)cnt+=i.S*(j.S-1)/2;
			}
		}
	cout<<cnt;
}
int32_t main()
{
  ibs;cti;
  solve();return 0;
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 3776
// Author : MohamedSameh
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
#include<stack>
#include<deque>
#include <sstream>
#include <string.h>

typedef long long ll ;
// random in each run --> srand(time(NULL));

#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define IN(n) scanf("%d" , &n )
#define debug(x) cout<<#x<<" = { "<<x<<" }\n"
void fo (){fflush(stdout);}
using namespace std;
vector <int> adj[100000];
int n , m ;
int dp[100000];
int sol (int i )
{
  if (SZ(adj[i]) == 0 )return 0 ;
  int &ret = dp[i];
  if (~ret)return ret ;

  for (int ch : adj[i])
  {
    ret = max (ret , 1 + sol (ch));
  }
  return ret ;
}
int main ()
{
memset (dp , -1 , sizeof dp );
scanf ("%d%d" , &n ,&m );
for (int i =0 ; i < m ;i++)
{
  int u , v ;
  scanf ("%d%d" , &u , &v );
  u--;v--;
  adj[u].pb(v);
}
int ans =0 ;
for (int i =0 ; i < n ;i++)
{
  dp[i] = sol(i);
  ans = max (ans,dp[i]);
}
printf ("%d\n" , ans );

  return 0;
}


Measured memory_bytes: 7424
#[allow(unused_imports)]
use std::cmp::Ordering;

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get {
    ([$t: ty]) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let mut a = get!([isize]).into_iter().enumerate().collect::<Vec<_>>();

    a.sort_by_key(|e| -e.1);

    let mut dp = vec![vec![0; n + 1]; n + 1];
    for s in 0..n + 1 {
        for x in 0..s + 1 {
            let y = s - x;
            if x > 0 {
                dp[x][y] = max!(
                    dp[x][y],
                    dp[x - 1][y] + a[s - 1].1 * (a[s - 1].0 as isize - x as isize + 1).abs()
                );
            }
            if y > 0 {
                dp[x][y] = max!(
                    dp[x][y],
                    dp[x][y - 1] + a[s - 1].1 * (a[s - 1].0 as isize - (n - y) as isize).abs()
                );
            }
        }
    }

    let mut mx = 0;
    for i in 0..n + 1 {
        for j in 0..n + 1 {
            mx = max!(mx, dp[i][j]);
        }
    }
    println!("{}", mx);
}


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

using namespace std;
typedef long long ll;

int main() {
  ll N; cin >> N;
  vector<ll> L(N);
  for (ll j=0; j < N; ++j) cin >> L[j];
  ll max_idx = 0, max_val = L[0];
  for (ll j=0; j < N; ++j) {
    if (max_val < L[j]) {
      max_val = L[j];
      max_idx = j;
    }
  }
  ll sum = 0;
  for (ll j=0; j < N; ++j) {
    if (j == max_idx) continue;
    sum += L[j];
  }
  cout << (sum > max_val ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n; cin >> n;
  queue<ll> q; queue<ll> last;
  
  q.push(3); q.push(5); q.push(7);
  
  while(!q.empty()){
    ll x = q.front(); last.push(x);
    q.pop();
    
    ll a = 10*x+3; ll b = 10*x+5; ll c = 10*x+7;
    if(a <= n) q.push(a);
    if(b <= n) q.push(b);
    if(c <= n) q.push(c);
    
  }
  
  ll ans = 0;
  
  while(!last.empty()){
    ll x = last.front(); 
    last.pop();
    
    bool cnt3,cnt5,cnt7; cnt3 = cnt5 = cnt7 = false;
    while(x != 0){
      ll a = x % 10;
      
      if(a == 3) cnt3 = true;
      if(a == 5) cnt5 = true;
      if(a == 7) cnt7 = true;
     
      x /= 10;
    }
    
    if(cnt3 and cnt5 and cnt7) ans++;
  }
  
  cout << ans << endl;
  
  
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c; cin>>c;
    if (c=='a'||c=='e'||c=='i'||c=='u'||c=='o'){
        cout<<"vowel\n";
    }else{
        cout<<"consonant\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

static const int MAX = 100;
static const int INF = 1 << 30;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim(){
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    for (int i = 0; i < n; ++i){
        d[i] = INF;
        p[i] = -1;
        color[i] = WHITE;
    }
    d[0] = 0;

    while (true){
        minv = INF;
        u = -1;
        for (int i = 0; i < n; ++i){
            if( minv > d[i] && color[i] != BLACK ){
                u = i;
                minv = d[i];
            }
        }
        if( u==-1){
            break;
        }
        color[u] = BLACK;

        for (int v = 0; v < n; ++v){
            if( color[v] != BLACK && M[u][v] !=INF){
                if(d[v] > M[u][v]){
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int sum = 0;
    for (int i = 0; i < n; ++i){
        if(p[i] != -1)
            sum += M[i][p[i]];
    }
    return sum;
}

int main()
{
    cin >> n;

    for (int i = 0; i < n; ++i){
        for (int j = 0; j < n;++j){
            int e;
            cin >> e;
            M[i][j] = (e == -1) ? INF : e;
        }
    }
    cout << prim() << endl;

    return 0;
}


Measured memory_bytes: 3124
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n,x,y;
  cin>>n>>x>>y;
  cout << min(x,y) << " " << max(0LL,x+y-n) << endl;
  return 0;
}

Measured memory_bytes: 256
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n = inp[0]
ans = 0
s = gets.chomp
n.times do |i|
  h = {}
  c = 0
  (0..i).each do |j|
    h[s[j]] = true
  end
  ((i+1)...n).each do |j|
    c+= 1 if h[s[j]] == true
    h[s[j]]=false if h[s[j]] == true
  end
  ans = [c,ans].max
end
p ans

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

int main(){
    int n;
    cin>>n;
    int i,j;
    for(i=1;i<10;i++){
    	for(j=1;j<10;j++){
    		if(i*j==n){
			    cout<<"Yes"<<endl;
			    return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

int main() {
    constexpr double pi = 3.141592653589793;
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double pos_h_x = static_cast<double>(a) * sin(static_cast<double>(360. / (12. * 60.) * (h * 60. + m)) * pi / 180);
    double pos_h_y = static_cast<double>(a) * cos(static_cast<double>(360. / (12. * 60.) * (h * 60. + m)) * pi / 180);
    double pos_m_x = static_cast<double>(b) * sin(static_cast<double>(360. / 60. * m) * pi / 180);
    double pos_m_y = static_cast<double>(b) * cos(static_cast<double>(360. / 60. * m) * pi / 180);

    cout << fixed << setprecision(20) << sqrt((pos_h_x - pos_m_x) * (pos_h_x - pos_m_x) + (pos_h_y - pos_m_y) * (pos_h_y - pos_m_y)) << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 4064
#include <cstdio>
#include <iostream>
#include <sstream>

#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

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

i64 gcd(i64 l, i64 r){
  while(r){
    i64 t = r;
    r = l % r;
    l = t;
  }
  return l;
}

i64 lcm(i64 l, i64 r){
  return l / gcd(l, r) * r;
}

int main() { 
  int n;
  cin >> n;
  i64 t;
  cin >> t;
  for(int i=1;i<n;i++){
    i64 tt;
    cin >> tt;
    t = lcm(t, tt);
  }
  cout << t << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> B(N+10),A(N+10, 1e13),C(N+10,1e10),D(N+10);
    rep(i,N+1){
        cin >> B[i];
    }
    /*
    A[0] = 1;
    C[0] = A[0] - B[0];
    if(C[0] < 0){
        cout << -1 << endl;
        return 0;
    }
    A[1] = C[0]*2;
    */
   if(N == 0){
       if(B[0] != 1){
           cout << -1 << endl;
           return 0;
       }else{
           cout << 1 << endl;
           return 0;
       }
   }
   
    A[0] = 1;
    rep(i,N+1){
        C[i] = A[i] - B[i];
        if(C[i] < 0){
            cout << -1 << endl;
            return 0;
        }
        A[i+1] = C[i]*2;
        if(A[i+1] >= 1e13){
            break;
        }
    }
    //PR(A,N+1);
    /*ll ans = 0;
    rep(i,N+1){
        ans += A[i];
    }*/
    C[N] = 0;
    D[N] = B[N];
    for(ll i=N-1;i>=0;i--){
        D[i] = B[i] + D[i+1];
        /*
        if(D[i+1] > (D[i]-B[i])*2){
            D[i] = B[i] + D[i+1]/2;
            //cout << -1 << endl;
            //return 0;
        }*/
        /*if(D[i+1] > A[i]*2){
            cout << -1 << endl;
            return 0;
        }*/
        if(D[i] > A[i]){
            //if(A[i] == 1e17)continue;
            D[i] = A[i];
        }
        //C[i] = D[i] - B[i];
    }
    ll ans = 0;
    rep(i,N+1){
        ans += D[i];
    }
    cout << ans << endl;
}


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

#define vi vector<int>
#define vvi vector<vi>

int main() {

    int N, D;
    cin >> N >> D;

    if (N % (D * 2 + 1) == 0) {
        cout << N / (D * 2 + 1) << endl;
    }
    else {
        cout << N / (D * 2 + 1) + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import collections
N = int(input())
S = []
ans = []
for i in range(N):
  S.append(input())
d = collections.Counter(S)
ome = max(d.values())
for k, v in d.items():
  if v == ome:
    ans.append(k)
ans.sort()
for x in ans:
  print(x)


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

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

int main()
{
    int n, m;
    cin >> n >> m;

    //m×nの2次元配列
    int a[n][m];
    vector<int> b(m);

    int sum = 0;

    rep(i, n)
    {
        rep(j, m)
        {
            cin >> a[i][j];
        }
    }
    rep(i, m)
    {
        cin >> b.at(i);
    }

    rep(i, n)
    {
        rep(j, m)
        {
            sum += a[i][j] * b.at(j);
        }
        cout << sum << endl;
        sum = 0;
    }

    return 0;
}


Measured memory_bytes: 3132