akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

int n;
int a[10][10];

int dfs(const vector<pair<int,int> > &v,int b,int m){
  if(b+1==1<<n)return v.back().second;
  for(int i=0;i<n;i++){
    if(!(b>>i&1)){
      int p=0;
      for(auto e:v){
	p=max(p,e.second+a[e.first][i]);
      }
      if(m<=p)continue;
      auto nv=v;
      nv.emplace_back(i,p);
      m=min(m,dfs(nv,b|1<<i,m));
    }
  }
  return m;
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cin>>a[i][j];
      }
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<i;j++){
	a[i][j]=a[j][i]=max(a[i][j],a[j][i]);
      }
    }
    cout<<dfs(vector<pair<int,int> >(),0,1<<29)<<endl;
  }
}

Measured memory_bytes: 1200
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <limits>
#include <set>
#define MAX 100000
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;
typedef long long int lli;

int main(void)
{
	int N; cin >> N;
	vector<string> s(N); rep(i, 0, N)cin >> s[i];
	int M; cin >> M;
	vector<string> t(M); rep(i, 0, M)cin >> t[i];
	set<string> say; rep(i, 0, N)say.insert(s[i]);
	set<string>::iterator li;
	int ans = 0;
	for (li = say.begin(); li != say.end(); li++) {
		int tmp_s = 0, tmp_t = 0;
		rep(i, 0, N)if (s[i] == *li)tmp_s++;
		rep(i, 0, M)if (t[i] == *li)tmp_t++;
		int tmp = max(tmp_s - tmp_t, 0);
		ans = max(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static public void main(String[] args){
       Scanner sc = new Scanner(System.in);
        while(true){
            String s = sc.next();
            if(s.equals("0")) break;
            int sum = 0;
            for(int i = 0; i<s.length(); i++){
                sum += Integer.parseInt(s.substring(i, i+1));
            }
            System.out.println(sum);
        }
        sc.close();
    }
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  for (int i = 0; i < (W + 2); i++) {
  	cout << "#";
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    cin >> a.at(i);
  	cout << "#";
    cout << a.at(i);
    cout << "#" << endl;;
  }
  for (int i = 0; i < (W + 2); i++) {
  	cout << "#";
  }
  cout << endl;
}


Measured memory_bytes: 256
S = list(input())

def dfs(i, S):
    if i == len(S):
        #print(S)
        sum = 0
        num = 0
        for char in S:
            if num == 0 and char != '+':
                num += int(char)
            elif num != 0 and char != '+':
                num = num * 10 + int(char)
            else:
                #print(num, end=' ')
                sum += num
                num = 0
        #print(num)
        sum += num
        return sum
    else:
        # +を入れるパターン
        S.insert(i, '+')
        num1 = dfs(i + 2, S)
        S.pop(i)

        # +を入れないパターン
        num2 = dfs(i + 1, S)

    return num1 + num2

print(dfs(1, S))

Measured memory_bytes: 39152
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<stack>

class Stack{
private:
    std::vector<std::string> dataSet;
    std::stack<double> st;
public:
    Stack(std::vector<std::string> vec);
    double calc();
};

Stack::Stack(std::vector<std::string> vec){
    this->dataSet = vec;
}

double Stack::calc(){
    for(std::string str : dataSet){
        
        double a, b;
        
        if(str == "+"){
            b = st.top();
            st.pop();
            a = st.top();
            st.pop();
            st.push(a + b);
        }else if(str == "-"){
            b = st.top();
            st.pop();
            a = st.top();
            st.pop();
            st.push(a - b);
        }else if(str == "*"){
            b = st.top();
            st.pop();
            a = st.top();
            st.pop();
            st.push(a * b);
        }else{
            st.push(std::stoi(str));
        }
    }

    return st.top(); 
}

/*
* split method
*/
std::vector<std::string> split(const std::string&input,char delimiter){
    std::istringstream iss(input);

    std::string field;
    std::vector<std::string> result;
    while(std::getline(iss, field, delimiter)){
        result.push_back(field);
    }

    return result;
}

int main(){

    std::string input;
    std::getline(std::cin,input);
 
    /*
    std::cout << s << std::endl;

    for(std::string str : split(s,' ')){
        std::cout << str << std::endl;
    }
    */

    Stack s = Stack(split(input,' '));
    std::cout << s.calc() << std::endl;
    

    return 0;
}

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

int mDist(int x1, int y1, int x2, int y2) {
	return abs(x1-x2) + abs(y1-y2);
}

int main() {
	int n; cin>>n;
	vector<int> x, y, h;
	for (int i=0; i<n; i++) {
		int a,b,c;
		cin>>a>>b>>c;
		if (c != 0) {
			x.push_back(a);
			y.push_back(b);
			h.push_back(c);
		}
	}

	vector<int> a,b,c;
	bool consistent=false;
	for (int i=0; i<=100; i++) {
		for (int j=0; j<=100; j++) {
			int height = mDist(i,j, x[0],y[0]) + h[0];

			consistent=true;
			for (int k=1; k<x.size(); k++)
				if (height != h[k]+mDist(i,j,x[k],y[k]))
					consistent=false;

			if (consistent) {
				a.push_back(i);
				b.push_back(j);
				c.push_back(height);
			}
		}
	}

	int ans=0;
	for (int i=0; i<a.size(); i++)
		if (c[i] < c[ans]) ans=i;
	cout << a[ans] << ' ' << b[ans] << ' ' << c[ans] << endl;

	return 0;
}

Measured memory_bytes: 512
from collections import deque

s=input()
q=int(input())
d=deque(s)

cnt=0
for _ in range(q):
    query=list(input().split())
    if query[0]=='1':
        cnt=(cnt+1)%2
    else:
        if query[1]=='1':
            if cnt==1:
                d.append(query[2])
            else:
                d.appendleft(query[2])
        else:
            if cnt==1:
                d.appendleft(query[2])
            else:
                d.append(query[2])
                
ans=list(d)
                
if cnt==1:
    print(*ans[::-1],sep='')
else:
    print(*ans,sep='')

Measured memory_bytes: 14704
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> s(n);
    REP(i,n) cin >> s[i];
    VI a(n), b(m);
    REP(i,n){
        bool ok = true;
        REP(j,m) if (s[i][j] == '#') ok = false;
        a[i] = ok;
    }
    REP(j,m){
        bool ok = true;
        REP(i,n) if (s[i][j] == '#') ok = false;
        b[j] = ok;
    }

    REP(i,n){
        if (a[i]) continue;
        REP(j,m) if (!b[j]) cout << s[i][j];
        cout << endl;
    }

    return 0;
}

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

int x,y;

int main()
{
	scanf("%d%d",&x,&y);
	
	if (x==0 && y<0) printf("%d\n",-y+1);
	else if (x==0 && y>0) printf("%d\n",y);
	else if (y==0 && x>0) printf("%d\n",x+1);
	else if (y==0 && x<0) printf("%d\n",-x);
	else if (x<0 && y<0)
	{
		if (x<y) printf("%d\n",y-x);
		else printf("%d\n",x-y+2);
	}
	else if (x<0 && y>0)
	{
		printf("%d\n",abs(x+y)+1);
	}
	else if (x>0 && y<0)
	{
		printf("%d\n",abs(x+y)+1);
	}
	else
	{
		if (x<y) printf("%d\n",y-x);
		else printf("%d\n",x-y+2);
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

void swap(int *, int *);

int main(void)
{
    int a, b, c, n;

    scanf("%d", &n);
    while (n--) {
        scanf("%d %d %d", &a, &b, &c);
        if (a < b)
            swap(&a, &b);
        if (a < c)
            swap(&a, &c);
        if (a * a == b * b + c * c)
            printf("YES\n");
        else
            printf("NO\n");
    }

    return 0;
}

void swap(int *x, int *y)
{
    int tmp;
    tmp = *x;
    *x = *y;
    *y = tmp;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int N=1000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}

void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }



const int N1=1e6+1;
vector<int> isprime(N1,1),prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.pb(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.pb(i);
}



struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};
struct time{
  int c,s,f;
};
void solve(){
  int n;
  cin>>n;
  int a[n];
  map<int,int> m1;
  rep(i,0,n) {cin>>a[i];m1[a[i]]++;}
  int cnt=0;
  for(auto i:m1){
    if(i.s>=i.f) cnt+=i.s-i.f;
    else cnt+=i.s;
  }
  cout<<cnt<<endl;
}

int main(){
    optimizeIO();
    int r=1;
    {solve();}
}


Measured memory_bytes: 11884
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>

using namespace std;
using pii=pair<int, int>;
using mii=map<int, int>;

double l2(const pii &a, const pii &b) noexcept {
    return sqrt(pow(a.first - b.first, 2) + pow(a.second - b.second, 2));
}

int facctorialMethod(int k) {
    int sum = 1;
    for (int i = 1; i <= k; ++i) {
        sum *= i;
    }
    return sum;
}

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

    vector<pii> town(N);
    for (auto i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        town.at(i) = pii(x, y);
    }

    double sum = 0;
    for (auto i = 0; i < N; i++) {
        for (auto j = 0; j < N; j++) {
            if (i != j) {
                sum += l2(town.at(i), town.at(j)) / N;
            }
        }
    }
    cout << setprecision(10) << sum << endl;
    return 0;
}


