akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int A, B; 
  cin >> A >> B;

  string s;
  cin >> s;

  bool flag = true;
  REP(i, A){
    if(s[i] < '0' || '9' < s[i]) flag = false;
  }
  if(s[A] != '-') flag = false;
  REP(i, B){
    if(s[i+A+1] < '0' || '9' < s[i+A+1]) flag = false;
  }

  flag? Yes: No;

  return 0;
}

Measured memory_bytes: 256
<?php
 
$n = trim(fgets(STDIN));

$sqrt = ceil(sqrt($n));

$ans = $n - 1;

for ($i = 2; $i <= $sqrt; $i++) {
     if($n % $i === 0) {
         $ans = min($ans, $i + ($n / $i) - 2);
     }
}

echo $ans;

Measured memory_bytes: 4604
#include<stdio.h>
int main()
{
    char a;
    scanf("%c",&a);
    if(a=='a' | a=='e' | a=='i' | a=='o' | a=='u')
    {
        printf("vowel\n");
    }
    else
    {
        printf("consonant\n");
    }
    return 0;
}


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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = max(0,min(min(d-c,b-c),min(b-a,d-a)));
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 256
n, k = map(int, input().split())
s = list(input())
v = s[0]
cnt = 0
a = []
for t in s:
    if t == v:
        cnt += 1
    else:
        a.append(cnt)
        cnt = 1
        v = t
a.append(cnt)
la = len(a)
b, c = [0] * (la + 1), [0] * (la + 1)
for i in range(1, la + 1):
    b[i] = b[i - 1] + a[i - 1]
    c[i] = b[i] - i
l = 2 * k + 1
if la < l:
    print(n - 1)
    exit()
ans = 0
i, j = l, 0
while True:
    ans = max(ans, b[i] - b[j] + c[la] + c[j] - c[i] - 1)
    i += 1
    j += 1
    if i > la:
        print(ans)
        exit()

Measured memory_bytes: 9388
#include <stdio.h>

int main(void)
{
	int i=0,cnt=0;
	char s[16];
	scanf("%s",s);
	while(s[i] != '\0'){
		if(s[i] == 'x') cnt++;
		i++;
	}
	if(cnt > 7) printf("NO\n");
	else printf("YES\n");
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
      
      	int e = Math.max(a, b);
      	 e= Math.max(e,c);
 
			System.out.println(a+b+c+e*9);
	}
}

Measured memory_bytes: 21716
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val xs = readLine()!!.split(" ").map { it.toLong() }
    val ys = LongArray(n + 1)
    for (i in 0 until n) {
        ys[i + 1] = ys[i] + xs[i] + 1
    }
    var ans = 0.0
    for (i in k..n) {
        ans = Math.max(ans, 0.5 * (ys[i] - ys[i - k]))
    }
    println(ans)
}

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

int main()
{
    int n,m;
    cin >> n >> m;
    int count = 0;

    for (int i = 0; i < m; i++) {
        int s;
        cin >> s;
        count += s;
    }

    if (n-count < 0)
        cout << -1 << endl;
    else 
        cout << n - count << endl;
        
    return 0;
}

Measured memory_bytes: 3552
import sys
import os
from collections import deque

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")

INF = float("inf")

H,W = LI()
C = LI()
D = LI()
maze = [list(_S()) for i in range(H)]

def bfs():
    # すべてのマスを INF で初期化
    d = [[INF] * W for i in range(H)]
    
    sx = C[0]-1
    sy = C[1]-1
    gx = D[0]-1
    gy = D[1]-1

    # スタート地点をキューに入れ、ワープ数を0にする
    que = deque([])
    que.append((sx, sy))
    d[sx][sy] = 0

    # ワープ対象
    que2 = deque([])

    # 移動4方向のベクトル
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    # ワープのベクトル
    dx2 = [-2, -2, -2, -2, -2, -1, -1, -1, -1,  0, 0, 1, 1,  1,  1, 2, 2, 2,  2, 2]
    dy2 = [-2, -1,  0,  1,  2, -2, -1,  1,  2, -2, 2, 2, 1, -1, -2, 2, 1, 0, -1, -2]

    while que: 
        while que:
            p = que.popleft()       
            # 取り出してきた状態がゴールなら探索をやめる
            if p[0] == gx and p[1] == gy:
                ans = d[p[0]][p[1]]
                print(ans)
                exit()
            que2.append((p[0], p[1]))
            # 移動4方向をループ
            for i in range(4):
                # 移動した後の点を (nx, ny) とする
                nx = p[0] + dx[i]
                ny = p[1] + dy[i]

                # 移動可否判定、d[nx][ny] == INF であれば訪れたことがない
                if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] != "#" and d[nx][ny] == INF:
                    # 移動できるならキューに入れ、その点のワープ回数を p までのワープ回数で確定する
                    que.append((nx, ny))
                    d[nx][ny] = d[p[0]][p[1]]
                    
        while que2:
            # キューの先頭を取り出す
            p = que2.popleft()
            for i in range(20):
            # for dxi in range(-2,3):
            #     for dyi in range(-2,3):
                nx = p[0] + dx2[i]
                ny = p[1] + dy2[i]
                if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] != "#" and d[nx][ny] == INF:
                    # 移動できるならキューに入れ、その点のワープ回数を p からのワープ回数 +1 で確定する
                    que.append((nx, ny))
                    d[nx][ny] = d[p[0]][p[1]]+1  
        # print('after que2: ',d)  
    return

