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

using namespace std;
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << "{" << p.first << ", " << p.second << "}";
    return os;
}

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

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

const int INF = (ll) 1e9;
const ll INFLL = (ll) 1e18 + 1;
const ll MOD = (ll) 1e9 + 7;
const double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    int N;
    cin >> N;
    deque<ll> B,B2;
    rep(i, N) {
        ll a;
        cin >> a;
        B.push_back(a);
        B2.push_back(a);
    }
    sort(all(B));
    sort(all(B2));
    deque<ll> w,w2;
    w.push_front(B.front());
    B.pop_front();

    w2.push_front(B2.back());
    B2.pop_back();
    auto f = [&](deque<ll> &A, deque<ll>& v, int x) -> ll{
        ll res = 0;
        int sz = A.size();
        for (int i = 0; i < sz / 2; i++) {
            if ((i+x) & 1) {
                //最小を二つ入れる
                ll nax1 = A.front();
                A.pop_front();
                ll nax2 = A.front();
                A.pop_front();
                ll add1 = abs(nax1 - v.back()) + abs(nax2 - v.front());
                ll add2 = abs(nax1 - v.front()) + abs(nax2 - v.back());
                res += max(add1, add2);
                v.push_back(nax1);
                v.push_front(nax2);
            } else {
                //最大を二つ入れる
                ll nax1 = A.back();
                A.pop_back();
                ll nax2 = A.back();
                A.pop_back();
                ll add1 = abs(nax1 - v.back()) + abs(nax2 - v.front());
                ll add2 = abs(nax1 - v.front()) + abs(nax2 - v.back());
                res += max(add1, add2);
                v.push_back(nax1);
                v.push_front(nax2);
            }
        }
        if (A.size() == 1) {
            res += max(abs(v.back() - A[0]),
                       abs(v.front() - A[0]));
        }
        return res;
    };

    ll ans = max(f(B,w,0), f(B2,w2,1));
    cout << ans << endl;
}

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

struct Node
{
	int key;
	Node* parent;
	Node* left;
	Node* right;
};

Node* root_ptr = NULL;

void insert_node(int key)
{
	Node* x_ptr = root_ptr;
	Node* y_ptr = NULL;
	Node* z_ptr = new Node();
	z_ptr->key = key;

	while (x_ptr != NULL) {
		y_ptr = x_ptr;
		if (z_ptr->key < x_ptr->key) x_ptr = x_ptr->left;
		else x_ptr = x_ptr->right;
	}
	z_ptr->parent = y_ptr;

	if (y_ptr == NULL) root_ptr = z_ptr;
	else {
		if (z_ptr->key < y_ptr->key) y_ptr->left = z_ptr;
		else y_ptr->right = z_ptr;
	}
}

Node* find_node(int key)
{
	Node* ptr = root_ptr;
	while (ptr != NULL) {
		if (key < ptr->key) ptr = ptr->left;
		else if (ptr->key < key) ptr = ptr->right;
		else return ptr;
	}
	return NULL;
}

Node* get_delete_node(Node* ptr)
{
	while (ptr->left != NULL) ptr = ptr->left;
	while (ptr->right != NULL) ptr = ptr->right;
	return ptr;
}

void delete_node(int key)
{
	// keyを持つnodeのポインタを探索
	Node* ptr = find_node(key);
	if (ptr == NULL) return;

	// 削除対象のポインタの決定
	Node* delete_ptr;
	if (ptr->left == NULL || ptr->right == NULL) delete_ptr = ptr;
	else delete_ptr = get_delete_node(ptr->right);

	// ポインタの削除処理
	if (delete_ptr->left == NULL && delete_ptr->right == NULL) {
		if (delete_ptr->key < delete_ptr->parent->key) delete_ptr->parent->left = NULL;
		else delete_ptr->parent->right = NULL;
	}
	else if (delete_ptr->left == NULL) {
		delete_ptr->right->parent = delete_ptr->parent;
		if (delete_ptr->key < delete_ptr->parent->key) delete_ptr->parent->left = delete_ptr->right;
		else delete_ptr->parent->right = delete_ptr->right;
	}
	else {
		delete_ptr->left->parent = delete_ptr->parent;
		if (delete_ptr->key < delete_ptr->parent->key) delete_ptr->parent->left = delete_ptr->left;
		else delete_ptr->parent->right = delete_ptr->left;
	}
	ptr->key = delete_ptr->key;
	delete delete_ptr;
}

// 左部分木->根->右部分木
void print_inorder(Node* ptr)
{
	if (ptr == NULL) return;
	print_inorder(ptr->left);
	cout << " " << ptr->key;
	print_inorder(ptr->right);
}

// 根->左部分木->右部分木
void print_preorder(Node* ptr)
{
	if (ptr == NULL) return;
	cout << " " << ptr->key;
	print_preorder(ptr->left);
	print_preorder(ptr->right);
}

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

	for (int i = 0; i < n; i++) {
		string cmd;
		cin >> cmd;
		if (cmd == "insert") {
			int key;
			cin >> key;
			insert_node(key);
		}
		else if (cmd == "find") {
			int key;
			cin >> key;
			if (find_node(key) != NULL) cout << "yes" << endl;
			else cout << "no" << endl;
		}
		else if (cmd == "delete") {
			int key;
			cin >> key;
			delete_node(key);
		}
		else {
			print_inorder(root_ptr);	cout << endl;
			print_preorder(root_ptr);	cout << endl;
		}
	}
}


