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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 998244353;

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

    ll a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a), t(b);
    REP(i, a) cin >> s[i];
    REP(i, b) cin >> t[i];
    
    while(q--) {
        ll x;
        cin >> x;
        ll s1;
        auto itr = lower_bound(ALL(s), x);
        if(itr != s.begin()) itr--, s1 = *itr;
        else s1 = -LLINF;
        ll s2;
        itr = lower_bound(ALL(s), x);
        if(itr != s.end()) s2 = *itr;
        else s2 = LLINF;

        ll t1;
        itr = lower_bound(ALL(t), x);
        if(itr != t.begin()) itr--, t1 = *itr;
        else t1 = -LLINF;
        ll t2;
        itr = lower_bound(ALL(t), x);
        if(itr != t.end()) t2 = *itr;
        else t2 = LLINF;

        ll ret = LLINF;
        chmin(ret, abs(x-min(s1,t1)));
        chmin(ret, abs(x-max(s2,t2)));
        chmin(ret, abs(x-s1)+abs(x-t2)+min(abs(x-s1),abs(x-t2)));
        chmin(ret, abs(x-s2)+abs(x-t1)+min(abs(x-s2),abs(x-t1)));
        // cout << "ans=";
        cout << ret << endl;
    }

    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <cstring>
#include <map>
#include <set>
#define int long long int
#define cons 1000000007 
using namespace std;

signed main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
 
    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
s = list(str(input()))

checker = 0
n = len(s)
new_s = list(reversed(s))
if s == new_s:
    checker += 1


split_s = s[0:(n-1)//2]
new_s = list(reversed(split_s))
if new_s == split_s:
    checker += 1


split_s = s[(n+2)//2:n]
new_s = list(reversed(split_s))
if new_s == split_s:
    checker += 1
if checker == 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
package main

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

func main() {
	bf := bufio.NewReader(os.Stdin)
	line, _, _ := bf.ReadLine()
	d, _ := strconv.Atoi(string(line))
	fmt.Println("Christmas" + strings.Repeat(" Eve", 25-d))
}


Measured memory_bytes: 640
#include<stdio.h>

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

int main(void){
  long long a , b , c , d;
  scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
  if(d < c){
    long long temp = d;
    d = c;
    c = temp;
  }
  long long k = gcd(c,d);
  long long g = k;
  g *= c/k;
  g *= d/k;
  
  long long len = b-a;
  
  //printf("%lld %lld\n",k,g);
  long long e = a - 1;
  long long ans1 = e - (e/c) - (e/d) + (e/g);
  long long ans2 = b - (b/c) - (b/d) + (b/g);
  
  printf("%lld\n",ans2 - ans1);
  
  return 0;
}


Measured memory_bytes: 128
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun solve (s)
  (let ((res 0)
        (len (length s)))
    (loop with base = 0
          with base-c = (aref s base)
          for i below len
          do (unless (char= base-c (aref s i))
               (setf res (max res (min i (- len  base)))
                     base i
                     base-c (aref s i)))
          finally (setf res (max res (min i (- len base)))))
    res))

(defun main ()
  (let* ((s (read-line))
         (len (length s)))
    (println
     (max (solve s)
          (ceiling len 2)))))

#-swank(main)


Measured memory_bytes: 18660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}



int main()
{
	int N;
	int A[200010] = {0};
	int i,j,k;
	std::vector<int> v;
	cin >> N;
	for(i=1;i<=N;++i)
	{
		cin >> A[i];
	}
	for(i=N;i>0;--i)
	{
		if(A[i]&1)
		{
			v.push_back(i);
			j = 1;
			while(j*j <= i)
			{
				if(!(i%j))
				{
					++A[j];
					if(j != i/j)
						++A[i/j];
				}
				++j;
			}
		}
	}
	j = v.size();
	cout << j << endl;
	if(j > 0)
	{
		for(i=0;i<j;++i)
		{
			cout << v[i] << " ";
		}
		cout << endl;
	}

	return 0;
}




















Measured memory_bytes: 2424
#include <iostream>

void print_rectangle(int& height, int& width);

int main(void)
{
    int width, height;
    while(true) {
        std::cin >> height;
        std::cin >> width;
        if (height == 0 && width == 0) {
            break;
        }
        print_rectangle(height, width);
    }
    return 0;
}

