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

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf (ll)2e18
#define EPS 1e-12
#define mod 1000000007LL
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;

inline void solve()
{
	int n, m;
	cin >> n >> m;
	vector<int> v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	vector<vector<int>> g(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	int otv = 0;

	for (int i = 0; i < n; i++) {
		bool is = 1;
		for (int to : g[i]) {
			if (v[to] >= v[i])
				is = 0;
		}
		if (is)
			otv++;
	}

	cout << otv;
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	fore(t, 0, q)
	{
		solve();
		cout << '\n';
	}
}

Measured memory_bytes: 8728
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+7
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

ll n, I, u, a, p;
vector< pair<P, P> > vpp;

bool flag(const pair<P, P> pp1, pair<P, P> pp2){
	if (pp1.first.first == pp2.first.first){
		if (pp1.first.second == pp2.first.second){
			return pp1.second.first < pp2.second.first;
		}
		return pp1.first.second < pp2.first.second;
	}
	return pp1.first.first > pp2.first.first;
}

int main(){
	while (cin >> n&&n){
		vpp.clear();
		ll cntall = 0;
		int cnt[1010] = {};
		REP(i, n){
			cin >> I >> u >> a >> p;
			vpp.push_back(make_pair(P(a, p), P(I, u)));
		}
		sort(ALL(vpp), flag);
		REP(i, vpp.size()){
			int t = vpp[i].second.first, id = vpp[i].second.second;
			if (cntall < 10){
				if (cnt[id] < 3){
					cout << t << endl;
					cnt[id]++;
					cntall++;
				}
			}
			else if (cntall < 20){
				if (cnt[id] < 2){
					cout << t << endl;
					cnt[id]++;
					cntall++;
				}
			}
			else if (cntall < 26){
				if (cnt[id] < 1){
					cout << t << endl;
					cnt[id]++;
					cntall++;
				}
			}
		}
	}
}

Measured memory_bytes: 1216
#include <cstdio>

using namespace std;

bool is_prime(int n) {
    for(int i=2; i*i<=n; i++) {
        if(n % i == 0) return false;
    }
    return n != 1;
}

int main(void)
{
    int n;
    while(~scanf("%d", &n)) {
        for(int i=n-1; i>=0; i--) {
            if(is_prime(i)) {
                printf("%d ", i);
                break;
            }
        }
        for(int i=n+1; ; i++) {
            if(is_prime(i)) {
                printf("%d\n", i);
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 22 14:57:09 2020

@author: liang
"""

N = int(input())
X = [int(x) for x in input().split()]
Y = X.copy()
Y.sort()
upper = Y[N//2]
lower = Y[N//2-1]

for i in range(N):
    if X[i] < upper:
        print(upper)
    else:
        print(lower)

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    string s;
    cin >> s;
    bool flag = false;
    lint ans = 0, cnt = 0;
    repr(i, s.size()){
        if(s[i] == 'W'){
            flag = true;
        }
        if(s[i] == 'B'){
            ++cnt;
            if(flag){
                ans += (lint)s.size() - (lint)i - cnt;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#define INF 1e+18
#define int long long
using namespace std;

struct edge{ int to,cost; };
struct edge_krus{
	int from,to,cost;
	bool operator<(const edge_krus &e) const{
		return cost > e.cost;
	}
};

int rnk[200],par[200];

void init(int n){
	for(int i = 0;i < n;i++){
		rnk[i] = 0;
		par[i] = i;
	}
}

int find(int x){
	if(x == par[x]) return x;
	return par[x] = find(par[x]);
}

void unite(int x,int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	if(rnk[x] < rnk[y]) par[x] = y;
	else{
		par[y] = x;
		if(rnk[x] == rnk[y]) rnk[x]++;
	}
}

bool same(int x,int y){
	return find(x) == find(y);
}

const int MAX_H = 1000000;
vector<int> sink[MAX_H];

signed main(){
	int n,m;
	while(scanf("%lld %lld",&n,&m),n){
		int ans = 0;
		vector<edge> G[200];
		bool sank[200] = {};
		for(int i = 0;i < MAX_H;i++) sink[i].clear();
		for(int i = 0;i < n;i++){
			int h;
			scanf("%lld",&h);
			sink[h - 1].push_back(i);
		}
		for(int i = 0;i < m;i++){
			int a,b,c;
			scanf("%lld %lld %lld",&a,&b,&c); a--;b--;
			G[a].push_back({b,c});
			G[b].push_back({a,c});
		}
		init(n);
		for(int j = 0;j < n;j++){
			for(edge e : G[j]){
				if(!sank[j] && !sank[e.to]) unite(j,e.to);
			}
		}
		int mi = INF,ma = -1;
		for(int j = 0;j < n;j++){
			if(sank[j]) continue;
			mi = min(mi,find(j));
			ma = max(ma,find(j));
		}
		if(mi != ma){
			printf("0\n");
			continue;
		}
		int last = -1;
		for(int i = 0;i < MAX_H;i++){
			if(!sink[i].size()) continue;
			for(int v : sink[i]) sank[v] = true;
			init(n);
			for(int j = 0;j < n;j++){
				for(edge e : G[j]){
					if(!sank[j] && !sank[e.to]) unite(j,e.to);
				}
			}
			int mi = INF,ma = -1;
			for(int j = 0;j < n;j++){
				if(sank[j]) continue;
				mi = min(mi,find(j));
				ma = max(ma,find(j));
			}
			if(mi != ma){
				for(int v : sink[i]) sank[v] = false;
				break;
			}
			last = i;
		}
		init(n);
		priority_queue<edge_krus> es;
		for(int i = 0;i < n;i++){
			for(edge e : G[i]){
				if(!sank[i] && !sank[e.to]) es.push({i,e.to,e.cost});
			}
		}
		while(!es.empty()){
			edge_krus e = es.top();es.pop();
			if(!same(e.from,e.to)){
				unite(e.from,e.to);
				ans += e.cost;
			}
		}
		for(int i = last;i >= 0;i--){
			if(!sink[i].size()) continue;
			for(int v : sink[i]) sank[v] = false;
			for(int v : sink[i]){
				for(edge e : G[v]){
					if(!sank[e.to]) es.push({v,e.to,e.cost});
				}
			}
			while(!es.empty()){
				edge_krus e = es.top();es.pop();
				if(!same(e.from,e.to)){
					unite(e.from,e.to);
					ans += e.cost;
				}
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 29644
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	int res = 0;
	int X, Y, Z;
	UnionFind uf(N);
	for (int i = 0; i < M; i++) {
		cin >> X >> Y >> Z; X--; Y--;
		uf.unionSet(X, Y);
	}
	set<int> st;
	for (int i = 0; i < N; i++) {
		st.insert(uf.root(i));
	}
	cout << st.size() << endl;
}

Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;

int main() {
  vector<int> side(3);  // ???, ?¨?, ??????
  int n;                // ??\??£????????°
  int rad;              // ??\??£?????????
  int diagonal;         // ????§?????????????
  string ans[2] = { "NG", "OK" }; // ??????
  while(1) {
    cin >> side[0] >> side[1] >> side[2];
    if (side[0] + side[1] + side[2] == 0) break;
    // ????§????????¨????
    {
      sort(side.begin(), side.end());
      diagonal = sqrt(pow((double)side[0], 2) + pow((double)side[1], 2));
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> rad;
      cout << (rad*2 > diagonal ? "OK" : "NA") << endl;
    }
  }

}

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

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

  int Tcount=0;
  int Acount=0;

  if(A%D==0){
    Tcount = A/D;
  }
  else{
    Tcount = A/D+1;
  }

  if(C%B==0){
    Acount = C/B;
  }
  else{
    Acount = C/B+1;
  }

  if(Tcount>=Acount){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

const ll mod = 1e9 + 7;

int D;
string K;
ll dp[10001][100][2];

ll rec(int idx, int modulo, bool flag) {
  if (idx == K.size()) return modulo == 0;
  if (dp[idx][modulo][flag] != -1) return dp[idx][modulo][flag];

  ll ret = 0;
  if (flag == 1) {
    ret = rec(idx + 1, (modulo + D - (K[idx] - '0')) % D, true);
    REP(i, K[idx] - '0') {
      ret = (ret + rec(idx + 1, (modulo + D - i) % D, false)) % mod;
    }
  } else {
    REP(i, 10) {
      ret = (ret + rec(idx + 1, (modulo + D - i) % D, false)) % mod;
    }
  }
  dp[idx][modulo][flag] = ret;
  return ret;
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> K >> D;
  memset(dp, -1, sizeof(dp));
  cout << (rec(0, 0, true) + mod - 1) % mod << endl;

  return 0;
}


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

int main() {
  string s, t;
  cin >> s;

  t = s;
  reverse(t.begin(), t.end());

  int cnt = 0;
  rep(i, s.size()) if (s[i] != t[i]) cnt++;

  int ans = cnt / 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define    PI            acos(-1)
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const long double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=0;
double get_dist(double x1,double y1,double x2,double y2){

  return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}
int main(){
    GO();
    int a,b,h,m;
    cin>>a>>b>>h>>m;

    int thr=h;
    thr%=12;
    double hr=thr;
    hr+= (m+0.0)/60;
    hr/=12.0;
   // cout<<hr<<endl;
    hr*=(2*PI);

    double x1,y1,x2,y2;

    x1= cos(hr)*a;
    y1= sin(hr)*a;

    double mn=m;
    mn/=60.0;
    mn*=(2*PI);

    x2= cos(mn)*b;
    y2= sin(mn)*b;
  //  cout<<x2<<" "<<y2<<" "<<x1<<" "<<y1<<endl;
    cout<<fixed<<setprecision(10)<<get_dist(x1,y1,x2,y2)<<endl;

}

























Measured memory_bytes: 4144
import itertools
N, M = map(int, input().split())
p=[[0]*N for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    p[a-1][b-1]=1
    p[b-1][a-1]=1
cnt=0
a=[i for i in range(N)]

for i in itertools.permutations(a):
    flag=0
    if i[0]==0:
        for j in range(1,N):
            if p[i[j]][i[j-1]]!=1:
                flag=1
        if flag==0:
            cnt+=1
    
print(cnt)
      

Measured memory_bytes: 73572
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [i32; n],  // Vec<(i32, i32, i32)>
    }
    let mut ans = 0;
    for i in (0..n).step_by(2) {
        if a[i] % 2 == 1 { ans += 1 }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2148
#include <iostream>
#include <vector>
#include <algorithm>

int main() {

	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);
	int N; std::cin >> N;
	std::vector<int> V(N), C(N);
	for (int i = 0; i < N; i++)std::cin >> V[i];
	for (int i = 0; i < N; i++)std::cin >> C[i];

	std::vector<int> arr(N); for (int i = 0; i < N; i++)arr.at(i) = V.at(i) - C[i];
	std::vector<int> dp(N + 1); dp.at(0) = 0;
	for (int i = 0; i < N; i++) {
		dp[i + 1] = std::max(dp[i], dp[i] + arr[i]);
	}

	std::cout << dp[N];


	return 0;
}

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

def solve():
    N = input()
    if N[-1] in ("2","4","5","7","9"):
        print("hon")
    elif N[-1] in ("0","1","6","8"):
        print("pon")
    else:
        print("bon")


if __name__ == "__main__":
    solve()


Measured memory_bytes: 9104
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {
ll atack_cnt(ll H) {
  if(H<2) {
    return 1;
  }
  return atack_cnt(H/2) * 2  + 1;
}

int main(void) {
  ll H;cin>>H;
  // ll res=0;
  pr(atack_cnt(H));
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll; 
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
  ll n,bob=0,alice=0,cnt=3;
  cin>>n;
  vector<ll> a;
  REP(i,0,n-1)
  {
    ll x;
    cin>>x;
    a.push_back(x);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  REP(i,0,n-1)
  {
    if(cnt%2==1)
    {
      alice+=a[i];
      cnt++;
    }
    else if(cnt%2==0)
    {
      bob+=a[i];
      cnt++;
    }
  }
  cout<<alice-bob;
}

Measured memory_bytes: 256
def main():
    MOD = 1000000007
    s,t = input(),input()
    n,m = len(s),len(t)
    dp = [[0 for i in range(m+1)] for j in range(n+1)]
    dp[0][0] = 1
    for i in range(n):
        for j in range(m-1,-1,-1):
            dp[i+1][j] += dp[i][j]
            dp[i+1][j] %= MOD
            if s[i] == t[j]:
                dp[i+1][j+1] += dp[i][j]
                dp[i+1][j+1] %= MOD
    sum = 0
    for i in range(n+1):
        sum += dp[i][m]
    print(sum%MOD)

if __name__ == "__main__":
    main()

Measured memory_bytes: 32012
# 2019/09/03

n=int(input())
b=[-1]+list(map(int,input().split()))

ans=[]
while b:
    lb=len(b)
    if lb==1:break
    idx=0
    for i in range(lb):
        if i==b[i]:
            idx=i
    if idx:
        ans.append(idx)
        b.remove(idx)
    else:
        print(-1)
        exit()

print(*ans[::-1],sep='\n')


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

 vector<int> dp; 
 vector<int> n[100050]; 
 vector<int> le; 
 int lp(int i) {
  if(dp[i] != -1) 
  return dp[i];
   // cout << "EE " << i << endl; 
   if(le[i] == 0) {
    // cout << "OI" << endl; 
    dp[i] = 0; 
    return 0;
     } 
     else { 
     int ma = -1; 
     for(int o = 0; o < n[i].size(); o++) 
     { 
       if(lp(n[i][o]) > ma) 
          ma = dp[n[i][o]]; 
      } 
       dp[i] = 1+ma; 
       return dp[i]; 
       } 
       } 
       int main() 
       { 
       int N, M; cin >> N >> M; 
       vector<int> pom; 
       for(int i = 0; i <= N; i++) 
       pom.push_back(0); 
       for(int i = 1; i <= N+1; i++) 
       { 
       le.push_back(0); 
       dp.push_back(-1); 
     //  n[i-1]=pom; 
       } 
       int x, y; 
       for(int i = 1; i <= M; i++) 
       { cin >> x >> y; 
       n[x].push_back( y); 
       le[x]++; 
       } 
       int rez = 0; 
       for(int i = 1; i <= N; i++) 
       {
       
       rez  = max(rez, lp(i)); 
       } 

       cout << rez; 
       return 0; 
       } 


Measured memory_bytes: 9080
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    ll k;
    cin >> s >> k;
    for(int i = 0; i < k and i < s.size(); i++) {
        if(s[i] != '1') {
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << '1' << endl;
    return 0;
}


Measured memory_bytes: 256
unittest
{

assert( q"INPUT
2 4
0 9 9 9 9 9 9 9 9 9
9 0 9 9 9 9 9 9 9 9
9 9 0 9 9 9 9 9 9 9
9 9 9 0 9 9 9 9 9 9
9 9 9 9 0 9 9 9 9 2
9 9 9 9 9 0 9 9 9 9
9 9 9 9 9 9 0 9 9 9
9 9 9 9 9 9 9 0 9 9
9 9 9 9 2 9 9 9 0 9
9 2 9 9 9 9 9 9 9 0
-1 -1 -1 -1
8 1 1 8
INPUT".split( '\n' ).parse.expand.solve == 12 );

assert( q"INPUT
5 5
0 999 999 999 999 999 999 999 999 999
999 0 999 999 999 999 999 999 999 999
999 999 0 999 999 999 999 999 999 999
999 999 999 0 999 999 999 999 999 999
999 999 999 999 0 999 999 999 999 999
999 999 999 999 999 0 999 999 999 999
999 999 999 999 999 999 0 999 999 999
999 999 999 999 999 999 999 0 999 999
999 999 999 999 999 999 999 999 0 999
999 999 999 999 999 999 999 999 999 0
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
INPUT".split( '\n' ).parse.expand.solve == 0 );

assert( q"INPUT
3 5
0 4 3 6 2 7 2 5 3 3
4 0 5 3 7 5 3 7 2 7
5 7 0 7 2 9 3 2 9 1
3 6 2 0 2 4 6 4 2 3
3 5 7 4 0 6 9 7 6 7
9 8 5 2 2 0 4 7 6 5
5 4 6 3 2 3 0 5 4 3
3 6 2 3 4 2 4 0 8 9
4 6 5 4 3 5 3 2 0 8
2 1 3 4 5 7 8 6 4 0
3 5 2 6 1
2 5 3 2 1
6 9 2 5 6
INPUT".split( '\n' ).parse.expand.solve == 47 );

}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hw = input.front.split.to!( long[] );
	auto css = new long[][]( 10, 10 );
	foreach( ref cs; css )
	{
		input.popFront;
		cs = input.front.split.to!( long[] );
	}
	auto ass = new long[][]( hw[ 0 ], hw[ 1 ] );
	foreach( ref as; ass )
	{
		input.popFront;
		as = input.front.split.to!( long[] );
	}
	return tuple( css, ass );
}

auto solve( long[][] css, long[][] ass )
{
	css = warshallfloyd( css );
	auto ans = 0L;
	foreach( as; ass )
	{
		foreach( a; as )
		{
			if( 0 <= a ) ans += css[ a ][ 1 ];
		}
	}
	return ans;
}

// 正負の重み付きグラフの全二点間最短経路探索（ワーシャルフロイド法）
auto warshallfloyd( ref long[][] dss )
{
	foreach( p; 0L .. dss.length )
	{
		foreach( f; 0L .. dss.length )
		{
			foreach( t; 0L .. dss.length )
			{
				if( dss[ f ][ p ] == long.max || dss[ p ][ t ] == long.max ) continue;
				dss[ f ][ t ] = min( dss[ f ][ t ], dss[ f ][ p ] + dss[ p ][ t ] );
			}
		}
	}
	return dss;
}


Measured memory_bytes: 2556
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define pb push_back
#define mk make_pair
#define ull unsigned long long
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
    fastIO;
    ll m,d,m1,d1;
    cin>>m>>d>>m1>>d1;
    ll val;
    if(m+1==m1)
    {
        if(d1==1)
        {
            cout<<1<<'\n';
        }
        else
        {
            cout<<0<<'\n';
        }
    }
    else
    {
        cout<<0<<'\n';
    }
    return 0;
}

Measured memory_bytes: 256
t = list(map(int,input()))

for i in range(8):
    log = []
    x = t[0]
    for s in range(3):
        if i>>s&1:
            x += t[s+1]
            log.append("+")
        else:
            x -= t[s+1]
            log.append("-")
    if x == 7:
        print(str(t[0])+log[0]+str(t[1])+log[1]+str(t[2])+log[2]+str(t[3])+"=7")
        break

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

#define ll long long

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int k;
	string s;
	cin>>k;
	cin>>s;
	
	if((int)s.size()<=k){
		cout<<s;
	}
	else{
		for(int i=0;i<k;i++){
			cout<<s[i];
		}
		cout<<"...";
	}
	
	
	return 0;
}


Measured memory_bytes: 3580
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#define A 10
#define B 11
#define C 12
#define D 13
#define E 14
#define F 15
using namespace std;
int main()
{
	char x,y;
	scanf("%c %c",&x,&y);
    if(x < y) printf("\n<");
   else if(x > y) printf("\n>");
   else if(x = y) printf("\n=");

    return 0;
}

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

void swap(string &s_1, string &s_2, int &p_1, int &p_2, int &c_1, int &c_2){
    string a;
    int x;
    
    a = s_1;
    s_1 = s_2;
    s_2 = a;
    
    x = p_1;
    p_1 = p_2;
    p_2 = x;
    
    x = c_1;
    c_1 = c_2;
    c_2 = x;
}

int main(void){
    int n;
    
    cin >> n;
    
    vector<string> s(n);
    int p[n], count[n];
    
    rep(i, n){
        cin >> s[i] >> p[i];
        count[i] = i+1;
    }
    
    rep(j, n-1){
        rep(i, n-1){
            if(s.at(i) > s.at(i+1)){
                swap(s.at(i), s.at(i+1), p[i], p[i+1], count[i], count[i+1]);
            } else if(s.at(i) == s.at(i+1) && p[i] < p[i+1]){
                swap(s.at(i), s.at(i+1), p[i], p[i+1], count[i], count[i+1]);
            }
        }
    }
    
    rep(i, n){
        cout << count[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long eki[][] = new long[3][n-1];
		for(int i=0;i<n-1;i++) {
			eki[0][i]=sc.nextInt();
			eki[1][i]=sc.nextInt();
			eki[2][i]=sc.nextInt();
		}
		long ichiji = 0;
		long dp[] = new long[n];
		for(int i=0;i<n;i++) {
			dp[i]=0;
		}

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

				if(dp[i]<=eki[1][j]) {
					dp[i]= eki[1][j]+eki[0][j];
				}
				else {
					if(dp[i]%eki[2][j]==0) {
						dp[i]=dp[i]+eki[0][j];
					}
					else {
						dp[i]=(dp[i]/eki[2][j]+1)*eki[2][j]+eki[0][j];
					}
				}
			}
		}
		for(int i=0;i<n;i++) {
			System.out.println(dp[i]);
		}



	}

}


Measured memory_bytes: 26860
def resolve():
    n, k = map(int, input().split())
    ans = 0
    for i in range(k, n+2):
        lower = ((i-1)*i)//2
        upper = ((2*n-i+1)*i)//2
        ans += upper-lower + 1
        ans %= (10**9)+7
    print(ans)

resolve()

Measured memory_bytes: 63308
import sys
sys.setrecursionlimit(10 ** 8)


def dp(x, memo={}):
    if x in memo:
        return memo[x]
    if x in products:
        return True
    elif x == 0:
        return True
    elif x < 0:
        return False
    res = any(dp(x - p, memo) for p in products)
    memo[x] = res
    return res


x = int(input())
products = {100, 101, 102, 103, 104, 105}
if dp(x):
    print('1')
else:
    print('0')

Measured memory_bytes: 45020
#include<stdio.h>
int main(){

int a,b,c;
scanf("%d %d %d",&a,&b,&c);

if((a<c)&&(b<c))
{
    if(a<b)printf("%d %d %d\n",a,b,c);
    else printf("%d %d %d\n",b,a,c);
}
else if((a<b)&&(c<b))
{
    if(a<c)printf("%d %d %d\n",a,c,b);
    else printf("%d %d %d\n",c,a,b);
}
if((b<a)&&(c<a))
{
    if(c<b)printf("%d %d %d\n",c,b,a);
    else printf("%d %d %d\n",b,c,a);
}
return 0;
}



Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  long long arr[n];
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
  long long max=0;
  for(int i=0;i<n;i++){
    if(max<arr[i]){
      max=arr[i];
    }
    else if(max==arr[i]+1){
      arr[i]++;
    }
    else if(max>arr[i]+1){
      cout<<"No\n";
      return 0;
    }
  }
  cout<<"Yes\n";
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
	string s1, s2;
	cin >> s1;
	cin >> s2;
	bool flag = true;
	for (int i = 0; i < s1.length(); i++){
		if (s1[i] != s2[i]){
			flag = false; break;
		}
	}
	if (flag){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


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

P = (N - 1) * (N - 2) // 2
if K > P:
    print(-1)
else:
    print(N - 1 + P - K)
    for i in range(2, N + 1):
        print(1, i)
    S, D = 2, 3
    for i in range(P - K):
        print(S, D)
        D += 1
        if D > N:
            S, D = S + 1, S + 2


Measured memory_bytes: 3608
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  vi v(n);
  int c = 0, e = 0;
  rep(i, n) {
    if (s[i] == 'a' && c < a + b) {
      v[i] = true;
      c++;
    }
    if (s[i] == 'b' && c < a + b && e < b) {
      v[i] = true;
      c++, e++;
    }
  }
  for (auto x : v) cout << (x ? "Yes" : "No") << endl;
}


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

int main() {

    int n;
    int h = 0;
    int m = 0;
    int s = 0;
    cin >> n;

    //while (n % 3600 == 0){
    //    n = n / 3600 ;
    //    h++;
    //}
    h = n / 3600 ;
    m = ((n % 3600) / 60 );
    s = ((n % 3600) % 60 );
    cout << n / 3600 << ":" << m  << ":" << s << endl;

    return 0;
}

Measured memory_bytes: 3108
#include<stdio.h>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<cstring>
#include<queue>
#include<stack>
#include<vector>
#define re register 
using namespace std;
const int mod = 998244353;
int ad(int x,int y) { x+=y; return x>=mod?x-mod:x; }
int sb(int x,int y) { x-=y; return x<0?x+mod:x; }
int mu(int x,int y) { return 1ll*x*y%mod; }
void up(int &x,int y) { x+=y; x%=mod; }
int f[200005][3][3][2];//mod lst 0/1
char ss[200005];
int n,SM;

void tp() {
	if(ss[1]!=ss[2]&&ss[2]!=ss[3]&&ss[1]!=ss[3]) puts("3");
	else if(ss[1]==ss[2]&&ss[2]==ss[3]) puts("1"); 
	else if(ss[1]==ss[3]) puts("7");
	else puts("6");//ss1==ss2||ss2==ss3
} 

int main() {
	scanf("%s",&ss[1]);
	n = strlen(ss+1);
	
	if(n==3) {
		tp(); return 0;
	}
	
	for(int i=0;i<=2;i++) f[1][i][i][0] = 1;
	bool mk = 0;
	bool mm = 0;
	ss[0] = 233;
	for(int i=1;i<=n;i++) {
		ss[i]-='a'; SM+=ss[i]; SM%=3;
		if(ss[i]==ss[i-1]) mk = 1;
		if(i!=1&&ss[i]!=ss[i-1]) mm = 1;
	}
	if(!mm) {
		puts("1"); return 0;
	}
	int ans = 0;
	if(!mk) ans = 1;
	for(re int i=1;i<=n-1;i++) {
		for(re int j=0;j<=2;j++) {
			for(re int k=0;k<=2;k++) {
				for(re int o=0;o<=1;o++) {
					if(!f[i][j][k][o]) continue;
					for(re int d=0;d<=2;d++) {
						up(f[i+1][(j+d)%3][d][o|(d==k?1:0)],f[i][j][k][o]);
					}
				}
			}
		}
	}
	//100000 * (3^3) * 2 == 5400000
	for(int i=0;i<=2;i++) {
		up(ans,f[n][SM][i][1]);
	}
	printf("%d",ans);
}

Measured memory_bytes: 14464
N,W = map(int,input().split())
dp = [float('inf')]*(10**5+5)
dp[0] = 0 
for _ in range(N):
    w,v=map(int,input().split())
    for i in range(10**5+4,v-1,-1):
        dp[i]=min(dp[i],dp[i-v]+w)
ans=0
for v,w in enumerate(dp):
    if w <= W:
        ans = v
print(ans)

Measured memory_bytes: 93132
#include "bits/stdc++.h"
#include "math.h"
#include "string.h"
#include "algorithm"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())

int main(){
  int n,k;
  cin>>n>>k;
  vll a(n);
  REP(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  ll m=INT_MAX;
  REP(i,n-k+1){
    m=min(m,a[i+k-1]-a[i]);
  }
  cout<<m<<endl;
}


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

int main(){
	int n, a, x, y, z;
	vector<int> v;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a;
		v.push_back(a);
	}
	int max = *max_element(v.begin(), v.end());
	
	y = max;
	for(int j = 0; j < n; j++){
		z = abs(v[j] - max/2.0);
		if(y>=z){
			y = z;
			x = j;
		}
	}
	printf("%d %d", max, v[x]);
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;

    for (int i = 1; i <= n; ++i) {
        int sum = 0, j = i;
        while (j) {
            sum += j % 10;
            j /= 10;
        }
        if (sum <= b && sum >= a) ans += i;
    }
    cout << ans;
    return 0;
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int main(){
    int n;
    cin>>n;
    vector<int> a(n), b(n), c(n);
    rep(i,n) cin>>a[i]>>b[i]>>c[i];
    vector<int> dp(3);
    dp[0]=a[0]; //幸福度
    dp[1]=b[0];
    dp[2]=c[0];
    for(int i=1;i<n;i++){
        vector<int> dpt(3);
        dpt[0]=max(dp[1],dp[2])+a[i];
        dpt[1]=max(dp[0],dp[2])+b[i];
        dpt[2]=max(dp[0],dp[1])+c[i];
        dp=dpt;
    }
    int ans=0;
    rep(i,3) ans=max(ans,dp[i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

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

    string s;
    cin >> s;

    int w = 0;

    for (const char &c : s)
        w += (c == 'o');

    w += (15 - s.size());


    if (w > 7) {
        cout << "YES\n";
    }
    else {
        cout << "NO\n";
    }

    return 0;
}

Measured memory_bytes: 256
n,W=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
dp=[[0 for _ in range(W+1)] for _ in range(n+1)]
for i in range(n):
    weight,value=a[i]
    for j in range(W+1):
        dp[i+1][j]=max(dp[i][j],dp[i+1][j])
        if j+weight<=W:
            dp[i+1][j+weight]=max(dp[i][j+weight],dp[i][j]+value)
print(dp[-1][-1])

Measured memory_bytes: 217792
//بسم الله الرحمن الرحيم
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define el << endl
#define PI 3.141592653589793238
#define _test_ int t; cin >> t; while(t--)
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
ll gcd ( ll  a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }
int dx[]={0,0,+1,-1,+1,-1,-1,+1};
int dy[]={+1,-1,0,0,+1,-1,+1,-1};
///*......................*//* LET'S BEGIN (-_^) *//*............................///
const int mx= 3e5+123;
string s;
int k;
bool b;

void _case_()
{
    cin >> s;
    if(s[0]=='R') k++;
    if(s[1]=='R')
    {
        k++;
        b=1;
    }
    b and s[2]=='R' ? cout << ++k el : s[2]=='R' ? cout << 1 : cout << k;
}

int main()
{

    optimize();
    //_test_
      _case_();
    return 0;

}

///////////*  N A Y E M  *///////////

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define FINISH cout<<"No"<<endl;return 0;

int main(){
	int N;
	cin >> N;
	int a = 1;
	for (int i = 0;i < N;i++)a *= 2;
	vector<int> X(a);
	multiset<int> S;
	priority_queue<int> Q, R;
	for (int i = 0;i < a;i++) {
		cin >> X[i];
		S.insert(X[i]);
	}
	auto it = S.end();it--;
	Q.push(*it);
	S.erase(it);

	for (int i = 0;i < N;i++) {
		while (!Q.empty()) {
			a = Q.top();
			Q.pop();
			it = S.lower_bound(a);
			if (it == S.begin()) { FINISH; }
			it--;
			R.push(a);
			R.push(*it);
			S.erase(it);
		}
		swap(Q, R);
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 15280
def lscan; gets.split.map(&:to_i); end

x, y = lscan

(0..50).each do |a|
  (0..25).each do |b|
    if a+b == x && a*2+b*4 == y
      puts 'Yes'
      exit
    end
  end
end
puts 'No'

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 1000000007;
const lli e3 = 1 << 13;
const lli INF = 1ll << 62;

lli n;
lld x[e5];
lli m,k;
lli a[e5];
lld dy[e5];
lld dy_[e5];
lli s[e5];
lli s_[e5];

int main(){
  cin >> n;
  for(lli i = 1;i <= n;i++) cin >> x[i];
  cin >> m >> k;
  for(lli i = 1;i <= m;i++) cin >> a[i];
  for(lli i = 1;i < n;i++){
    dy[i] = x[i+1]-x[i];
  }
  iota(s,s+n,0ll);
  for(lli i = 1;i <= m;i++){
    swap(s[a[i]],s[a[i]-1]);
  }
  for(lli b = 1;b <= k;b <<= 1){

    if((b&k) != 0){
      for(lli i = 1;i < n;i++){
        dy_[i] = dy[s[i]];
      }
      swap(dy,dy_);
    }
    for(lli i = 1;i < n;i++){
      s_[i] = s[s[i]];
    }
    swap(s,s_);

  }
  lli point = x[1];
  for(lli i = 1;i <= n;i++){
    cout << point << endl;
    point = point + dy[i];
  }

}


Measured memory_bytes: 38144
#include<iostream>

using namespace std;

int main(){
  long long int n,x,r;
  cin >> n;
  
  x=n;
  r=0;
  while(x>0){
  r+=x%10;
  x=x/10;  
  }
  
  if(n%r==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
using ll = unsigned long long;
ll u18 = 1000000000000000000;
int main()
{
    
    long double a, b;
    cin >> a >> b ;

    cout << (ll)(a*b) << endl;
   
    return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll MOD = 1000000007;
string s;
ll LA[100010], RC[100010];
ll LL[100010], RR[100010];

ll mod_pow(ll x, ll n, ll mod) {
  if (n < 0) return mod_pow(x, -n * (mod - 2), mod);
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> s;
  for (int i = 0; i + 1 < s.size(); i++) {
    LA[i + 1] = LA[i] + (s[i] == 'A');
    LL[i + 1] = LL[i] + (s[i] == '?');
  }  
  for (int i = s.size() - 1; i - 1 >= 0; i--) {
    RC[i - 1] = RC[i] + (s[i] == 'C');
    RR[i - 1] = RR[i] + (s[i] == '?');
  }
  ll ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A' || s[i] == 'C') continue;
    ll tmp = 1;
    (tmp *= mod_pow(3, LL[i] + RR[i] - 2, MOD)) %= MOD;
    (tmp *= (LL[i] + 3 * LA[i] % MOD) % MOD) %= MOD;
    (tmp *= (RR[i] + 3 * RC[i] % MOD) % MOD) %= MOD;
    (ans += tmp) %= MOD;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890

using namespace std;

int main()
{
    int i,j;
    int M,D;

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

    int cnt = 0;
    for( i=1; i<=M; i++)
    {
        for( j=1; j<=D; j++)
        {
            int d1 = j%10;
            int d2 = j/10;
            if( d1>=2 && d2>=2 && d1*d2==i)
                cnt++;
        }
    }

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

    return 0;
}


Measured memory_bytes: 384
from itertools import product
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

ans = -(10 ** 30)
for p in product(range(2), repeat=10):
    if sum(p) == 0: continue
    tmp = 0
    for i in range(N):
        # お店ごとにかぶっている日数を数える
        cnt = 0
        for j in range(10):
            if p[j] and F[i][j]:
                cnt += 1
        tmp += P[i][cnt]
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 44508
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

bool isPrime(int N){
	int A = sqrt( (double)N);
	while( A != 1){
		if( N % A == 0) return false;
		A--;
	}
	return true;
}

int main()
{
	int n;
	cin>>n;
	for(int i = n; i <= 1e6; i++){
		if(isPrime(i) == true){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  char dif='A'-'a';
  printf("%c%c%c\n",s1[0]+dif,s2[0]+dif, s3[0]+dif);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int seach(int A[], int n, int key){
  int i = 0;
  A[n] = key;
  while(A[i] != key)i++;
  return i != n;
}

int main(){
  int i,n,A[10000+1],q,key,sum = 0;

  scanf("%d",&n);
  for(i = 0; i < n; i++)scanf("%d",&A[i]);

  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&key);
    if(seach(A,n,key))sum++;
  }
  printf("%d\n",sum);

  return 0;
}



Measured memory_bytes: 2096
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int p,l,r;
};

struct Node T[MAX];
int n;

void preParse(int u){
  if(u == NIL) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u ==NIL) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(){
  int i,v,l,r,root;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    T[i].p = NIL;
  }

  for(i = 0;i < n;i++){
    scanf("%d %d %d",&v,&l,&r);

    T[v].l = l;
    T[v].r = r;

    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }

  for(i = 0;i < n;i++){
    if(T[i].p == NIL) root = i;
  }
  
  printf("Preorder\n");
  preParse(root);
  printf("\nInorder\n");
  inParse(root);
  printf("\nPostorder\n");
  postParse(root);
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    int N,K;
    cin>>N>>K;
    LL a[N];
    REP(i,N)cin>>a[i];

    int dpbot[N+1][K+1];
    int dptop[N+1][K+1];

    fill(dpbot[0],dpbot[N+1],0);
    fill(dptop[0],dptop[N+1],0);

    REP(i,N+1){
        dpbot[i][0]=1;
        dptop[i][0]=1;
    }

    REP(i,N){
        REP(j,K){
            if(dpbot[i][j]){
                dpbot[i+1][j]=1;
                if(j+a[i]<K)dpbot[i+1][j+a[i]]=1;
            }
            if(dptop[N-1-i][j]){
                dptop[N-i-2][j]=1;
                if(j+a[N-i-1]<K)dptop[N-i-2][j+a[N-i-1]]=1;
            }
        }
    }


    int ans=0;
    REP(i,N){
        for(int j=K-1;j>=0;j--){
            if(dptop[i][j]>0&&j+a[i]<K){
                dptop[i][j+a[i]]--;
            }
        }
        REP(j,K-1)dptop[i][j+1]+=dptop[i][j];

        REP(j,K){
            if(dpbot[i][j]>0){
                if(dptop[i][K-1-j]>0){
                    ans++;
                    break;
                }
            }
        }
    }

    cout<<N-ans<<endl;



    return 0;
}

Measured memory_bytes: 195712
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
using namespace std;
typedef long long ll;

vector<pair<int, int>> to[100010];
bool visited[100010];
ll dist[100010];
int main() {
    
    vector<vector<int>>c(3,vector<int>(3));
    rep(i,0,3){
        rep(j,0,3){
            cin>>c[i][j];
        }
    }
    vector<int>tmp(3);
    rep(i, 0, 2){
        tmp[0] = c[i+1][0] - c[i][0];
        tmp[1] = c[i+1][1] - c[i][1];
        tmp[2] = c[i+1][2] - c[i][2];
        if( tmp[0] != tmp[1] || tmp[0]!=tmp[2] || tmp[1]!=tmp[2] ){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 5980
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
#define int long long
#define All(v) (v.begin(),v.end())
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
int modpow(int a,int b){
    if(!b)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int fac(int a){
    int Ans=1;
    for(int i=1;i<=a;i++){
        Ans*=i;
        Ans%=MOD;
    }
    return Ans;
}//kaijo
int comb(int a,int b){
    return fac(a)*modpow(fac(a-b),MOD-2)%MOD*modpow(fac(b),MOD-2)%MOD;
}
signed main(){
	int n;
	int a[110];
	cin>>n;
	int sum=0;
	int ans=100000;
	rep(i,n){
		cin>>a[i];
		sum+=a[i];
		ans=min(ans,sum/(i+1));
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 3108
n = int(input())
t, x, y = 0, 0, 0
for _ in range(n):
    nt, nx, ny = map(int, input().split())
    d = abs(nx-x)+abs(ny-y)
    
    if nt-t<d or d%2!=(nt-t)%2:
        print('No')
        exit()
    
    t, x, y = nt, nx, ny

print('Yes')


Measured memory_bytes: 46056
import math
A,B,H,M=input().split()

  #長針:M*PI/30
  #短針:H*PI/6+M*PI/360
  #a^2=b^2+c^2-2bc*cos(arg)
a=int(A)
b=int(B)
h=int(H)
m=int(M)

Pi=math.pi
radi=abs(m*Pi/30-(h*Pi/6+m*Pi/360))
ans1=math.pow(a,2)+math.pow(b,2)-2*a*b*(math.cos(radi))
ans2=math.sqrt(ans1)
print('{:.10f}'.format(ans2))


Measured memory_bytes: 9452
Sset=set(input())
Sset=sorted(Sset)

ans = "None"
flg = True
last = "None"
for i,c in enumerate(Sset):
	if i+97 !=ord(c):
		flg=False
		ans = chr(i+97)
		break
	last = c

if flg and last != 'z' :
	ans = chr(ord(last)+1)
print(ans)


Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b >>c;
  if (a+b==c || a+c==b || b+c==a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

void A()
{
  string S;
  cin >> S;
  
  if( S == "ABC" ) cout << "ARC" << endl;
  else cout << "ABC" << endl;
}

void B()
{
  int N, K;
  cin >> N >> K;
  
  vector<int> d(K);
  vector<vector<int>> A;
  for( int i = 0; i < K; ++i ){
    cin >> d[i];
    
    vector<int> a(d[i]);
    for( int j = 0; j < d[i]; ++j ){
      cin >> a[j];
    }
    A.push_back(a);
  }
  
  vector<bool> sunuke_kun(N);
  for( int i = 0; i < N; ++i ) sunuke_kun[i] = true;
  
  for( int i = 0; i < K; ++i )
    for( int j = 0; j < d[i]; ++j )
      sunuke_kun[A[i][j]-1] = false;
  
  int ans = 0;
  for( auto i : sunuke_kun )
    if( i ) ++ans;
  
  cout << ans << endl;
}

int main()
{
  //A();
  B();
  
  return 0;
}

Measured memory_bytes: 3628
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>

using namespace std;

#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

//10^9 + 7
const ll MOD = 1000000007;

int main() {
	ll A[3][3];

	bool B[3][3];

	rep(i, 3) {
		rep(j, 3) {
			cin >> A[i][j];
			B[i][j] = false;
		}
	}




	ll N;
	cin >> N;

	ll b;
	rep(i, N) {
		cin >> b;

		rep(j, 3) {
			rep(k, 3) {
				if (A[j][k] == b) {
					B[j][k] = true;
				}
			}
		}

	}
	string Bingo = "No";
	bool isBingo[4];
	rep(i, 3) {

		isBingo[0] = B[i][0] && B[i][1] && B[i][2];
		isBingo[1] = B[0][i] && B[1][i] && B[2][i];
		isBingo[2] = B[0][0] && B[1][1] && B[2][2];
		isBingo[3] = B[0][2] && B[1][1] && B[2][0];


		if (isBingo[0] || isBingo[1] || isBingo[2] || isBingo[3]) {
			Bingo = "Yes";
			break;
		}

	}

	cout << Bingo << endl;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    sa = ''
    for c in s:
        if c == '?':
            sa += 'a'
        else:
            sa += c
    t = S()
    r = None
    l = len(t)
    for i in range(len(s)-l+1):
        f = True
        for j in range(l):
            if s[i+j] != '?' and s[i+j] != t[j]:
                f = False
                break
        if f:
            tr = sa[:i] + t + sa[i+j+1:]
            if not r or r > tr:
                r = tr

    if not r:
        return 'UNRESTORABLE'
    return r


print(main())




Measured memory_bytes: 67052