Measured memory_bytes: 888
#include <cstdio>
#include <cstdint>
#include <cctype>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>

class union_find {
  mutable std::vector<intmax_t> c;

public:
  union_find(size_t n): c(n, -1) {}

  size_t find(size_t v) const {
    if (c[v] < 0)
      return v;

    return (c[v] = find(c[v]));
  }

  bool unite(size_t u, size_t v) {
    u = find(u);
    v = find(v);
    if (u == v)
      return false;

    if (-c[u] > -c[v])
      std::swap(u, v);

    c[v] += c[u];
    c[u] = v;
    return true;
  }

  bool connected(size_t u, size_t v) const {
    return (find(u) == find(v));
  }

  size_t size() const { return c.size(); }
  size_t size(size_t v) const {
    return -c[find(v)];
  }
};

int main() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);

  union_find uf(N);
  size_t res = N;
  for (size_t i = 0; i < M; ++i) {
    size_t X, Y;
    scanf("%zu %zu %*d", &X, &Y);
    --X;
    --Y;
    if (uf.unite(X, Y)) --res;
  }

  printf("%zu\n", res);
}


Measured memory_bytes: 1152
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

N,d=gets.chomp.split(' ').map{|n| n.to_i}
min = 10000000000
flg = false
sum = 0
1.upto(N){|d|
	a,b=gets.chomp.split(' ').map{|n| n.to_i}
	if(a > b && b < min)
		min = b
		flg = true
	end
	sum += a
}
if(flg)
	puts sum-min
