akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,a,b,i,j,s=0;
  cin>>N>>M;
  vector<pair<int,int>>E(M);
  for(i=0;i<M;i++){
    cin>>a>>b;
    E.at(i)=make_pair(a,b);
  }
  vector<int>v(N);
  for(i=0;i<N;i++)v.at(i)=i+1;
  sort(v.begin(),v.end());
  do{
    if(v.at(0)==1){
      for(i=1;i<N;i++){
        for(j=0;j<M;j++)if((v.at(i-1)==E.at(j).first&&v.at(i)==E.at(j).second)||(v.at(i)==E.at(j).first&&v.at(i-1)==E.at(j).second))break;
        if(j==M)break;
      }
      if(i==N)s++;
    }
  }while(next_permutation(v.begin(),v.end()));
  cout<<s<<endl;
}

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

int F[44];
int fibonacci(int);

int main(){
  int n;
  int f;

  scanf("%d", &n);
  if(n < 0 || 44 < n)
    exit(0);

  f = fibonacci(n);

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

  return 0;
}

int fibonacci(int n){
  if(n == 0 || n == 1)
    return F[n] = 1;
  if(F[n] != NULL)
    return F[n];
  return F[n] = fibonacci(n - 2) + fibonacci(n - 1);
}

Measured memory_bytes: 596
# INPUT
x1, y1, x2, y2 = map(int,input().split())

# PROCESS
dx, dy = x2-x1, y2-y1
 
x3, y3 = x1 + dx - dy, y1 + dy + dx
x4, y4 = x1 - dy, y1 + dx

# OUTPUT 
print(x3, y3, x4, y4)

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

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];
    auto A = readln.split.map!(to!long).array;

    auto dp = new long[](N);
    fill(dp, 1L << 59);
    dp[0] = 0;

    foreach (i; 1..N) {
        foreach (j; max(0, i - K)..i) {
            dp[i] = min(dp[i], dp[j] + abs(A[i] - A[j]));
        }
    }

    dp[N-1].writeln;
}


Measured memory_bytes: 4380
/**
 *    author:  yoseph
 *    created: 28.08.2020 16:38:21      
**/
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	long long sum = 0;
	for (auto &x : s) {
		sum += x - '0';
	}
	cout << (sum % 9 == 0 ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 3772
<?php

fscanf(STDIN, '%d', $a);
fscanf(STDIN, '%d', $b);
fscanf(STDIN, '%d', $c);
fscanf(STDIN, '%d', $d);
fscanf(STDIN, '%d', $e);
fscanf(STDIN, '%d', $k);

if ($e - $a <= $k) {
    echo 'Yay!' . PHP_EOL;
} else {
    echo ':(' . PHP_EOL;
}

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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        int n;
        cin >> n;
        double ans = 0.0;
        for( int i = 1; i <= n; i++ ) {
                double x;
                cin >> x;
                ans += ( 1.0 / x );
        }
        cout << setprecision(5) << fixed << 1.0/ans << endl;
        return 0;
}










Measured memory_bytes: 256
import fractions

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

ans = 0

ls = [0]*n
rs = [0]*n

for i in range(1,n):
  ls[i] = fractions.gcd(ls[i-1],a[i-1])
  rs[i] = fractions.gcd(rs[i-1],a[-i])

ans = 0
for i in range(n):        
    ans = max(ans,fractions.gcd(ls[i],rs[-i-1]))

print(ans)    

Measured memory_bytes: 16144
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

int main(){
    int N;
    cin >> N;
    cout << N * (N + 1) / 2 << endl;
}



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

int main() {
    ll N, K;
    cin >> N >> K;

    cout << min(N % K, K - N % K) << endl;
}

Measured memory_bytes: 256
import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())))
b=np.array(list(map(int,input().split())))
c=a-b
c.sort()
g=0
p=-1
for i in range(n):
    if c[i]<0:
        g+=c[i]
    else:
        break
if g==0:
    print(0)
else:
    for j in range(1,n+1):
        if g>=0:
            p=0
            break
        if c[-j]>0:
            g+=c[-j]
        else:
            break
    if p==-1:
        print(-1)
    else:
        print(i+j-1)

Measured memory_bytes: 23936
#include<stdio.h>

#define N 1000000

int n,m,BOX[N];

int research(int x);

int main()
{
  int i,right=100000*10000,left=0,res;

  scanf("%d%d",&n,&m);

  for(i=0; i<n; i++){
    scanf("%d",&BOX[i]);
  }

  while(right-left>1){
    
    res = (right+left)/2;

    if(research(res)==1) right=res;
    else left = res;
  }
  
  printf("%d\n",right);

  return 0;
}

