akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
vector<int> to[200010];
bool ok;
int n,m;
void solve(){
    queue<pair<int,int>> que;
    que.push({0,0});
    int cnt = 0;
    while(1){
        auto now = que.front();
        que.pop();
        if(now.second == 2) break;
        for(auto u : to[now.first]){
            if(u == n-1){
                ok = 1;
                break;
            }
            que.push({u,now.second+1});
        }
    }
}
int main(){
    cout << fixed << setprecision(10);
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ok = 0;
    solve();
    if(ok) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 12784
N, K = list(map(int, input().split()))

if K==0:
    print(N*N)
    exit(0)

ans = 0
for b in range(K+1, N+1):
    #print(b, (b-K)*(N//b))
    ans += (b-K)*(N//b)
    if N%b>=K:
        ans += N%b - K + 1

print(ans)


Measured memory_bytes: 2940
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <unordered_set>
using namespace std;

string S;

int main() {
	cin >> S;
	int n = S.size();
	for (int i = 0; i < n; i++)
		for (int j = 0; j < i; j++)
			if (S[j] == 'C' && S[i] == 'F') {
				printf("Yes\n");
				return 0;
			}
	printf("No\n");
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))

mod=1000000007
S=0
sl=0

for i in range (N):
    sl+=A[i]
    sl%=mod
    
for j in range(N):
    sl-=A[j]
    if sl<0:
        sl+=mod
    S+=A[j]*sl
    S=S%mod

print(S)


Measured memory_bytes: 31412
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ld pi=3.14159265358979323846;
 
int main() {
    ll n;
    cin>>n;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    vector<ll> x(n);
    rep(i,n) x[i]=v[i];
    sort(all(x));
    ll max=x[n-1],max_sec=x[n-2];
    rep(i,n){
        if (v[i]==max){
            cout<<max_sec<<endl;
        }
        else{
            cout<<max<<endl;
        }
    }

}

Measured memory_bytes: 6424
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;

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

  long long ans = 0;
  for (int b = 1; b <= 31; ++b) {
    for (int p = 2; p <= 31; ++p) {
      const long long n = pow(b, p);
      if (n > X) break;
      ans = max(ans, n);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S, T, answer;
  int N;
  cin >> N;
  cin >> S >> T;
  for(int i=0; i<N; i++){
    answer += S.at(i);
    answer += T.at(i);
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll inf=1e9+7;

ll mult(ll n,ll m){//n^m%infを求める
    if(m==1){
        return n%inf;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%inf;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%inf;
    }
}

typedef pair<int,int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    s[3]='8';
    cout<<s<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long X = sc.nextLong();
		long money = 100L;
		long count = 0L;

		for (; ;) {
			count += 1;
			money *= 1.01;

			if (money >= X) {
				break;
			}
		}

		System.out.println(count);
	}

}


Measured memory_bytes: 35780
/**
*    created: 01.07.2020 23:36:22
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int MOD = 1000000007;
// const int MOD = 998244353;
const long double pi = acos(-1.0);
const int INF = 1LL << 60;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;
    if ((a*b) % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
using namespace std;
using ll = long long;
using graph = std::vector<std::vector<long long>>;
int main(){
    string S;
    cin >> S;
    int count = 0;
    int cost = 0;
    for (int i = 0; i < S.size(); ++i) {
        if(S[i] == 'S'){
            count++;
        }else{
            if(count > 0){
                cost++;
                count--;
            }
        }
    }
    cout << S.size() - 2 * cost << endl;
}

Measured memory_bytes: 640
/*input
3000
*/

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
 
using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define tests int t; cin >> t; while(t--)
#define MP make_pair
#define PI acos(-1)
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
#define godspeed ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() {
	godspeed;
	int N;
	cin >> N;
	cout << (1000 - (N%1000))%1000 << endl;
}

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

struct data{
    char name;
    int win, lose;
    data(char n, int w, int l) : name(n), win(w), lose(l) {}
    bool operator<(const data other) const{
        if(win != other.win)    return win < other.win;
        else                    return lose > other.lose;
    }
};

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

        if(n == 0)  break;

        vector<data> result;
        char t;
        int r;

        for(int i = 0; i < n; i++){
            cin >> t;
            int w = 0, l = 0;
            for(int j = 0; j < n-1; j++){
                cin >> r;
                if(r == 0)  w++;
                if(r == 1)  l++;
            }
            result.push_back(data(t, w, l));
        }

        sort(result.rbegin(), result.rend());

        for(data d : result)    cout << d.name << endl;
    }
    return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL) x=x->left;
  return x;
}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key) return u;
  if(k<u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
  if(x->right!=NIL) return treeMinimum(x->right);

  root=x->parent;

  while(root!=NIL && x==root->right){
    x=root;
    root=root->parent;
}

  return root;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left==NIL || z->right==NIL) y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL) x=y->left;
  else x=y->right;

  if(x!=NIL) x->parent=y->parent;

  if(y->parent==NIL) root=x;
  else if(y==y->parent->left) y->parent->left=x;
  else y->parent->right=x;

  if(y!=z) z->key=y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){

    y=x;

    if(z->key<x->key) x=x->left;
    else x=x->right;
  }

    z->parent=y;

  if(y==NIL) root=z;
  else if(z->key<y->key) y->left=z;
  else y->right=z;

}


