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

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

    for (int i = 1; i < m; i++)
    {
        int lt, rt;
        cin >> lt >> rt;
        l = max(l, lt);
        r = min(r, rt);
    }
    if(l <= r){
        cout << r - l + 1 << endl;
    }else{
        cout << 0 << endl;
    }
    
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a + b > c + d)	puts("Left");
	else if(a + b < c + d)	puts("Right");
	else puts("Balanced");
	return 0;
}

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

int main() {
  char c;
  cin >> c;
  
  if( c=='a' || c=='e'  || c=='i' || c=='o' || c=='u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
// ------------------------------------
// Date:2018/ 3/13
// Problem:one stroke path b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;
static const int MAX_N = 8;

int N, M;
bool l[MAX_N][MAX_N] = {false};
int V[MAX_N];

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

  cin >> N >> M;
  vector< int > a(M);
  vector< int > b(M);
  REP(i, M) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    l[a[i]][b[i]] = l[b[i]][a[i]] = true;
  }

  REP(i, N) {
    V[i] = i;
  }

  bool ok;
  int ans = 0;
  do {
    ok = true;
    if (V[0] != 0) continue;
    REP(i, N - 1) {
      if (!l[V[i]][V[i + 1]]) {
	ok = false;
      }
    }
    if (ok) ans++;
  } while(next_permutation(V, V + N));

  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
    ll N,C,K;
    cin >> N >> C >> K;
    vector<int> T(N);
    for(int i=0;i<N;i++){
        cin >> T[i];
    }
    sort(T.begin(),T.end());
    int ct=0;
    int ans=0;
    for(;ct<N;ans++){
        int tm=T[ct];
        int jg=0;
        for(int i=ct;i<N && jg<C;i++){
            if(T[i]<=tm+K){
                ct++;
                jg++;
            }
            else break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    ll n; cin >> n;
    string ans = "";

    ll k = 0;
    while(n != 0){
        if((n - (ll)pow(-2,k)) % (ll)pow(-2,k+1) == 0) { ans = '1' + ans; n -= (ll)pow(-2,k); }
        else ans = '0' + ans;
        k++;
    }
    if(ans.length()) cout << ans << endl;
    else cout << "0" << endl;
}

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

#define forn(l, r) for(int i = l; i < (r); ++i)
#define forj(l, r) for(int j = l; j < (r); ++j)
#define TAM 1000100
#define SYNC ios::sync_with_stdio(0);
#define $ << ' ' <<
#define F first
#define S second
#define endl '\n'


using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const int MAXN = 112345;
const ll mod = 1000000007;

int main() {
    //SYNC
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += i;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

void solve()
{
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for (int i = 1; i <= m; i++)
        for (int j = 10; j <= d; j++)
        {
            if (j > 20 && j % 10 > 1 && j / 10 * (j % 10) == i)
            {
                ans++;
                // cout << i << ' ' << j << endl;
            }
        }
    cout << ans << endl;
}

int main()
{
    solve();
    cerr << "\"努力不足ですね！\"" << endl;
    return 0;
}

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

int main() {
  int h,w;
  string str;
  
  cin >> h >> w;
  
  vector<vector<string>> vec(h+2, vector<string>(w+2));
  
  for(int i = 0; i < h+2; i++){
    if(i == 0 || i == h+1){
      for(int j = 0; j < w+2; j++){
       vec.at(i).at(j) = "."; 
      }
    }else{
      cin >> str;
      for(int j = 0; j < w+2; j++){
        if(j == 0 || j == w+1){
          vec.at(i).at(j) == ",";
        }else{
          vec.at(i).at(j) = str.substr(j-1,1);
        }
      }
    }
  }
  
  int cnt;
  for(int i = 1; i < h; i++){
    for(int j = 0; j < w; j++){
      cnt = 0;
      if(vec.at(i).at(j) == "#"){
        if(vec.at(i-1).at(j) == "#") cnt++;
        else if(vec.at(i).at(j-1) == "#") cnt++;
        else if(vec.at(i).at(j+1) == "#") cnt++;
        else if(vec.at(i+1).at(j) == "#") cnt++;
        
        if(cnt == 0){
          cout << "No";
          return 0;
        }
      }
    }
  }
  
  cout << "Yes";
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    int n;
  cin>>n;
  int a,b;
  a=n%10;
  b=(n-a)/10;
  if(a==9||b==9){
    cout<<"Yes";
  }else{
	cout<<"No";
  }
    return 0;
}

Measured memory_bytes: 256
# frozen_string_literal: true

def factor(n)
  return [1] if n == 1

  `factor #{n}|sed -r 's/[0-9]+://g'|tr ' ' '\n'|sort -n`.split.map(&:to_i)
end

# Example: factors(100) => {2=>2, 5=>2}
def factors_and_num(n)
  factors = factor(n)
  ret = Hash.new(0)
  factors.each do |i|
    ret[i] += 1
  end
  ret
end

def uniq_factor(n)
  `factor #{n}|sed -r 's/[0-9]+://g'|tr ' ' '\n'|sort -n|uniq`.split.map(&:to_i)
end

n = gets.to_i
table = {}
(0...n).each do |_i|
  name = gets
  table[name] = 0 unless table.key?(name)
  table[name] += 1
end

puts table.length


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

struct RMQ {
  static const int MAX_N = 1 << 17;
  int n,dat[2*MAX_N-1];
  // RMQ(){}
  RMQ(int n_){init(n_);}
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    for(int i=0;i<2*n-1;i++) dat[i]=INT_MAX;
  }
  void update(int k,int a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
  }
  int query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return INT_MAX;
    if(a<=l&&r<=b) return dat[k];
    else{
      int vl=query(a,b,k*2+1,l,(l+r)/2);
      int vr=query(a,b,k*2+2,(l+r)/2,r);
      return min(vl,vr);
    }
  }
  int query(int a,int b){
    return query(a,b,0,0,n);
  }
};
int main(){
  int n,q;
  cin>>n>>q;
  RMQ rmq(n);
  for(int i=0;i<q;i++){
    int c,x,y;
    cin>>c>>x>>y;
    if(c) cout<<rmq.query(x,y+1)<<endl;
    else rmq.update(x,y);
  }
  return 0;
}

Measured memory_bytes: 4108
class Card
  include Comparable
  def initialize(val)
    @val = val
  end

  def mark
    @val[0]
  end

  def number
    @val[1].to_i
  end

  def <=>(other)
    number <=> other.number
  end

  def to_s
    @val.dup
  end
end

def bubble_sort(arr)
  n = arr.size - 1
  0.upto(n) do |i|
    n.downto(i + 1) do |j|
      arr[j-1], arr[j] = arr[j], arr[j-1] if arr[j] < arr[j-1]
    end
  end
end

def selection_sort(arr)
  n = arr.size - 1
  0.upto(n) do |i|
    mini_j = i
    i.upto(n) do |j|
      mini_j = j if arr[j] < arr[mini_j]
    end
    arr[i], arr[mini_j] = arr[mini_j], arr[i]
  end
end

def same_order?(cards, sorted)
  orig_order = order_hash(cards)
  sorted_order = order_hash(sorted)
  orig_order.map{|k, v| sorted_order[k] == v}.all?
end

def order_hash(cards)
  order = Hash.new {|h, k| h[k] = ''}
  cards.each{|c| order[c.number] << c.mark }
  order
end


n = gets.to_i
cards = gets.split.map{|v| Card.new(v)}

bubble = cards.dup
selection = cards.dup

bubble_sort(bubble)
puts bubble.join("\s")
puts same_order?(cards, bubble) ? 'Stable' : 'Not stable'

selection_sort(selection)
puts selection.join("\s")
puts same_order?(cards, selection) ? 'Stable' : 'Not stable'

Measured memory_bytes: 8880
#include <vector>

template <class expr>
class binary_elimination
{
    std::vector<expr> base;
public:
    bool add(expr e)
    {
        for(const expr &b : base) if((b ^ e) < e) e ^= b;
        if(e) base.emplace_back(e);
        return e;
    }
    size_t dim() const { return base.size(); }
    typename decltype(base)::iterator begin() const { return std::begin(base); }
    typename decltype(base)::iterator end() const { return std::end(base); }
}; // class binary_elimination

#include <bits/stdc++.h>
using i64=int64_t;
using namespace std;

main()
{
    int T; cin>>T;
    while(T--)
    {
        binary_elimination<i64> elim;
        int n; cin>>n;
        vector<i64> a(n);
        for(i64 &x:a) cin>>x;
        string s; cin>>s;
        bool lose=0;
        for(int i=n-1;i>=0;i--)
        {
            if(s[i]=='0')
            {
                elim.add(a[i]);
            }
            else
            {
                if(elim.add(a[i])) lose=1;
            }
        }
        cout << lose << "\n";
    }
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int h,w,K;
char s[11][1010];
signed main(){
    cin>>h>>w>>K;
    rep(i,h){
        rep(j,w){
            cin>>s[i][j];
        }
    }
    int ans=INF;
    rep(i,(1<<(h-1))){
        int res=__builtin_popcount(i);
                vector<int>v[10];
                int cnt[10];
                fill(cnt,cnt+10,0);
                int n=0;
                rep(k,h){
                    v[n].pb(k);
                    if(k!=h-1){
                        if((i>>k)&1)n++;
                    }
                }
                n++;
                rep(k,w){
                    rep(l,n){
                        int hoge=0;
                        for(int c:v[l]){
                            if(s[c][k]=='1'){
                                cnt[l]++;
                                hoge++;
                            }
                        }
                        if(hoge>K)goto ng;
                    }
                    bool f=true;
                    rep(l,n)if(cnt[l]>K)f=false;
                    if(!f){
                        res++;
                        k--;
                        rep(l,n)cnt[l]=0;
                    }
                }
        chmin(ans,res);
        ng:;
    }
    cout<<ans<<endl;
    return 0;
}


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

int dp[20001];

int main(){
  
  ll n;
  cin>>n;
  
  ll dp[2005] = {0};
	dp[0] = 1;
	
	for (ll i = 0; i < n; i++) {
		for (ll j = i + 3; j <= n; j++) {
			dp[j] = (dp[j] + dp[i]) % mod;
		}
	}
	
	cout << dp[n] << '\n';
  
  
 return 0; 
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
#define REP(i,a,b) for (int i = (int)(a); (i) < (int)(b); i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int n,k;
	cin >> n >> k;
	int h[n];
	rep(i,n){ cin >> h[i]; }
	
	int res = 0;
	rep(j,n){ if (h[j] >= k){ res++; } }
	cout << res << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

template <int mod>
struct ModInt {
  int x;
  ModInt(): x(0) {}
  ModInt(long long a) { x = a % mod; if (x < 0) x += mod; }
  ModInt &operator+=(ModInt that) { x = (x + that.x) % mod; return *this; }
  ModInt &operator-=(ModInt that) { x = (x + mod - that.x) % mod; return *this; }
  ModInt &operator*=(ModInt that) { x = (long long) x * that.x % mod; return *this; }
  ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
  ModInt inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return ModInt(u);
  }
  #define op(o, p) ModInt operator o(ModInt that) { return ModInt(*this) p that; }
    op(+, +=) op(-, -=) op(*, *=) op(/, /=)
  #undef op
  friend ostream& operator<<(ostream &os, ModInt m) { return os << m.x; }
};

using mint = ModInt<1000000007>;

void solve() {
  int n;
  cin >> n;
  vi32 a(n);
  cin >> a;
  vi32 cnt(n);
  rep(i, n) cnt[a[i]]++;
  if (n % 2 == 0) {
    for (int i = 1; i < n; i += 2) {
      if (cnt[i] != 2) {
        cout << 0 << endl;
        return;
      }
    }
  } else {
    if (cnt[0] != 1) {
      cout << 0 << endl;
      return;
    }
    for (int i = 2; i < n; i += 2) {
      if (cnt[i] != 2) {
        cout << 0 << endl;
        return;
      }
    }
  }
  cout << exp((mint) 2, n / 2) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

#define EPS 1e-6

int main(){
  int q;
  while(cin >> q){
    if(q == -1) break;
    double x = double(q/2);
    while(!(fabs(x*x*x-q) < EPS*q)){
      x = x - ((x*x*x-q) / (3*x*x));
    }
    printf("%f\n", x);
  }
  return 0;
}

Measured memory_bytes: 1184
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

a, b= MAP()

if a >= 10 or b >= 10:
    print(-1)
else:
    print(a*b)


Measured memory_bytes: 38384
#include <stdio.h>


int main(){
	
	int a,b,c,i,n,sum=0,j;
	scanf("%d %d %d",&a,&b,&c);
	
	for(i=1;i<=a;i++){
		j=i;
		n=0;
		while(i){
			n=n+i%10;
			i=i/10;
		}
		i=j;
		if(b<=n&&n<=c)sum=sum+i;
	}
	
	printf("%d\n",sum);
	
	return 0;
}


Measured memory_bytes: 128
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

h,w=map(int,input().split())
if h==1 or w==1:
    print(1)
    quit()
print(math.ceil(h*w/2))

Measured memory_bytes: 64364
'use strict'

function main(s) {

  const n = Number(s);

  let max = 0;
  let i = 0;

  while (max <= n) {
    i += 1;
    max = Math.pow(i, 2);
  }

  const ans = Math.pow(i - 1, 2);

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7628
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Edge = Tuple!(int, "to", int, "idx");

void main() {
    int N;
    scan(N);

    auto adj = new Edge[][](N, 0);

    foreach (i ; 0 .. N - 1) {
        int ai, bi;
        scan(ai, bi);
        ai--, bi--;
        adj[ai] ~= Edge(bi, i);
        adj[bi] ~= Edge(ai, i);
    }

    int M;
    scan(M);

    auto useEdge = new ulong[](M);

    ulong dfs(int u, int p, int v) {
        foreach (e ; adj[u]) if (e.to != p) {
            if (e.to == v) {
                return 1UL << e.idx;
            }
            auto b = dfs(e.to, u, v);
            if (b != 0) {
                return b | (1UL << e.idx);
            }
        }
        return 0;
    }

    foreach (i ; 0 .. M) {
        int ui, vi;
        scan(ui, vi);
        ui--, vi--;
        useEdge[i] = dfs(ui, -1, vi);
    }

    debug {
        writeln(useEdge);
    }

    long ans;

    foreach (s ; 0 .. (1 << M)) {
        ulong b;
        foreach (i ; 0 .. M) {
            if (s & (1 << i)) {
                b |= useEdge[i];
            }
        }
        auto p = s.popcnt % 2;
        auto t = (-1)^^p * 2L^^(N - 1 - b._popcnt);
        ans += t;
    }

    writeln(ans);
}




void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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


int main(){
  long long int A, B, C, K;
  cin >> A >> B >> C >> K;

  long long int ans = min(K, A);
  K -= A;
  if(K>0) K -= B;
  if(K>0) ans -= min(K, C);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()

N = int(input())
a = list(map(int, input().split()))

d = {}
for e in a:
    if e not in d:
        d[e] = 1
    else:
        d[e] += 1

ans = ""


if len(d) > 3:
    ans = "No"
elif len(d) == 1:
    if 0 in d:
        ans = "Yes"
    else:
        ans = "No"
elif N % 3 == 0:
    if len(d) == 2:
        if 0 in d and d[0] == N // 3:
            ans = "Yes"
        else:
            ans = "No"
    elif len(d) == 3:
        keys = list(d.keys())
        if keys[0] ^ keys[1] == keys[2] and d[keys[0]] == N // 3 and d[keys[1]] == N // 3:
            ans = "Yes"
        else:
            ans = "No"
else:
    ans = "No"

print(ans)
    




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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
// #define M_PI 3.14159265358979323846 // CFでは定義しておく必要あり
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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;
};

void print() {
  cout << endl;
};

template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
};

template <class T>
void print(vector<T> &vec, ll k){
   ll n = vec.size();
   k = min(k, n);
   rep(i, 0, k-1) cout << vec[i] << " ";
   cout << vec[k-1] << endl;
};

template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
    print(vec);
  }
};

template<class T, class U>
void print(pair<T,U> &p){
  cout << p.first << " " << p.second << "\n";
};


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

  int N; cin >> N;
  int M; cin >> M;
  int Q; cin >> Q;

  vvi table(N, vi(N, 0));
  rep(i, 0, M) {
    int L, R;
    cin >> L >> R;
    L--; R--;
    for (int i = L; i >= 0; i--) {
      table[i][R]++;
    }
  }

  rep(i, 0, N) {
    rep(j, 1, N) {
      table[i][j] += table[i][j-1];
    }
  }

  rep(i, 0, Q) {
    int p, q; cin >> p >> q;
    p--; q--;
    cout << table[p][q] << endl;
  }



  return 0;
};


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int a[10010];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);

    long long sum=0;
    for(int i=1;i<=n;i++)
    {
        while(a[i]%2==0)
        {
            sum++;
            a[i]/=2;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;
const int qq = 1e5 + 10;
ll n, m;
char str[qq];
int vis[qq];
bool judge(){
//	for(int i = 1; i <= n; ++i)
//		printf("%d ", vis[i]);
//	printf("\n");
	for(int i = 2; i < n; ++i)
		if(vis[i] == 1){
			if(str[i] == 'o'){
				if(vis[i + 1] != vis[i - 1])	return false;
			}else{
				if(vis[i + 1] == vis[i - 1])	return false;
			}
		}else{
			if(str[i] == 'o'){
				if(vis[i + 1] == vis[i - 1])	return false;
			}else{
				if(vis[i + 1] != vis[i - 1])	return false;
			}
		}
	if(vis[1] == 1){
		if(str[1] == 'o'){
			if(vis[2] != vis[n])	return false;
		}else{
			if(vis[2] == vis[n])	return false;
		}
	}else{
		if(str[1] == 'o'){
			if(vis[2] == vis[n])	return false;
		}else{
			if(vis[2] != vis[n])	return false;
		}
	}
	if(vis[n] == 1){
		if(str[n] == 'o'){
			if(vis[n - 1] != vis[1])	return false;
		}else{
			if(vis[n - 1] == vis[1])	return false;
		}
	}else{
		if(str[n] == 'o'){
			if(vis[n - 1] == vis[1])	return false;
		}else{
			if(vis[n - 1] != vis[1])	return false;
		}
	}
	return true;
}

void print(){
	for(int i = 1; i <= n; ++i)
		if(vis[i] == 1)	printf("S");
		else	printf("W");
	puts("");
}

int main(){
	scanf("%lld", &n);
	scanf("%s", str + 1);
	int flag = false;
	vis[1] = 1;
	vis[2] = 1;
	for(int i = 2; i < n; ++i)
		if(vis[i] == 1){
			if(str[i] == 'o')	vis[i + 1] = vis[i - 1];
			else				vis[i + 1] = (vis[i - 1] == 1 ? 0 : 1);
		}else{
			if(str[i] == 'x')	vis[i + 1] = vis[i - 1];
			else				vis[i + 1] = (vis[i - 1] == 1 ? 0 : 1);
		}
	flag = judge();
	if(flag == true){
		print();
		return 0;
	}
	vis[1] = 0;
	vis[2] = 0;
	for(int i = 2; i < n; ++i)
		if(vis[i] == 1){
			if(str[i] == 'o')	vis[i + 1] = vis[i - 1];
			else				vis[i + 1] = (vis[i - 1] == 1 ? 0 : 1);
		}else{
			if(str[i] == 'x')	vis[i + 1] = vis[i - 1];
			else				vis[i + 1] = (vis[i - 1] == 1 ? 0 : 1);
		}
	flag = judge();
	if(flag == true){
		print();
		return 0;
	}
	vis[1] = 1;
	vis[2] = 0;
	for(int i = 2; i < n; ++i)
		if(vis[i] == 1){
			if(str[i] == 'o')	vis[i + 1] = vis[i - 1];
			else				vis[i + 1] = (vis[i - 1] == 1 ? 0 : 1);
		}else{
			if(str[i] == 'x')	vis[i + 1] = vis[i - 1];
			else				vis[i + 1] = (vis[i - 1] == 1 ? 0 : 1);
		}
	flag = judge();
	if(flag == true){
		print();
		return 0;
	}
	vis[1] = 0;
	vis[2] = 1;
	for(int i = 2; i < n; ++i)
		if(vis[i] == 1){
			if(str[i] == 'o')	vis[i + 1] = vis[i - 1];
			else				vis[i + 1] = (vis[i - 1] == 1 ? 0 : 1);
		}else{
			if(str[i] == 'x')	vis[i + 1] = vis[i - 1];
			else				vis[i + 1] = (vis[i - 1] == 1 ? 0 : 1);
		}
	flag = judge();
	if(flag == true){
		print();
		return 0;
	}
	printf("-1\n");
}

Measured memory_bytes: 768
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    try(
      Scanner scanner = new Scanner(System.in);) {
      int numPersons = scanner.nextInt();
      scanner.nextInt();
      Map<Integer, Integer> foods = new HashMap<>();
      for (int personIndex = 0; personIndex < numPersons; personIndex++) {
        int numFoods = scanner.nextInt();
        for (int foodIndex = 0; foodIndex < numFoods; foodIndex++) {
          Integer food = scanner.nextInt();
          if (foods.containsKey(food)) {
            foods.put(food, foods.get(food) + 1);
          } else {
            foods.put(food, 1);
          }
        }
      }
      int count = 0;
      for (Integer food: foods.keySet()) {
        if (foods.get(food).equals(numPersons)) {
          count++;
        }
      }
      System.out.println(count);
    }
  }
}