Measured memory_bytes: 21868
#include<stdio.h>
int main(void){
	int a,b,c,z,i;
	scanf("%d %d %d",&a,&b,&c);
	for(i=0;i<6;i++)
	if(a>b){
			z=b,b=a,a=z,z=0;
			}
			if(a>c){
			z=c,c=a,a=z,z=0;}
			if(b>c){
			z=c,c=b,b=z,z=0;}
	printf("%d %d %d\n",a,b,c);
	return 0;}
	

Measured memory_bytes: 596
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	s := getString()

	a := 0
	b := 0
	for _, v := range s {
		if v == 'A' {
			a++
		} else {
			b++
		}
	}
	if a != 0 && b != 0 {
		out("Yes")
	} else {
		out("No")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll s,w;
	cin>>s>>w;
	if (w>=s)
		cout<<"unsafe";
	else
		cout<<"safe";
}

Measured memory_bytes: 3656
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

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

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


int main(){
  vl num(3);
  
  rep(i,3) cin >> num[i];
  
  sort(all(num)); reverse(all(num));
  
  cout << num[0]*10 + num[1] + num[2] << endl;
}

Measured memory_bytes: 256
/**
 *    author:  FromDihPout
 *    created: 2020-08-03
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    int i = 0;
    vector<vector<int>> grid(h, vector<int> (w));
    for (int r = 0; r < h; r++) {
        for (int c = 0; c < w; c++) {
            if (a[i] == 0)
                i++;
                
            if (r & 1) {
                grid[r][w-c-1] = i;
                a[i]--;
            }
            else {
                grid[r][c] = i;
                a[i]--;
            }
        }
    }
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << grid[i][j] + 1 << ' ';
        }
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		long count = 0;
		for (int i = 0; i < n + 1; i++) {
			a[i]=sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			b[i]=sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			int sub = Math.min(a[i],b[i]);
			b[i]-=sub;
			count += sub;
			sub = Math.min(a[i+1], b[i]);
			count += sub;
			a[i+1]-=sub;

		}
		System.out.println(count);
	}
}


Measured memory_bytes: 66260
N = gets.to_i

if N == 1
  puts 0
  exit
end

C = []
ans = 0

N.times do
  a, b = gets.split.map(&:to_i)

  ans += a

  if a > b
    C << b
  end
end

if C.empty?
  ans = 0
else
  ans -= C.min
end

puts ans



Measured memory_bytes: 1916
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
template <class T>
void print(const T &value)
{
	std::cout << value << std::endl;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}



int main()
{
	int n;
	cin>>n;
	vector<int>h(n);
	rep(i,n)cin>>h[i];
	vector<int>cost(n,1e9);
	cost[0]=0;
	rep(i,n){
		FOR(j,1,3){
			if(i-j>=0){
				cost[i]=min(cost[i],cost[i-j]+abs(h[i-j]-h[i]));
			}
		}
	//	cout<<cost[i]<<endl;
	}
	cout<<cost[n-1]<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-9;

typedef long long ll;

#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

char s1[12];
char s2[12];
char s3[12];
int main(int argc, char * argv[])
{
    ios::sync_with_stdio(false);
    cin >> s1 >> s2 >> s3;
    cout << (char)((int)s1[0] - 32);
    cout << (char)((int)s2[0] - 32);
    cout << (char)((int)s3[0] - 32);
    cout << endl;
    return 0;
}




Measured memory_bytes: 888
#include <cstdio>
#include <algorithm>
#define max_n 1000
using namespace std;
long long x[max_n+1],y[max_n+1],ton[33];
void solve(long long x,long long y,int sz){
	for(int i=sz; /*printf("\n*%d %d|\n",x,y),*/~--i; labs(x)>labs(y)?(x<0?(putchar('L'),x+=ton[i]):(putchar('R'),x-=ton[i])):(y<0?(putchar('D'),y+=ton[i]):(putchar('U'),y-=ton[i])));
    puts("");
}
int main(){
	int n,sz;
    bool flg[2]={0,0};
    scanf("%d",&n);
    for(int i=0; ++i<=n; flg[(x[i]+y[i])&1]=1)
    	scanf("%lld%lld",x+i,y+i);
    if(flg[0]&&flg[1]){
    	puts("-1");
		return 0;
    }
    if(flg[1]){
        printf("%d\n",sz=32);
        for (int i=sz; --i; printf("%lld ",ton[i]=1LL<<i));
        printf("%lld\n",ton[0]=1);
    }
	else{
        printf("%d\n",sz=33);
        for (int i=sz; --i; printf("%lld ",ton[i]=1LL<<(i-1)));
        printf("%lld\n",ton[0]=1);
    }
    for(int i=0; ++i<=n; solve(x[i],y[i],sz));
    return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  bool ok = true;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != T.at(i)) {
      ok = false;
      break;
    }
  }
  if (ok) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  

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

import sys
import os
import math
import re
import random