bfs()
print(-1)

Measured memory_bytes: 135656
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < n; ++i)
using namespace std;
const int INF = 2147483647;
using ll = long long;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin >> n >> m;
    if(n>m) cout << "safe" << endl;
    else cout << "unsafe" << endl;
    return 0;
}



Measured memory_bytes: 3608
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

int n,ans;
int di(int x){
	int res=0;
	while(x>0){
		x/=10;
		res++;
	}
	return res;
}
int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		if(di(i)%2==1){
			ans++;
		}
	}
	printf("%d\n",ans);	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private void rect(){
		Scanner scanner = new Scanner(System.in);
		
		while(scanner.hasNextInt()){
			int h =scanner.nextInt();
			int w =scanner.nextInt();
			int checker;
			if(h==0 && w==0)break;
			
			if(h<=300 && w<=300){
				for(int i=0; i<h; i++){
					for(int j=0; j<w; j++){
						checker=(i+j)%2;
						if(checker==0){
							System.out.printf("#");
						}else System.out.printf(".");
					}
					System.out.println("");
				}
				System.out.println("");
				
			}
			
		}
	}
	
	public static void main(String[] args) {
		Main run =new Main();
		run.rect();

	}
}

Measured memory_bytes: 44708
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);
#define readV(_v) rep(j, _v.size()) cin >> _v[j];
#define readVV(_vv) rep(i, _vv.size()) readV(_vv[i]);
#define output(_x) cout << _x << endl;

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

template <typename T>
struct edge {
    int from, to;
    T cost;
    edge(){}
    edge(int _from, int _to, T _cost) : from(_from), to(_to), cost(_cost) {}
    bool operator< (const edge& e) const {
        return cost == e.cost ? (from == e.from ? to < e.to : from < e.from) : cost < e.cost;
    }
    bool operator> (const edge& e) const {
        return cost == e.cost ? (from == e.from ? to > e.to : from > e.from) : cost > e.cost;
    }
};

template <typename T>
class Prim {
private:
    const int n;
    vector<vector<edge<T>>> G;
public:
    Prim(int _n) : n(_n), G(_n) {}
    // undirected
    void addEdge(int u, int v, T c) {
        G[u].emplace_back(u, v, c);
        G[v].emplace_back(v, u, c);
    }
    T calc(int s = 0) {
        T total_weight = 0;
        vector<bool> visited(n);
        int num_visited = 0;
        priority_queue<edge<T>, vector<edge<T>>, greater<edge<T>>> pq;
        pq.push(edge<T>(-1, s, 0));
        vector<T> values;
        while (!pq.empty() && num_visited < n) {
            auto e = pq.top(); pq.pop();
            if (visited[e.to]) continue;
            total_weight += e.cost;
            values.emplace_back(e.cost);
            visited[e.to] = true;
            num_visited++;
            for (const auto& ne: G[e.to]) {
                if (!visited[ne.to]) pq.push(ne);
            }
        }
        sort(all(values));
        return values[1 + (values.size() - 1)/2];
    }
};
/* !!!!! T: ?????????????????????(int, double) !!!!! */

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

    int n, m;
    while (cin >> n >> m, n) {
        Prim<int> prim(n);
        rep(i, m) {
            int s, t, c;
            cin >> s >> t >> c;
            s--, t--;
            prim.addEdge(s, t, c);
        }
        cout << prim.calc() << endl;
    }
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const vs res = { "AC", "WA", "TLE", "RE" };

int main(){
    int n;
    cin >> n;
    vs s(n);
    rep(i, n) cin >> s[i];
    map<string, int> cnt;
    rep(i, n) cnt[s[i]]++;
    for (auto t : res) {
        printf("%s x %d\n", t.c_str(), cnt[t]);
    }
    return 0;
}


Measured memory_bytes: 6440
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int N=gi();
	    int M=gi();
	    //int[] A=new int[N];
	    int[] C=new int[N];

	    for(int i=0;i<M; i++) {
	    	int a=gi();
	    	int b=gi();
	    	C[a-1]++;
	    	C[b-1]++;
	    }
	    for(int i=0;i<N; i++) {
	    	System.out.println(C[i]);
	    }
        //System.out.println((H-h)*(W-w));