else
	puts 0
end


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

typedef long long ll;
typedef pair<int,int> ii;

int eval(int x) {
	if(x==1) return 300000;
	if(x==2) return 200000;
	if(x==3) return 100000;
	return 0;
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int x,y; cin>>x>>y;
	cout<<eval(x)+eval(y)+int(x==1&&y==1)*400000<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A-B>C) cout<<0<<endl;
  else cout<<C-A+B<<endl;
}

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

int main(){
    ll A,B,C,K;
    cin>>A>>B>>C>>K;
    if(K<=A){
        cout<<K;
    }
    else if(K<=A+B){
        cout<<A;
    }
    else if(K<=A+B+C){
        cout<<A-(K-(A+B));
    }
}

Measured memory_bytes: 3628
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

MOD = 1000000007  # type: int


def prime_table(n):
    t = [True] * (n + 1)
    t[0] = False
    t[1] = False

    for p in range(2, n + 1, 2):
        if n < p ** 2:
            break
        if t[p]:
            for i in range(p * p, n + 1, 2 * p):
                t[i] = False
    return [2] + [p for p in range(3, n + 1, 2) if t[p]]


def pow_mod(a, k, M):
    if k == 0:
        return 1
    t = pow_mod(a, k // 2, M)
    res = (t * t) % M
    if k % 2 == 1:
        res = (res * a) % M

    return res


def inv_mod(a, M):
    return pow_mod(a, M - 2, M)


def fact_mod(a, M):
    ret = 1
    for i in range(2, a + 1):
        ret = (ret * i) % M
    return ret

def perm_mod(n, m, M):
    ret = 1
    for i in range(n, n - m, -1):
        ret = (ret * i) % M
    return ret


def comb_mod(n, m, M):
    return (perm_mod(n, m, M) * inv_mod(fact_mod(m, M), M)) % M


def solve(N: int, M: int):
    fs = defaultdict(int)
    for p in prime_table(int(M ** 0.5) + 1):
        while (M % p) == 0:
            fs[p] += 1
            M //= p
    if M != 1:
        fs[M] = 1

    ret = 1
    for c in fs.values():
        ret = (ret * comb_mod(c + N - 1, c, MOD)) % MOD

    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    result = solve(N, M)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 6052
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, Y;
	cin >> N >> Y;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N - i; j++) {
			if ((Y - 10000 * i - 5000 * j) / 1000 == N - i - j && N - i - j >= 0) {
				cout << i << " " << j << " " << N - i - j << endl;
				return 0;

			}

		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;

// ?????¬???????????¬??????
#define REP(i,n) for(int i=0; i<(int)n; ++i)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), c.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<long, long> pil;

// ??°?????????????????¬??????
typedef int Weight;

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

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;


int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  printf("%d %d\n", a*b, a*2+b*2);
  return 0;
}

Measured memory_bytes: 3160
// :)
// "Khodaya, be man "Tagwaye setiz" biamooz ta
//  dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>

using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int64> pii64;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int maxn = 1e5+10;
const int64 MO = 1e9+7;
const int64 IN = 1e9;