void print_rectangle(int& height, int& width)
{
    int i = 0;
    int j = 0;
    for (i = 0; i < height; ++i) {
        if (i == 0 || i == height - 1) {
            for (j = 0; j < width - 1; ++j) {
                std::cout << "#";
            }
            if (j == width - 1) {
                std::cout << "#" << std::endl;
            }
        } else {
            for (j = 0; j < width; ++j) {
                if (j == 0) {
                    std::cout << "#";
                } else if (j == width - 1) {
                    std::cout << "#" << std::endl;
                } else {
                    std::cout << ".";
                }
            }
        }
    } 
    std::cout << "" << std::endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

const int EMPTY = -1;
const int MOVE = 0;
const int BARRIIER = 1;
const int JUMP = 2;

int course[15][15];
int sizeX, sizeY;
int answer = 0;

void initCourse() {
  for (int i = 0; i < 15; i++) {
    for (int j = 0; j < 15; j++) {
      course[i][j] = EMPTY;
    }
  }
}

void inputCourse() {
  for (int i = 0; i < sizeY; i++) {
    for (int j = 0; j < sizeX; j++) {
      cin >> course[i][j];
    }
  }
}

void move(int x, int y) {
  if (course[y][x] == BARRIIER) {
    return;
  }
  if (y >= sizeY - 1) {
    answer++;
    return;
  }
  if (course[y][x] == JUMP) {
    move(x, y + 2);
  }
  if (course[y][x] == MOVE) {
    if ((x - 1) >= 0) {
      if (course[y + 1][x - 1] == MOVE) {
        move(x - 1, y + 1);
      }
    }
    if (course[y + 1][x] == MOVE || course[y + 1][x] == JUMP) {
      move(x, y + 1);
    }
    if ((x + 1) < sizeX) {
      if (course[y + 1][x + 1] == MOVE) {
        move(x + 1, y + 1);
      }
    }
  }
}

int main(int argc, char* argv[]) {
  while (cin >> sizeX >> sizeY, sizeX) {
    initCourse();
    inputCourse();
    answer = 0;
    for (int i = 0; i < sizeX; i++) {
      if (course[0][i] == MOVE) {
        move(i, 0);
      }
    }
    cout << answer << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

N, M = map(int, input().split()) 
S = input()
T = input()

n = N // gcd(N, M)
m = M // gcd(N, M)

IsOk = True
for i in range(gcd(N, M)):
  if S[n * i] != T[m * i]:
    IsOk = False

if IsOk:
  print(lcm(N, M))
else:
  print(-1)


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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define endl "\n"

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 q, query, element; vector<_i64> A; cin >> q;
        _rep(i, q) {
            cin >> query;
            switch(query) {
                case 0: cin >> element; A.push_back(element); break;
                case 1: cin >> element; cout << A[element] << endl; break;
                case 2: A.pop_back(); break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4996
INF=10**20
from heapq import heappop,heappush,heapify
def dijkstra(G,H,W,sh,sw):
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]
    que=[(0,sh*10000+sw)]
    dist=[[INF]*W for i in range(H)]
    dist[sh][sw]=0
    while que:
        mincost,u=heappop(que)
        h,w=u//10000,u%10000
        if(mincost>dist[h][w]):
            continue
        for di in range(4):
            nh=h+dx[di]
            nw=w+dy[di]
            if(nh>H-1 or nh<0 or nw>W-1 or nw<0):
                continue
            if(G[nh][nw]=='#'):
                continue
            if(dist[h][w]<dist[nh][nw]):
                dist[nh][nw]=dist[h][w]
                heappush(que,(dist[nh][nw],nh*10000+nw))
        for nh in range(h-2,h+3):
            for nw in range(w-2,w+3):
                if (nh>H-1 or nh<0 or nw>W-1 or nw<0):
                    continue
                if(G[nh][nw]=='#'):
                    continue
                if dist[h][w]+1<dist[nh][nw]:
                    dist[nh][nw]=dist[h][w]+1
                    heappush(que,(dist[nh][nw],nh*10000+nw))
    return dist

H,W=map(int,input().split())
Ch,Cw=map(lambda x:int(x)-1,input().split())
Dh,Dw=map(lambda x:int(x)-1,input().split())
G=[tuple(input()) for i in range(H)]
dist=dijkstra(G,H,W,Ch,Cw)
ans=dist[Dh][Dw]
if ans!=INF:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 168792
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i = 0; i < n; i++)

double dist (int i, int j, vector<int> x, vector<int> y) {
    return pow(pow((x[i] - x[j]), 2) + pow((y[i] - y[j]), 2), 0.5);
}

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

    vector<int> point_x, point_y;
    vector<int> idx;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        point_x.emplace_back(x);
        point_y.emplace_back(y);
        idx.emplace_back(i);
    }

    double total = 0;
    int cnt = 0;
    do {
        for (int i = 0; i < idx.size()-1; i++) {
            total += dist(idx[i], idx[i+1], point_x, point_y);
        }
    } while(next_permutation(idx.begin(), idx.end()));
    

    int f = 1;
    for(int i = 2;i <= n;i++)f *= i;

    // cout << total / f << endl;
    printf("%0.10f\n", total / f);
}

Measured memory_bytes: 4276
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
#include<math.h>
#include<sstream>
typedef long long ll;
#define N (1000000000+7)
#define INF (-1000000)
using namespace std;
typedef pair<int, int> P;

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

int d[55][55];

char board[55][55];
int h, w;

int bfs() {
	queue<P>q;
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			d[i][j] = INF;
		}
	}
	q.push(P(1, 1));
	d[1][1] = 0;
	while (!q.empty()) {
		P p = q.front();q.pop();
		if ((p.first == h) && (p.second == w))break;
		for (int i = 0;i < 4;i++) {
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if ((1 <= nx) && (nx <= h) && (1 <= ny) && (ny <= w) && (board[nx][ny] != '#') && (d[nx][ny] == INF)) {
				q.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[h][w];
}


int main(void) {
	int n, i;
	cin >> n >> i;
	cout << n - i + 1 << endl;
	return 0;
}

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

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("codefi.txt", "r", stdin);
	freopen("codefo.txt", "w", stdout);
#endif

	 int h,w;
    cin>>h>>w;
    if(h==1 or w==1)
    {
        cout<<1<<endl;
    }
    else
    {
      int ans=h*w;
      if(ans%2==0)
        {
            cout<<(h*w)/2<<endl;
        }
       else
       {
        cout<<((h*w)+1)/2<<endl;
       }
    }
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  int alice=0,bob=0;
  int card;
  cin>>card;
  vector<int>n;
  for(int i=0;i<card;i++){
    int a;
    cin>>a;
    n.push_back(a);
  }
  sort(n.begin(),n.end());
  int j=1;
  for(int i=card;i>0;i--){
    if(j%2) alice+=n.back();
    else bob+=n.back();
    n.pop_back();
    j++;
  }
  cout<<alice-bob<<endl;
  return 0;
}


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

int main() {
    int d;
    cin >> d;
    if (d == 25) cout << "Christmas" << endl;
    else if (d == 24) cout << "Christmas Eve" << endl;
    else if (d == 23) cout << "Christmas Eve Eve" << endl;
    else if (d == 22) cout << "Christmas Eve Eve Eve" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int k = sc.nextInt();
    int row = 7 % k;
      int i =0;

    //数列の定義
    for(i = 0; i < k ; i++ ){
			if(row == 0){
					System.out.println(i+1);
					break;
			}
      row = (row * 10 + 7) % k;
     // System.out.println(row);
    }
      if(i>=k){
      System.out.println("-1");
      }
	}
}




