akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define pb push_back
#define vi vector<int >
#define vii vector < pair<int ,int > >
#define IO ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define IOfiles freopen("input.txt","r+",stdin) ; freopen("output.txt","w+",stdout)
#define PI 3.14159265
const long long mod = 1e9 + 7LL;
typedef long long ll;
typedef pair<int, int> ii;
typedef double db;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;}
ll pwr(ll x , ll n) { ll ans = 1; while (n) {ans *= x; n--;} return ans;}


int main()
{
    IO;
    string s;
    cin>>s;
    int n=s.length();
    //int dp[n][2019];
    //memset(dp,0,sizeof dp);
    int arr[2][2019];
    memset(arr,0,sizeof arr);
    arr[0][s[0]-'0']++;
    //dp[0][s[0]-'0']++;
    int ans=0;
    for(int i=1;i<n;i++){
        int v=s[i]-'0';
        
        int p=(i+1)%2;
        for(int j=0;j<2019;j++)
            arr[i%2][j]=0;
        arr[i%2][v]++;
        for(int j=0;j<2019;j++){
            arr[i%2][(j*10+v)%2019]+=arr[p][j];
        }
        //if(arr[i%2][0])
        //cout<<arr[i%2][0]<<endl;
        ans+=arr[i%2][0];
    }
    /*for(int i=0;i<n;i++){
        for(int j=0;j<2019;j++){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    /*cout<<dp[8][0]<<endl;
    cout<<dp[n-1][0]<<endl;*/
    //int ans=0;
    /*for(int i=0;i<n;i++)
        ans+=dp[i][0];*/
    cout<<ans<<endl;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

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

  vector<char> a(1);
  a.at(0) = s.at(0);
  for(int i = 1; i < s.size(); i++) {
    for(int j = 0; j < a.size(); j++) {
      if(s.at(i) == a.at(j)) {
        cout << "no" << endl;
        return 0;
      }
    }
    a.push_back(s.at(i));
  }
  cout << "yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int b[3][3];
int main(){
	int a[3][3];
	for(int i=0;i<3;i++)
	for(int j=0;j<3;j++)
	cin>>a[i][j];
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int h;
		cin>>h;
		for(int j=0;j<3;j++)
		{
			for(int k=0;k<3;k++)
			{
				if(a[j][k]==h)
				b[j][k]=1;
			}
		}
	}
	if(b[0][0]&&b[0][1]&&b[0][2]||b[1][0]&&b[1][1]&&b[1][2]||b[2][0]&&b[2][1]&&b[2][2])
	{
		cout<<"Yes";
	}
	else if(b[0][0]&&b[1][0]&&b[2][0]||b[0][1]&&b[1][1]&&b[2][1]||b[0][2]&&b[1][2]&&b[2][2])
	{
		cout<<"Yes";
	}
	else if(b[0][0]&&b[1][1]&&b[2][2]||b[2][0]&&b[1][1]&&b[0][2])
	{
		cout<<"Yes";
	}
	else
	cout<<"No";
} 

Measured memory_bytes: 256
import numpy as np
#import math
N, K = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
F = np.array(sorted(list(map(int, input().split())), reverse=True))



left = - 1
right = 10**12

def f(x):
    l = x//F
    return A[A > l].sum() <= K + l[A > l].sum()

while right - left > 1:
    mid = (left + right)//2
    if f(mid):
        right = mid
    else:
        left = mid
    
print(right)

Measured memory_bytes: 37276
#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 <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

int A() {
    int x; cin >> x;

    if (x >= 30) {
        pYes;
    }
    else {
        pNo;
    }

    return 0;
}

int main() {
    A();
}

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

int main(){
	int n , mod = 0 , sam = 0 ; 
	string word , wordp ;
	cin >> n >> word >> wordp ;
	for( int i = 0 ; i < n ; i++ ){
		if( word == wordp ){
			sam = word.size() ;
			break ;
		}
		wordp.erase( wordp.size() -1 , 1 ) ;
		word.erase( 0 , 1 ) ;
	}
	cout << 2 * n - sam ;
}


// start : 77 ; 8:50 
//https://atcoder.jp/contests/agc005/tasks