Measured memory_bytes: 23764
from collections import deque
N = int(input())
X = [[] for _ in range(N)]
for i in range(N):
    s = input()
    for j in range(N):
        if s[j] == "1":
            X[i].append(j)

def bipartite(n, E):
    col = [-1] * n
    f = 0
    for i in range(n):
        if col[i] >= 0: continue
        que = deque([[i, 0]])
        while que:
            v, c = que.popleft()
            if col[v] == -1:
                col[v] = c
            elif col[v] == c:
                continue
            else:
                f = 1
                break
            for ne in E[v]:
                if col[ne] == c:
                    f = 1
                    break
                if col[ne] < 0:
                    que.append([ne, 1-c])

            if f:
                break
        if f:
            break
    return 1-f

def BFS(n, E, i0=0):
    Q = deque([i0])
    D = [-1] * n
    D[i0] = 0
    while Q:
        x = Q.popleft()
        for c in E[x]:
            if D[c] == -1:
                D[c] = D[x] + 1
                Q.append(c)
    return D

if bipartite(N, X):
    print(max([max(BFS(N, X, i)) for i in range(N)])+1)
else:
    print(-1)


Measured memory_bytes: 41456
import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
A = sorted(list(map(int,readline().split())))

sumA = [0] + A.copy()
for i in range(1,len(sumA)):
  sumA[i] += sumA[i - 1]
  