# copy of cima code
# to confirm system is working correctly

en='ABCDEFGHIJKLMNOPQRSTUVWXYZ'+' .,-\'?'
de={
'101':' ','000000':'\'','000011':',','10010001':'-','010001':'.','000001':'?',
'100101':'A','10011010':'B','0101':'C','0001':'D','110':'E','01001':'F',
'10011011':'G','010000':'H','0111':'I','10011000':'J','0110':'K','00100':'L',
'10011001':'M','10011110':'N','00101':'O','111':'P','10011111':'Q','1000':'R',
'00110':'S','00111':'T','10011100':'U','10011101':'V','000010':'W','10010010':'X',
'10010011':'Y','10010000':'Z'
}
while 1:
    try:s=input()
    except:break
    a=b=c=''
    for x in s:a+=str(bin(en.index(x)))[2:].zfill(5)
    for x in a:
        b+=x
        if b in de:c+=de[b];b=''
    print(c)

Measured memory_bytes: 11824
#include "bits/stdc++.h"
#include "sstream"
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=1e5+1;
const double EulerConstant = exp(-1);
int arr[N];
int main() {
        quick
int n,x; cin>>n;
for(int i=0;i<n;i++){
    cin>>x; arr[x-1]=i+1;
}
for(int  i=0;i<n;i++){
    if(i){cout<<" ";}
    cout<<arr[i];
}
}

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

void solve(string s){
    
    vector<vector<char>> v;
    vector<char> tmp;
    tmp.push_back('.');
    tmp.push_back(',');
    tmp.push_back('!');
    tmp.push_back('?');
    tmp.push_back(' ');
    v.push_back(tmp);
    tmp.clear();
    tmp.push_back('a');
    tmp.push_back('b');
    tmp.push_back('c');
    v.push_back(tmp);
    tmp.clear();
    tmp.push_back('d');
    tmp.push_back('e');
    tmp.push_back('f');
    v.push_back(tmp);
    tmp.clear();
    tmp.push_back('g');
    tmp.push_back('h');
    tmp.push_back('i');
    v.push_back(tmp);
    tmp.clear();
    tmp.push_back('j');
    tmp.push_back('k');
    tmp.push_back('l');
    v.push_back(tmp);
    tmp.clear();
    tmp.push_back('m');
    tmp.push_back('n');
    tmp.push_back('o');
    v.push_back(tmp);
    tmp.clear();
    tmp.push_back('p');
    tmp.push_back('q');
    tmp.push_back('r');
    tmp.push_back('s');
    v.push_back(tmp);
    tmp.clear();
    tmp.push_back('t');
    tmp.push_back('u');
    tmp.push_back('v');
    v.push_back(tmp);
    tmp.clear();
    tmp.push_back('w');
    tmp.push_back('x');
    tmp.push_back('y');
    tmp.push_back('z');
    v.push_back(tmp);
    tmp.clear();
    
    int t;
    for(auto itr=s.begin()+1;itr!=s.end();itr++){
        if(*itr=='0'){
            if(*(itr-1)!='0'){
                t=*(itr-1)-'0';
                int count=0;
                for(auto it=itr-1;*it!='0';it--){
                    count++;
                    if(it==s.begin()||*(it-1)=='0'){
                        break;
                    }
                }
                cout<<v[t-1][(count-1)%v[t-1].size()];
                
            }
        }
    }
    cout<<endl;
    
}


int main(void){
    int n;
    cin>>n;
    string s;
    for(int i=0;i<n;i++){
        cin>>s;
        solve(s);
    }
    
}

Measured memory_bytes: 3040
#include<stdio.h>
#include<stdlib.h>/*atoi(文字列から数値に変換)*/
#include<string.h>/*後で消す*/

int top, S[1000];

void push(int x){
	S[++top] =x;/*S[top++]はだめ*/
	/*++○→先に足して処理 ○++後に足して処理*/
}

int pop(){
	top--;/**/
	return S[top+1];
}

int main(){
	int a,b;
	top = 0;/*空っぽなので初期化しておく*/
	char s[100];/*キーボードからの入力用*/
	
	while(scanf("%s",s) != EOF){
		if(s[0] == '+'){
			a = pop();
			b = pop();
			push(a + b);
		}else if(s[0] == '-'){
		b = pop();
		a = pop();
		push(a-b);
		}else if(s[0] == '*'){
		a = pop();
		b = pop();
		push(a*b);
		}else{
			push(atoi(s));
		}
	}
	
	printf("%d\n",pop());
	
	return 0;
}


Measured memory_bytes: 2124
MOD = 10 ** 9 + 7
s = input()
n = len(s)
dp = [[0 for j in range(13)] for i in range(n + 1)]
dp[0][0] = 1
dpi = dp[0]
for i, si in enumerate(s):
    dpi1 = dp[i + 1]
    if si == '?':
        k_list = range(10)
    else:
        k_list = [int(si)]
    for j in range(13):
        xij = dpi[j]
        for k in k_list:
            dpi1[(j * 10 + k) % 13] += xij
    for j in range(13):
        dpi1[j] %= MOD
    dpi = dpi1
print(dp[-1][5])


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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007 
typedef vector<int> vi;
typedef long long int ll;