Measured memory_bytes: 256
#include<bits/stdc++.h>    
using namespace std;
#define ll long long 
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define pb push_back
#define inf 1e16
#define mod 998244353
#define en '\n'
#define ld long double
#define ff first
#define ss second
#define ull unsigned long long 
ll pw(ll b, ll r, ll md){
	ll ans = 1;
	while(r){
		if(r&1)ans = (ans*b)%md;
		b = (b*b)%md;
		r>>=1;
	}
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,m;cin>>n>>m;
	string arr[n];for(int i = 0 ; i < n ; i ++ )cin>>arr[i];
	ll dp[n][m];memset(dp,0,sizeof dp);
	for(int i = 0 ; i < n ; i ++ ){
		for(int j = 0 ; j < m ; j ++ ){
			if(i==0){
				if(j==0)dp[i][j]=(arr[i][j]=='.'?0:1);
				else {
					if(arr[i][j-1]==arr[i][j])dp[i][j]=dp[i][j-1];
					else if(arr[i][j]=='#')dp[i][j]=dp[i][j-1]+1;
					else dp[i][j]=dp[i][j-1];
				}
			} else if(j==0){
				if(arr[i-1][j]==arr[i][j])dp[i][j]=dp[i-1][j];
				else if(arr[i][j]=='#')dp[i][j]=dp[i-1][j]+1;
				else dp[i][j]=dp[i-1][j];
			} else {
				ll mn = inf;
				if(arr[i][j-1]==arr[i][j])mn=dp[i][j-1];
				else if(arr[i][j]=='#')mn=dp[i][j-1]+1;
				else mn=dp[i][j-1];

				if(arr[i-1][j]==arr[i][j])mn=min(mn,dp[i-1][j]);
				else if(arr[i][j]=='#')mn=min(mn,dp[i-1][j]+1);
				else mn=min(mn,dp[i-1][j]);
				dp[i][j]=mn;
			}
		}
	}
	// for(int i = 0 ; i < n ; i ++ ){
	// 	for(int j = 0 ; j < m ; j ++ )cout<<dp[i][j]<<" ";
	// 	cout<<en;
	// }
	cout<<dp[n-1][m-1]<<en;
	return 0 ; 
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

PII operator+(const PII &a, const PII &b){
    return PII(a.first + b.first, a.second + b.second);
}

PII operator-(const PII &a, const PII &b){
    return PII(a.first - b.first, a.second - b.second);
}
bool operator==(const PII &a, const PII &b){
    return (a.first == b.first) && (a.second == b.second);
}
int main(){
    int N;
    cin >> N;
    vector<PII> line(N);
    REP(i, N){
        cin >> line[i].first >> line[i].second;
    }
    int ans = N;
    REP(i, N){
        REP(j, N){
            if(i==j)continue;
            PII slide = line[i] - line[j];
            int count = 0;
            REP(k, N){
                REP(l, N){
                    if((line[k] + slide) == line[l]){
                        ++count;
                    }
                }
            }
            ans = min(ans, N - count);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const long long MOD = 998244353;
const long long MAX = 1e6;

long long fact[MAX], fact_inv[MAX];

long long power(long long a, long long b){
	long long ret = 1;
	while(b > 0){
		if(b & 1){
			ret = (ret * a) % MOD;
		}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return ret;
}

void init_nCr(long long n){
	fact[0] = 1;
	for (int i = 0; i < n; i++){
		fact[i + 1] = (fact[i] * (i + 1)) % MOD;
	}
	fact_inv[n] = power(fact[n], MOD - 2);
	for (int i = n - 1; i >= 0; i--){
		fact_inv[i] = (fact_inv[i + 1] * (i + 1)) % MOD;
	}
}

long long nCr(long long n, long long r){
	return (((fact[n] * fact_inv[r]) % MOD) * fact_inv[n - r]) % MOD;
}

long long pow(long long n, long long c){
	long long ret = 1;
	while(n != 0){
		if(n&1){
			ret = ret * c % MOD;
		}
		c = c * c % MOD;
		n /= 2;
	}
	return ret;
}

int main(){
	long long N, M, K;
	cin >> N >> M >> K;

	init_nCr(2 * 1e5);

	long long ans = 0;
	for (int i = 0; i <= K; i++){
		long long add = (M * pow(N - i - 1, M - 1) % MOD) * nCr(N - 1, i) % MOD;
		ans = (ans + add) % MOD;
	}

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


Measured memory_bytes: 6720
N=int(input())
p=1
S=[]
A=[]
U=[]
T=[]
L= [list(map(str,input().split())) for i in range(N)]
for j in range(1,N+1):
  L[j-1].append(j)
L.sort(key=lambda x: x[0])
#print(L)
S=L[:]
S.sort(reverse=True,key=lambda x: int(x[1]))
#print(S)
T.append(L[0][0])
for i in range(1,N):
  if L[i-1][0]!=L[i][0]:
    T.append(L[i][0])
#print(T)
for j in range(len(T)):
  for k in range(N):
    if S[k][0]==T[j]:
      A.append(S[k][2])
for i in range(N):
  print(A[i])

Measured memory_bytes: 3064
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int ans = 0, cur = 0;
    for (auto c : s) {
        if (c == 'R') {
            cur++;
            ans = max(ans, cur);
        } else {
            cur = 0;
        }
    }

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

Measured memory_bytes: 3608
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = 998244353;
map<string, int> F;
int go(string s) {
	if (s.empty()) return 1;
	if (F.count(s)) return F[s];
	string t = s.substr(1);
	int ret = go(t) * ((s[0] == '1') + 1);
	if (ret >= MOD) ret -= MOD;
	int n = s.length();
	for (int i = 1; i + i <= n; ++i) {
		int j = i;
		string t = s.substr(0, i);
		while (j + i <= n) {
			for (int k = 0; k < i; ++k)
				if (s[j + k] == '0') t[k] = '0';
			j += i;
			ret = (ret + (ll)go(t) * go(s.substr(j))) % MOD;
		}
	}
	return F[s] = ret;
}
int main() {
	string s;
	cin >> s;
	printf("%d\n", go(s));
}


Measured memory_bytes: 6784
import java.util.Scanner;

public class Main {

	static int[] memo;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		memo = new int[100010];
		for(int i = 0 ; i < 100010 ; i++) {
			memo[i] = -1;
		}
		System.out.println(rec(n));
	}

	static int rec(int x) {
		if(x == 0) return 0;
		if(memo[x] != -1) return memo[x];
		int res = x;
	    for (int pow6 = 1; pow6 <= x; pow6 *= 6) res = Math.min(res, rec(x - pow6) + 1);
	    for (int pow9 = 1; pow9 <= x; pow9 *= 9) res = Math.min(res, rec(x - pow9) + 1);
		return memo[x] = res;
	}
}


Measured memory_bytes: 27860
k, n = gets.chop.split.map(&:to_i)
a = gets.chop.split(' ').map(&:to_i)


dis = []

a.each_with_index do |val, i|
  if i == 0
    dis.push(val) 
  else
    dis.push(val - a[i - 1])
  end
end

dis.push(k - a[-1] + a[0])
max = dis.max

puts k - max


Measured memory_bytes: 18308
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		for(;;){


			int n = sc.nextInt(),k=sc.nextInt();
			if(n+k==0)break;
			long[]a  = new long[n];
			long[]sum=new long[n+1];
			for(int i =0;i<n;i++){
				a[i]=sc.nextInt();
				sum[i+1]=sum[i]+a[i];
			}
			long max=Long.MIN_VALUE;
			for(int i=k;i<n+1;i++){
				max=Math.max(max, sum[i]-sum[i-k]);
			}
			System.out.println(max);

		}

	}
}

Measured memory_bytes: 64428
#include <iostream>
#include <string>

int main() {
    std::string s;

    std::cin >> s;

    int count = 0;
    if(s[0] == '1')count++;
    if(s[1]=='1')count++;
    if(s[2]=='1')count++;
    std::cout << count << std::endl;
    return 0;   

}

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

int main(void){
    string s;
    cin >> s;
    vector<int> v;
    for(int i=0; i<s.length(); i++){
        v.push_back(stoi(s.substr(i, 1)));
    }
    int ans = 1e5;
    for(int i=0; i+2<v.size(); i++){
        int a = v.at(i)*100 + v.at(i+1)*10 + v.at(i+2);
        int d = abs(753 - a);
        if(d < ans){
            ans = d;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    string s;
    cin>>a>>b;
    cin>>s;
        if(s[a] == '-')
        {
            int flag = 0;
            for(int i=0; i<a; i++)
            {
                if(s[i] == '0' || s[i] == '1' || s[i] == '2' || s[i] == '3' || s[i] == '4' || s[i] == '5' || s[i] == '6' || s[i] == '7' || s[i] == '8' || s[i] == '9')
                    continue;
                else
                    flag = 1;
            }
            for(int i=a+1; i<a+b+1; i++)
            {
                if(s[i] == '0' || s[i] == '1' || s[i] == '2' || s[i] == '3' || s[i] == '4' || s[i] == '5' || s[i] == '6' || s[i] == '7' || s[i] == '8' || s[i] == '9')
                    continue;
                else
                    flag = 1;
            }

            if(flag == 0)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }
        else
            cout<<"No"<<endl;
    return 0;
}


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

int main(){
  int n; cin >>n;
  map<string, int> mp;
  vector<string> s(n);
  rep(i,n){
    cin >>s[i];
    sort(s[i].begin(), s[i].end());
    mp[s[i]]++;
  }
  ll ans = 0;
  for(string t : s){
    if(mp[t]>1) {
      ans += mp[t]-1;
      mp[t]--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 14364
import sys
from itertools import combinations
input = sys.stdin.readline
N = int(input())
A = [i for i in range(N)]
XY = [[] for n in range(N)]

for n in range(N):
    A[n] = int(input().strip())
    for a in range(A[n]):
        x, y = [int(x) for x in input().strip().split()]
        XY[n].append((x, y))

ans = 0
def check(honests, A, XY, N):
    #print('in check(honests: {})'.format(honests))
    honest = [0] * N
    for h in honests:
        honest[h] = 1
    f = True
    for nn in range(N):
        if nn not in honests:
            continue
        #print('nn = {}'.format(nn))
        xy = XY[nn][:]
        #print('  honest={}'.format(honest))
        for x, y in xy:
            if x-1 in honests and y == 0:
                #print('x = {}, break'.format(x))
                f = False
                break
            elif honest[x-1] != y:
                #print('xxxx')
                f = False
                break
        #print('  honest={}'.format(honest))
        if not f:
            break
    else:
        return True
    return False

for n in range(N, 0, -1):
    for honests in combinations(range(N), n):
        if check(honests, A[:], XY[:], N):
            print(n)
            exit()
else:
    print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    int L,R,d;
    cin >> L >> R >> d;
    int ans = (R - L)/d;
    if(R%d == 0){
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll s,c; cin>>s>>c;
	ll ans=0;
	if(s*2>=c){
		c/=2;
		cout<<c;
		return 0;
	}
	else{
		ans=s;
		c-=(s*2);
		ans+=(c/4);
		cout<<ans;
	}
	
	return 0;
}

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

int main(){

    int n;
    cin >> n;

    vector<long long> val(n);
    for(int i  = 0; i < n; i++){
        cin >> val[i];
    }

    if(n % 2 == 0){
        for(int i = n -1; i > 0; i-=2){
            cout << val[i] << " ";
        }
        for(int i = 0; i < n; i+=2){
            cout << val[i] << " ";
        }
    }
    else{
        for(int i = n -1; i >= 0; i-=2){
            cout << val[i] << " ";
        }
        for(int i = 1; i < n; i+=2){
            cout << val[i] << " ";
        }
    }


}

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

int main() {
  int k,a,b;
  cin >> k >> a >> b;
  
  if (a % k == 0 || a % k > b % k || b - a + 1 >= k) {
    cout << "OK" << endl;
  }
  else {
    cout << "NG" << endl;
  }
}
    

Measured memory_bytes: 3516
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, d = ns()
    ans = 0
    lim = d ** 2
    for _ in range(n):
        xi, yi = ns()
        if lim >= xi ** 2 + yi ** 2:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11236
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <stack>

typedef long long ll;
typedef std::vector< int > VI;

const double EPS = 1e-10;
const double PI  = acos(-1);
const ll     INF = 1e10;

int main(int argc, char* argv[])
{
  int n;
  std::cin >> n;

  std::vector< int > v10(10, 0);
  std::vector< std::vector< int > > vf(n, v10);

  std::vector< int > v11(11, 0);
  std::vector< std::vector< int > > vp(n, v11);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      std::cin >> vf[i][j];
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      std::cin >> vp[i][j];
    }
  }

  ll ans = -INF;
  for (int i = 1; i < std::pow(2, 10); i++) {
    ll val = 0;
    for (int j = 0; j < n; j++) { // 店ループ
      int cnt = 0;
      for (int k = 0; k < 10; k++) {
	int x = i >> k;
	if (x & 1 && vf[j][k] == 1) {
	  cnt++;
	}
      }
      val += vp[j][cnt];
    }
    ans = std::max(ans, val);
  }

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if((max(a,b)-min(a,b))%2==0)
	{
		printf("%d\n",min(a,b)+(max(a,b)-min(a,b))/2);
	}
	else
	{
		printf("IMPOSSIBLE\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define plll pair<pll,ll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;

ll rank1[100010];
ll parent[100010];
ll connected;

ll find_set(ll idx)
{
    if(parent[idx]==idx)
    {
        return idx;
    }
    parent[idx]=find_set(parent[idx]);
    return parent[idx];
}

void union_set(ll vert1,ll vert2)
{
    vert1=find_set(vert1);
    vert2=find_set(vert2);
    if(vert2==vert1)
    {
        return;
    }
    connected--;
    if(rank1[vert1]>rank1[vert2])
    {
        rank1[vert1]+=rank1[vert2];
        parent[vert2]=vert1;
    }
    else
    {
        rank1[vert2]+=rank1[vert1];
        parent[vert1]=vert2;
    }
}

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

    ll vert,edge;
    cin>>vert>>edge;
    connected=vert;
    for(ll i=1;i<=vert;i++)
    {
        parent[i]=i;
        rank1[i]=1;
    }
    ll vert1,vert2,waste;
    while(edge--)
    {
        cin>>vert1>>vert2>>waste;
        union_set(vert1,vert2);
    }
    cout<<connected;
    return 0;
}

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

using ll = long long int;

const int MAX = (int)(200 + 5);

ll n;

stack<int> ans;

int main(void) {
  // Here your code !
  scanf("%lld", &n);

  ll acc = 0;
  ll base = 1;
  for (ll i = 0; i < MAX; ++i) {
    ll mod_true = n % (abs(base) * 2);
    ll mod_0 = (acc + 0 * base) % (abs(base) * 2);
    ll mod_1 = (acc + 1 * base) % (abs(base) * 2);

    mod_true = (mod_true < 0) ? mod_true + (abs(base) * 2) : mod_true;
    mod_0 = (mod_0 < 0) ? mod_0 + (abs(base) * 2) : mod_0;
    mod_1 = (mod_1 < 0) ? mod_1 + (abs(base) * 2) : mod_1;

    // cout << mod_true  << ":" << mod_0 << ":" << mod_1 << ":" << endl;

    if (mod_0 == mod_true) {
      ans.push(0);
    }
    else {
      ans.push(1);
      acc += base;
    }

    if (acc == n) break;
    base *= -2;
  }

  while (!ans.empty()) {
    printf("%d", ans.top());
    ans.pop();
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int dis[MAXN];
int main(){
    //~ freopen("file.in", "r", stdin);
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
		dis[i]=INF;
	queue<int>q;	
	q.push(1);
	dis[1]=1;
	while(!q.empty()){
		int nd=q.front();
		q.pop();
		if(umin(dis[(nd*10)%n],dis[nd]))
			q.push((nd*10)%n);
		if(umin(dis[(nd+1)%n],dis[nd]+1))	
			q.push((nd+1)%n);
	}
	printf("%d\n",dis[0]);
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    string s;
    cin >> s;
    if(s=="RRR") cout << "3";
    else if(s=="SRR" or s=="RRS") cout << "2";
    else if(s=="SSS") cout << "0";
    else cout << "1";
    return 0;
}

Measured memory_bytes: 3616
from collections import deque


def nearlist(N, LIST):  # 隣接リスト
    NEAR = [{} for _ in range(N)]
    for a, b, c in LIST:
        NEAR[a - 1][b - 1] = c
        NEAR[b - 1][a - 1] = c
    return NEAR


def dfs(NEAR, S, N):  # 深優先探索  # スタック
    DIST = [-1 for _ in range(N)]  # 前処理
    DIST[S] = 0
    stack, frag = [S], set([S])

    while len(stack) > 0:
        q = stack.pop()
        for i, c in NEAR[q].items():  # 移動先の候補
            if i in frag:  # 処理済みか否か
                continue
            DIST[i] = DIST[q] + c
            stack.append(i), frag.add(i)
    return DIST


n = int(input())
abc = [list(map(int, input().split())) for _ in range(n - 1)]
q, k = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(q)]

near = nearlist(n, abc)
dist = dfs(near, k - 1, n)
for x, y in xy:
    print(dist[x - 1] + dist[y - 1])


Measured memory_bytes: 169020
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
#include <queue>

using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()

#define MAX_W 1010
#define MAX_H 1010

int H, W, N;
char A[MAX_H][MAX_W];
vector<bool**> global;

pair<int, int> find_char(char c) {
  rep(y, H) {
    rep(x, W) {
      if (A[y][x] == c) return make_pair(x, y);
    }
  }
  return make_pair(-1, -1);
}

bool visited[MAX_W][MAX_H];
int bfs(int start_x, int start_y, int target_x, int target_y) {
  queue<int> q;
  rep(i, W) rep(j, H) visited[j][i] = false;

  q.push(start_x); q.push(start_y); q.push(0);
  while (!q.empty()) {
    int x  = q.front(); q.pop();
    int y  = q.front(); q.pop();
    int dist = q.front(); q.pop();

    char m = A[y][x];
    if (x == target_x && y == target_y) return dist;

    int dx[] = {0, 1, 0, -1};
    int dy[] = {-1, 0, 1, 0};
    rep(i, 4) {
      int tx = x + dx[i];
      int ty = y + dy[i];
      if (tx >= 0 && tx < W && ty >= 0 && ty < H &&
          A[ty][tx] != 'X' && !visited[ty][tx]) {
        q.push(tx);
        q.push(ty);
        q.push(dist + 1);
        visited[ty][tx] = true;
      }
    }
  }
  return INT_MIN;
}

int main() {
  cin >> H >> W >> N;
  rep(i, H) cin >> A[i];

  // ????§???????
  auto pos_s = find_char('S');
  int start_x = pos_s.first;
  int start_y = pos_s.second;

  int ans = 0;
  for (int i=1; i<=N; i++) {
    auto pos = find_char((char)((int)'0'+i));
    int tx = pos.first;
    int ty = pos.second;
    ans += bfs(start_x, start_y, tx, ty);
    start_x = tx;
    start_y = ty;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 4976
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var a,b int
    fmt.Scan(&a,&b)
    ans := max32(a+b,max32(a-b,a*b))
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);

		int x = Integer.parseInt(strArr[0]);
		int y = Integer.parseInt(strArr[1]);
		if (group(x) == group(y))
			System.out.println("Yes");

		else
			System.out.println("No");
	}

	private int group(int n) {
		if (n == 2)
			return 1;
		if (n == 4)
			return 2;
		if (n == 6)
			return 2;
		if (n == 9)
			return 2;
		if (n == 11)
			return 2;
		return 3;
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}
}


Measured memory_bytes: 21204
A, B, C, X, Y = map(int, input().split())

# AB購入数が決まるとA購入数とB購入数が決まるので、それを利用して総当りする

cost = set()
for n_AB in range(0, max(X,Y)*2 + 1, 2):
    n_A = max(0, X - n_AB//2)
    n_B = max(0, Y - n_AB//2)
    cost.add(n_A*A + n_B*B + n_AB*C)

print(min(cost))

Measured memory_bytes: 11968
#include <stdio.h>

int main()
{
    int h,n,a;
    scanf("%d %d",&h,&n);
    while(n--)
    {
        scanf("%d",&a);
        h=h-a;
    }
    if(h>0)
        printf("No");
    else
        printf("Yes");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
int func(int a, int b, int cnt){
    if(a >= b){
        return cnt;
    }
    return func(a + a * 0.01, b, cnt + 1);
}
signed main(){
    int x;
    cin >> x;
    cout << func(100, x, 0) << endl;
}

Measured memory_bytes: 3676
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;

int one = 0;
vector<int> split(const string &str, char delim){
    istringstream iss(str); string tmp; vector<int> res;
    while(getline(iss, tmp, delim)){
        int n = atoi(tmp.c_str());
        if(n == 1) one++;
        else{
            if(n >= 10) n = 10;
            res.push_back(n);
        }
    }
    return res;
}

int main(){
    string str;
    while(getline(cin, str)){
        one = 0;
        int ans = 0;
        if(str == "0") break;
        vector<int> num = split(str, ' ');
        REP(i, num.size()) ans += num[i];


        int onenum = one * 11;
        REP(i, one){
            if(onenum + ans >= 22) onenum -= 10;
        }

        ans += onenum;
        ans = (ans < 22)? ans : 0;
        cout <<ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> A(N);
    rep(i, N) cin >> A[i];
    
    long long ans = 1e18;
    rep(bit, (1 << N)) {
        vector<int> S;
        rep(i, N) {
            if (bit & (1 << i)) S.push_back(i);
        }
        
        long long MAX = 0;
        long long cost = 0;
        vector<long long> B = A;
        for (int x : S) {
            if (B[x] > MAX) {
                MAX = B[x];
                continue;
            }
            cost += MAX - B[x] + 1;
            MAX += 1;
            B[x] = MAX;
        }
        
        MAX = 0;
        int cnt = 0;
        rep(i, N) {
            if (B[i] > MAX) {
                ++cnt;
                MAX = B[i];
            }
        }
        if (cnt >= K) ans = min(ans, cost);
    }
    
    cout << ans << endl;
    return 0;
}


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

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

int main(void){
    ll N;
    cin >> N;
    ll x[N+1];
    for (int i = 0; i < N+1; i++)
    {
        cin >> x[i];
    }
    if(N==1){
        cout << abs(x[1]-x[0]) << endl;
        return 0;
    }
    sort(x,x+N);
    ll dif[N];
    for (int i = 0; i < N; i++)
    {
        dif[i] = x[i+1] - x[i];
    }
    
    ll ans = gcd(dif[0],dif[1]);
    for (int i = 2; i < N; i++)
    {
        ans = gcd(ans,dif[i]);
    }
     cout << ans << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int n;
	cin >> n;
	vector<int>a(n);
	deque<int>b;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		if (i % 2 == 0) {
			b.push_back(a[i]);
		}
		else {
			b.push_front(a[i]);
		}
	}
	if (n % 2 == 0) {
		rep(i, n) {
			print(b[i]);
		}
	}
	else {
		rrep(i, n) {
			print(b[i]);
		}
	}
}

Measured memory_bytes: 6432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int main(){
  ll i,j;
  ll n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  string u="";
  for(i=0;i<n;i++){
    u+=s[i];
    u+=t[i];
  }
  cout<<u<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>

#define repd(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template <typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

int main(){
	//source
	int n=inputValue();
	int s=n%28;
	rep(i,4){
		rep(j,7){
			if(i*7+j*4==s){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
	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 a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        sc.close();

        int ans = c - (a - b);
        if (ans < 0) {
            ans = 0;
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 23764
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K + 1 - (s_z - K))
  else:
    ans.append(s_z + 1)
 
print(sum(ans))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{

    int W, H = 0;
    int x, y = 0;
    cin >> W >> H;
    cin >> x >> y;

    if (W % 2 == 0 && H % 2 == 0)
    {
        if (x == W / 2 && y == H / 2)
        {
            cout << (double)W * H / 2 << " " << 1;
        }
        else
        {
            cout << (double)W * H / 2 << " " << 0;
        }
    }
    else
    {
        cout << (double)W * H / 2 << " " << 0;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX1 10000
#define MAX2 500

typedef struct kk{
  int a[MAX1];
}P;
typedef struct ll{
  int b[MAX2];
}Q;

int comp(P,int);
int n,q;

int main()
{
  int i,j = 0;
  P u;
  Q m;

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&u.a[i]);
  }

  scanf("%d",&q);
  for(i = 0;i < q;i++){
    scanf("%d",&m.b[i]);
    j += comp(u,m.b[i]);
  }
  printf("%d\n",j);
  return 0;
}

int comp(P x,int y)
{
  int i;
  for(i = 0;i < n;i++){
    if(y == x.a[i]) return 1;
  }
  return 0;
}
  



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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

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

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int N = input(), K = input();
    vector< int > cnt(N);
    range(i, 0, K) {
        int d = input();
        range(j, 0, d) {
            int A = input();
            cnt[A - 1]++;
        }
    }

    int ans = 0;
    range(i, 0, N) {
        if (cnt[i] == 0) ans++;
    }

    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
 
using namespace std;
 
void show(vector<int> a){
	for(int unsigned i=0;i<a.size();i++){
		cout << a[i] << " ";
	}
	cout << endl;
}
 
int main(){
	int n,x;
	cin >> n >> x;
	vector<int> a(n),c(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
		c[i] = a[i];
	}
	for(int i = 1; i < n; i++){
		int b = a[i] + a[i-1];
		if(b > x){
			int d = b - x;
			int di = min(a[i], d);
			a[i] = a[i] - di;
			int dim = min(a[i-1], d - di);
			a[i-1] = a[i-1] - dim;
		}
	}
	long long int ans = 0;
	for(int i=0;i<n;i++){
		ans += c[i] - a[i];
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	h, a := nextInt(), nextInt()
	value := float64(h) / float64(a)
	fmt.Println(math.Ceil(value))
}

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

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


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

int main(){
    int N;
    cin >> N;
    string str[N];


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

    for(int i = 1; i < N; i++){
        if(str[i-1][str[i-1].size()-1] != str[i][0]){
            cout << "No" << endl;
            return 0;
        }
        for(int n = i-1; n >=0; n--){
            if(str[i] == str[n]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 50
using namespace std;
typedef long long LL;
const LL mod = 1000000007;
struct mat{
	LL ary[maxn][maxn];
	mat operator * (const mat &b){
		mat c;
		memset(c.ary, 0, sizeof(c.ary));
		for(int k = 0; k < maxn; k += 1)
			for(int j = 0; j < maxn; j += 1)
				for(int i = 0; i < maxn; i += 1)
					c.ary[i][j] = (c.ary[i][j] + ary[i][k] * b.ary[k][j]) % mod;
		return c;
	}
}one;
mat power(LL k){
	mat res;
	memset(res.ary, 0, sizeof(res.ary));
	for(int i = 0; i < maxn; i += 1) res.ary[i][i] = 1;
	for(; k; k >>= 1, one = one * one)
		if(k & 1) res = res * one;
	return res;
}
int main(){
	int N;
	LL K;
	cin >> N >> K;
	for(int i = 0; i < N; i += 1)
		for(int j = 0; j < N; j += 1)
			cin >> one.ary[i][j];
	LL ans = 0;
	mat res = power(K);
	for(int i = 0; i < N; i += 1)
		for(int j = 0; j < N; j += 1)
			ans = (ans + res.ary[i][j]) % mod;
	cout << ans;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static boolean solve(int x, int y) {
        for (int i = 0; i <= x; i++) {
            if (2 * i + 4 * (x - i) == y) return true;
        }
        return false;
    }
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println(solve(input.nextInt(), input.nextInt()) ? "Yes" : "No");
    }
}


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

int main(void){
    int k,a;
    string s,t;
    t = "...";

    cin >> k >> s;
    a = s.size();

    if(a <= k){
        cout << s << endl;
    }else{
        s = s.substr(0,k);
        cout << s + t << endl;
    }

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int sum = 0;
    for(int i = 1;i <= n;i += 2) {
        int count = 0;
        for(int j = 1;j <= i;j++) {
            if(i % j == 0) {
                count++;
            }
        }
        if(count == 8) {
            sum++;
        }
    }
    cout << sum << endl;
}


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

ll gcd(ll a,ll b)
{
   	if(a<b)swap(a,b);
   	if(b!=0&&a%b)return (gcd(b,a%b));
   	else return b;
}


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


int main()
{	
	ll n,a,ans=1;
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		cin>>a;
		ans=lcm(ans,a);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <unordered_map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#include <sstream>

using namespace std;

typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;
float likeabutterfly;
string likeabee;
ll n,m,q,h,k,w;
ll T;

vector<ll> A;

int main()
{
    ll c1,c2,c3,c4,c5,c6;
    ll a,b,d,e,g,c;
    ll x,y,z;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    cin >> m >> n;
    for(c1 = 0; c1 < n; c1++){
        cin >> a;
        A.push_back(a);

    }

    sort(A.begin() , A.end());

    a = m-A[n-1];

    if(A[n-1]-a-1 < 0){cout << "0\n";}
    else{

        cout << A[n-1]-a-1 << "\n";

    }

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a,b;
    cin >> a >> b;
    cout << 2*b - a << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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


string findLCS(string &S, string &T)
{
	int n = S.length();
	int m = T.length();

	vector<vector<int>> dp(n+1, vector<int>(m+1, 0));

	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			if(S[i-1] == T[j-1])
				dp[i][j] = dp[i-1][j-1] + 1;
			else
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	
	/*
	for(auto row : dp)
	{
		for(auto data : row)
			cout<<data<<" ";
		cout<<"\n";
	}*/

	int i = n;
	int j = m;
	string ans = "";
	stack<pair<string, pair<int, int> > > st;
	

	while(i > 0 and j > 0)
	{
		if(dp[i-1][j] == dp[i][j])
		{
			i--;
		}
		else if(dp[i][j-1] == dp[i][j])
		{
			j--;
		}
		else
		{
			ans = S[i-1] + ans;
			i--;
			j--;
		}

	}

	return ans;

}


int main()
{
    string S, T;
    cin>>S;
    cin>>T;

    string ans = findLCS(S, T);

    cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 38944
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int imo[100009];
int main(){
	int n,t,ans=0;
	cin>>n>>t;
	while(n--){
		int a,b;
		cin>>a>>b;
		imo[a]++;
		imo[b]--;
	}
	for(int i=1;i<100009;i++){
		ans=max(ans,imo[i-1]);
		imo[i]+=imo[i-1];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3500