Measured memory_bytes: 35668
// Name        : isitarightriangle.cpp

#include <iostream>
using namespace std;

int main() {
	int tensu[5], tasu = 0;

	for (int i = 0; i < 5; i++) {
		cin >> tensu[i];
		if (tensu[i] < 40)
			tensu[i] = 40;
		tasu = tasu + tensu[i];
	}

	cout << tasu / 5 << endl;

}

Measured memory_bytes: 1160
n,m= map(int,input().split())
langdic = {key:[] for key in range(1,m+1)}
for i in range(1,n+1):
    k,*p= map(int,input().split())
    for j in p:langdic[j].append(i)
newlanglist = []
for key in langdic.keys():
    if len(langdic[key])>1:newlanglist.append((langdic[key]))
par = [-1]*(n+1)
def find(x):
    if par[x]<0:return x
    else:
        par[x]=find(par[x])
        return par[x]
def unites2(alist):
    top = min(alist)
    toproot = find(top)
    for a in alist:
        aroot = find(a)
        if top!=a:
            if aroot==toproot:pass
            else:
                grp = par[aroot]
                par[aroot]=toproot
                par[toproot]+=grp
for lis in newlanglist:unites2(lis)
c=0
for t in par[1:]:
    if t<0:c+=1
if c==1:print('YES')
else:print('NO')

Measured memory_bytes: 25112
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(ll i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(ll i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<ll, ll> II;
typedef vector<II> vi;

int main()
{
    ll n, a, b, u, v, g, h;
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    cin >> n;
    cin >> a >> b;
    FOR(i,2,n) {
        cin >> u >> v;
        if (a % u == 0) g = a/u;
        else g = a/u+1;
        if (b % v == 0) h = b/v;
        else h = b/v+1;
        if (g*u >= a && g*v >= b) a = g*u, b = g*v;
        else a = h*u, b = h*v;
    }
    cout << a + b;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    vector<ll> a(n);
    ll mini=1e+7,maxi=(-1e+7);
    int maxid=-1,minid=-1;
    rep(i,n){
        cin>>a[i];
        if(chmax(maxi,a[i]))maxid=i;
        if(chmin(mini,a[i]))minid=i;
    }
    vector<pair<int,int>> p(2*n);
    if(maxi>(-mini)){
        rep(i,n){
            p[i]={i,maxid};
            //a[i]+=maxi;
        }
        rep(i,n-1) p[i+n]={i+1,i};
        cout<<2*n-1<<endl;
        rep(i,2*n-1)cout<<p[i].second+1<<" "<<p[i].first+1<<endl;
    }else{
        rep(i,n){
            p[i]={i,minid};
            //a[i]+=maxi;
        }
        rep(i,n-1) p[i+n]={n-i-2,n-i-1};
        cout<<2*n-1<<endl;
        rep(i,2*n-1)cout<<p[i].second+1<<" "<<p[i].first+1<<endl;
    }
}

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

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

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

    int hv[N + 100][3];
    rep(i, N)   rep(j, 3)   cin >> hv[i][j];

    int dp[N + 100][3];
    rep(i, N + 100) rep(j, 3) dp[i][j] = 0;

    rep(i, N)
    {
        rep(j, 3)
        {
            rep(k, 3)
            {
                if(j == k)  continue;
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + hv[i][k]);
            }
        }
    }

    int ans = 0;
    rep(i, 3)   ans = max(ans, dp[N][i]);

    cout << ans << endl;
}

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