int64 K, A, B;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	// 
	cin >> K >> A >> B;
	if (B - A <= 1 || K <= A) {
		cout << K + 1 << "\n";
		return 0;
	}
	K -= A + 1;
	cout << B + (K / 2) * (B - A) + K % 2 << "\n";
	//
	//
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	ll a;
	string b;
	cin >> a >> b;
	
	ll ans = 0LL;
	int x = 1;
	for(int i = 0; i < b.size(); ++i) {
		if( b[i] != '.' ) {
			ans += (ll)(b[i] - '0') * 100LL / x;
			x *= 10;
		}
	}

	ans *= a;
	ans /= 100LL;
	cout << ans << endl;
	
	return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int num = s.length();
    rep(i, num) s[i] = 'x';
    cout << s << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def isprime(n):
  if n <= 1:
    return False
  else:
    for i in range(2,int((n)**0.5+1)):
      if n%i == 0:
        return False
    return True

def solve():  
  n = int(input())
  query = []
  for i in range(2,55555):
    if isprime(i):
      if i%5 == 1:
        query.append(i)
  print(*query[0:n])
    
solve()

Measured memory_bytes: 3444
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    println!("{}", (0..read::<i32>()).map(|_| "ACL").collect::<String>());
}

Measured memory_bytes: 2128
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        System.out.println(solve(in));
        
      }
      
      public static String solve(Scanner in) {

        int A = in.nextInt();
        int B = in.nextInt();
        int count = sock(A, B, 1);

        return String.valueOf(count);
      }

      public static int sock(int a, int b, int num) {
          if (num >= b) return 0;
          return 1 + sock(a, b-(a-1),num);
      }
      
    
}

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