# 左手34,33,19,14,10
# 右手34,33,19,14,10
# X以上の握手をできる組だけ採用する
# 例：50以上の握手をできるのは、
# 左手34に対しては34,33,19
# 右手33に対しては34,33,19
# この合計がM回を越えると採用できない。
# M回を下回る場合は、すべての握手の合計で最大値を更新

ok = -1
ng = 10 ** 5 * 2 + 1

import bisect
def isOk(x):
  # x以上の握手だけ採用するとき、採用できる場合に全体の合計点はいくつになるか
  cnt = 0
  for left in A:
    right = x - left
    ind = bisect.bisect_left(A, right)
    cnt += N - ind
  if cnt > M:
    return True
  else:
    return False

while abs(ng - ok) > 1:
  mid = abs(ng + ok) // 2
  if isOk(mid):
    ok = mid
  else:
    ng = mid
    
# ok以上の握手だけ許容する場合の点数を算出
ans = 0
num = 0
for left in A:
  right = ok - left
  ind = bisect.bisect_left(A, right)
  ans += sumA[-1] - sumA[ind] + (N - ind) * left
  num += N - ind

if num > M:
  ans -= (num - M) * ok

print(ans)


Measured memory_bytes: 20024
#include "bits/stdc++.h"
using namespace std;
struct Node{
  int parent,left,right;
};
Node T[100005];
int n,D[1000005],hei[1000005];