int research(int x)
{
  int i,con=0,total=0;

  for(i=0; i<m; i++){
    total=0;
  
    while(BOX[con]+total<=x){
    
      total+= BOX[con];
      con++;

      if(con==n) return 1;
    }
  }
  return 0;
}



Measured memory_bytes: 2216
#include<stdio.h>


int main(){
  char s[10];
  char ans[10];
  int k=0;
  scanf("%s",&s);
  for(int i=0;s[i]!='\0';++i){
    if(s[i]=='0' ||s[i]=='1'){
      ans[k]=s[i];
      ++k;
    }
    else{
      if(k!=0){
        --k;
      }
    }
  }
  ans[k]='\0';
  printf("%s",ans);
  return 0;
}


Measured memory_bytes: 128
import sys, math
ip = sys.stdin.readline

def get_key(L:list):
    if len(L) == 0:
        return 1
    else:
        s = L[0]
        l_sorted = sorted(L, reverse=False)
        p = l_sorted.index(s)
        return p * math.factorial(len(l_sorted)-1) + get_key(L[1:])

N = int(ip().rstrip())
P = list(map(int, ip().rstrip().split()))
Q = list(map(int, ip().rstrip().split()))
key_P, key_Q = get_key(P), get_key(Q)
print(abs(key_P-key_Q))

Measured memory_bytes: 3064
#include <stdio.h>
//jarak ke titik adalah kelipatan k
//a antara b
//si antara itu hrs terpenuhi
//kl terpenuhi ok, klk ga ng
//k = kelipatan
//a titik awal, b ujung
//7 
//500 600
//600/7 = 85
//85*7 = 595
//baru dicek
//4
// 5 7
//7/4 = 1
//1 *4 = 5
//kalo lebih kecil dari bates 1 jadinya false
int main(){
	int kelipatan, awal, akhir, patokan;
	
	scanf("%d", &kelipatan);
	scanf("%d %d", &awal, &akhir);
	
	patokan = akhir/kelipatan;
	
	if(patokan*kelipatan >= awal){
		printf("OK\n");
	}	else {
		printf("NG\n");
	}
	
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, k;
  cin >> n >> k;

  vll a(n);
  rep(i, n) {
    cin >> a[i];
  }

  vll dp(k + 1);
  FOR(i, a[0], k + 1) {
    for (const auto it : a) {
      if (i - it >= 0) {
        if (dp[i - it] == 0) {
          dp[i] = 1;
          break;
        }
      }
    }
  }

  cout << (dp[k] == 1 ? "First" : "Second") << endl;

  return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python
# -*- coding: utf-8 -*-

if __name__ == "__main__":
    N,K = map(int,input().split(" "))
    place = list(map(int,input().split(" ")))
    time = []
    for i in range(N-K+1):
        left = place[i]
        right = place[i+K-1]
        n1 = abs(left) + abs(right - left)
        n2 = abs(right) + abs(left - right)
        time.append(min(n1,n2))
    print(min(time))


Measured memory_bytes: 14228
#include <bits/stdc++.h>
using namespace std;
int main(){
  int vals[5];
  for(int i =0 ; i < 5;i++){
    cin >> vals[i];
  }
  
  int sum = 0;
  int min = 200;
  int chagrge;
  for(int i =0 ; i < 5;i++){
    chagrge = vals[i] % 10;
    if(chagrge < min && chagrge != 0){
      min = chagrge;
    }
    int ans = vals[i] / 10;
    if(chagrge != 0){
          sum += (ans + 1) * 10;
    }
    else{
      sum += (ans) * 10;

    }
  }
  
 if(min!=200){
  
   sum -= 10;
  sum += min;
  }
  
 
  
  cout << sum <<  endl;
  
  return 0; 
}

Measured memory_bytes: 764
dp1=[None]*100001
dp2=[None]*100001
dp1[0]=0
dp2[0]=0
n,W=map(int,input().split())
for i in range(n):
    w,v=map(int,input().split())
    for i in range(v,100001):
        if(dp2[i-v]!=None):
            if(dp2[i]==None):
                dp1[i]=dp2[i-v]+w
            else:
                dp1[i]=min(dp2[i],dp2[i-v]+w)
    dp2=list(dp1)
for i in range(100000,-1,-1):
    if(dp2[i]!=None and dp2[i]<=W):
        print(i)
        break
# 3 8
# 3 3
# 4 5
# 5 6

Measured memory_bytes: 73468
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,i,x;
	scanf("%d",&n);
	x=1;
	i=1;
	while(x<=n)	{
		x=x*2+1;
		i++;
	}
	i--;
	printf("%d\n",i);
	return 0;
}