void inorder(Node u){
  if(u==NIL) return;

  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return;

  printf(" %d",u->key); 
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19360
n=int(input())
a1=list(map(int, input().split()))
a2=list(map(int, input().split()))
maxanswer=0

for i in range(0, n):
    answer=0
    for j in range(0,i+1):
        answer+=a1[j]
    for k in range(i,n):
        answer+=a2[k]
    if answer>maxanswer:
        maxanswer=answer
print(maxanswer)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
void chmin(LL& a, LL b) {
	a = min(a, b);
}
//////////////

LL cal(LL Cx, LL Cy, LL X, LL Y, LL Hxy) {
	LL len = abs(Cx - X) + abs(Cy - Y);
	LL ans = Hxy + len;
	return ans;
}

LL f(LL Cx, LL Cy, LL H, LL X, LL Y) {
	LL ret = max(H - abs(Cx - X) - abs(Cy - Y), (LL)0);
	return ret;
}
void solve() {
	int N;
	cin >> N;
	vector < LL> X(N), Y(N), H(N);

	for (int i = 0; i < N; ++i) {
		cin >> X[i] >> Y[i] >> H[i];
	}

	for (int Cx = 0; Cx <= 100; ++Cx) {
		for (int Cy = 0; Cy <= 100; ++Cy) {
			LL now = -1;
			bool flag = true;
			for (int i = 0; i < N; ++i) {
				if (H[i] == 0)continue;

				LL res = cal(Cx, Cy, X[i], Y[i], H[i]);
				if (now == -1) {
					now = res;
				}
				else if (now != res) {
					flag = false;
					break;
				}
			}
			if (flag) {
				bool OK = true;
				for (int i = 0; i < N; ++i) {
					LL res = f(Cx, Cy, now, X[i], Y[i]);
					if (res != H[i]) {
						OK = false;
						break;
					}
				}
				if (OK) {
					cout << Cx << " " << Cy << " " << now << endl;
					return;
				}
			}
		}
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n, x, y;
	cin >> n >> x >> y;
	vector<int> bin(n, 0);

	for(int i = 1; i <= n - 1; ++i)
	{
		for(int j = i + 1; j <= n; ++j)
		{
			int w_straight = j - i;

			int w_curve = min( (abs(i - x) + abs(j - y) + 1),
							 (abs(i - y) + abs(j - x) + 1) );

			bin[ min(w_straight, w_curve) ]++;
		}
	}

	for(int i = 1; i < n; ++i)
	{
		cout << bin[i] << endl;
	}
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

int prob[4] = {1,-1,4,-4};
queue<string> que;
map<string,int> memo;

void bfs () {
  que.push("01234567");
   
  while ( !que.empty() ) {
    string tmp;
    tmp = que.front(); que.pop();

    int zero;
    for ( int i = 0; i < 8; i++ ) {
      if ( tmp[i] == '0' ) zero = i;
    }

    int next;
    for ( int i = 0; i < 4; i++ ) {
      string tmp2 = tmp;     
      next = prob[i]+zero;
      if ( next >= 0 && next <= 7 && 
	!( ( zero == 3 && next == 4 ) || ( zero == 4 && next == 3 ) ) ) {

	swap(tmp2[zero],tmp2[next]);
	if ( !memo[tmp2] ) {
	  que.push(tmp2);
	  memo[tmp2] = memo[tmp] + 1;
	}
      }
    }

  }

}

int main() {
  char ch;
  bfs();
  while ( cin >> ch ) {
    string str = "";
    str += ch;
    for ( int i = 0; i < 7; i++ ) {
      cin >> ch;
      str += ch;
    }
    // cout << str << endl;
    if ( str == "01234567" ) cout << 0 << endl;
    else cout << memo[str] << endl;
  }
  
  return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9+1)
#define MAXX (int)1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (ll)(1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
//printf("myco\n");//for debug
/*--------------------------------------------*/
int main(){
    int n;cin>>n;
    V d(n);rep(i,n)cin>>d[i];
    int l=n/2-1;
    int r=l+1;
    sort(ALL(d));
    int ans=d[r]-d[l];
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
    int N;
    scanf("%d", &N);

    int A0;
    scanf("%d", &A0);

    int res = A0;
    int Ap = A0;
    for(int ni=1; ni<N-1; ni++){
        int A;
        scanf("%d", &A);
        res += A < Ap ? A : Ap;
        Ap = A;
    }
    res += Ap;

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

    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    a = []
    b = []
    a.append(list(map(int, input().split())))
    a.append(list(map(int, input().split())))
    a.append(list(map(int, input().split())))
    n = int(input().strip())
    for i in range(n):
        b.append(int(input().strip()))

    n_to_k = {}
    for i in range(3):
        for j in range(3):
            n_to_k[a[i][j]] = (i, j)

    board = set()
    for i in b:
        if i not in n_to_k:
            continue
        board.add(n_to_k[i])

    # check
    for i in range(3):
        if (i, 0) in board and (i, 1) in board and (i, 2) in board:
            print("Yes")
            return
        if (0, i) in board and (1, i) in board and (2, i) in board:
            print("Yes")
            return
    if (0, 0) in board and (1, 1) in board and (2, 2) in board:
        print("Yes")
        return
    if (2, 0) in board and (1, 1) in board and (0, 2) in board:
        print("Yes")
        return

    print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, ll> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

vector<P> v;

int n;
ll p[225816],q[225816];

int main(void){
	int i,x,y,a,b,m,j;
	ll ans=INFLL,c;
	fill(p,p+225816,INFLL);
	fill(q,q+225816,INFLL);
	cin >> n >> y >> x;
	for(i=0; i<n; ++i){
		cin >> a >> b >> c;
		v.push_back(P(a*x-b*y,c));
	}
	if(n==1){
		cout << ((v[0].first)?(-1ll):v[0].second) << endl;
		return 0;
	}
	m = (1<<(n/2));
	for(i=1; i<m; ++i){
		a = 0; c = 0;
		for(j=0; j<(n/2); ++j){
			if(i&(1<<j)){
				a += v[j].first;
				c += v[j].second;
			}
		}
		if(a){
			p[a+111111] = min(p[a+111111],c);
		}else{
			ans = min(c,ans);
		}
	}
	m = (1<<(n-n/2));
	for(i=1; i<m; ++i){
		a = 0; c = 0;
		for(j=(n/2); j<n; ++j){
			if(i&(1<<(j-n/2))){
				a += v[j].first;
				c += v[j].second;
			}
		}
		if(a){
			q[a+111111] = min(q[a+111111],c);
		}else{
			ans = min(c,ans);
		}
	}
	for(i=0; i<=222222; ++i){
		ans = min(ans,p[i]+q[222222-i]);
	}
	cout << ((ans==INFLL)?-1:ans) << endl;
	return 0;
}


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

int main() {
 UL N;scanf("%u",&N);
 int A[1000]; rep(i,N) scanf("%d",&A[i]);
 UL Q; scanf("%d",&Q);
 rep(q,Q){
  UL s,t; scanf("%u%u", &s,&t);
  reverse(A+s,A+t);
 }
 rep(i,N) {if(i)printf(" "); printf("%d",A[i]);}
 printf("\n");
 return 0;
}




Measured memory_bytes: 3188
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var S string
	fmt.Scanf("%s", &S)

	s1, _ := strconv.Atoi(S[:2])
	s2, _ := strconv.Atoi(S[2:])

	fmt.Println(format(s1, s2))
}

func format(a, b int) string {
	if a > 12 && b > 12 || (a == 0 && b == 0) {
		return "NA"
	}
	if (a == 0 || b == 0) && (a > 12 || b > 12) {
		return "NA"
	}
	if (a <= 12 && b <= 12) && (a != 0 && b != 0) {
		return "AMBIGUOUS"
	}
	if a <= 12 && a != 0 {
		return "MMYY"
	}
	if b <= 12 {
		return "YYMM"
	}
	return "NA"
}

Measured memory_bytes: 512
#include<stdio.h>

int main(void) {
    int r,g,b;
    scanf("%d%d%d",&r,&g,&b);
    int result = 100*r+10*g+b;
    if (result%4 == 0) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
}


Measured memory_bytes: 128
using System;
class Program
{
    static void Main(string[] args)
    {
        // 整数の入力
        int X = int.Parse(Console.ReadLine());
        int M = 0;

        if (400 <= X && X < 600) M = 8;
        else if (600 <= X && X < 800) M = 7;
        else if (800 <= X && X < 1000) M = 6;
        else if (1000 <= X && X < 1200) M = 5;
        else if (1200 <= X && X < 1400) M = 4;
        else if (1400 <= X && X < 1600) M = 3;
        else if (1600 <= X && X < 1800) M = 2;
        else if (1800 <= X && X < 2000) M = 1;

        //出力
        Console.WriteLine(M);
    }
}

Measured memory_bytes: 27480
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my ($w, $h, $n) = split / /, <STDIN>);
my (@x, @y, @a, $w0, $h0);
for my $i (0..$n-1) {
  chomp (my $in = <STDIN>);
  my @c = split ' ', $in;
  $x[$i] = $c[0];
  $y[$i] = $c[1];
  $a[$i] = $c[2];
}
for my $i (0..$n-1) {
  if ($a[$i] == 1) {
    $w0 = $x[$i] if $w0 < $x[$i];
  } elsif ($a[$i] == 2) {
    $w = $x[$i] if $w > $x[$i];
  } elsif ($a[$i] == 3) {
    $h0 = $y[$i] if $h0 < $y[$i];
  } elsif ($a[$i] == 4) {
    $h = $y[$i] if $h > $y[$i];
  }
}
if (($w - $w0) <= 0 || ($h - $h0) <= 0) {
  say 0;
} else {
  say (($w - $w0) * ($h - $h0));
}

Measured memory_bytes: 896
// ABC101B - Digit Sums

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

// n 各桁の和を返す関数
int SumOfDigits(int n) {
	int ans = 0;

	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}

	return ans;
}

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

	if (N % SumOfDigits(N) == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


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


int main() {
	
	int N;
	cin >> N;
	for(int i=1; i<=9; i++){
		if(i*111>=N){
			cout << i*111 <<endl;
			break;
		}
	}
	
	
	return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

bool compare_by_a(tuple<ll, ll, ll> a, tuple<ll, ll, ll> b) {
    return get<2>(a) > get<2>(b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<tuple<ll, ll, ll> > t(N);
    
    REP(i, N){
        ll x, y, h;
        cin >> x >> y >> h;
        get<0>(t[i]) = x;
        get<1>(t[i]) = y;
        get<2>(t[i]) = h;
    }

    sort(t.begin(), t.end(), compare_by_a);

    // REP(i, N){
    //     cout << get<0>(t[i]) << " " << get<1>(t[i]) << " " << get<2>(t[i]) << endl;
    // }

    for(ll xi=0; xi<=100; xi++){
        for(ll yi=0; yi<=100; yi++){
            ll H = 0;
            for(ll i=0; i<N; i++){
                if(i==0){
                    H = get<2>(t[i]) + abs(get<0>(t[i]) - xi) + abs(get<1>(t[i]) - yi);
                }
                else{
                    if(get<2>(t[i]) > 0){
                        ll temp;
                        temp = get<2>(t[i]) + abs(get<0>(t[i]) - xi) + abs(get<1>(t[i]) - yi);
                        if(temp != H) break;
                    }
                    else{
                        ll temp;
                        temp = get<2>(t[i]) + abs(get<0>(t[i]) - xi) + abs(get<1>(t[i]) - yi);
                        if(H > temp) break;
                    }
                }
                if(i== N-1){
                    cout << xi << " " << yi << " " << H << endl;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
num_list = list(map(int, input().split())) + [-1]


cnt = 0
ret = 0


for i in range(n+1):
    num = num_list[i]
    if num == i+1:
        cnt += 1
    else:
        if cnt:
            ret += (cnt+1) // 2
            cnt = 0


print(ret)

Measured memory_bytes: 53036
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  int D, M, ans = 0, check = 0, count = 0 ;
  int C[27] ;
  cin >> D ;
  int S[27][D+1], choice[D+1] = {}, history[27] = {} ;
  for(int i=1;i<27;i++) cin >> C[i] ;
  for(int i=1;i<(D+1);i++){
    for(int j=1;j<27;j++){
      cin >> S[j][i] ;
    }
  }
  for(int date=1;date<(D+1);date++){
    cin >> choice[date] ;
    history[choice[date]] = date ;
    ans += S[choice[date]][date] ;
    for(int i=1;i<27;i++){
      ans -= C[i] * ( date - history[i]) ;
    }
  }
  cin >> M ;
  int qdate[M], qplay[M] ;
  for(int que=0;que<M;que++){
    cin >> qdate[que] >> qplay[que] ;
  }
  for(int que=0;que<M;que++){
    choice[qdate[que]] = qplay[que] ;
    ans = 0 ;
    for(int i=1;i<27;i++){
      history[i] = 0 ;
    }
    for(int date=1;date<(D+1);date++){
      history[choice[date]] = date ;
      ans += S[choice[date]][date] ;
      for(int i=1;i<27;i++){
        ans -= C[i] * ( date - history[i]) ;
      }
    }
    cout << ans << endl ;
  }
  return 0 ;
}  

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

ll power(ll a,ll b,ll mod){
    return b?power(a*a%mod,b/2,mod)*(b%2?a:1)%mod:1;
}

ll cal(ll n){
    ll cnt=1;
    while(n){
        n=n%__builtin_popcount(n);
        cnt++;
    }
    return cnt;
}

int main(){
    int n;cin>>n;
    string x;cin>>x;
    ll ans1=0,ans2=0,cnt=0,ans;
    for(int i=0;i<n;i++){
        if(x[i]=='1')
            cnt++;
    }
    if(cnt>1){
        for(int i=0;i<n;i++)
            if(x[i]=='1'){
            ans1=(ans1+power(2,n-i-1,cnt+1))%(cnt+1),ans2=(ans2+power(2,n-i-1,cnt-1))%(cnt-1);
        }
        for(int i=0;i<n;i++){
            if(x[i]=='1'){
                ans=(ans2+((cnt-1)-power(2,n-i-1,cnt-1)%(cnt-1))%(cnt-1))%(cnt-1);

                cout<<cal(ans)<<endl;
            }
            else{
                    //cout<<ans1;
                ans=(ans1+power(2,n-i-1,cnt+1)%(cnt+1))%(cnt+1);
                //cout<<' '<<ans<<endl;
                cout<<cal(ans)<<endl;
            }
        }
    }
    else if(cnt){
        for(int i=0;i<n;i++)
            if(x[i]=='1')
                ans1=power(2,n-i-1,cnt+1)%(cnt+1);
        for(int i=0;i<n;i++){
            if(x[i]=='0'){
            ans=(ans1+power(2,n-i-1,cnt+1)%(cnt+1))%(cnt+1);
            cout<<cal(ans)<<endl;
            }
            else{
                cout<<'0'<<endl;
            }
        }
    }
    else{
        for(int i=0;i<n;i++)
            cout<<'1'<<endl;
    }
    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define MAX 128
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
#define int long long
const double PI = 3.141593;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double EPS = 1e-9;
template <class T>
bool chmax(T &a, const T &b){if (a < b){a = b;return 1;}return 0;}
template <class T>bool chmin(T &a, const T &b){if (b < a){a = b;return 1;}return 0;}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }     //最小公倍数
ll combination(ll n, ll r){if (r * 2 > n)r = n - r;ll dividend = 1;ll divisor = 1;for (ll i = 1; i <= r; ++i){dividend *= (n - i + 1);divisor *= i;}return dividend / divisor;}


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

    double r;
    cin >> r;
    cout << 2*r * PI << endl;

    return 0;
}

Measured memory_bytes: 3760
#include <stdio.h>
int main()
{
    int  i, j = 0;
    long long int num = 0, sum, b[201001] = {0},a[201001],n;
    scanf("%lld", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
        b[a[i]]++;
        if (j < a[i])
        {
            j = a[i];
        }
    }
    for (i = 0; i <= j; i++)
    {
        num += b[i] * (b[i] - 1) / 2;
    }
    for (i = 0; i < n; i++)
    {
        sum = (b[a[i]] * (b[a[i]] - 1) / 2) - ((b[a[i]] - 1) * (b[a[i]] - 2) / 2);
        printf("%lld\n", num - sum);
    }
    return 0;
}

Measured memory_bytes: 5632
def distance p1, p2
  (p1[:x] - p2[:x]).abs + (p1[:y] - p2[:y]).abs
end

N = STDIN.gets.chomp.to_i
xyh = N.times.map do 
  data = STDIN.gets.chomp.split(" ").map(&:to_i)
  {:x => data[0], :y => data[1], :h => data[2]}
end
non_zero_xyh = xyh.select{|item| item[:h] > 0}.first

result = nil
(0..100).each do |cx|
  (0..100).each do |cy|
    center = {:x => cx, :y => cy}
    dist = distance(center, non_zero_xyh)
    center[:h] = non_zero_xyh[:h] + dist

    if xyh.all?{|item| [center[:h] - distance(item, center), 0].max == item[:h]}
      result = center
      break
    end
  end

  break unless result.nil?
end

puts "#{result[:x]} #{result[:y]} #{result[:h]}"


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
const ll INF = 1e10;

int main() {
    int n,m; cin >> n >> m;
    vector<vector<int>> dist(n,vector<int>(n,1));
    for (int i = 0; i < m; i ++) {
        int a,b; cin >> a >> b;
        a --; b --;
        dist[a][b] = 0;
        dist[b][a] = 0;
    }
    
    vector<int> list(n - 1);
    for (int i = 0 ; i < n - 1; i ++) {
        list[i] = i + 1;
    }
    
    int cnt = 0;
    do {
        bool flag = true;
        if (dist[0][list[0]]) continue;
        for (int i = 0; i < n - 2; i ++) {
            if (dist[list[i]][list[i + 1]]) {
                flag = false;
                break;
            }
        }
        if (flag) cnt ++;

    }while(next_permutation(list.begin(),list.end()));

    cout << cnt << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int n;
    cin>>n;
    set<int> a;
    rep(i,n){
        int c;
        cin>>c;
        a.emplace(c);
    }
    cout<<a.size()<<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

Measured memory_bytes: 888
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n,m ;
	cin >> n >> m ;
	vector<pair<pll,ll>> a(m) ;
	for(int i=0;i<m;i++){
		cin >> a.at(i).first.first >> a.at(i).first.second ;
		a.at(i).second = i ;
	}
	sort(all(a)) ;
	ll pre = -1 ;
	for(int i=0;i<m;i++){
		if(a.at(i).first.first!=pre){
			a.at(i).first.second = 1 ;
		}else{
			a.at(i).first.second = a.at(i-1).first.second+1 ;
		}
		pre = a.at(i).first.first ;
	}
	for(int i=0;i<m;i++){
		swap(a.at(i).first.first,a.at(i).second) ;
	}
	sort(all(a)) ;
	for(int i=0;i<m;i++){
		string s = to_string(a.at(i).second) ;
		string t = to_string(a.at(i).first.second) ;
		for(int i=0;i<6-s.size();i++) cout << 0 ; cout << s ;
		for(int i=0;i<6-t.size();i++) cout << 0 ; cout << t ;
		cout << endl ;
	}
}


Measured memory_bytes: 3840
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		int g,r;

		Scanner scan = new Scanner(System.in);

		while(true)
		{
			boolean bool=false;

			g = scan.nextInt();
			r = scan.nextInt();

			if( (g|r) == 0) break;

			for(int i=0; i<g; i++)
			{
				for(int j=0; j<r; j++)
				{
					if(!bool) System.out.print("#");
					else System.out.print(".");

					bool = !bool;
				}

				System.out.println();

				if(r%2 == 0) bool = !bool;
			}

			System.out.println();

		}

		scan.close();

	}
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

int32_t main() {
    IOS;
    string s, t;
    cin>>s>>t;
    bool isPossible = t.length() - s.length() == 1 ? true : false;

    loop(i, s.length()) {
        if (s[i]!=t[i]) isPossible = false;
    }

    if (!isPossible) {
        cout<<"No\n";
    } else {
        cout<<"Yes\n";
    }

    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int x,y,n,x2,y2,a;
    while(cin >> x >> y >> n)
    {
        int xl = 0,yl = 0,xr = x,yr = y;
        while(n--)
        {
            cin >> x2 >> y2 >> a;
            if(a == 1)
            xl = max(xl,x2);
            else if(a == 2)
            xr = min(xr,x2);
            else if(a == 3)
            yl = max(yl,y2);
            else
            yr = min(yr,y2);
        }
        int xe = xr - xl < 0 ? 0 : xr - xl;
        int ye = yr - yl < 0 ? 0 : yr - yl;
        cout << xe * ye << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as V
import Data.Array.IArray (listArray, accumArray, (!))
import Data.Array.MArray
import Data.Array.ST (STUArray, runSTUArray)
import Data.Array.Unboxed (UArray)
import Data.List (sortOn, sortBy, unfoldr, partition)
import Data.Char (isSpace)
import Control.Monad.ST (ST)
import Control.Monad.Trans.State (StateT(..))
import Control.Arrow ((***), second)
import qualified Data.ByteString.Char8 as B

-- utility functions

--   Input functions
readInt = B.readInt . B.dropWhile isSpace

readInts :: Int -> B.ByteString -> [Int]
readInts n = take n . unfoldr readInt

readIntsV :: Int -> B.ByteString -> V.Vector Int
readIntsV n = V.unfoldrN n readInt

readIntsA :: Int -> B.ByteString -> UArray Int Int
readIntsA n bs = runSTUArray $ do
  arr <- newArray_ (0,n-1)
  go arr 0 bs
  return arr
  where
    go :: STUArray s Int Int -> Int -> B.ByteString -> ST s ()
    go arr i bs
      | i==n = return ()
      | otherwise = do
        let Just (x,bs') = readInt bs
        writeArray arr i x
        go arr (i+1) bs'

readTsV :: Int -> B.ByteString -> V.Vector (Int,Int)
readTsV n = V.unfoldrN n $ runStateT ((,) <$> StateT readInt <*> StateT readInt)

readTs :: Int -> B.ByteString -> [(Int,Int)]
readTs n = take n . unfoldr readT where
  readT = runStateT ((,) <$> StateT readInt <*> StateT readInt)

-- main

ceildiv x y = (x + (y-1)) `div` y

main = do
  [n,k] <- map read . words <$> getLine
  print $ ceildiv (n-1) (k-1)


Measured memory_bytes: 508
#include <iostream>
using namespace std;
template <class T> inline bool chmax(T& a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  string s;
  cin >> s;
  char cc = s[0];
  int count = 1;
  int ans = 0;
  for(int i = 1; i < s.size(); ++i) {
    if(cc == s[i]) {
      count++;
    } else {
      count = 1;
    }
    chmax(ans, count);
    cc = s[i];
  }
  // cout << ans << endl;
  if(ans >= 3) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
#include <limits.h>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;

// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}

struct ReferenceBook {
	int price;
	vector<ll> understandings;

	bool isUnderstandOK(ll understand) {
		for (auto itr = understandings.begin(); itr != understandings.end(); ++itr) {
			if (*itr < understand)	return false;
		}

		return true;
	}
	void Print() {
		cout << price << endl;
	}
};

ll ansPrice = LLONG_MAX;

void func(ll index, const vector<ReferenceBook>& referenceBooks, ReferenceBook& ans, ll understand) {

	if (ans.isUnderstandOK(understand)) {
		//ans.Print();
		if (ansPrice > ans.price) {
			ansPrice = ans.price;
		}
		return;
	}
	if (index >= referenceBooks.size())	return;

	func(index + 1, referenceBooks, ans, understand);

	auto tmpAns = ans;
	tmpAns.price += referenceBooks[index].price;
	for (int i = 0; i < referenceBooks[index].understandings.size(); ++i) {
		tmpAns.understandings[i] += referenceBooks[index].understandings[i];
	}
	func(index + 1, referenceBooks, tmpAns, understand);

}

int main(void) {


	ll n, m, x;
	cin >> n >> m >> x;

	vector<ReferenceBook> referenceBooks;
	for (int i = 0; i < n; ++i) {
		ReferenceBook rb;

		cin >> rb.price;

		for (int j = 0; j < m; ++j) {
			ll a;
			cin >> a;
			rb.understandings.push_back(a);
		}
		referenceBooks.push_back(rb);
	}

	ReferenceBook ans;
	ans.price = 0;
	ans.understandings.resize(m);

	func(0, referenceBooks, ans, x);

	if (ansPrice == LLONG_MAX) {
		ansPrice = -1;
	}
	auto output = ansPrice;
	cout << output;

	return 0;
}


Measured memory_bytes: 3632
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k,ans=0;
  string s;
  cin>>n>>k>>s;
  vector<pair<char,ll>> p;
  runlength(s,p);
  rep(i,p.size()){
    ans+=p[i].second-1;
  }
  cout<<min(ans+2*k,n-1)<<endl;
}

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

ll solve() {
    ll N, D, x, y;
    cin >> N >> D;
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        cin >> x >> y;
        if ( x*x + y*y <= D*D ) ans++;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define take freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);freopen("error.txt","w",stderr);
#define speed ios_base::sync_with_stdio(false);
#define int long long
#define endl "\n"
#define maxi 10000007
#define rof(i,a,b) for(int i=a;i<b;i++)
int32_t main()
{
    speed
    //take
    int c;
    c=1;
    while(c--)
    {
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        int total=0;
        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                for(int z=j+1;z<n;z++)
                {
                    if(a[i]!=a[j]&&a[j]!=a[z]&&a[i]!=a[z]&&(a[i]<(a[j]+a[z]))&&(a[j]<(a[i]+a[z]))&&(a[z]<(a[i]+a[j])))
                    {
                        // cout<<i+1<<" "<<j+1<<" "<<z+1<<endl; 
                        total++;
                    }
                }
            }
        }
        cout<<total<<endl;
    }
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void answer1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void answer2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void answer3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void answer(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i, j;
  ll n,k;
  cin >> n >>k ;
  //ll a, b, c;
  //cin >> a >> b;
  //string s; cin >> s;
  ll result = 0;
  bool judge = true;
  cout << n-k+1 << endl;

  /*
  vector<ll> a(n);
  for(i=0;i<n;i++)
    cin >> a[i];
  //for(i=0;<n;i++)
  */





  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Comparator;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Kenji
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC091C solver = new ABC091C();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC091C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] redX = new int[N];
            int[] redY = new int[N];
            int[] blueX = new int[N];
            int[] blueY = new int[N];
            boolean[] used = new boolean[N];
            int ans = 0;
            List<Integer> list = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                redX[i] = in.nextInt();
                redY[i] = in.nextInt();
                used[i] = false;
            }
            for (int i = 0; i < N; i++) {
                blueX[i] = in.nextInt();
                blueY[i] = in.nextInt();
                list.add(i);
            }

            // sort
            Collections.sort(list, Comparator.comparingInt(o -> blueX[o]));

            for (Integer i : list) {
                List<Integer> candidate = new ArrayList<>();
                for (int j = 0; j < N; j++) {
                    if (redX[j] < blueX[i]
                            && redY[j] < blueY[i]
                            && !used[j]) {
                        candidate.add(j);
                    }
                }

                double maxY = -1;
                int index = -1;
                for (Integer j : candidate) {
                    double d = redY[j];
                    if (maxY < d) {
                        maxY = d;
                        index = j;
                    }
                }
                if (index != -1) {
                    ans++;
                    used[index] = true;
                }
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 28116
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF const ll INF = 1001001001;
#define PI const ld PI = 3.14159265358979323846;


int main() {
    ll N;
    cin>>N;
    cout<<N*(N-1)/2<<endl;
return 0;
}

Measured memory_bytes: 256