void setDepth(int u, int p){
  if(u==-1)return;
  D[u]=p;
  setDepth(T[u].left,p+1);
  setDepth(T[u].right,p+1);
}

int setHeight(int u){
  int h=0,hh=0;
  if(T[u].left!=-1){
    h=setHeight(T[u].left)+1;
  }
  if(T[u].right!=-1){
    hh=setHeight(T[u].right)+1;
  }
  if(h>hh)return hei[u]=h;
  else return hei[u]=hh;
}
int get(int u){
  if(T[u].parent==-1){
    return -1;
  }
  if(T[T[u].parent].right!=-1&&T[T[u].parent].right!=u){
    return T[T[u].parent].right;
  }
  if(T[T[u].parent].left!=-1&&T[T[u].parent].left!=u){
    return T[T[u].parent].left;
  }
  return -1;
}
int main(){
  int i=0,j=0,k=0,c=0,l=0,r=0,Tc=0;
  int id=0;
  cin>>n;
  for(i=0;i<n;i++){
    T[i].parent=T[i].left=T[i].right=-1;
  }
  for(i=0;i<n;i++){
    cin>>id>>l>>r;
    T[id].left=l;
    T[id].right=r;
    if(l!=-1)T[l].parent=id;
    if(r!=-1)T[r].parent=id;
  }
  for(i=0;i<n;i++){
    if(T[i].parent==-1){
      Tc=i;
    }
  }
  setDepth(Tc,0);
  setHeight(Tc);
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, ",i,T[i].parent,get(i));
    int c=0;
    if(T[i].left!=-1)c++;
    if(T[i].right!=-1)c++;
    printf("degree = %d, depth = %d, height = %d, ",c,D[i],hei[i]);
    if(T[i].parent==-1)cout<<"root"<<endl;
    else if(T[i].left==-1&&T[i].right==-1)cout<<"leaf"<<endl;
    else cout<<"internal node"<<endl;
    //cout<<"[";
    //for(j=0,Tc=T[i].left;Tc!=-1;j++,Tc=T[Tc].right){
      //while(1){
      //if(j)cout<<", ";
      //cout<<Tc;
	//if(T[i].left==-1||T[i].left==T[T[i].left].right)break;
    //}
    //cout<<"]"<<endl;
    /*while(1){
      if(T[i].left==-1)break;
      
    }*/
  }
  return 0;
}