int main() {
	int N;
	cin >> N;
	vector <double> v(N);
	for (int i = 0; i < N; ++i) {
		cin >> v[i];
	}

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

	for (int i = 0; i < N - 1; ++i) {
		v[i+1] = ((v[i]) + (v[i+1])) / 2;
	}

	cout << v[N - 1] << endl;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), c
  cout << fixed << setprecision(15);

  ll n;
  string s;
  cin >> n >> s;

  ll ans = 0;
  rep(i, 10) rep(j, 10) rep(k, 10){
    size_t idx = s.find(to_string(i));
    if(idx == string::npos) continue;
    size_t jdx = s.find(to_string(j), idx+1);
    if(jdx == string::npos) continue;
    size_t kdx = s.find(to_string(k), jdx+1);
    if(kdx == string::npos) continue;
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3760
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef long long int lli;

int main(void){
  int n;
  vector<int> a;
  int x;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x;
    a.pb(x);
  }
  sort(a.begin(),a.end(),greater<int>());
  int res=0;
  for(int i=0;i<n;i++){
    if(i%2==0) res+=a[i];
    else res-=a[i];
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll positive(ll x){
    if(x < 0)return -x;
    else return x;
}
//ミョ(-ω- ?)
int main() {
    ll x,y;
    cin >> x >> y;
    ll res = LONG_LONG_MAX;
    if (x <= y)  chmin(res, y - x);
    if (-x <= y) chmin(res, y + x + 1);
    if (x <= -y) chmin(res, -y - x + 1);
    if (-x <= -y)chmin(res, -y + x + 2);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {


	static long tot = 0;

	public static void backtrack(int ind,long cur,long sum,String s) {
		if (ind == s.length()) {
			if (cur == 0) {
				tot += sum;
			}
			return;
		}
		backtrack(ind + 1,cur * 10 + (s.charAt(ind) - '0'),sum,s);
		backtrack(ind + 1,0,sum + cur * 10 + s.charAt(ind) - '0',s);


	}
	public static void main(String[]args) throws Throwable {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		backtrack(0,0,0,s);
		System.out.println(tot);
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

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

const int INF = 10000;
const int Max = 60;
typedef pair<int, int> P;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int h, w;
char field[Max][Max];
int d[Max][Max];
int black, path;

int bfs(){
    queue<P> que;
    int i, j;
    REP(i, h) REP(j, w) d[i][j] = INF;
    que.push(P(0, 0));
    d[0][0] = 1;

    while(que.size()){
        P p = que.front(); que.pop();
        if (p.first == h - 1 && p.second == w - 1) break;

        for (int i = 0; i < 4; i++){
            int nx = p.first + dx[i], ny = p.second + dy[i];
            if (0 <= nx && nx < h && 0 <= ny && ny < w && d[nx][ny] == INF && field[nx][ny] != '#'){
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }

    return d[h - 1][w - 1];
}

int main(){
    cin >> h >> w;
    int i, j;
    REP(i, h) REP(j, w){
        cin >> field[i][j];
        if (field[i][j] == '#') black++;
    }

    path = bfs();
    if (path == INF){
        cout << -1 << endl;
        return 0;
    }

    cout << h * w - black - path << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 1005

struct Info{

	int x,y;
};

int N,M;
Info info[SIZE];

int V;
vector<int> G[2*SIZE];
map<int,int> X,Y;
int match[2*SIZE];
bool used[2*SIZE];

void add_edge(int from,int to){
	G[from].push_back(to);
	G[to].push_back(from);
}


int dfs(int node_id){
	used[node_id] = true;

	for(int i = 0; i < G[node_id].size(); i++){
		int adj_node_id = G[node_id][i],pair_id = match[adj_node_id];
		if((pair_id < 0)||
				(used[pair_id] == false && dfs(pair_id) == true)){

			match[node_id] = adj_node_id;
			match[adj_node_id] = node_id;
			return true;
		}
	}
	return false;
}


int bipartie_matching(){
	int ret = 0;
	for(int i = 0; i < V; i++)match[i] = -1;
	for(int node_id = 0; node_id < V; node_id++){
		if(match[node_id] < 0){
			for(int i = 0; i < V; i++)used[i] = false;
			if(dfs(node_id)){
				ret++;
			}
		}
	}
	return ret;
}

int boss[SIZE],height[SIZE];

int get_boss(int id){
	if(boss[id] == id)return id;
	else{
		return boss[id] = get_boss(boss[id]);
	}
}

int isSame(int x,int y){
	return get_boss(x) == get_boss(y);
}

void unite(int x,int y){
	int boss_x = get_boss(x);
	int boss_y = get_boss(y);

	if(boss_x == boss_y)return;

	if(height[boss_x] > height[boss_y]){

		boss[boss_y] = boss_x;

	}else if(height[boss_x] < height[boss_y]){

		boss[boss_x] = boss_y;

	}else{ //height[boss_x] == height[boss_y]

		boss[boss_y] = boss_x;
		height[x]++;
	}
}

int main(){

	scanf("%d %d",&N,&M);

	int num_x = 0,num_y = 0;

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

		scanf("%d %d",&info[i].x,&info[i].y);
		info[i].x--;
		info[i].y--;

		auto at = X.find(info[i].x);

		if(at == X.end()){

			X[info[i].x] = num_x;
			num_x++;
		}

		at = Y.find(info[i].y);

		if(at == Y.end()){


			Y[info[i].y] = num_y;
			num_y++;
		}
	}

	V = num_x+num_y;

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

		add_edge(X[info[i].x],num_x+Y[info[i].y]);
	}

	int minimum = M-bipartie_matching(); //最も多くルークを残したので、キャプチャする数は最小


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

		boss[i] = i;
		height[i] = 0;
	}

	for(int i = 0; i < M-1; i++){
		for(int k = i+1; k < M; k++){
			if(info[i].x != info[k].x && info[i].y != info[k].y)continue;

			unite(i,k);
		}
	}

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

			num_group++;
		}
	}

	int maximum = M-num_group; //残るルークを最小化したので、キャプチャする数は最大

	printf("%d %d\n",minimum,maximum);

	return 0;
}



Measured memory_bytes: 3452
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll, ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const int sz=1e5+100;
ll last[sz];
bool cmp(PII a,PII b)
{
    return (a.f<b.f);
}
ll Find(ll p)
{
    if(last[p]==p) return p;
    else return (last[p]=Find(last[p])) ;
}
int main()
{
    Khela
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>m>>n)
    {
        PII ara[m];
        for(i=0;i<m;i++) cin>>ara[i].f>>ara[i].s;
        sort(ara,ara+m,cmp);
        priority_queue<ll> pq;
        ll time=n-1;
        i=0;
        ll sum=0;
        while(time>=0)
        {
             while(i<m && ara[i].first+time<=n) {
                 pq.push(ara[i].s);
                 ++i;
             }
             if(!pq.empty()){
                 sum+=pq.top();
                 pq.pop();
             }
             --time;
        }
        cout<<sum<<endl;
    }
 
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    int c[3][3];
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> c[i][j];
        }
    }
    int a[3],b[3];
    a[0] = 0;
    b[0] = c[0][0];
    b[1] = c[0][1];
    b[2] = c[0][2];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];

    bool flg = 1;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if(a[i]+b[j] != c[i][j]) flg = 0;
        }
    }
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
# 入力もらう
D,G = list(map(int,input().split()))
PC = []
for i in range(D):
    PC.append(list(map(int,input().split())))

#[0,0,0,0,0,0,0,0,0,0]という形で、どのボーナスをもらうかを管理したい
#例えば[1,0,0,0,1,0,0,0,0,0]は100点問題と500点問題のボーナスをもらうということ
#2^D通り(D<=10)だから全探索できる
#itertools使って2^D通りのケースを用意
a = [0,1]
Ls = list(itertools.product(a, repeat=D))

#pは100以下、Dは10以下だから解く問題数は多くて1000
#最大値を初期値として設定して、小さい値が実現できたら更新していく
out = 1000

#戦略としては、「ボーナスをもらう問題」を先に決めて計算し、
#その後「中途半端に解く問題」を合計得点がGに足るまで計算する、というもの。