Measured memory_bytes: 2736
#include<bits/stdc++.h>
#define mod 1000000007
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int a[110],f[51][101][101];
void add(int&a,int b){a=a+b>=mod?a+b-mod:a+b;}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi();
	for(int i=1;i<2*n;++i)a[i]=gi();
	std::sort(a+1,a+2*n);
	f[n][1][0]=1;
	for(int i=n-1;i;--i){
		int dl=a[i]!=a[i+1],dr=a[n*2-i]!=a[n*2-i-1];
		for(int j=0;j<2*n;++j)
			for(int k=0;j+k<2*n;++k){
				for(int l=1;l<=j+dl;++l)add(f[i][j+dl-l+1][k+dr+(l>1)],f[i+1][j][k]);
				for(int l=1;l<=k+dr;++l)add(f[i][j+dl+1][k+dr-l],f[i+1][j][k]);
			}
	}
	int ans=0;
	for(int i=0;i<2*n;++i)for(int j=0;j<2*n;++j)ans=(ans+f[1][i][j])%mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
	char op;
	int a, b;
	do{
		cin >> a >> op >> b;
		if(op == '+'){
			cout << a + b << endl;
		}else if(op == '-'){
			cout << a - b << endl;
			}else if(op == '*'){
				cout << a * b << endl;
				}else if(op == '/'){
					cout << a / b << endl;
					}
	}while(op != '?');
	return 0;
}


Measured memory_bytes: 3084
def nikkei2019_b
    n = gets.chomp.to_i
    a = gets.chomp
    b = gets.chomp
    c = gets.chomp

    if a == b && b == c
        puts 0
        exit
    end

    cnt = 0
    for i in 0..n-1
        cnt += [a[i], b[i], c[i]].uniq.length - 1
    end

    puts cnt
end

nikkei2019_b

Measured memory_bytes: 1788
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}
func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	q := nextInt(sc)
	ans := make([]int, 0)
	m := make(map[string]int)
	for i := 0; i < q; i++ {
		t := nextInt(sc)
		k := nextString(sc)
		if t == 0 {
			x := nextInt(sc)
			m[k] = x
		} else {
			ans = append(ans, m[k])
		}
	}
	wtr := bufio.NewWriter(os.Stdout)
	for i := 0; i < len(ans); i++ {
		fmt.Fprintln(wtr, ans[i])
	}
	wtr.Flush()
}



Measured memory_bytes: 18740
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

mint factorial(ll n) {
  mint answer = 1;
  while (n > 1) {
    answer *= n;
    n--;
  }
  return answer;
}

mint combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

mint permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

// setprecision(8) 桁数指定
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