Measured memory_bytes: 3248
#include <stdio.h>
#include <stdlib.h>

struct node {
    int num;
    struct node * next;
};

static struct node *head=NULL;

struct node * create (int, struct node *);
void push (int);
int pop ();
void print_head ();

int main (void) {
    char ch;
    int num;

    for (;;) {
        scanf ("%c", &ch);
        if (ch>='0' && ch<='9') {
            ungetc (ch, stdin);
            scanf ("%d", &num);
            push (num);
        }
        else if (ch=='+') push(pop()+pop());
        else if (ch=='-') {
            int a = pop();
            int b = pop();
            push (b-a);
        } else if (ch=='*') push(pop()*pop());
        else if (ch=='\n') break;
        // print_head ();
    }

    printf ("%d\n", pop());

    return 0;
}

struct node * create (int num, struct node *next) {
    struct node * new;
    new = (struct node *) malloc (sizeof(struct node));
    new -> num = num;
    new -> next = next;
    return new;
}

void push (int num) {
    head = create (num, head);
}

int pop () {
    int num = head->num;
    struct node * t = head->next;
    free(head);
    head = t;
    return num;
}

void print_head () {
    struct node *t=head;
    for (;t!=NULL;t=t->next) printf ("%d ", t->num);
    printf ("\n");
}