for L in Ls: #どの問題でボーナスをもらうか、2^D通りのシナリオを逐一チェック
    #Lには「ボーナスをもらう問題」をどれにするか決めた結果が格納されている
    num = 0 #このシナリオにおける解いた問題の数
    point = 0 #このシナリオにおける得点

    #このシナリオにおいて「ボーナスをもらう問題」をまずは計算
    for i in range(D):
        if L[i]==1: #ボーナスをもらう問題では
            num+=PC[i][0] #解いた問題の数にプラス
            point+=PC[i][1] #特典もプラス
            point+=(i+1)*100*PC[i][0] #ボーナスもプラス

    #ここから、「中途半端に解く問題」の計算を行う
    #1問あたりの得点が高い方を選んだ方が得。D*100点問題から埋めていく。
    #ただしその問題でボーナスをもらっていた場合はすでに計算に入れているので、スキップする必要がある
    #さらに、重要なこととして、「ボーナスをもらわない問題」は1種類で十分である
    #なぜなら、「ボーナスをもらわない問題」を2問作るくらいなら、その2問のうち1問あたりの得点が高い方に集中させた方がいいからである。

    #「中途半端に解く問題」をどれにするか決めて、そのインデックスをhampaに格納する
    hampa = D-1 #D*100点問題
    while (L[hampa]==1)and(hampa>=0): #もし「ボーナスをもらう問題」に入れていたら
        hampa+=-1 #次に得点が高い問題を候補とする
        #ただし、[1,1,1,1,1,1,1,1,1,1]の時はそもそも「中途半端に解く問題」は作らない
        #hampaが負になったら抜ける、という方法でそれを実装している

    if hampa==-1: #先述のように、hampaが負の時は「中途半端に解く問題」は作らない
        cnt = 0
    else:
        cnt = 0 #「中途半端に解く問題」を解いた数を格納
        #「中途半端に解く問題」を解き進める条件は「今まだ得点がGに達していないこと」及び「あと一問解いてもまだ中途半端であること」
        while (point<G)and(cnt<PC[hampa][0]):
            cnt+=1
            num+=1
            point+=(hampa+1)*100

    #以上でこのシナリオにおける計算はおしまい、
    #「中途半端に解く問題」が1種類ではGに届いていないケースもある。
    #その場合はこの時点でpointはG未満であり、outの候補としては不適切。除くことが必要。
    if (point>=G)and(num<out): #問題数の最小値を更新したら、outに格納
        out=num
print(out)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll ans = 0;
    rep(i, N) {
        ans += A[i] - 1;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
with Ada.Text_IO;
with Ada.Integer_Text_IO;
with Ada.Float_Text_IO;
use Ada.Text_IO;
use Ada.Integer_Text_IO;
use Ada.Float_Text_IO;

procedure hoge is
 n: integer;
begin
 get(n);
 put(n/2+(n rem 2));
end hoge;

Measured memory_bytes: 3692
use proconio::{input, fastout};
use std::cmp::max;

#[fastout]
fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        d: i64,
    };

    let mut ans = a*c;

    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);

    println!("{}", ans);
}


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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

//r本再利用されない時、N本から再利用して売れる本数
int rec(int m,int n,int N,int r){
  if(N == 0) return 0;

  int k = N/m * n;//新たに作り出す本数
  r = N%m;//再利用されない本数
  int res = N + k;//売った本数
  
  while(1){
    k = k/m * n;//k本からk/m本再利用
    res += k;
    r += k%m;
    if(k < m){//k本で再利用できなくなったら
      k += r;
      res += rec(m,n,k,r);
    }
  }
}