vector<ll> Eratosthenes(const ll N) {
  bool is_prime[1000000 + 1];
  vector<ll> P;
  for (ll i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  for (ll i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (ll j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int h, a;
  cin >> h >> a;
  int ans = 0;
  while (h > 0) {
    ans++;
    h -= a;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in [0]*N ]

AB += [[10*M,0]]

AB.sort(reverse=True)

from heapq import *

q = []
ans = 0

for i in range(1,M+1):
    a,b = AB[-1]
    while a<=i:
        a,b = AB.pop()
        heappush(q,-b)
        a,b = AB[-1]
    if len(q)>0:
        ans += -heappop(q)
print(ans)

Measured memory_bytes: 28100
#include<bits/stdc++.h>
#define ll long long int
#define sz  200010
using namespace std;


ll cnt[sz];
ll num[sz];




int main()
{

  ll n,k,q,i,j,a,b,l,r,x;

  cin>>n>>k>>q;

  for(i=1;i<=n;i++)num[i]=k;

  while(q--)
  {
      cin>>x;
      a=1;
      b=x-1;
      cnt[a]=cnt[a]-1;
      cnt[b+1]=cnt[b+1]+1;

       a=x+1;
       b=n;
       cnt[a]=cnt[a]-1;
       cnt[b+1]=cnt[b+1]+1;



  }


  for(i=1;i<=n;i++)
  {
      cnt[i]=cnt[i]+cnt[i-1];
    //  cout<<cnt[i]<<endl;
  }

  for(i=1;i<=n;i++)
  {
      num[i]=num[i]+cnt[i];

      if(num[i]>0)cout<<"Yes"<<endl;
      else
        cout<<"No"<<endl;
  }

  return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}

int main() {
    int n,k,x;
    cin >> n >> k;
    vector<int> X(n);
    int res = 0;
    rep(i,n) {
        cin >> x;
        res += 2*min(abs(0-x),abs(k-x));
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }



int main() {
  int n;
  scanf("%d", &n);
  set<int> s;
  FOR(i,0,n-1){
    int a;
    cin >> a;
    s.insert(a);
  }

  if(s.size()%2!=0) cout << s.size() << endl;
  else cout << s.size()-1 << endl;
}



Measured memory_bytes: 4992
#include<iostream>
#include<sstream>
#include<cmath>

using namespace std;

unsigned long int a;
unsigned long int b;
unsigned long int c;
long long int x;
long long int y;

int main() {

	cin >> a >> b >> c;

	x = c - a - b;

	y = x * x - 4 * a * b;

	if ((x > 0) && (y > 0)) {

		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;

}

Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int X, Y, A, B, C;
	std::vector<long> P, Q, R;
	std::cin >> X >> Y >> A >> B >> C;
	P.resize(A);
	Q.resize(B);
	R.resize(C);
	for (auto& p : P)
		std::cin >> p;
	for (auto& q : Q)
		std::cin >> q;
	for (auto& r : R)
		std::cin >> r;
	

	std::sort(P.begin(), P.end());
	std::sort(Q.begin(), Q.end());
	std::sort(R.begin(), R.end());

	while (!R.empty() && (P[P.size() - X] < R.back() || Q[Q.size() - Y] < R.back())) {
		if (P[P.size() - X] < Q[Q.size() - Y])
			P.push_back(R.back());
		else
			Q.push_back(R.back());
		R.pop_back();
	}

	long result = 0;
	for (int i = P.size() - X; i < P.size(); ++i)
		result += P[i];
	for (int i = Q.size() - Y; i < Q.size(); ++i)
		result += Q[i];
	std::cout << result << "\n";
}


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

int main()
{	
	string s;
	cin >> s;
	int k = 1;
	string temp = s.substr(0,1);
	string t = "";
	for(int i = 1;i < s.size();i++){
		t += s[i];
		if(t == temp) continue;
		temp = t;
		t = "";
		k++;
	}
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 640
/* template.cpp [[[ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)s)
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)s)
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* ]]] */

int h, w;
vector<string> a, b, c;
vector<int> x, y;
vector<string> aa, bb, cc;

int main(){
  cin >> h >> w;
  a.resize(h);
  rep(i, h) cin >> a[i];
  b = c = a;
  rep(i, h - 1) rep(j, w){
    if (a[i][j] != a[i + 1][j]){
      x.push_back(i);
      x.push_back(i + 1);
    }
  }
  rep(i, h) rep(j, w - 1){
    if (a[i][j] != a[i][j + 1]){
      y.push_back(j);
      y.push_back(j + 1);
    }
  }
  x.push_back(h);
  y.push_back(w);
  sort(all(x));
  x.erase(unique(all(x)), end(x));
  sort(all(y));
  y.erase(unique(all(y)), end(y));
  aa = vector<string>(x.size() - 1, string(y.size() - 1, '.'));
  rep(i, x.size() - 1) rep(j, y.size() - 1) aa[i][j] = a[x[i]][y[j]];
  bb = cc = aa;
  rep(i, x.size() - 1) bb[i][0] = '#';
  rep(i, x.size() - 1) cc[i][y.size() - 2] = '#';
  /*
  cout << endl;
  each(i, aa) cout << i << endl;
  cout << endl;
  each(i, bb) cout << i << endl;
  cout << endl;
  each(i, cc) cout << i << endl;
  cout << endl;
  */
  rep(i, x.size() - 1) rep(j, 1, y.size() - 2){
    if (i & 1) bb[i][j] = '#';
  }
  rep(i, x.size() - 1) rep(j, 1, y.size() - 2){
    if (~i & 1) cc[i][j] = '#';
  }
  rep(i, x.size() - 1) rep(j, y.size() - 1){
    rep(ii, x[i], x[i + 1]) rep(jj, y[j], y[j + 1]){
      b[ii][jj] = bb[i][j];
      c[ii][jj] = cc[i][j];
    }
  }
  rep(i, h) cout << b[i] << endl;
  cout << endl;
  rep(i, h) cout << c[i] << endl;
}


Measured memory_bytes: 6284
#include<stdio.h>
int main()
{
    int count=0;
    long long t,p,N,h,n,w;
    scanf("%lld",&N);
        for(h=1;h<=3500;h++)
        {
            for(n=1;n<=3500;n++)
            {
                t=N*h*n;
                p=4*h*n-N*h-N*n;
                if(p>0)
                    if(t%p==0)
                    {
                        w=t/p;
                        count++;
                        break;
                    }
            }
            if(count!=0) break;
        }
    printf("%lld %lld %lld\n",h,n,w);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>A(N);
  for (int i=0;i<N;i++){
    cin>>A[i];
  }
  vector<int>rev(N);
  for (int i=0;i<N;i++){
    rev[A[i]-1]=i+1;
  }
  for (int i=0;i<N;i++){
    cout<<rev[i]<<endl;
  }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long lnt;
#define REP(i, n) for (lnt i = 0; i < (n); i++)
#define FOR(i, a, b) for (lnt i = (a); i < (b); i++)
#define ALL(a) a.begin(), a.end()
#define MAXEL max_element
#define MINEL min_element
#define POW (lnt) pow
#define BIT(i) (lnt) pow(2, i)
#define INF 2e18 // cf. LLONG_MAX ≒ 9x10^18
#define START int main
#define SET unordered_set
#define MAP unordered_map

//最大公約数:gcd(n, m)
long long gcd(const long long n, const long long m) {
  long long nDivided, nDividing;
  nDivided = max(n, m);
  nDividing = min(n, m);
  while (nDivided % nDividing) {
    nDivided = nDivided % nDividing;
    swap(nDivided, nDividing);
  }
  return nDividing;
}

START() {
  string S, T;
  cin >> S >> T;

  SET<char> stS;
  for (char c : S) {
    stS.emplace(c);
  }

  MAP<char, char> mpStoT;
  for (char c : stS)
    REP(i, S.size()) {
      if (S[i] == c) {
        mpStoT.emplace(c, T[i]);
        break;
      }
    }

  SET<char> stRangeT;
  for (char c : stS) {
    stRangeT.emplace(mpStoT[c]);
  }

  if (stS.size() != stRangeT.size()) {
    cout << "No" << endl;
  }

  else {
    bool fOK = true;
    for (char c : stS) {
      REP(i, S.size()) {
        if (S[i] == c and T[i] != mpStoT[c]) {
          fOK = false;
          break;
        }
      }
      if (not fOK) {
        break;
      }
    }
    cout << (fOK ? "Yes" : "No") << endl;
  }
}


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

#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define endl "\n"
#define sz(x) ((ll)((x).size()))
const ll N=1e5+5,inf=1e18;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	ll x;
	cin >> x;
	ll ans=0;
	ans+=2*(x/500)*500;
	x%=500;	    
	ans+=(x/5)*5;
	cout<<ans<<endl;
	return 0;
}

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

int main(void)
{
  int n,m,p;
  char s[3];

  char *buf_ac = NULL;
  int  *buf_wa = NULL;
  int  sum_ac =0;
  int  sum_wa =0;
  
  
  scanf("%d %d", &n, &m);

  buf_ac = (char *)calloc(n, sizeof(char));
  buf_wa = (int *)calloc(n, sizeof(int));
  
  for (int i=0; i<m; i++){
    scanf("%d %s", &p, s);
    int d = p-1;
    
    if (s[0] == 'A') {
      buf_ac[d] = 1;
    } else {
      if (!buf_ac[d])
        buf_wa[d]++;
    }
  }
  
  
  for (int i=0; i<n; i++) {
	if (buf_ac[i]) {
		sum_ac++;
		sum_wa += buf_wa[i];
	}
  }
  
  printf("%d %d\n", sum_ac, sum_wa);
  
  return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    ios::sync_with_stdio(false);
    ll x,y;
    cin >> x >> y;
    ll ans = 1;
    while(1) {
        x *= 2;
        if(x > y) break;
        else ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var arr=(Arr.shift()).split(" ").map(Number);
   if(arr[0]==0 && arr[1]==0 && arr[2]==0)break;
   arr.sort(function(a,b){return a-b;});
   var R=Math.sqrt(arr[0]*arr[0]+arr[1]*arr[1]);
   var n=Arr.shift()-0;
   for(var i=0;i<n;i++){
      var r=Arr.shift()-0;
      console.log((r*2>R)?"OK":"NA");
   }
}

Measured memory_bytes: 7640
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//  
//

#include <bits/stdc++.h>
#include <random>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;

//#define __DBG__



void solve(void){

  vector<int> A={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
  };
  
  int K;
    
  cin >> K;
  

   
  cout << A[K-1] << endl;
  
  return;
}


int main(int argc, const char * argv[]) {
 
    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}


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

int main(void){
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  int a[n], b[m];
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < m; i++) cin >> b[i];
  int max = a[0];
  int min = b[0];
  for(int i = 1; i < n; i++) if(max < a[i]) max = a[i];
  for(int i = 1; i < m; i++) if(min > b[i]) min = b[i];
  bool flag = false;
  for(int i = x + 1; i <= y; i++){
    if(max < i && i <= min) {
      flag = true;
      break;
    }
  }
  if(flag) cout << "No War" << endl;
  else cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define scan(n) scanf("%d",&n)
#define put(n) printf("%d\n",n)
#define SENTINEL 1000000007
typedef long long lli;

int main()
{
    int i, n;
    char s[10];
    char y[4], m[2], d[2];
    scanf("%s",s);
    for(i=4; i<9; i++) {
        s[i] = s[i+1];
    }
    for(i=6; i<8; i++) {
        s[i] = s[i+1];
    }
    s[8] = '\0';
    //printf("%s",s);

    if(strcmp(s, "20190430") >0) {
        puts("TBD");
    } else {
        puts("Heisei");
    }

    return 0;
}


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

#define ll long long

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
        int n;
	cin>>n;
	int arr[n][3];
	int dp[110000][3];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
			cin>>arr[i][j];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			if(i==0)
			{
				dp[i][j]=arr[i][j];
			}
			else
			{
				for(int k=0;k<3;k++)
				{
					if(k==j)
						continue;
					else
						dp[i][j]=max(dp[i][j],dp[i-1][k]+arr[i][j]);
				}
			}
		}
	}
	int sum=max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
	cout<<sum<<'\n';
}

Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main()
{
  int k,a,b;
  int c=0;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++)
  {
     if(i%k==0)
     {
       c++;
     }
  }
       
       
       
       
       
       
       
   if(c>0)    
  {
    cout<<"OK"<<endl;
  }
  else
  {
    cout<<"NG"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    String[] split = S.split("");
    int N = S.length();
    long add = 0;
    for(int i = 0; i < N; i++){
      int a = Integer.valueOf(split[i]);
      add += a;
    }
    if(add % 9 == 0){
      System.out.println("Yes");
    }
	else{
      System.out.println("No");
    }
  }
}
    

Measured memory_bytes: 65308
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e14 + 10 ;
int n , m ;
vector<vector<int> > v ;
vector<int> a ;
int dp[1005][( (1 << 12) + 10)] ;
int dfs(int x, int cur){
    if ( x == m ){
        for(int i = 0; i < n; i++){
            if ( ((1LL << i) & cur) == false ) return INF ;
        }
        return 0 ;
    }
    if ( dp[x][cur] != -1 ) return dp[x][cur] ;
    int choice1 = dfs(x + 1, cur) ;
    int mask = cur ;
    vector<int> &c = v[x] ;
    for(int &p : c){
        mask = mask | (1LL << p) ;
    }
    int choice2 = a[x] + dfs(x + 1, mask) ;
    return dp[x][cur] = min(choice1, choice2) ;
}
signed main(){
    fastio
    memset(dp, -1, sizeof dp) ;
    cin >> n >> m ;
    v = vector<vector<int> >(m) ;
    a = vector<int>(m) ;
    for(int i = 0; i < m; i++){
        cin >> a[i] ;
        int b ; 
        cin >> b ;
        for(int j = 0; j < b; j++){
            int x ;
            cin >> x ; 
            x--;
            v[i].push_back(x) ;
        }
    }
    int ans = dfs(0, 0) ;
    if ( ans == INF ) {
        cout << -1 << endl;
    }
    else cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 36044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  int res = 0;
  res = pow(10,9);
  for(int i = 0;i < s.size() - 2;i++){
    string t;
    t = s.substr(i,3);
    //cout << t << endl;
    int now = 0;
    now = stoi(t);
    res = min(res,abs(753 - now));
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
long long ans;
int a[100005];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		ans+=(long long)a[i]/2;
		a[i]%=2;
		if(a[i] && a[i+1])
		{
			ans++;
			a[i]-=1;
			a[i+1]-=1;
		}
	}
	cout<<ans<<"\n";
 	return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_Training
{

    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            Console.WriteLine(a >= 3200 ? s : "red");
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

struct edge {
  i64 from;
  i64 to;
  i64 cap;
  i64 cost;
  i64 rev;
};

i64 INF = 1e18;

i64 capacity_scaling_bflow(std::vector<std::vector<edge>>& g, std::vector<i64> b) {
  i64 ans = 0;


  i64 U = *std::max_element(begin(b), end(b));
  i64 delta = (1 << ((int)(std::log2(U)) + 1));
  int n = g.size();

  std::vector<i64> e = b;

  std::vector<i64> p(n, 0);

  int zero = 0;

  for(auto x : e) {
    if(x == 0) zero++;
  }

  for(;delta > 0; delta >>= 1) {
    if(zero == n) break;
    for(int s = 0;s < n;s++) {
      if(!(e[s] >= delta)) continue;
      std::vector<std::size_t> pv(n, -1);
      std::vector<std::size_t> pe(n, -1);
      std::vector<i64> dist(n, INF);
      using P = std::pair<i64,i64>;
      std::priority_queue<P,std::vector<P>,std::greater<P>> que;
      dist[s] = 0;
      que.push({dist[s], s});
      while(!que.empty()) {
        int v = que.top().second;
        i64 d = que.top().first;
        que.pop();
        if(dist[v] < d) continue;
        for(std::size_t i = 0;i < g[v].size();i++) {
          const auto& e = g[v][i];
          std::size_t u = e.to;
          if(e.cap == 0) continue;
          if(dist[u] > dist[v] + e.cost + p[v] - p[u]) {
            dist[u] = dist[v] + e.cost + p[v] - p[u];
            pv[u] = v;
            pe[u] = i;
            que.push({dist[u], u});
          }
        }
      }

      for(int i = 0;i < n;i++) {
        if(pv[i] != -1) p[i] += dist[i];
      }

      int t = 0;
      for(;t < n;t++) {
        if(!(e[s] >= delta)) break;
        if(e[t] <= -delta && pv[t] != -1) {
          std::size_t u = t;
          for(;pv[u] != -1;u = pv[u]) {
            ans += delta * g[pv[u]][pe[u]].cost;
            g[pv[u]][pe[u]].cap -= delta;
            g[u][g[pv[u]][pe[u]].rev].cap += delta;
          }
          e[u] -= delta;
          e[t] += delta;
          if(e[u] == 0) zero++;
          if(e[t] == 0) zero++;
        }
      }
    }
  }
  
  if(zero == n) return ans;
  else return -1e18;
}

int main() {
  i64 N,M,F;
  cin >> N >> M >> F;
  vector<vector<edge>> g(N + M);
  vector<i64> e(N + M, 0);
  int s = 0;
  int t = N - 1;
  e[s + M] = F;
  e[t + M] = -F;
  for(int i = 0;i < M;i++) {
    i64 a,b,c,d;
    cin >> a >> b >> c >> d;

    e[i] = c;
    e[a + M] -= c;

    g[i].push_back({i, a + M, (i64)1e18, 0, (i64)g[a + M].size()});
    g[a + M].push_back({a + M, i, 0, 0, (i64)g[i].size() - 1});

    g[i].push_back({i, b + M, (i64)1e18, d, (i64)g[b + M].size()});
    g[b + M].push_back({b + M, i, 0, -d, (i64)g[i].size() - 1});
  }


  i64 ans = capacity_scaling_bflow(g, e);
  if(ans == -1e18) {
    cout << -1 << endl;
  }
  else {
    cout << ans << endl;
  }
}



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

int main() {
	int N, M, A;
	cin >> N >> M;

	int count = 0;

	for (int i = 0; i < M; i++) {
		cin >> A;
		count += A;
	}

	if (N - count >= 0) {
		cout << N - count << endl;
	} else {
		cout << -1 << endl;
	}

	return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <stack> 
#include <map>
#include <queue>
#include <unordered_map>
#include <cassert>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
#define pb 					push_back
#define FAST_IO          ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
template<typename T,typename S>
ostream& operator <<(ostream& os, pair<T, S> input) {
	os<<"("<<input.first<<", "<<input.second<<")";
	return os;
}
template<typename T>
ostream& operator <<(ostream& os, vector<T> input) {
	for(auto t: input)
		os << t <<" ";
	return os;
}
template<typename T>
ostream& operator <<(ostream& os, set<T> input) {
	for(auto t: input)
		os << t <<" ";
	return os;
}

string s[100002];

vector<char> ans;

int arr[3];
int n;
void solveDeterministic() {
	for(int i=1; i<=n; i++) {
		string ss = s[i];
		int moves =0;
		for(char c: ss){ 
			int in = c-'A';
			if(arr[in]>0) {
				moves++;
			}
		}	
		if(moves ==1) {
			char x = ss[0];
			char y = ss[1];
			if(arr[x-'A'] <=0) {
				swap(x, y);
				assert(arr[x-'A']>0);
			}
			ans.push_back(y);
			arr[y-'A']++;
			arr[x-'A']--;
			 // cout << arr[0] << " " << arr[1] << " " <<arr[2] << "\n";
			assert(arr[0] >=0 && arr[1] >= 0 && arr[2] >= 0);
			
		} else if(moves ==0) {
			cout << "No\n";
			exit(0);
		} else {
			return;
		}

	}
}

int lastGroup[100002];

char different(string a, string b) {
	assert(a!=b);
	if(a[0]==b[0])
		return a[1];
	if(a[0] == b[1])
		return a[1];
	return a[0];
}
int main() {	
	cin >> n;
	cin >> arr[0] >> arr[1] >> arr[2];
	for(int i=1; i<=n; i++) {
		cin >> s[i];
	}
	solveDeterministic();
	int i = ans.size();
	if(i==n) {
		cout << "Yes\n";
		for(char c: ans)
			cout << c << "\n";
	} else {
		lastGroup[n] = n;
		for(int i=n-1; i>=1; i--) {
			if(s[i]==s[i  + 1]) {
				lastGroup[i] = lastGroup[i +1];
			} else {
				lastGroup[i] = i;
			}
		}
		int i = ans.size();
		i++;
		while(i<=n) {
			int d = lastGroup[i];
			char diffChar = s[i][0];
			if(d+ 1<=n)
				diffChar = different(s[i], s[d +1]);
			char sameChar = (s[i][0]==diffChar) ? s[i][1] : s[i][0];
			if((d-i)%2!=0 ) {
				swap(sameChar, diffChar);	
			}

			if(arr[diffChar - 'A'] ==0)
				swap(sameChar, diffChar);

			arr[sameChar-'A']++;
			arr[diffChar-'A']--;
			// cout << arr[0] << " " <<arr[1] << " " << arr[2] << "\n";
			// assert(arr[0] >=0 && arr[1] >= 0 && arr[2] >= 0);
			ans.push_back(sameChar);
			i++;
		}
		cout << "Yes\n";
		for(char c: ans)
			cout << c << "\n";
	}	
	return 0;
}














Measured memory_bytes: 7228
from operator import itemgetter
n, *ABCD = map(int, open(0).read().split())
AB = sorted([(a, b) for a, b in zip(ABCD[:2*n:2], ABCD[1:2*n:2])])
CD = sorted([(c, d) for c, d in zip(ABCD[2*n::2], ABCD[2*n+1::2])])

for c, d in CD:
    t_AB = [(a, b) for a, b in AB if a < c and b < d]
    if t_AB:
        t_AB.sort(key=itemgetter(1))
        AB.remove(t_AB[-1])
print(n-len(AB))

Measured memory_bytes: 3064
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const ll INF = 1e16 + 7;
const int MAXN = 19;
const double eps = 1e-9;
ll a[MAXN];
map<pii,ll> dp[MAXN][MAXN];

ll dfs(int l, int r, int x, int y) {
	if (abs(r-l) == 1) return 0;
	if (dp[l][r].count(mp(x,y)))
		return dp[l][r][{x,y}];
	ll &ret = dp[l][r][{x,y}];
	ret = INF;
	for (int i = l+1; i < r; i++)
		ret = min(ret, dfs(l,i,x,x+y) + dfs(i,r,x+y,y) + (ll)(x+y) * a[i]);
	return ret;
}

int main() {
	int n; ni(n); nal(a, n);
	prl(a[0] + a[n-1] + dfs(0, n-1, 1, 1));
    return 0;
}


Measured memory_bytes: 16512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;string s;
    cin>>n>>s;
    string s1=s,s2=s;
    int ans=INF;
    int W=0,B=0;
    for(int i=0;i<n;i++){
        if(s[i]=='.'){
            W++;
        }
        else{
            B++;
        }
    }
    ans = min(W,B);
    int w=0,b=0;
    REP(i,n){
        if(s[i]=='#') b++;
        else w++;
        ans=min(ans,b+W-w);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 788
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  string A,B;
  A="";B="";
  for(int i=1;i<=b;i++){
    ostringstream oss;
    oss << a;
    A+=oss.str();
  }
  for(int i=1;i<=a;i++){
    ostringstream oss;
    oss << b;
    B+=oss.str();
  }
  if (A<=B)cout << A;
  else cout << B;
}


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

int concatenation(int a, int b) {
   int counter = 1;
   while (counter <= b)
      counter *= 10;
   return a*counter + b;
}

int main() {

  int A,B,C,D;
  cin>>A>>B;
  C=concatenation(A,B);
  D=sqrt(C);
  if(C==(D*D)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in);) {
			
			StringBuilder sb = new StringBuilder();
			
			while(true) {
				int n = sc.nextInt();
				int x = sc.nextInt();
				
				if(n == 0 && x == 0) break;
				
				boolean used[] = new boolean[n];
				int count = 0;
				
				for(int i = 1; i <= n; i++) {
					used[i - 1] = true;
					for(int j = i + 1; j <= n; j++) {
						if(used[j - 1]) {
							continue;
						}
						used[j - 1] = true;
						for(int k = j + 1; k <= n; k++) {
							if(i + j + k == x) {
								count++;
							}
						}
						used[j - 1] = false;
					}
					used[i - 1] = false;
				}
				
				sb.append(count);
				sb.append("\n");
			}
			
			System.out.print(sb.toString());
		}
	}
}


Measured memory_bytes: 27200
#include <iostream>

using namespace std;

int main(){
	int x, y;
	cin >> x >> y;

	if (x == 2 || y == 2) cout << "No";
	else if (x == 4 || x == 6 || x == 9 || x == 11) {
		if (y == 4 || y == 6 || y == 9 || y == 11) cout << "Yes";
		else cout << "No";
	}
	else {
		if (y == 4 || y == 6 || y == 9 || y == 11) cout << "No";
		else cout << "Yes";
	}

}

Measured memory_bytes: 256