Measured memory_bytes: 2084
#include <iostream>
#include <vector>
#include <math.h>
#include <stdio.h>

int main() {
  int n; std::cin >> n;
  std::vector<int> x(n);
  std::vector<int> y(n);
  for (int i = 0; i < n; ++i) std::cin >> x[i] >> y[i];
  double sum = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      int dx = x[i]-x[j];
      int dy = y[i]-y[j];
      sum += sqrt((double)dx*dx + (double)dy*dy);
    }
  }
  double ans = sum * 2 / (double)n;
  printf("%.10lf\n", ans);
  
  return 0;
}

Measured memory_bytes: 3792
import sys
from collections import Counter

input = sys.stdin.readline
N = int(input())
C = list(input().strip())

counter = Counter(C)
if len(counter) == 1:
    print(0)
else:
    red_n = counter["R"]
    ans = 0
    for i in range(N):
        if red_n <= i:
            break
        if C[i] == "W":
            ans += 1
    print(ans)

Measured memory_bytes: 11064
A_1 = list(map(int, input().split()))
A_2 =list(map(int, input().split()))
A_3 =list(map(int, input().split()))
A = A_1 +A_2 +A_3
N = int(input())
b = [int(input()) for _ in range(N)]
for i in range(N):
    for j in range(9):
        if b[i] == A[j]:
            A[j] = 0
if A[0]==A[1]==A[2]==0 or A[3]==A[4]==A[5]==0 or A[6]==A[7]==A[8]==0 or A[0]==A[3]==A[6]==0 or A[1]==A[4]==A[7]==0 or A[2]==A[5]==A[8]==0 or A[0]==A[4]==A[8]==0 or A[2]==A[4]==A[6]==0:          
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <cstdio>

int main(){
    int A, B, C;
    scanf("%d%d%d", &A, &B, &C);
    if(A+B+C==17 && (A==5)+(B==5)+(C==5)==2) printf("YES\n");
    else printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <array>


int main()
{
    int N,K;
	std::cin >> N >> K;
	std::string S;
	std::cin >> S;
	std::transform(S.begin() + K-1, S.begin() + K, S.begin() + K-1, tolower);
	std::cout << S;
	return 0;
}

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

int main() {  
  int k, x;
  cin >> k >> x;
  for(int i = x - k + 1; i < x + k; i++) {
  	cout << i << ' ';
  }
}


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

namespace ABC151
{
    class C
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];

            bool[] isAc = new bool[N];
            int[] waCount = new int[N];

            for (int i = 0; i < M; i++)
            {
                string[] input2 = Console.ReadLine().Split().ToArray();
                int p = int.Parse(input2[0]);
                string s = input2[1];

                if (isAc[p - 1]) continue;

                if (s == "AC") isAc[p - 1] = true;
                else waCount[p - 1]++;
            }

            int acRes = isAc.Count(x => x == true);
            int waCountRes = 0;

            for (int i = 0; i < N; i++)
            {
                if (isAc[i]) waCountRes += waCount[i];
            }

            Console.WriteLine("{0} {1}", acRes, waCountRes);

        }
    }
}