int main(){
  int N;
  cin >> N;
  vector<int> L(2*N);
  rep(i,2*N){
    cin >> L[i];
  }
  sort(L.begin(),L.end());
  int ans = 0;
  for(int i = 0;i<=2*N-2;i += 2){
    ans += L[i];
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;


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

  int a, b; cin >> a >> b;
  if (a == 1) a+=100;
  if (b == 1) b+=100;
  string ans;
  if (a > b) {
    ans = "Alice";
  } else if (a == b) {
    ans = "Draw";
  } else {
    ans = "Bob";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int A, B, C, D;

    std::cin >> A >> B >> C >> D;

    int left = A + B;
    int right = C + D;

    if (left < right) {
        std::cout << "Right" << std::endl;
    } else if (left > right) {
        std::cout << "Left" << std::endl;
    } else {
        std::cout << "Balanced" << std::endl;
    }


    return 0;
}

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

typedef pair<int,int> P;
const int INF = (1<<21);
const int MAX = 100000;
const int MAX_V = 10000;
struct edge{int to, cap, cost, rev;};

int V;
vector<edge> G[MAX_V];
int h[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];
 
void init(){
  for(int i = 0 ; i < MAX_V ; i++){
    G[i].clear();
  }
}
 
void add_edge(int from,int to,int cap,int cost){
  G[from].push_back((edge){to, cap, cost, G[to].size()});
  G[to].push_back((edge){from, 0, -cost, G[from].size() - 1});
}
 
int min_cost_flow(int s,int t,int f){
  int res = 0;
  fill(h,h+V,0);
  while(f > 0){
    priority_queue<P,vector<P>,greater<P> > que;
    fill(dist,dist + V,INF);
    dist[s] = 0;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      int v = p.second;
 
      if(dist[v] < p.first)continue;
      for(int i = 0 ; i < G[v].size() ; i++){
        edge &e = G[v][i];
         
        if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
          dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
          prevv[e.to] = v;
          preve[e.to] = i;
          que.push(P(dist[e.to],e.to));
        }
      }
    }
 
    if(dist[t] == INF){
      return -1;
    }
 
    for(int v = 0 ; v < V ; v++) h[v] += dist[v];
       
    int d = f;
 
    for(int v = t; v != s; v = prevv[v]){
      d = min(d,G[prevv[v]][preve[v]].cap);
    }
    f -= d;
    res += d * h[t];
    for(int v = t ; v != s ; v = prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}

int A,B,K;
int W[555][555];
int main(){
  cin >> A >> B >> K;
  for(int i=0;i<A;i++){
    for(int j=0;j<B;j++){
      char c; cin >> c; if( c == '1' ) W[i][j]++;
    }
  }
  for(int i=0;i<B;i++){
    for(int j=0;j<A;j++){
      char c; cin >> c; if( c == '1' ) W[j][i]++;
    }
  }
  for(int i=0;i<A;i++)
    for(int j=0;j<B;j++)
      add_edge( i,A+j, 1, W[i][j] );
  for(int i=0;i<A;i++)
    add_edge( A+B, i, 1, 0 );
  for(int i=0;i<B;i++)
    add_edge( A+i, A+B+1, 1, 0 );
  V = A+B+2;
  

  int cost = 0;
  int res = 0;
  for(;;){
    int st = min_cost_flow(A+B,A+B+1,1);
    if( st == -1 ) break;
    // cout << st << " " << cost << endl;
    cost+=st;
    if( cost > K ) break;
    res++;
  }
  cout << res << endl;
  
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std; 
int N,ptr=0,res=0;
int A[100000];
int main(){
  cin>>N;
  for(int i=0;i<N;i++) cin>>A[i]; 
  sort(A,A+N);
  while(ptr<N){
    int cc=A[ptr],f=0;
    while(A[ptr]==cc){
      f++;
      ptr++;
    }
    res+=f%2;
  }
  cout<<res<<endl;
}

Measured memory_bytes: 640
//code by parshuram_84
#include <bits/stdc++.h>
#define floop(i,a,n) for (int i=a;i<n;i++)
#define pii pair<int,int>
#define pll pair<long long,long long>
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define vvl vector<vector<long long> >
#define vp vector<pair<long long,long long>>
#define vpp vector<pair<pair<long long,long long>,long long>>
#define mp make_pair
#define all(c) c.begin(),c.end()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin();it != container.end(); it++)
typedef std::numeric_limits< double > dbl;
using namespace std;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }

int32_t main() {
	IOS;
	ll t,i,j,k,n,x,y,z;
	string s;
	t=1;
	for(i=0;i<t;i++)
	{
		cin>>s;
		n=s.length();
		cout<<s;
		if(s[n-1]!='s') cout<<"s";
		else cout<<"es";
	}
	return 0;
}

Measured memory_bytes: 3660
from itertools import product
from operator import itemgetter

N, M = map(int, input().split())
lights = list(tuple(map(int, input().split())) for _ in range(M))
cons = list(map(int, input().split()))

ans = 0
for switch in product(range(2), repeat=N):
    reminders = []
    for idx, light in enumerate(lights):
        f = itemgetter(*map(lambda x: x - 1, light[1:]))
        if isinstance(f(switch), int):
            s = f(switch)
        else:
            s = sum(f(switch))
        reminders.append(s % 2)
    if cons == reminders:
        ans += 1
print(ans)


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

int main()
{
	int a, b, c;
	
	while (cin >> a >> b >> c) {
		if (a < b && b < c)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	return 0;
} 

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int vector_finder(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance(vec.begin(), itr);
  if (index != vec.size()) {  // 発見できたとき
    return 1;
  } else {  // 発見できなかったとき
    return 0;
  }
}
int main() {
  int n;
  cin >> n;
  if (n >= 30)
    cout << "Yes";
  else
    cout << "No";

  return 0;
}

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

int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  static int C[100000]={0};
  for(int i=0;i<m;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    a--,b--;
    C[a]++;
    C[b]++;
  }
  bool F=0;
  for(int i=0;i<n;i++){
    if(C[i]%2==1){
      F=1;
    }
  }
  puts(F?"NO":"YES");
  return 0;
}


Measured memory_bytes: 640
using System;
using System.Text;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' ');
            int n = int.Parse(input1[0]);
            int k = int.Parse(input1[1]);
            int q = int.Parse(input1[2]);
            int[] a = new int[q];

            int[] points = new int[n+1];

            for (var i = 0; i < q; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
                points[a[i]]++;
            }

            for (var i = 1; i <= n; i++)
            {
                if (q - points[i] < k) Console.WriteLine("Yes");
                else Console.WriteLine("No");
            }
            
        }
    }
}