#define int long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int N = 2002;


void solve() {
    int n;
    cin >> n;
    map<string , int> s;
    while(n --) {
        string a;
        cin >> a;
        s[a] ++;
    }
    cout << s.size();
}

/*
 
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    while(testcase --) {
        solve();
        cout << '\n';
    }
    
    return 0;
}
 



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

#define ull unsigned long long

const int MaxA(4003);
const int MaxN(200003);
const int Mod(1e9 + 7);
const int inv2(500000004);

inline int add(int x, int y)
{
	return (x += y) >= Mod ? x -= Mod : x;
}

inline int inc(int x, int y)
{
	return (x -= y) < 0 ? x += Mod : x;
}

int fac[MaxN], rfac[MaxN];
int a[MaxN], b[MaxN];
int F[MaxA][MaxA];

inline int C(int n, int m)
{
	return n < m ? 0 : (ull) fac[n] * rfac[m] % Mod * rfac[n - m] % Mod;
}

int fexp(int x, int k)
{
	int res = 1;
	for(; k; k >>= 1, x = (ull) x * x % Mod)
		if(k & 1) res = (ull) res * x % Mod;
	return res;
}

int main()
{
	int n;
	scanf("%d", &n);
	for(int i = fac[0] = 1; i <= 8000; i++)
		fac[i] = (ull) fac[i - 1] * i % Mod;
	rfac[8000] = fexp(fac[8000], Mod - 2);
	for(int i = 8000; i; i--)
		rfac[i - 1] = (ull) rfac[i] * i % Mod;
	for(int i = 1; i <= n; i++)
	{
		scanf("%d%d", &a[i], &b[i]);
		++F[-a[i] + 2001][-b[i] + 2001];
	}
	for(int i = 1; i <= 4001; i++)
		for(int j = 1; j <= 4001; j++)
			F[i][j] = add(F[i][j], add(F[i - 1][j], F[i][j - 1]));
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		ans = add(ans, F[a[i] + 2001][b[i] + 2001]);
		ans = inc(ans, C(2 * a[i] + 2 * b[i], 2 * a[i]));
	}
	ans = (ull) ans * inv2 % Mod;
	printf("%d\n", ans);
	return 0;
}


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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> h(N);
  for(int i=0;i<N;i++)
    cin>>h[i];
  vector<int> dp(N,INT_MAX);
  dp[0] = 0;
  for(int i=0;i<N;i++){
    for(int j=1;j<=K;j++){
      if(i+j == N) break;
      int cost = dp[i] + abs(h[i] - h[i+j]);
      if(dp[i+j] > cost)
        dp[i+j] = cost;
    }
  }
  cout<<dp[N-1]<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d[110];
    cin>>n;
    for(int i=0;i<n;i++)cin>>d[i];
    set<int>m;
    for(int i=0;i<n;i++)m.insert(d[i]);
    int ans=m.size();
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
#define SWAP(x,y,z) {if ( y > z ) swap(y,z); if ( x > y ) swap(x,y); if (y > z) swap(y,z);}


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    if ( a*b >= c*d ) cout << a*b;
    else cout << c*d;
    // 274751WM
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<std::string> v(n);
    for (auto &e : v) {
        std::cin >> e;
        std::sort(e.begin(), e.end());
    }

    std::sort(v.begin(), v.end());
    i64 ret = 0;
    for (int i = 0; i < n;) {
        int j = i;
        while (j < n && v[j] == v[i]) j++;

        i64 d = j - i;
        ret += d * (d - 1) / 2;
        i = j;
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <vector>
typedef long long ll;

using namespace std;

int main() {
    int goodsNum, maxWeight;
    cin >> goodsNum >> maxWeight;
    
    vector<ll> goodsWeight(goodsNum);
    vector<ll> goodsValue(goodsNum);
    for(int i = 0; i < goodsNum; i++) {
        cin >> goodsWeight[i] >> goodsValue[i];
    }
    
    vector<vector<ll>> dp = vector<vector<ll>>(goodsNum, vector<ll>(maxWeight + 1, 0));
    for(int i = 0; i < goodsNum; i++) {
        for(int j = 0; j <= maxWeight; j++) {
            if(j >= goodsWeight[i]) {
                if(i == 0) {
                    dp[i][j] = goodsValue[i];
                }
                else {
                    dp[i][j] = max(dp[i - 1][j], goodsValue[i] + dp[i - 1][j - goodsWeight[i]]);
                }
            }
            else if(i > 0){
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    
    cout << dp[goodsNum - 1][maxWeight] << endl;
    return 0;
}


Measured memory_bytes: 79360
n,x = map(int,input().split())
 
#レベルnバーガーの構造は、1,2^(n+1)-3,1,2^(n+1)-3,1
 
ans = 0
x2 = x
k=n
while True:
  thk = [1,2**(k+1)-3,1,2**(k+1)-3,1]
  pc = [0,2**k-1,1,2**k-1,0]
  for i in range(5):
    x2-=thk[i]
    if x2<0:
      x2+=thk[i]
      k-=1
      break
    elif x2==0:
      ans+=pc[i]
      print(ans)
      exit()
    else:
      ans+=pc[i]


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int main(){
    int a,b,s,k;
    cin >> a >> b >> k;
    s = b-a;
    vector<ll>t(k+1);
    rep(i,k+1){
        cin >> t[i];
    }
    ll dp[1010][32]={};
    Fill(dp,(ll)10000000000);
    ll X[1010]={};
    Fill(X,(ll)10000000000);
    X[0] = 0;
    X[1] = 0;
    X[2] = t[0]+t[1];
    dp[2][1] = t[0]+t[1];
    for(int i=3;i<=s;i++){
        for(int j=1;j<min(i,k+1);j++){
            if(j==1){
                for(int p=1;p<i;p++){
                    dp[i][j] = min(dp[i][j],X[p]+p*t[0]+X[i-p]+(i-p)*t[1]);
                }
            }else{
                for(int p=1;p<=i-j;p++){
                    dp[i][j] = min(dp[i][j],dp[i-p][j-1]+X[p]+p*t[j]);
                }
            }
            X[i] = min(X[i],dp[i][j]);
        }
    }
    cout << fixed << setprecision(10) <<  (double)X[s]/(double)s << endl;
    return 0;
}


Measured memory_bytes: 3520
//R<3S
#include <bits/stdc++.h>
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define vecmax(v) max_element(all(v))
#define vecmin(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(x) for(auto i : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define int long long
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vl vector<ll>
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define mll map<ll,ll>


using namespace std;

vector <int> adj[100005];
bool vis[100005];
int dp[100005];
int dfs(int node) 
{
    vis[node] = true;
    int maxm=0;
    if(dp[node]!=-1)return dp[node];
    for(int i = 0;i < adj[node].size();++i)    
    {
         
        maxm=max(maxm,1+dfs(adj[node][i]));
    }
    return dp[node]=maxm;
}


void solve()
  {
	int n,m,x,y;
	cin>>n>>m;
	memset(vis,false,sizeof vis);
	rep(i,100005)dp[i]=-1;
	rep(i,m)
	{
		cin>>x>>y;
		adj[x].pb(y);
	}
	int maxm=0;
	repA(i,1,n)
	{
		if(!vis[i])maxm=max(maxm,dfs(i));
	}
	cout<<maxm;


  }



signed main()
{
   std::ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int t;
   t=1;
   //cin>>t;
   while(t--)
    {
        solve();
    }


   return 0;
}


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

int main() { 	
 int A,C,D,E,F,G;
 string B;
 cin >>A>>B;
 vector<int> AA(1);
  vector<int> BB(1);
   
    if(A>=3200){
	cout <<B<<endl; 
    }else{
        cout <<"red"<<endl; 
    }
 
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String arg[]){
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt();
		int b=sc.nextInt();
		int sum = 0;
		for(int i=0;i<b;i++)
			sum+=sc.nextInt();
		if(sum >= h)
			System.out.println("Yes");
		else 
			System.out.println("No");
	}
}

Measured memory_bytes: 47620
// Problem : E - This Message Will Self-Destruct in 5s
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
//#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
//int rnd(int x) { return mrand() % x;}
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 2e5 + 10; 

int n,a[maxn];
map<ll,int>mp;
int main()
{
	fastIO;
	cin >> n;
	rep(i,0,n) cin >> a[i];
	ll ans = 0;
	rep(i,0,n) {
		ans += mp[i - a[i]];
		//cout << i << " " << ans << endl;
		mp[a[i] + i]++;
	}		
	cout << ans << endl;
	return 0;
}

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

c = 0
for i in range(2,n):
    c = c^a[i]

start = a[0]
a,b = a[0],a[1]
if((a^b)==c):
    print(0)
    exit()

dif = a+b-c
if(dif%2==1):
    print(-1)
    exit()

dif = dif//2
for i in range(40):
    if((c >> i)&1)&((dif >> i)&1):
        print(-1)
        exit()

if(dif > start):
    print(-1)
    exit()

goal = dif

for i in range(40,-1,-1):
    if(c >> i)&1:
        if(goal + 2**i <= start):
            goal += 2**i

if(goal==0):
    print(-1)
    exit()

print(start-goal)


Measured memory_bytes: 62072
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rer(i,l,r) for(int(i)=(l); (i)<(r); ++(i))
#define rep(i,n) rer(i,0,n)
#define gnr(i,l,r) for(int (i)=(r)-1; (i)>=(l); --(i))
#define pri(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<(p).fi<<' '<<(p).se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

int main(){
  cin.tie(nullptr); ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);
  
  cin>>n;
  rep(i,n){
    int a[3]; cin>>a[0]>>a[1]>>a[2]; sort(a,a+3);
    pri(a[0]*a[0]+a[1]*a[1]==a[2]*a[2]?"YES":"NO");
  }
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
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;}

int main(){
   int n,m;
   cin >> n >> m;
   priority_queue<int,vector<int>,less<int>> a;
   rep(i,n){
      int score;
      cin >> score;
      a.push(score);
   }
   
   rep(i,m){
      int aa=a.top();
      a.pop();
      a.push(aa/2);
   }
   ll sum =0;
   rep(i,n){
      sum += a.top();
      a.pop();
   }
   cout << sum << endl;
   return 0;
}


Measured memory_bytes: 892
let N = Int(readLine()!)!

var num: [Int: Int] = [:]
for a in readLine()!.split(separator: " ").map({Int($0)!}) {
    // 辞書型で a が何個あるかを記録する
    // - a があるたびに, aの個数にどんどん 1 を足していく
    // ※ a が初めて登場した数の時 ( ちょっとメンドウ...(~_~;) )
    // num[a] = 〇〇 で a を key, 〇〇 を value とする要素を作る(ex. [a: 〇〇]
    // num[a] は(まだ値がないから) nil を帰すので, (num[a] ?? 0) で nil じゃなくて 0 を帰すようにする
    num[a] = (num[a] ?? 0) + 1
}

var res: Int = 0
for (a, aNum) in num {
    // aの個数 が a より小さいときあるだけ取り除く,
    // aの個数 が a 以上のとき aの個数 - a だけ取り除く٩(๑❛ᴗ❛๑)۶
    res += aNum < a ? aNum : aNum - a
}
print(res) // (๑•ૅㅁ•๑)

Measured memory_bytes: 14328
#include<bits/stdc++.h>
#include "boost/multi_array.hpp"
using namespace std;

int main(){
  int H,W,i,j,k,l; cin>>H>>W; H+=2;W+=2; string T;
  boost::multi_array<char, 2> S(boost::extents[H][W]);
  for(i=0;i<H;i++){
    if(i==0 || i==H-1) for(j=0;j<W;j++) S[i][j]='.';
    else {
      cin>>T;
      for(j=W-2;0<j;j--) S[i][j]=T[j-1];
      S[i][0]=(S[i][W-1]='.');
  	}
  }
  for(i=1;i<H-1;i++)
    for(j=1;j<W-1;j++){
      if(S[i][j]=='.'){
        S[i][j]='0';
        for(k=i-1;k<=i+1;k++)
          for(l=j-1;l<=j+1;l++)
            if(i!=k || j!=l) S[i][j]+=(S[k][l]=='#'?1:0);
      }
    }
  for(i=1;i<H-1;i++) {for(j=1;j<W-1;j++) cout<<S[i][j]; cout<<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
# define PI  3.14159265358979323846
ll maxi=LLONG_MIN;
ll mini=LLONG_MAX;
vector<int> adj[100001];
ll vis[100005]={0},dp[100005]={0};
ll n,m,a,b;
void dfs(int u)
{
  vis[u]=1;
  for (int i = 0; i < adj[u].size(); ++i)
  {
  	if (vis[adj[u][i]]==0)
  	{
  		dfs(adj[u][i]);
  	}
  	dp[u]=max(dp[u],1+dp[adj[u][i]]);
  }
}
int main() 
{
	// #ifndef ONLINE_JUDGE
 // 	freopen("L:\\Codes\\in.txt", "r", stdin);
 // 	freopen("L:\\Codes\\out.txt", "w", stdout);
 // 	#endif
 	cin>>n>>m;
 	for (int i = 0; i < m; ++i)
 	{
 	   cin>>a>>b;
 	   adj[a].pb(b);
 	}
 	for (int i = 1; i <= n; ++i)
 	{
 		if(!vis[i])
 		{
 			dfs(i);
 		}
 	}
 	for (int i = 1; i <= n; ++i)
 	 {
 	 	maxi=max(maxi,dp[i]);
 	 } 
 	cout<<maxi;
 	return 0;
 }

Measured memory_bytes: 9344
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();
        int result,x,result2,y;
        int mov = 0;
        int ikisaki[][] = new int[n][2];
        for(int i = 0; i < n; i++){
            for(int k = 0; k < 2; k++){
                ikisaki[i][k] = sc.nextInt();
            }
        }
        for(int i = 1; i < n; i++){
            result = ikisaki[i][0] - ikisaki[i-1][0];
            x = Math.abs(result);
            result2 = ikisaki[i][1] - ikisaki[i-1][1];
            y = Math.abs(result2);
            mov = mov + x + y;
            if(result > 0 && result2 > 0 || result < 0 && result2 < 0){
                if(x <= y){
                    mov = mov - x;
                }else{
                    mov = mov - y;
                }
            }
        }
        System.out.println(mov);
    }
}

Measured memory_bytes: 25440
s = int(input())

def f(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1
a = [s]
i = 1
while True:
    i += 1
    p = f(a[-1])
    if p in a:
        print(i)
        break
    a.append(p)


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

using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
ll n;
ll arr[200006];

int main(){
    ios_base::sync_with_stdio(false);
    ll k;
    cin >> n >> k;
    ll currtime = 0;
    ll total = 0;
    for(int i = 0; i < n; i++){
        ll t; cin >> t;
        if(t < currtime){
            total += k - (currtime - t) ;
        }else{
            total += k;

        }
        currtime = t + k;
    }
    cout << total;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MAX_V 100000
#define MAX_N 1000
using namespace std;

struct edge{int to, cap,cost,rev;};
int V;
vector<edge> G[MAX_V];
vector<int> dist[MAX_V];
const vector<int> INF(1<<8,1000);
int prevv[MAX_V],preve[MAX_V];

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){
  while(f>0){
    for(int i=0;i<V;i++) dist[i]=INF;
    dist[s]=vector<int>(1<<8,0);

    bool update = true;
    while(update){
      update = false;
      for(int v=0; v<V ;v++){
	if(dist[v]==INF) continue;
	for(int i=0; i<G[v].size(); i++){
	  edge &e = G[v][i];
	  vector<int> ncost=dist[v];
	  if(e.cost!=0)ncost[abs(e.cost)]+=e.cost/abs(e.cost);
	  
	  if(e.cap > 0 && dist[e.to] > ncost){
	    dist[e.to] = ncost;
	    prevv[e.to] = v;
	    preve[e.to] = i;
	    update = true;
	  }
	}
      }
    }
    if(dist[t]==INF) return -1;    

    int d = f;
    for(int v=t; v!=s; v=prevv[v])d=min(d,G[prevv[v]][preve[v]].cap);
    f -= d;
    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 1;
}


int can[MAX_N][MAX_N];
int Biparite_Matching(int N,int K){
  int s = N+K, t = s+1;
  for(int i=0; i<N; i++) add_edge(s,i,1,0);
  for(int i=0; i<K; i++) add_edge(N+i,t,1,0);

  for(int i=0;i<N;i++)
    for(int j=0;j<K;j++)add_edge(i, N+j,1,can[i][j]);
  V=N+K+2;
  return min_cost_flow(s,t,N);
}



int main(){
  int n;
  cin>>n;
  string mp[51];
  for(int i=0;i<n;i++)cin>>mp[i];
  
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)can[i][j] = -mp[i][j];

  Biparite_Matching(n,n);
  string ans;
  for(int i=0;i<n;i++)
    for(int j=0;j<G[i].size();j++)
      if(G[i][j].cap==0) ans+=mp[i][G[i][j].to-n];
  sort(ans.begin(),ans.end());

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

Measured memory_bytes: 8208
a,b,c=map(int,input().split())
if a==b==c:print(-1+(a%2==1));exit()
i=0
while a%2==0 and b%2==0 and c%2==0:
  aa=b//2+c//2
  bb=a//2+c//2
  cc=a//2+b//2
  a,b,c=aa,bb,cc
  i+=1
print(i)

Measured memory_bytes: 3060
//
//  main.cpp
//  CoderWork
//
//  Created by Minoru Hayashi on 2020/02/29.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//

#include <bits/stdc++.h>
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;
using P = pair<int,int>;

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;

//#define __DBG__



void solve(void){

  int N;
  cin >> N;
  
  vector<string> S;
  
  vector<int> nums(N);
  
  REP(i,N){
    nums[i]=i+1;
  }

  int count=0;
  
  do {
    string tmp="";
    REP(i,N){
      tmp = tmp + to_string(nums[i]);
    }
    S.push_back(tmp);
//    cout << S[count] << endl;
    count++;
  } while (next_permutation(nums.begin(), nums.end()));
  
//  sort(S.begin(),S.end());
  
  string PP="";
  string QQ="";
  
  REP(i,N){
    int P;
    cin >> P;
    PP = PP + to_string(P);
  }
  REP(i,N){
    int Q;
    cin >> Q;
    QQ = QQ + to_string(Q);
  }
  
  int A=0;
  int B=0;
  
  REP(i,S.size()){
    if(S[i] == PP){
      A = i;
    }
    if(S[i] == QQ){
      B = i;
    }
  }
  
  cout << abs(A-B) << endl;
  
  return;
}

int main(int argc, const char * argv[]) {



    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    solve();
 
    return 0;
}





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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll MOD = 1000000007;
ll INF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

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

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

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

  ll h, w, m;
  cin >> h >> w >> m;

  set<pll> st;

  vll cnth(h,0);
  vll cntw(w,0);

  REP(i,m){
    ll x, y;
    cin >> x >> y;
    x--; y--;
    st.insert({x,y});
    cnth[x]++; cntw[y]++;
  }

  vpll ch(h);
  REP(i,h){
    ch[i] = {cnth[i],i};
  }

  vpll cw(w);
  REP(i,w){
    cw[i] = {cntw[i],i};
  }

  sort(ALL(ch));
  sort(ALL(cw));
  reverse(ALL(ch));
  reverse(ALL(cw));

  ll hm = ch[0].first;
  ll wm = cw[0].first;

  vpll dh;
  vpll dw;

  REP(i,h) if(ch[i].first == hm) dh.push_back(ch[i]);
  REP(i,w) if(cw[i].first == wm) dw.push_back(cw[i]);

  for(ll i = 0; i < dh.size(); i++){
    for(ll j = 0; j < dw.size(); j++){
      ll x = dh[i].second;
      ll y = dw[j].second;
      ll tmp = hm + wm;
      if(st.find({x, y}) == st.end()){
        cout << tmp << endl;
        return 0;
      }
    }
  }
  cout << hm + wm - 1 <<endl;

  

    
    
  return 0;
}



Measured memory_bytes: 53048
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  string S;
  cin >> S;
  // true: begin, false: end;
  vector<bool> ops(N * 2);
  long state = 0;
  rep (i, N * 2) {
    // cout << "i: " << i << ", state: " << state << endl;
    if (state % 2 == 0 and S[i] == 'B') {
      state++;
      ops[i] = true;
      continue;
    }
    if (state % 2 == 0 and S[i] == 'W') {
      ops[i] = false;
      state--;
      if (state < 0) {
        cout << 0 << endl;
        return;
      }
      continue;
    }
    if (state % 2 != 0 and S[i] == 'B') {
      ops[i] = false;
      state--;
      continue;
    }
    if (state % 2 != 0 and S[i] == 'W') {
      state++;
      ops[i] = true;
      continue;
    }
  }
  if (state != 0) {
    cout << 0 << endl;
    return;
  }
  long result = 1;
  state = 0;
  rep (i, N * 2) {
    if (ops[i]) state++;
    else {
      result *= state;
      result %= MOD;
      state--;
    }
  }
  // cout << "tmp: " << result << endl;
  rep (i, N) {
    result *= i + 1;
    result %= MOD;
  }
  cout << result << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
int n,k,ans;
int f[12][6]= {{4,2,0,9,7},{1,10,8,6,4},{9,7,5,3,1},{6,4,2,0,9},{3,1,10,8,6},{0,9,7,5,3},{8,6,4,2,0},{5,3,1,10,8},{2,0,9,7,5},{10,8,6,4,2},{7,5,3,1,10}};
int main() {
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for(int i = 0; i < (n - 2) % 11; i++)
		for(int j = 0; j < 5; j++)
			ans += f[i][j] == k;
	cout << ans  + (n - 2) / 11 * 5 << endl;
	return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
import random
import time
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def scorei(ti, i, last, minus):
        k = [i for i in last]
        mi = minus-(i+1-last[ti])*c[ti]
        v = s[i][ti]-mi
        mi += sum_
        k[ti] = i+1
        return v, k, mi

    def score(t):
        n = 26
        v = 0
        minus = sum_ = sum(c)
        last = [0]*n
        for i in range(d):
            ti = t[i]-1
            minus -= (i+1-last[ti])*c[ti]
            v += s[i][ti]-minus
            minus += sum_
            last[ti] = i+1
        return v
    start = time.time()
    d = I()
    c = LI()
    s = LIR(d)
    n = 26
    m = 1000
    sum_ = sum(c)
    q = [(0, 0, [0]*n, sum_)]
    pre = [[None]*n for i in range(d)]
    sc = [[float("inf")]*n for i in range(d)]
    argmax = 0
    for i in range(d):
        nq = []
        for _ in range(m):
            if not q:
                break
            v, x, last, minus = heappop(q)
            if i > 0 and v > sc[i-1][x]:
                continue
            for ti in range(n):
                vi,nl,nm = scorei(ti,i,last,minus)
                nv = v-vi
                heappush(nq,(nv,ti,nl,nm))
                if sc[i][ti] > nv:
                    sc[i][ti] = nv
                    pre[i][ti] = x
        q = [i for i in nq]
    t = []
    argmax = 0
    m = sc[-1][0]
    for i in range(1,n):
        sci = sc[-1][i]
        if m > sci:
            m = sci
            argmax = i
    t.append(argmax)
    x = argmax
    for i in range(1,d)[::-1]:
        y = pre[i][x]
        t.append(y)
        x = y
    t = [i+1 for i in t[::-1]]
    v = score(t)
    i = 0
    while time.time() < 1.5+start:
        nt = [i for i in t]
        r = random.random()
        if r > 0.5:
            if nt[i] < n:
                nt[i] += 1
        else:
            if nt[i] > 1:
                nt[i] -= 1
        nv = score(nt)
        if v < nv:
            t = [i for i in nt]
            v = nv
        i += 1
        i %= d
    for i in t:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 119144