Measured memory_bytes: 17736
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, l int
	fmt.Scan(&n, &l)
	strs := make([]string, n)
	for i := range strs {
		fmt.Scan(&strs[i])
	}
	sort.Strings(strs)
	for i := range strs {
		fmt.Print(strs[i])
	}
	fmt.Println()
}


Measured memory_bytes: 512
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#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 _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  int n;cin>>n;
  double res = 0;
  rep(i, n){
    double v;cin>>v;
    string t;cin>>t;
    res += v * (t=="JPY"?1.0:380000.0);
  }
  // cout << res << endl;
  printf("%06f", res);

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {

   val scanner: Scanner = Scanner(System.`in`)
    val array: Array<Int> = arrayOf(1,2,3)
    val i1 = scanner.nextInt()
    val i2 = scanner.nextInt()
    array.forEach { e -> if (i1 != e && i2 != e ){
    print(e)}
    }
}

Measured memory_bytes: 29352
#include<stdio.h>

int main(){
  char s[128];
  int y,m,d;
  while(scanf("%s%d%d%d",s,&y,&m,&d),s[0]!='#'){
    if(y<31 || (y==31 && m<5)){
      printf("HEISEI %d %d %d\n",y,m,d);
    }
    else{
      printf("? %d %d %d\n",y-30,m,d);
    }
  }
  return 0;
}



Measured memory_bytes: 2028
using System;
using System.Collections;
using System.Collections.Generic;

public class AOJ1
{
    static int Comp(KeyValuePair<long, long> a, KeyValuePair<long, long> b)
    {
        return a.Key.CompareTo(b.Key);
    }
    static void Main()
    {
        while (true)
        {
            long n = long.Parse(Console.ReadLine());
            if (n == 0) break;
            long[] tmp = new long[9];
            List<KeyValuePair<long, long>> TimeTeam = new List<KeyValuePair<long, long>>();
            for (long i = 0; i < n; i++)
            {
                string[] Input = Console.ReadLine().Split(' ');
                for (int j = 0; j < Input.Length; j++) tmp[j] = long.Parse(Input[j]);
                long Sum=0;
                for (int j = 1; j <= 8; j += 2) Sum += 60 * tmp[j] + tmp[j + 1];
                TimeTeam.Add(new KeyValuePair<long, long>(Sum, tmp[0]));
            }
            TimeTeam.Sort(Comp);
            Console.WriteLine(TimeTeam[0].Value);
            Console.WriteLine(TimeTeam[1].Value);
            Console.WriteLine(TimeTeam[TimeTeam.Count-2].Value);
        }
    }
}

Measured memory_bytes: 6088
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&!(1<<i);}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mul(int a, int b) {return ((a%MOD)*(b%MOD))%MOD;}
int add(int a, int b) {return (a+b)%MOD;}
int sub(int a, int b) {return (((a-b)%MOD)+MOD)%MOD;}
int __div(int a, int b) {return mul(a, powmod(b, MOD-2, MOD));} //if MOD is prime;
const int inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

int32_t main(void)
{
	IOS;
	int n, W; 
	cin>>n>>W;
	vi v(n); vi w(n);
	for(int i = 0; i < n; i++)
		cin>>w[i]>>v[i];
	int LIM = 100010;
	int dp[n][LIM];
	memset(dp, W+1, sizeof(dp));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < LIM; j++)
			dp[i][j]=W+1;
	}
	dp[0][v[0]]=w[0];
	for(int i = 0; i < n; i++)
		dp[i][0]=0;
	for(int i = 1; i < n; i++) {
		for(int j = 0; j < LIM; j++) {
			int mn1=W+1, mn2=W+1;
			if(j-v[i] >= 0)
				mn1=dp[i-1][j-v[i]]+w[i];
			mn2=dp[i-1][j];
			dp[i][j]=min(mn1, mn2);
		}
	}
	// for(int i = 0; i < n; i++) {
	// 	for(int j = 0; j < 29; j++) {
	// 		if(dp[i][j]>W)
	// 			cout<<-1<<" ";
	// 		else cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	int mx=0;
	// cout<<dp[n-1][17]<<endl;
	for(int i = 0; i < LIM; i++) {
		if(dp[n-1][i] <= W)
			mx=i;
	}
	cout<<mx<<endl;
	time();	
	return 0;
}

Measured memory_bytes: 78464
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

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

    int sum=0;
    vector<int> a(n);
    for(int &x:a){
        cin >> x;
        sum+=x;
    }

    int ave1=sum/n+1,ave2=sum/n;
    
    int ans1=0,ans2=0;
    for(int x:a){
        ans1+=(x-ave1)*(x-ave1);
        ans2+=(x-ave2)*(x-ave2);
    }


    cout << min(ans1,ans2) << endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long llong;