Measured memory_bytes: 16092
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')   f=-1;c=getchar();}
    while(isdigit(c))   {x=x*10+c-'0';c=getchar();}
    x*=f;
}
int n,k;
int cn[1005][1005];
int ml=0;
int ss1[2005][2005];
int ss2[2005][2005];
int cc1=0;
int get1(int x1,int y1,int x2,int y2)
{
	if(x2<x1 || y2<y1)	return 0;
	int ans=ss1[x2][y2];
	if(x1)	ans-=ss1[x1-1][y2];
	if(y1)	ans-=ss1[x2][y1-1];
	if(x1 && y1)	ans+=ss1[x1-1][y1-1];
//	cout<<"Q "<<x1<<' '<<y1<<' '<<x2<<' '<<y2<<' '<<ans<<endl;
	return ans;
}
int get2(int x1,int y1,int x2,int y2)
{
	if(x2<x1 || y2<y1)	return 0;
	int ans=ss2[x2][y2];
	if(x1)	ans-=ss2[x1-1][y2];
	if(y1)	ans-=ss2[x2][y1-1];
	if(x1 && y1)	ans+=ss2[x1-1][y1-1];
	return ans;
}
bool check(int x,int y,int d)
{
	if(d<=0)	return 0;
//	if(d==0)	return get2(x,y,x+k-1,y+k-1)==0;
	if(get1(x,y,x+d-1,y+d-1)!=cc1)	return 0;
	if(get2(x+d,y+d,x+k-1,y+k-1)!=0)	return 0;
	return 1;
}
int main()
{
	read(n);
	read(k);
	int a,b;
	for(int i=0;i<n;i++)
	{
		read(a);
		read(b);
		cn[a%k][b%k]++;
		ml=max(ml,cn[a%k][b%k]);
	}
	int gg=0;
	for(;gg*gg<ml;gg++);
	ml=gg;
	for(int i=0;i<k;i++)
		for(int j=0;j<k;j++)
		{
				if(cn[i][j]<=(ml-1)*(ml-1))	continue;
				if(cn[i][j]<=ml*(ml-1))
				{
					ss2[i][j]=ss2[i+k][j]=ss2[i][j+k]=ss2[i+k][j+k]=1;
		//			cout<<"HIT2 "<<i<<' '<<j<<endl;
				}
				else
				{
					ss1[i][j]=ss1[i+k][j]=ss1[i][j+k]=ss1[i+k][j+k]=1;
		//			cout<<"HIT1 "<<i<<' '<<j<<endl;
					cc1++;
				}
		}
	for(int i=0;i<2*k;i++)
		for(int j=1;j<2*k;j++)
			ss1[i][j]+=ss1[i][j-1];
	for(int j=0;j<2*k;j++)
		for(int i=1;i<2*k;i++)
			ss1[i][j]+=ss1[i-1][j];
	for(int i=0;i<2*k;i++)
		for(int j=1;j<2*k;j++)
			ss2[i][j]+=ss2[i][j-1];
	for(int j=0;j<2*k;j++)
		for(int i=1;i<2*k;i++)
			ss2[i][j]+=ss2[i-1][j];
	int na=k;
	for(int i=0;i<k;i++)
		for(int j=0;j<k;j++)
			while(check(i,j,na-1))	na--;
//	cout<<"BS"<<ml<<endl;
//	cout<<"N"<<na<<endl;
	cout<<ml*k+na-k-1<<endl;
	return 0;
}


Measured memory_bytes: 35584
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  long n=sc.nextLong(),min=11;
	  String a="",b="";
	  for(int i=1;i<=Math.sqrt(n);i++) {
		  if(n%i==0) {
			 a=String.valueOf(i);
			 b=String.valueOf(n/i);
			 min=Math.min(min, Math.max(a.length(), b.length()));
		  }
	  }
	  System.out.println(min);
  }
	public static List<Long> divisorEnum(long n) {
		List<Long> l=new ArrayList<>();
		for(long i=1;i<=Math.sqrt(n);i++) {
			if(n%i==0) {
				l.add(i);
				if(i!=Math.sqrt(n))l.add(n/i);
			}
		}
		l.sort(null);
		return l;
	}
}


Measured memory_bytes: 35660