int main()
{
	int N;
	ll T;
	cin >> N >> T;
	vi D(N);
	vi DD(N);
	rep(i, 0, N) cin >> D[i];
	rep(i, 0, N) DD[i] = D[i];

	sort(D.begin(), D.end());
	sort(DD.begin(), DD.end(), greater<int>());

	ll ans = 1;
	rep(i, 0, N)
	{
		auto ite = upper_bound(D.begin(), D.end(), DD[i]+T);
		ll com = N - distance(D.begin(), ite);
		com = i - com + 1;

		ans = (ans * com) % MOD;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3584
package main

import (
	"fmt"
)

func main() {
	list := make([]int, 5)
	for i := range list {
		fmt.Scan(&list[i])
	}

	mini := 0
	mind := 9
	for i, v := range list {
		if v%10 == 0 {
			continue
		}
		if v%10 <= mind {
			mini = i
			mind = v % 10
		}
	}

	var sum int
	for i, v := range list {
		if i == mini || v%10 == 0 {
			sum += v
			continue
		}
		sum += v + 10 - v%10
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
<?php
    $NM = explode(" ",trim(fgets(STDIN)));
    $XN = explode(" ",trim(fgets(STDIN)));
    
    $N = $NM[0];
    $M = $NM[1];
    
    if ($N >= $M) {
        //0の場合
        echo 0;
    } else {
        //0以外の場合
        rsort($XN);
        
        for ($i = 0; $i < $M - 1; $i++) {
            $diff[] = $XN[$i] - $XN[$i + 1];
        }
        
        rsort($diff);
        $del = $N - 1;
        $diffEX = array_splice($diff, 0, $del);
        $output = array_sum($diffEX);
        echo array_sum($diff);

    }
?>


Measured memory_bytes: 37104
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*

 */
int n;
vector<int> ans;

int main(){
  cin>>n;
  if(n==0)
    cout<<0;
  
  while(n!=0){
    ans.push_back(abs(n%2));
    n = (n - abs(n%2)) / (-2);
    LOG("%d\n",n);
  }

  for(int i = ans.size()-1; i>=0; i--){
    cout<<ans[i];
  }

  cout<<endl;

  return 0;
}


Measured memory_bytes: 384
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

S=gets.chomp
if S=~/^YAKI.*$/
    puts "Yes"
else
    puts "No"
end

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

int main() {
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<vector<pair<unsigned long, unsigned long>>> x(N);
    for(auto& i : x){
        unsigned long a;
        cin >> a;
        i.resize(a);
        for(auto& j : i){
            cin >> j.first >> j.second;
            j.first--;
        }
    }
    unsigned long ans{0};
    for(unsigned long i = 0; i < 1UL << N; ++i){
        [&]{
            for(unsigned long j = 0; j < N; ++j){
                if(1 & (i >> j)){
                    for(const auto& k : x[j]){
                        if(k.second != (1 & (i >> k.first)))return;
                    }
                }
            }
            ans = max<unsigned long>(ans, __builtin_popcount(i));
        }();
    }
    cout << ans << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
s=input()
a=[]
b=0
w=0
for i in s:
  if i =='B':
    a.append(0)
    b+=1
  else:
    a.append(1)
    w+=1
A=len(a)
cnt=0
for i in range(A):
  if a[i]==1:
    cnt+=i
for i in range(w):
  cnt-=i
print(cnt)

Measured memory_bytes: 5096
a,z,u,i,j,d[9999][9];main(k){d[0][2]=scanf("%d ",&a);for(;i<a;i++){u=getchar()%4-1;for(j=8;j--;z+=d[a][j])for(k=8;k--;)d[i+1][j]+=j&k&&j>>u&1?d[i][k]%10007:0;}a=!printf("%d\n",z%10007);}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=605;
int n,m,u,v;
double dp[N],f[N],ans;
vector<int>E[N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i)
	{
		scanf("%d%d",&u,&v);
		E[u].push_back(v);
	}
	for(int i=n-1;i>=1;--i)
	{
		for(int v:E[i])
		{
			dp[i]+=dp[v]+1;
		}
		dp[i]/=E[i].size();
	}
	ans=dp[1];
	for(int i=n-1;i>=1;--i)
	{
		if(E[i].size()<=1)continue;
		double mx=0;
		for(int v:E[i])
		{
			mx=max(mx,dp[v]+1);
		}
		copy(dp+1,dp+n+1,f+1);
		f[i]=(f[i]*E[i].size()-mx)/(E[i].size()-1);
		for(int j=i-1;j>=1;--j)
		{
			f[j]=0;
			for(int v:E[j])
			{
				f[j]+=f[v]+1;
			}
			f[j]/=E[j].size();
		}
		ans=min(ans,f[1]);
	}
	printf("%.8lf\n",ans);
	return 0;
}


Measured memory_bytes: 1408
import java.io.PrintStream;
import java.util.Scanner;
public class Main {
    private static final PrintStream so = System.out;
    private static final Scanner     sc = new Scanner(System.in);

    public static void main(String[] args) {
        String s = sc.next() + sc.next() + sc.next() + sc.next();
        if (s.contains("1") && s.contains("9") && s.contains("7") && s.contains("4")) {
            so.println("YES");
        } else {
            so.println("NO");
        }
    }
}


Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string x;
    cin>>x;
    if((x[0]=='A'&&x[1]=='B')||(x[1]=='A'&&x[2]=='B')||(x[0]=='B'&&x[1]=='A')||(x[1]=='B'&&x[2]=='A'))
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
string S;
ll mo=1000000007;
vector<ll> C,R;
const int PAT=4;
vector<ll> A[PAT];
vector<ll> B[PAT];

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S;
	srand(time(NULL));
	FOR(i,PAT) {
		C.push_back(rand()%10000000+10000000);
		R.push_back(modpow(C.back()));
		A[i].push_back(1);
		B[i].push_back(0);
	}
	reverse(ALL(S));
	FORR(c,S) {
		FOR(i,PAT) {
			if(c=='+') {
				A[i].push_back(A[i].back());
				B[i].push_back((B[i].back()+1)%mo);
			}
			if(c=='-') {
				A[i].push_back(A[i].back());
				B[i].push_back((B[i].back()+mo-1)%mo);
			}
			if(c=='>') {
				A[i].push_back(A[i].back()*R[i]%mo);
				B[i].push_back(B[i].back()*R[i]%mo);
			}
			if(c=='<') {
				A[i].push_back(A[i].back()*C[i]%mo);
				B[i].push_back(B[i].back()*C[i]%mo);
			}
		}
	}
	ll ret=0;
	map<vector<ll>,int> memo;
	memo[vector<ll>(PAT,0)]++;
	FOR(j,N) {
		vector<ll> BA(PAT),BAS(PAT);
		FOR(i,PAT) {
			BA[i]=B[i][j+1]*modpow(A[i][j+1])%mo;
			BAS[i]=(B[i][j+1]+mo-B[i].back())*modpow(A[i][j+1])%mo;
		}
		ret+=memo[BAS];
		memo[BA]++;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 78656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  // 6,5,6,5,...
  ll x;
  cin >> x;

  ll ans = x / 11 * 2;
  ll r = x % 11;

  if (r > 0 && r <= 6) {
    ans++;
  } else if (r >= 7) {
    ans += 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
import itertools as it
import functools as ft

n,m = map(int, input().split())
xyz_l = []
for _ in range(n):
    x,y,z = map(int, input().split())
    xyz_l.append((x,y,z))

xyzs = np.array(xyz_l)

plus = lambda x, y : x + y
minus = lambda x, y : x - y

seed = (plus, minus)
pattern = np.array(list(it.product(seed,repeat=3)))

def map_pattern(p):
    reduce_func = lambda xs : ft.reduce((lambda t,k: k[0](t,k[1])), zip(p,xs), 0)
    bs = np.array(list(reversed(sorted(map(reduce_func, xyzs)))))
    return sum(bs[:m])

ans = np.max(np.array(list(map(map_pattern, pattern))))

print(ans)


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

typedef long long ll;

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

    ll x; cin >> x;
    ll ans = x / 11;
    ans *= 2;
    if(x%11!=0){
        if(x%11>6) ans += 2;
        else ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define forn(i,a,b) for (int i = a; i <= b; i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define pi pair <int, int>
#define sz(x) (int)((x).size())
#define int long long

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

const ll inf = 0x3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int N = (1 << 21) + 11;

int dp[N],pd[N],a[30][30],n,x;
//vector<int>v[N];

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

    cin >> n;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }

    dp[0] = 1;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){

            if(!a[i][j])continue;

            for(int mask = 0; mask < (1 << n); mask++){
                if(mask & (1 << j))continue;
                pd[mask | (1 << j)] += dp[mask];
                pd[mask | (1 << j)] %= mod;
            }
        }
        for(int mask = 0; mask < (1 << n); mask++) dp[mask] = pd[mask];
    }


    rc(dp[(1 << n)-1]);
return 0;
}


Measured memory_bytes: 33152
import java.util.*;
import java.io.*;
class Main{
    public static void main(String args[]){
	int r,l,m,n,q,i,j,count=0;
	int s[] = new int[1000000];
	int t[] = new int[1000000];
	Scanner scan = new Scanner(System.in);
	
	n = scan.nextInt();
	for(i=0;i<n;i++){
	    s[i] = scan.nextInt();
	}
	q = scan.nextInt();
	for(j=0;j<q;j++){
	    t[j] = scan.nextInt();
	}
	
	for(j=0;j<q;j++){
	    r = n;
	    l = 0;
	    m = n/2;
	    while(true){
		if(s[m]==t[j]){count++;break;}
		if(m==l){break;} 
		if(s[m]>t[j]){/*探す値が左側にあった場合*/
		    r = m;
		    m = (r+l)/2;
		}
		if(s[m]<t[j]){/*探す値が右側にあった場合*/
		    l = m+1;
		    m = (r+l)/2;
		}
		}
	}
	System.out.println(count);
    }
}



Measured memory_bytes: 95500
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

a,b,c =I()
k=k()

while cnt != k:
    if a >= b:
        b *= 2
    else:
        if b >= c:
            c *= 2
    cnt += 1

if a < b < c:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 10504
n, m = map(int, input().split())
conflicts = sorted((tuple(map(int, input().split())) for _ in range(m)), key=lambda tuple_: tuple_[1])

last_removed = conflicts[0][1]
bridge_removed = 1

for conflict in conflicts[1:]:
    if conflict[0] < last_removed and conflict[1] >= last_removed:
        continue
    else:
        last_removed = conflict[1]
        bridge_removed += 1

print(bridge_removed)


Measured memory_bytes: 18244
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout << endl
#define sp(x) cout << setprecision(x);
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w; cin >> h >> w;
	vs maze(h);
	rep(i, h)cin >> maze[i];
	vvl dp(h + 1, vl(w + 1, 0));
	rep(i, h)rep(j, w)
	{
		if (i == 0 && j == 0)dp[i + 1][j + 1] = 1;
		else if (maze[i][j] == '.')
		{
			dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1]) % mod;
		}
	}
	ll ans = dp[h][w];
	co(ans);
	return 0;
}


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

int main()
{
    int x;
    rep(i, 5)
    {
        cin >> x;
        if (x == 0)
        {
            cout << i + 1 << endl;
            return 0;
        }
    }
}

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

int main()
{
  double ans;
  int n, k;
  cin >> n >> k;
  for ( int i = 1; i <= n; i++ ) {
    ll x = (double)ceil((double)k/i*1.0);
    int exp = 0;
    ll tmp = 0;
    while ( tmp < x ) {
      tmp = (ll)pow(2,exp);
      exp++;
    }
    double temp1 = (1.0 / n);
    double temp2 = (long double)pow(0.5,exp-1);
    ans += temp1*temp2;
  }
  printf("%.15lf\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define maxn 100005
#define LL long long
#define tt 998244353
using namespace std;
LL ans;
int n,a[maxn],hsh[maxn];
inline char nc(){
	static char buf[100000],*L=buf,*R=buf;
	return L==R&&(R=(L=buf)+fread(buf,1,100000,stdin),L==R)?EOF:*L++;
}
inline int read(){
	int ret=0,f=1;char ch=nc();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=nc();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=nc();
	return ret*f;
}
inline LL qsm(int a,int b){
	LL s=1,w=a;
	while (b){
		if (b&1) s=s*w%tt;
		w=w*w%tt;
		b>>=1;
	}
	return s;
}
int main(){
	n=read();
	for (int i=1;i<=n;i++){
		a[i]=read();
		hsh[a[i]]++;
	}
	if (hsh[0]!=1||a[1]!=0){printf("0\n");return 0;}
	ans=1;
	for (int i=1;i<=n;i++)
	if (hsh[i]) ans=ans*qsm(hsh[i-1],hsh[i])%tt;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int maxv[1<<18][19],secv[1<<18][19];
int a[1<<18];
inline void assign(int sub,int mv,int val){
	if(maxv[sub][mv]==-1 || maxv[sub][mv]<=val){
		secv[sub][mv]=maxv[sub][mv];
		maxv[sub][mv]=val;
	}else if(secv[sub][mv]==-1 || secv[sub][mv]<val)
		secv[sub][mv]=val;
}
int main(){
	int n;
	scanf("%d",&n);
	int limt=1<<n;
	memset(maxv,-1,sizeof maxv);
	memset(secv,-1,sizeof secv);
	for(int i=0;i<limt;i++){
		scanf("%d",a+i);
		int sub=i;
		for(int j=0;j<=n;j++,sub>>=1)
			assign(sub,j,a[i]);
	}
	for(int mv=0;mv<=n;mv++)
		for(int i=0;i<n;i++)
			for(int sub=0;sub<limt;sub++)
				if((1<<i)&sub)
					assign(sub,mv,maxv[sub^(1<<i)][mv]);
	for(int k=1;k<limt;k++){
		int ans=maxv[k][0]+secv[k][0];
		for(int i=0;i<n;i++){
			if((1<<i)&k){
				int sub=(k>>i)^1;
				ans=max(ans,maxv[sub][i]+secv[sub][i]);
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 43008
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
using ll = long long int;

const ll INF = 1LL << 60;
const int L = 2010;
ll dp[L][L], num[L][L];

void update_dp(int nl, int nr, int pl, int pr, ll a) {
    if(dp[nl][nr] > dp[pl][pr] + a) {
        dp[nl][nr] = dp[pl][pr] + a;
        num[nl][nr] = num[pl][pr];
    }
    else if(dp[nl][nr] == dp[pl][pr] + a) {
        num[nl][nr] += num[pl][pr];
    }
    num[nl][nr] = min(num[nl][nr], INF);
}

int main() {
    string s; cin >> s;
    ll K; cin >> K;

    int N = s.size();
    fill(dp[0], dp[N+1], INF);
    for(int i=0; i<=N; i++) dp[i][i] = 0, num[i][i] = 1;
    for(int i=0; i<N; i++) dp[i][i+1] = 0, num[i][i+1] = 1;

    for(int d=2; d<=N; d++) {
        for(int l=0; l<=N-d; l++) {
            int r = l + d;
            if(s[l] == s[r-1]) {
                update_dp(l, r, l+1, r-1, 0);
            }
            else {
                update_dp(l, r, l+1, r, 1);
                update_dp(l, r, l, r-1, 1);
            }
        }
    }

    if(num[0][N] < K) {
        cout << "NONE" << endl;
        return 0;
    }
    
    int l = 0, r = N;
    string ans = "";

    while(r - l > 1) {
        if(s[l] == s[r-1]) {
            ans += s[l];
            l++; r--;
        }
        else if(dp[l+1][r] < dp[l][r-1]) {
            ans += s[l];
            l++;
        }
        else if(dp[l][r-1] < dp[l+1][r]) {
            ans += s[r-1];
            r--;
        }
        else if(s[l] < s[r-1]) {
            if(K <= num[l+1][r]) {
                ans += s[l];
                l++;
            }
            else {
                K -= num[l+1][r];
                ans += s[r-1];
                r--;
            }
        }
        else if(s[r-1] < s[l]) {
            if(K <= num[l][r-1]) {
                ans += s[r-1];
                r--;
            }
            else {
                K -= num[l][r-1];
                ans += s[l];
                l++;
            }
        }
    }
    
    string res = "";
    res += ans;
    if(r - l == 1) res += s[l];
    reverse(ans.begin(), ans.end()); res += ans;
    cout << res << endl;
}



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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

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

  ll ret = 2e10;
  if(H >= 3) {
    if(H % 3 == 0) ret = 0;
    else ret = min(ret, W);
  }
  if(W >= 3) {
    if(W % 3 == 0) ret = 0;
    else ret = min(ret, H);
  }
  for(int i = 1; i <= H - 1; ++i) {
    vector<ll> S(3);
    S[0] = i * W;
    S[1] = (H - i) * (W / 2);
    S[2] = (H - i) * W - S[1];
    sort(ALL(S));
    ret = min(ret, S[2] - S[0]);
  }
  for(int i = 1; i <= W - 1; ++i) {
    vector<ll> S(3);
    S[0] = i * H;
    S[1] = (W - i) * (H / 2);
    S[2] = (W - i) * H - S[1];
    sort(ALL(S));
    ret = min(ret, S[2] - S[0]);
  }
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 256
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N = int(input())
S = [input() for _ in range(N)]

s = set(S)
print(len(s))



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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

constexpr int inf = 1.01e9;
constexpr i64 inf64 = 4.01e18;
constexpr double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename A, typename T, size_t size>
void fill(A (&ary)[size], const T &val) {
    fill((T *)ary, (T *)(ary + size), val);
}

void solve() {
    //constexpr i64 mod = 1'000'000'007;
    i64 N;
    cin >> N;
    vector<i64> A(N);
    rep(i,0,N) cin >> A[i];
    
    vector<i64> l(N),r(N);
    l[0]=A[0];
    rep(i,1,N){
        l[i]=A[i];
        chmax(l[i],l[i-1]);
    }
    r[N-1]=A[N-1];
    for(i64 i=N-2; i>=0; --i){
        r[i]=A[i];
        chmax(r[i],r[i+1]);
    }
    
    rep(i,0,N){
        i64 ans=0;
        if(i>0) chmax(ans,l[i-1]);
        if(i+1<N) chmax(ans,r[i+1]);
        cout << ans << endl;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 7424
#include <iostream>

using namespace std;

#define INF 1e9

int dp[17][1 << 16];
int main() {
	int N;
	while (cin >> N, N) {
		int t[16][17];
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N+1; ++j) {
				cin >> t[i][j];
			}
		}

		fill(&dp[0][0], &dp[0][0]+17*(1<<16), INF);
		dp[0][0] = 0;
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < (1 << N); ++j) {
				for (int to = 0; to < N; ++to) {
					if ((j & (1 << to)) == 0) {
						int nj = j | (1 << to);
						int cost = t[to][0];
						for (int k = 0; k < N; ++k) {
							if (j & (1 << k)) cost = min(cost, t[to][k+1]);
						}
						dp[i+1][nj] = min(dp[i+1][nj], dp[i][j]+cost);
					}
				}
			}
		}
		cout << dp[N][(1 << N)-1] << endl;
	}
}

Measured memory_bytes: 5512
import java.io.*;

public class Main{
public static void main(String[] args){
	try{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String[] str = br.readLine().split(" ");
	int a = Integer.parseInt(str[0]);
	int b = Integer.parseInt(str[1]);

		if (a < b){
		System.out.println("a < b");
		}else if (a > b){
		System.out.println("a > b");
		}else{
		System.out.println("a == b");
		}
	}catch(IOException e){
	System.out.println(e);
	}
}
}

Measured memory_bytes: 16892
# sys.stdin.readline()
import sys
input = sys.stdin.readline

n = int(input())
S = [list(input().split()) for i in range(n)]
for i in range(n):
    S[i].append(i)
    S[i][1]= int(S[i][1])
S = sorted(S,key=lambda x:x[1],reverse=1)
S = sorted(S,key=lambda x:x[0])
for i in range(n):
    print(S[i][2]+1)

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

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    if ((int)count(s.begin(), s.end(), 'R')*2 > N) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
def solve():
    N = int(input())

    c = 0

    for A in range(1, N-1):
        B = 0
        ans = 0
        while ans<N:
            B += 1
            ans = A * B

            c += 1
        
        c -= 1
       # print(c)

    c += 1

    print(c)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 9176
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int mod = (int)1e9+7;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	vector<int> a(3);
	cin>>a[0]>>a[1]>>a[2];
	sort(a.begin(),a.end());
	if(a[0]==a[1] && a[1] != a[2]){
		cout<<"Yes";
	}
	else if(a[1]==a[2] && a[0] != a[1]){
		cout<<"Yes";
	}
	else cout<<"No";
	
	return 0;
}









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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    int i,n,k,now=1;
    sf(n);
    rep0(i,n)
    {
        sf(k);
        if(k==now)
            now++;
    }
    now--;
    if(!now)
        cout<<-1;
    else
        cout<<n-now;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        long sum = 0;
        
        int nl[] = new int[n];
        for (int i=0; i<n; i++) {
            nl[i] = sc.nextInt();
            sum = sum +nl[i];
        }
        
        Arrays.sort(nl);
        
        System.out.println(nl[0]+" "+nl[n-1]+" "+sum);
    }
    
}

Measured memory_bytes: 41648
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <list>
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 1;
    if (n % 2) cout << "No";
    else {
        for (int i = 0; i < n / 2; ++i) {
            if (s[i] != s[i + n / 2]) ans *= 0;
        }
        if (ans) cout << "Yes";
        else cout << "No";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
#include<cstdio>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;
int n ;
vector<int> G[MAX];
int color [MAX];
void dfs (int r,int c)
{
  stack<int> S;
  S.push(r);
  color[r] = c;
  while(!S.empty())
  {
    int u = S.top();
    S.pop();
    for(int i = 0;i<G[u].size();i++)
        {
          int v = G[u][i];
          if(color[v] == NIL)
          {
            color[v] = c;
            S.push(v);
          }
        }
  }
}
void ass()
{
  int id = 1;
  for(int i = 0;i<n;i++)
    color[i] = NIL;
  for(int u = 0;u<n;u++)
  {
    if(color[u] == NIL)
      dfs(u,id++);
  }
}
int main ()
{
  int s,t,m,q;
  cin>>n>>m;
  for(int i = 0;i<m;i++)
    {
      cin>>s>>t;
      G[s].push_back(t);
      G[t].push_back(s);
    }
  ass();
  cin>>q;
  for(int i = 0;i<q;i++)
  {
    cin>>s>>t;
    if(color[s] == color[t])
    {
      cout<<"yes"<<endl;
    }
    else cout<<"no"<<endl;
  }
  return 0 ;
}



Measured memory_bytes: 8972
#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 ll long long
#define ld long double
typedef vector <ll> vi;                 // Vector of long long
typedef vector <vi> vvi;                // Vector of vi
typedef vector <pair<ll,ll>> ii;        // Vector of pairs
#define ff first                        // For pairs
#define ss second                       // For pairs
#define sz(a) int((a).size())           // Function to determine size of any container
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define MAXV (ll)(1e5 + 5)
#define INF (ll)(1e12)

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

    ll n, w;
    cin >> n >> w;

    ll mg[n], val[n];
    for (int i = 0; i < n; i++)
        cin >> mg[i] >> val[i];

    ll dp[n + 1][MAXV];

    for (int i = 1; i < MAXV; i++)
        dp[0][i] = INF;
    dp[0][0] = 0;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < MAXV; j++)
        {
            ll ans = INF;
            if (j - val[i - 1] >= 0)
                ans = dp[i - 1][j - val[i - 1]] + mg[i - 1];
            ans = min(ans, dp[i - 1][j]);

            dp[i][j] = ans;
        }
    }

    /* for (int i = 0; i <= n; i++)
        for (int j = 0; j < MAX; j++)
            cout << dp[i][j] << " \n"[j == MAX - 1]; */

    for (int i = MAXV - 1; i >= 0; i--)
    {
        if (dp[n][i] <= w)
        {
            cout << i << "\n";
            break;
        }
    }
}


Measured memory_bytes: 79232
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MOD 1000000007
#define LL long long
#define maxn 100100
using namespace std;
int n, m;
LL A[maxn];
int main() {
	memset(A, 0, sizeof(A));
	A[0] = 1;
	for(int i = 1; i < maxn; i++) A[i] = (A[i - 1] * i) % MOD;
	while(~scanf("%d%d", &n, &m)) {
		if(m < n - 1 || m > n + 1) {
			puts("0");
		}
		else {
			LL ans;
			if(m == n - 1 || m == n + 1) {
				ans = (A[n] * A[m]) % MOD;
			}
			else {
				ans = (((A[n] * A[m]) % MOD) * 2) % MOD;
			}
			printf("%lld\n", ans);
		}
	}
	return 0;
} 

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

int main(){
  int a,b;
  cin >> a >> b;
  
  int per8,per10;
  
  for(int i=0; i<=1000; i++){
    per8  = 8*i/100;
    per10 = i/10;
    
    if(per8==a && per10==b){
      cout << i << endl;
      return 0;
    }
  }
  
  cout << -1 << endl;
  
  return 0;
}

Measured memory_bytes: 256