int main(){
    string s, ans;
    cin >> s;

    for (int i = 0; i < s.size(); i++){
        if (s[i] == '1') ans += '1';
        else if (s[i] == '0') ans += '0';
        else if (ans.size() > 0) ans.erase(ans.size() - 1);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M;
    cin >> N >> M;
    vector<int> O(N+1), R(N+1);
    for(int i = 1; i <= N; i++) {
        cin >> O[i];
        R[i] = 0;
    }

    for(int i = 1; i <= M; i++) {
        int a, b;
        cin >> a >> b;
        R[a] = max(R[a], O[b]);
        R[b] = max(R[b], O[a]);
    }

    int ans = 0;
    for(int i = 1; i <= N; i++) {
        if (O[i] > R[i]) ans++;
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
#include <array>
#include <bitset>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
	int n; CI n;
	ll mod = 1e9 + 7;
	vector<int> a(n);
	vector<int> b(n, 0);
	REP(i, n) {
		CI a[i];
		b[a[i]]++;
	}

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

	int i = 1;
	if (n % 2) {
		i++;
		if (b[0] != 1) { CO 0 EN; return 0; }
	}
	for (i; i <= n-1; i += 2) {
		if (b[i] != 2) {
			CO 0 EN; return 0;
		}
	}

	ll ans = 1;
	for (int i = 1; i <= n / 2; i++) {
		ans *= 2;
		ans %= mod;
	}

	CO ans EN;

}

Measured memory_bytes: 1024
#include<cstdio>//输入输出要用的文件。 
#include<cmath>//sqrt要用的文件。 
using namespace std;
long long n,ans;//10的10次方超int。 
int s;
int main(){
    scanf("%lld",&n);//long long的scanf要用lld。 
    for(int i=sqrt(n);i>0;--i) //从平方根开始搜索，用n除以搜到的第一个数，计算出它的位数就是答案。 
        if(n%i==0){
            ans=n/i;
            break;
        }
    while(ans>0)
    {//计算位数。 
        ++s;
        ans/=10;
    }
    printf("%d\n",s);//s为int型变量。 
    return 0;
}

Measured memory_bytes: 128
def main():
    n = int(input())
    xyp = [list(map(int, input().split())) for _ in [0]*n]
    d = []

    def calc(seq):
        m = len(seq)
        dp = [[10**15]*(m+1) for _ in [0]*(m+1)]
        dp[0][0] = 0
        for i in range(m):
            for j in range(i+1):
                temp = dp[j][0]
                for a, b in seq[:i+1]:
                    temp += min(abs(a), seq[i][0]-a)*b
                dp[j+1][i+1] = min(dp[j+1][i+1], temp)
                for k in range(1, i+1):
                    temp = dp[j][k]
                    for a, b in seq[k:i+1]:
                        temp += min(abs(a), a-seq[k-1][0], seq[i][0]-a)*b
                    dp[j+1][i+1] = min(dp[j+1][i+1], temp)
        for i in range(m+1):
            for a, b in seq[:m]:
                dp[i][0] += abs(a)*b
            for k in range(1, m+1):
                for a, b in seq[k:m]:
                    dp[i][k] += min(abs(a), a-seq[k-1][0])*b
        for i in range(m+1):
            dp[i] = min(dp[i])
        dp += [0]*(n-m)
        return dp

    xyp.sort()
    for i in range(2**n):
        x_list, y_list = [], []
        for j in range(n):
            x, y, p = xyp[j]
            if i & 1:
                x_list.append([x, p])
            else:
                y_list.append([y, p])
            i >>= 1
        y_list.sort()
        d.append([calc(x_list), calc(y_list)])

    ans = [10**15]*(n+1)
    for x, y in d:
        for i in range(n+1):
            for j in range(n-i+1):
                ans[i+j] = min(ans[i+j], x[i]+y[j])
    for i in ans:
        print(i)


main()


Measured memory_bytes: 117224
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
#define mod 1000000007
typedef long long LL;
LL c[maxn] = {};
LL modinv(LL a, LL p) {
    if (p == 1) return 0;
    LL pp = p, y = 0, x = 1;
    while (a > 1) {
        LL q = a / p, t = p;
        p = a % p, a = t, t = y, y = x - q * y, x = t;
    }
    if (x < 0) x += pp;
    return x;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	LL a[maxn];
	LL sum[maxn] = {};
	for(int i=1; i<=n; i++)
		cin >> a[i];
	sort(a+1, a+n+1);
	for(int i=1; i<=n; i++)
	{
		sum[i] = (sum[i-1] + a[i]) % mod;
	}
	if(k<2)
	{
		cout << 0 << endl;
		return 0;
	}
	k -= 2;
	c[k] = 1;
	for(int i=k+1; i<=n; i++)
	{
		c[i] = c[i-1] * i % mod * modinv(i-k, mod) % mod;
	}
	LL ans = 0;
	for(int i=k; i<=n-2; i++)
	{
		ans = (ans + (sum[n]-sum[n-i-1]-sum[i+1]) % mod * c[i] % mod) % mod;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 2176