//        if (flg) {
//        	System.out.print("YES");
//        }else {
//        	System.out.print("NO");
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35860
#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;

int N, K;

int main()
{
  int N, K; cin >> N >> K;
  vector<ll> num(K, 0);
  for (int i = 1; i <= N; ++i) num[i%K]++;

  ll ans = 0;
  for (int a = 0; a < K; ++a) {
    int b = (K-a)%K;
    int c = (K-a)%K;
    if ((b+c)%K != 0) continue;
    ans += num[a] * num[b] * num[c];
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var s = br.readLine().split(" ");
      final var l = Integer.parseInt(s[0]);
      final var r = Integer.parseInt(s[1]);
      final var d = Integer.parseInt(s[2]);

      int count = 0;
      for (int i = l; i <= r; i++) {
        if (i % d == 0) {
          count++;
        }
      }

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


Measured memory_bytes: 32508
#include<iostream>
using namespace std;
int w,h,i,j,c[50][50];

void visit(int i,int j){

  if(i<0||j<0)return;
  if(i>=50||j>=50)return;

  c[i][j]=0;
  for(int k=-1;k<=1;k++)
    for(int l=-1;l<=1;l++)
      if(c[i+k][j+l]==1)
	visit(i+k,j+l);
     
}
int main(){
  int count;
  while(1){ 
    count=0;
    cin>>w>>h;
    if(w==0&&h==0)break; 
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	cin>>c[i][j];
      }
    }
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(c[i][j]==1){
	  count++;
	  visit(i,j);
	}
      }
    }
    cout<<count<<endl;
  }
  return 0;
}

Measured memory_bytes: 1312
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cerr<<endl; 
	}
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int n,k;
		cin>>n>>k;
		ll int arr[n+1];
		for(ll int i=1;i<=n;i++)
		{
			cin>>arr[i];
		}
		ll int pos=1;
		ll int timer=1;
		for(ll int i=1;i<=min(k,n);i++)
		{
			pos=arr[pos];
			timer++;
		}
		if(timer==k+1)
		{
			cout<<pos<<endl;
			return 0;
		}
		ll int cycle=0;
		ll int npos=pos;
		while(true)
		{
			npos=arr[npos];
			cycle++;
			if(npos==pos) break;
		}
		k-=timer-1;
		k%=cycle;
		while(k--)
		{
			pos=arr[pos];
		}
		cout<<pos<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {
  long n, m[5] = {};
  cin >> n;
  string s[n];
  for (long i = 0; i < n; i++) {
    cin >> s[i];
    switch(s[i][0]) {
      case 'M':
        m[0]++;
        break;
      case 'A':
        m[1]++;
        break;
      case 'R':
        m[2]++;
        break;
      case 'C':
        m[3]++;
        break;
      case 'H':
        m[4]++;
    }
  }
  sort(m, m+5);
  cout << m[0] * m[1] * (m[2] + m[3] + m[4]) + m[0] * m[2] * (m[3] + m[4]) + m[0] * m[3] * m[4] + m[1] * m[2] * (m[3] + m[4]) + m[1] * m[3] * m[4] + m[2] * m[3] * m[4] << endl;
  return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n,a[60],sum=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			sum+=a[i]*a[j];
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
  int k,q;
  cin >> k >> q;

  vector<int> d(k);
  rep(i,k) cin >> d[i];

  vector<ll> ans(q);
  rep(qi,q){
    int n,x,m;
    cin >> n >> x >> m;
    ll val = x;
    rep(i,k){
      ll cnt = ((n-1-i) + k - 1) / k;
      val += (d[i]%m) * cnt;
      if ( d[i]%m == 0 ) {
        val += m * cnt;
      }
    }
    ans[qi] = n-1 - (val/m - x/m);
  }
  rep(i,q) cout << ans[i] << endl;
}


Measured memory_bytes: 888
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
MOD = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

N, M = LI()

a = []
b = []
c = []

for i in range(M):
    ai, bi = LI()
    ci = LI()
    a.append(ai)
    b.append(bi)
    c.append(ci)

dp = [[MOD] * (1 << N)]*(M+1)

for i in range(M+1):
    dp[i][0] = 0

for i in range(M):
    for j in range(1<<N):
        boxSets = 0
        for cij in c[i]:
            boxSets |= 1 << (cij - 1)
        dp[i][j | boxSets] = min(dp[i][j | boxSets], dp[i][j] + a[i])

print(-1 if (dp[M][(1 << N)-1] == MOD ) else dp[M][(1 << N)-1])




Measured memory_bytes: 44208
import java.util.Arrays;
import java.util.Scanner;

//Beaker
public class Main{

	int n;
	int[] a;
	boolean[] have, t;
	
	boolean dfs(int k, int rest){
		if(rest==0){
			for(int i=0;i<n;i++)t[i]=have[i];
			return greedy();
		}
		if(rest < a[k])return false;
		have[k] = true;
		if(dfs(k+1, rest-a[k]))return true;
		have[k] = false;
		return dfs(k+1, rest);
	}
	
	boolean choice(int k, int rest){
		if(rest==0)return true;
		if(k<0)return false;
		if(!t[k])return choice(k-1, rest);
		if(a[k]<=rest){
			t[k] = false;
			if(choice(k-1, rest-a[k]))return true;
			t[k] = true;
		}
		return choice(k-1, rest);
	}
	
	boolean greedy(){
		for(int i=0;i<n;i++)if(!t[i]){
			if(!choice(i-1, a[i]))return false;
			t[i] = true;
		}
		return true;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		t = new boolean[100];
		have = new boolean[100];
		for(;;){
			n = sc.nextInt();
			if(n==0)break;
			a = new int[n];
			for(int i=0;i<n;i++){
				a[i] = sc.nextInt();
			}
			Arrays.sort(a);
			Arrays.fill(have, false);
			have[0] = true;
			System.out.println(dfs(1, a[n-1]-a[0])?"YES":"NO");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

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

#define PB push_back
#define MP make_pair

#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORD(prom, a, b) for(int prom = (a); prom > (b); prom--)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define R1(a) do{scanf("%d", &(a));}while(0)
#define R2(a, b) do{scanf("%d%d", &(a), &(b));}while(0)
#define R3(a, b, c) do{scanf("%d%d%d", &(a), &(b), &(c));}while(0)
#define SV(vec) do{int s_v_;scanf("%d", &(s_v_));vec.PB(s_v_);}while(0)
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF 1000000007

int a, b;

int main ()
{
  R2(a, b);
  FOR(i, 0, max(a, b)) printf("%d", min(a, b));
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque

n,m=map(int,sys.stdin.readline().split()) 
al,cnt=[[] for _ in range(n)],[0]*n
for i in range(n+m-1):
    a,b=map(int,sys.stdin.readline().split())
    al[a-1].append(b-1)
    cnt[b-1] += 1
ans = [0]*n
que = deque()

# children = []
# child = 0
# for i in range(n):
#     if len(children) == 0:        
#         children = set(cnf)-set(bl)
#         parent = child
 
#     child = children.pop()
    
#     j = 0
#     while j < len(al):
#         if al[j] == child:
#             al.pop(j)
#             bl.pop(j)
#         else:
#             j += 1
#     ans[child-1] = parent
#     cnf.remove(child)

for i in range(n):
    if  cnt[i] == 0:
        que.append(i)
        break

while que:
    p = que.popleft()
    
    for j in al[p]:
        cnt[j] -= 1
        if cnt[j] == 0:
            que.append(j)
            ans[j]=p + 1

for i in range(n):
    print(ans[i])

Measured memory_bytes: 23864
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a,cnt=2;
	cin>>a;
	if(a==1)
	{
		cout<<4<<endl;
	}
	else
	{
		if(a==2)
		{
			cout<<4<<endl;
		}
		else
		{
			while(a!=1)
			{
				if(a%2==0)
				{
					a=a/2;
					cnt++;
				}
				else
				{
					a=a*3+1;
					cnt++;
				}
			} 
			cout<<cnt<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
    int N, L;
    cin>>N>>L;
    int A[N+1];
    int sum, cha1, cha2;
    sum = 0;
    cha1 = 9999;
    cha2 = -9999;
    for(int i=0;i<N;i++)
    {
        A[i] = L + i;
    }
    for(int i=0;i<N;i++)
        sum = sum + A[i];
    for(int i=0;i<N;i++)
    {
        int x = A[i] - 0;
        if(x > 0)
        {
            if(x < cha1)
                cha1 = x;
        }
        else
        {
            if(x > cha2)
                cha2 = x;
        }
    }
    if(cha1 > -cha2)
        cout<<sum - cha2;
    else
    {
            cout<<sum - cha1;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n;
  cin>>n;
  map<int64_t,int> f;
  for(int64_t i=2;i*i<=n;i++){
    while(n%i==0){
      f[i]++;
      n/=i;
    }
  }
  if(n!=1)
    f[n]++;
  int c=0;
  for(auto x:f){
    int p=1;
    while(p<=x.second){
      c++;
      x.second-=p;
      p++;
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 3628
[R, C] = [int(i) for i in input().split()]

if R == 1 or C == 1:
  print(1)
elif R % 2 == 0:
  n = R/2
  print(int(n * C))
else:
  n1 = (R+1) / 2
  n2 = n1 - 1
  c1 = int((C+1)/2)
  c2 = C -c1
  print(int(n1*c1 + n2*c2))

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

int main() {
    int n; cin>>n;
    long long int a[n], b[n], c[n];
    for(int i=0; i<n; i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    
    long long int dp[3][100000];
    
    dp[0][0]=a[0];
    dp[1][0]=b[0];
    dp[2][0]=c[0];
    
    for(int j=1; j<n; j++){
        dp[0][j]=a[j]+max(dp[1][j-1], dp[2][j-1]);
        dp[1][j]=b[j]+max(dp[0][j-1], dp[2][j-1]);
        dp[2][j]=c[j]+max(dp[0][j-1], dp[1][j-1]);
    }
    
    long long int ans=max(dp[0][n-1], dp[1][n-1]);
    ans=max(dp[2][n-1], ans);
    
    cout<<ans;

    return 0;
}



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

int main() {
  int a,b,c; cin >> a >> b >> c;
  vector<int>v{a,b,c};
  sort(v.begin(),v.end());
  cout << (v[2]-v[1])+(v[1]-v[0]) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lo;
lo a,b,c,d,e,x,y,n,m,t,a1[500005],a2[500005];
string s1,s2,s3,s4,s[105];
bool as=false,as2=false;
char c1,c2,c3,c4;
int main(){
    cin>>a>>b;
    if(b==1){
        cout<<0<<endl;
        return 0;
    }
    if(a>=b){
        cout<<1<<endl;
    }
    else{
        x++;
        a--;
        for(lo i=1;i<=23;i++){
            x+=a;
            if(x>=b){
                cout<<i<<endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>

using namespace std;
using namespace boost::numeric;

typedef long long ll;
#define FOR(i,n) for(int i=0; i<int(n); i++)
#define FOR1(i,m,n) for(int i=int(m); i<int(n); i++)

const int MAXN=1e9;
const int MAXM=1e5;
const int MOD=1e9+7;
int N, M, IDX=0;
int X[MAXM];
ublas::matrix<ll> mat1(3,3), mat2(3,3);
ublas::vector<ll> vec(3);

ublas::matrix<ll> pow(ublas::matrix<ll> base, int exponent) {
    ublas::matrix<ll> ans;
    if (exponent == 0)
        ans = ublas::identity_matrix<ll>(3);
    else if (exponent % 2 == 1)
        ans = ublas::prod(base, pow(base, exponent-1));
    else {
        ublas::matrix<ll> tmp = pow(base, exponent / 2);
        ans = ublas::prod(tmp, tmp);
    }

    transform(ans.data().begin(), ans.data().end(),
              ans.data().begin(), [](ll x){return x%MOD;});
    return ans;
}

ublas::vector<ll> dp(int n) {
    ublas::vector<ll> ans;

    if (IDX == M) {
        ans = ublas::prod(pow(mat1, N-n), vec);
    }
    else if (IDX < M && X[IDX] > n) {
        int exponent = X[IDX]-n;
        ans = ublas::prod(pow(mat1, exponent), dp(X[IDX]));
    }
    else {
        IDX++;
        ans = ublas::prod(mat2, dp(n+1));
    }

    transform(ans.data().begin(), ans.data().end(),
              ans.data().begin(), [](ll x){return x%MOD;});
    return ans;
}

int main(int argc, char *argv[])
{
    int init1[3][3] = {{1,2,1},
                       {0,1,1},
                       {1,2,2}};
    int init2[3][3] = {{1,2,1},
                       {0,1,1},
                       {0,0,1}};
    int init3[3] = {0,0,1};
    ublas::vector<ll> ans;
    
    FOR(i,3) {
        FOR(j,3) {
            mat1(i,j) = init1[i][j];
            mat2(i,j) = init2[i][j];
        }
        vec(i) = init3[i];
    }

    cin >> N >> M;
    FOR(i,M) cin >> X[i];

    ans = dp(0);
    cout << ans[0] << endl;
    
    return 0;
}


Measured memory_bytes: 75648
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e7;  
using  p = pair<string,int>;

int main(){
   int n,m;
   cin >> n;
   auto st = unordered_map<string,int>();
   for (int i = 0; i < n; i++)
   {
      string temp;
      cin >> temp;
      if(st.find(temp)!=st.end()){
         st[temp]++;
      }else{
         st[temp]=1;
      }
   }
   cin >> m;
   auto t = vector<string>(n,"");
   for (int i = 0; i < m; i++)
   {
      string temp;
      cin >> temp;
      if(st.find(temp)!=st.end()){
         st[temp]--;
      }else{
         st[temp]=-1;
      }
   }
   auto ans = max_element(st.begin(),st.end(),[](p i,p j){
      return i.second < j.second;
   });

   cout << (ans->second<0?0:ans->second);

   
}
  
  

Measured memory_bytes: 256
n = int(input())
a, b = [0, 0]
for i in range(n):
    Taro, Hanako = input().split()
    if Taro > Hanako:
        a += 3
    elif Taro < Hanako:
        b += 3
    else:
        a += 1
        b += 1
print(a, b)

Measured memory_bytes: 7652
#Nはノード数、Mはエッジ数
N, M = map(int, input().split())

path_matrix = []

#無向行列の初期化
for n in range(N):
    path_matrix.append([False] * N)

#まず無向グラフを表す行列を作る
for m in range(M):
    line = map(int, input().split())
    paths = [x - 1 for x in line]
    path_matrix[paths[0]][paths[1]] = True
    path_matrix[paths[1]][paths[0]] = True

#最初はvisited、つまり訪問したことのあるノードはひとつもないので、Falseにする
visited = [False] * N


#再帰関数、ここが難しいかもしれない。
def dfs(now, depth):
    if visited[now]:
        return 0
    if depth == N - 1:
        return 1

    visited[now] = True
    total_paths = 0
    for i in range(0, N):
        if path_matrix[now][i]:
            total_paths += dfs(i, depth + 1)

    visited[now] = False

    return total_paths

print(dfs(0, 0))



Measured memory_bytes: 73708
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	m := map[int]int{}
	for i := 0; i < 3; i++ {
		a := getNextInt(scanner)
		b := getNextInt(scanner)
		m[a] = m[a] + 1
		m[b] = m[b] + 1
	}
	mm := map[int]int{}
	for _, c := range m {
		mm[c] = mm[c] + 1
	}
	if mm[1] == 2 && mm[2] == 2 {
		fmt.Fprintln(writer, "YES")
		return
	}
	fmt.Fprintln(writer, "NO")
}


Measured memory_bytes: 640
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<i64>();
    let ans = (n - n / 2) as f64 / n as f64;
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <stdio.h>

int main()
{
  int m, n;
  scanf("%d %d\n", &n, &m);
  int c[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      scanf("%d", &c[i][j]);

  for (int i = 0; i < n; i++)
  {
    int s = 0;
    for (int j = 0; j < m; j++)
    {
      printf("%d ", c[i][j]);
      s += c[i][j];
    }
    printf("%d\n", s);
  }

  int s[m];
  for (int i = 0; i < m; i++)
  {
    s[i] = 0;
    for (int j = 0; j < n; j++)
      s[i] += c[j][i];
  }
  printf("%d", s[0]);
  for (int i = 1; i < m; i++)
  {
    printf(" %d", s[i]);
    s[0] += s[i];
  }
  printf(" %d\n", s[0]);
  return 0;
}


Measured memory_bytes: 2104
#include<stdio.h>
#include<queue>
#include<algorithm>
#include<set>
using namespace std;
int p[15];
struct wolf{
	int m[13];
};
inline bool operator <(const wolf &a,const wolf &b){
	for(int i=0;i<13;i++)if(a.m[i]!=b.m[i])return a.m[i]<b.m[i];
	return false;
}
int g[13][4]={
{2,-1,-1,-1},
{2,5,-1,-1},{0,1,3,6},{2,7,-1,-1},
{5,-1,-1,-1},{1,4,6,9},{2,5,7,10},{3,6,8,11},{7,-1,-1,-1},
{5,10,-1,-1},{6,9,11,12},{7,10,-1,-1},
{10,-1,-1,-1}
};
int row[]={0,1,1,1,2,2,2,2,2,3,3,3,4};
int col[]={2,1,2,3,0,1,2,3,4,1,2,3,2};
int ABS(int a){return max(a,-a);}
int main(){
	while(scanf("%d",p),~p[0]){
		for(int i=1;i<13;i++)scanf("%d",p+i);
		set<wolf>S;
		wolf st;
		for(int i=0;i<13;i++)st.m[i]=p[i];
		queue<pair<wolf,int> > Q;
		S.insert(st);
		Q.push(make_pair(st,0));
		bool yet=true;
		while(Q.size()){
			wolf at=Q.front().first;
			int cost=Q.front().second;
			Q.pop();
			bool ok=true;
			for(int i=1;i<12;i++)if(at.m[i]!=i)ok=false;
			if(ok){
				yet=false;
				printf("%d\n",cost);
				break;
			}
			int now=cost;
			for(int i=0;i<13;i++)if(at.m[i]){
				now+=ABS(row[i]-row[at.m[i]])+ABS(col[i]-col[at.m[i]]);
			}
			if(now>20)continue;
			for(int i=0;i<13;i++)if(!at.m[i]){
				for(int j=0;j<4;j++)if(~g[i][j]){
					swap(at.m[i],at.m[g[i][j]]);
					if(!S.count(at)){
						S.insert(at);
						Q.push(make_pair(at,cost+1));
					}
					swap(at.m[i],at.m[g[i][j]]);
				}
			}
		}
		if(yet)printf("NA\n");
	}
}

Measured memory_bytes: 2224
#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <vector>

namespace null_null {

using int64 = std::int_fast64_t;
using usize = std::size_t;

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename T, typename V>
inline void chmin(T &a, V b) {
  if (a > b) a = b;
}
template <typename T, typename V>
inline void chmax(T &a, V b) {
  if (a < b) a = b;
}

} // namespace null_null

#include <algorithm>
#include <iostream>
#include <utility>

namespace null_null {

void main_() {
  usize N;
  std::cin >> N;
  std::vector<std::pair<int, int>> v;
  std::vector<std::pair<int, int>> idx;
  for (usize i = 0; i < N; i++) {
    int a, b;
    std::cin >> a >> b;
    v.push_back({a, b});
    idx.push_back({b, i});
  }

  std::sort(idx.begin(), idx.end());

  int sum = 0;
  for (auto x : idx) {
    usize i = x.second;
    sum += v[i].first;
    if (v[i].second < sum) {
      std::cout << "No" << std::endl;
      return;
    }
  }

  std::cout << "Yes" << std::endl;
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define rep(p,a,b)    for(ll p=a;p<b;p++)
#define sz(v) ((int)v.size())
#define all(v) (v).begin(), (v).end()
#define INF 0x3f3f3f3f

ll nextPowerOf2(ll n)
{
    n--;
    n |= n >> 1ll;
    n |= n >> 2ll;
    n |= n >> 4ll;
    n |= n >> 8ll;
    n |= n >> 16ll;
    n++;
    return n;
}


int main()
{

    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("o1.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n,t,i,j,k,ans;
    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n;
        map<string,int> m;
        string s;

        rep(p,0,n)
        {
            cin>>s;
            m[s]++;
        }
        cout<<"AC x "<<m["AC"]<<"\n";
        cout<<"WA x "<<m["WA"]<<"\n";
        cout<<"TLE x "<<m["TLE"]<<"\n";
        cout<<"RE x "<<m["RE"]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;

//入力
ll n,a;
vector<ll>x;
ll dp[55][5100];

int main(){
    cin >> n >> a;
    x.resize(n);
    rep(i,n)cin>>x[i];
    dp[0][2500]=1;
    vector<ll>s(n);
    rep(i,n){
        s[i]=x[i]-a;
    }
    for(int i=1;i<=n;i++){
        rep(j,5010){
            dp[i][j]+=dp[i-1][j];
            if(j-s[i-1]<0)continue;
            dp[i][j]+=dp[i-1][j-s[i-1]];
        }
    }
    cout << dp[n][2500]-1 << endl;
    return 0;
}


Measured memory_bytes: 5564
#include<iostream>
using namespace std;
static const int MAX=100;
static const int INFTY=(1<<21);
static const int white=0;
static const int gray=1;
static const int black=2;

int n,M[MAX][MAX];

int prim(){
    int u,minv;
    int d[MAX],p[MAX],color[MAX];
    for(int i=0;i<n;i++){
	d[i]=INFTY;
	p[i]=-1;
	color[i]=white;
    }
    d[0]=0;
    while(1){
	minv=INFTY;
	u=-1;
	for(int i=0;i<n;i++){
	    if(minv>d[i]&&color[i]!=black){
		u=i;
		minv=d[i];
	    }
	}
	if(u==-1)break;
	color[u]=black;
	for(int v=0;v<n;v++){
	    if(color[v]!=black&&M[u][v]!=INFTY){
		if(d[v]>M[u][v]){
		    d[v]=M[u][v];
		    p[v]=u;
		    color[v]=gray;
		}
	    }
	}
    }

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

    return sum;

}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
	    int e;
	    cin>>e;
	    M[i][j]=(e==-1)?INFTY:e;
	}
    }
    cout<<prim()<<endl;
    return 0;
}


Measured memory_bytes: 3128
N=int(input())
s={}
for i in range(N):
    ss=input().strip()
    if ss in s:
        s[ss]+=1
    else:
        s[ss]=1
M=int(input())
for i in range(M):
    ss=input().strip()
    if ss in s:
        s[ss]-=1
    else:
        s[ss]=-1
print(max(max(s.values()),0))

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007

typedef pair<int,int>P;
#define INF (1<<29)
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

int n;
int a[105];
bool dp[105][10005];

int main() {
	cin >> n;
	int sum = 0;
	rep(i, n) {
		cin >> a[i+1];
		sum += a[i+1];
	}
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= sum; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j >= a[i]) {
				dp[i][j] |= dp[i - 1][j - a[i]];
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <=n ; i++) {
		for (int j = 0; j <= sum; j++) {
			if (j % 10 != 0 && dp[i][j]) {
				ans = max(ans,j);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1280
def c_switches(N, M, Switches, P):
    digit = N
    ans = 0
    for b in range(1 << digit):
        cnt = 0
        for i, (_, *switch) in enumerate(Switches):
            count = 0
            for d in range(digit):
                if (((1 << d) & b) != 0) and (d + 1 in switch):
                    count += 1
            if (count % 2) == P[i]:
                cnt += 1
        if cnt == M:
            ans += 1
    return ans

N, M = [int(i) for i in input().split()]
Switches = [[int(i) for i in input().split()] for j in range(M)]
P = [int(i) for i in input().split()]
print(c_switches(N, M, Switches, P))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 1e10
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve2() {
    ll N,M,K;
    cin >> N >> M >> K;

    queue<int> qa;
    queue<int> qb;
    REP(i,N) {
      int a;
      cin >> a;
      qa.push(a);
    }
    REP(i,M) {
        int b;
        cin >> b;
        qb.push(b);
    }

    ll t = 0;
    ll ans = 0;
    while (true) {
        ll re = INF;
        char flg = 'n';
        if(!qa.empty()) if(chmin(re,ll(qa.front()))) flg = 'a';
        if(!qb.empty()) if(chmin(re,ll(qb.front()))) flg = 'b';

        // empty book
        if (flg == 'n') {
            cout << ans << endl;
            return;
        }

        t += re;
        if (t > K) {
            cout << ans << endl;
            return;
        }
        if (flg == 'a') qa.pop();
        if (flg == 'b') qb.pop();
        ans++;
    }
}

void solve() {
    ll N,M,K;
    cin >> N >> M >> K;

    vector<int> va(N);
    vector<int> vb(M);
    REP(i,N) cin >> va[i];
    REP(i,M) cin >> vb[i];
    vector<ll> ruiA(N+1,0),ruiB(M+1,0);

    // Aがn冊読めるとしてBは何冊読めるかは簡単に出る
    FOR(i,1,N+1) ruiA[i] = ruiA[i-1] + va[i-1];
    FOR(i,1,M+1) ruiB[i] = ruiB[i-1] + vb[i-1];

    int mx = 0;
    REP(i,N+1) {
        // Aをi冊読む時の残り時間
        ll last = K - ruiA[i];
        // if eqov
        if (last < 0) continue;
        auto itr = lower_bound(ALL(ruiB),last);
        // 最後なら全部
        if (itr == ruiB.end()) {
            chmax(mx,i+int(M));
            continue;
        }
        // 同じ値ならそこまで読み込む違うなら位置-1
        int same = (*itr == last) ? 1 : 0;
        int dist = int(itr - ruiB.begin()) -1;

        chmax(mx,same+dist+i);


    }

    cout << mx << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 7916
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
 
// https://atcoder.jp/contests/abc122/submissions/4920926
 
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
 
int main(void) {
    int N, Q;
    char S[100001];
    scanf("%d %d", &N, &Q);
    scanf("%s", S);
 
    int ans[100001]={0};
    int i, j;
    for( i=0; i<N; i++) {
      // 「右隣がCであるようなA」を数える
      ans[i+1] = ans[i];
      if( S[i]=='A' && S[i+1]=='C') {
        ans[i+1]++;
      }
    }
 
    int ans2[100001];
    int l, r;
    for( i=0; i<Q; i++) {
      scanf("%d %d", &l, &r);
      ans2[i] = ans[r-1]-ans[l-1];
    }
 
    for( i=0; i<Q; i++) {
      printf("%d\n", ans2[i]);
    }
 
return 0;
}

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

int main(){
  ll h,w,d,a;
  cin >> h >> w >> d;
  
  vector<vector<ll>>c(h*w+1,vector<ll>(2));
  for(int i=1; i<=h; i++){
   for(int j=1; j<=w; j++){
     cin >> a;
     c[a][0]=i;
     c[a][1]=j;
   }
  }
  
  ll q;
  cin >> q;
  
  vector<ll>ans(w*h+1);
  for(int i=1; i<=d; i++){
   for(int j=i+d; j<=h*w; j+=d){
     ll x=pow(pow(c[j][0]-c[j-d][0],2),0.5)+pow(pow(c[j][1]-c[j-d][1],2),0.5);
     ans[j]=ans[j-d]+x;
   }
  }
  
  for(int i=0; i<q; i++){
   ll l,r;
   cin >> l >> r;
   cout << ans[r]-ans[l] << endl; 
  }
  
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t = 1, tt;
const ll N = 1000005;
void solve(){
	ll a, b;
	cin>>a>>b;
	rep(i,1,N){
		ll x = (double)(0.08)*i, y = (double)(0.10)*i;
		if(x==a and y==b){
			cout<<i;return;
		}
	}
	cout<<"-1";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	//cin>>t;
	tt=t;
    while(t--){
        solve();
        if(t!=0)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <atcoder/all>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    vector<long long> a(n), b(m);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &(a[i]));
    }
    for (int i = 0; i < m; i++) {
        scanf("%lld", &(b[i]));
    }

    vector<long long> c = convolution(a, b);
    // or: vector<long long> c = convolution<998244353>(a, b);

    for (int i = 0; i < n + m - 1; i++) {
        printf("%lld ", c[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 27256