akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define show(x) cout << #x << " = " << x << "\n"

using namespace std;

long double dp[105][105];
long double dp2[105][105];
long double comb[505][505];
int id[505];

void make(int N){
    rep(i,N+1){
        comb[i][0] = 1;
    }
    for(int i=1;i<=N;i++){
        for(int j=1;j<=i;j++){
            comb[i][j] = comb[i-1][j] + comb[i-1][j-1];
        }
    }
}

int main()
{
    int h,n,p,m,K;
    cin >> h >> n >> p >> m >> K;
    rep(i,h){
        id[i] = -1;
    }
    rep(i,m){
        int a,b;
        cin >> a >> b;
        id[h-a] = b-1;
    }
    dp[p-1][0] = 1;
    rep(i,h){
        if(id[i] >= 0){
            swap(dp[id[i]],dp[id[i]+1]);
        }else{
            rep(j,n){
                rep(k,K+1){
                    dp2[j][k] = dp[j][k];
                }
            }
            rep(j,n){
                if(j == 0){
                    rep(k,K){
                        dp2[j][k+1] += (n-2)*dp[j][k]+dp[j+1][k];
                    }
                }else if(j == n-1){
                    rep(k,K){
                        dp2[j][k+1] += (n-2)*dp[j][k]+dp[j-1][k];
                    }
                }else{
                    rep(k,K){
                        dp2[j][k+1] += (n-3)*dp[j][k]+dp[j-1][k]+dp[j+1][k];
                    }
                }
            }
            rep(j,n){
                rep(k,K+1){
                    dp[j][k] = dp2[j][k];
                }
            }
        }
    }
    long double mx = 0;
    rep(i,n){
        mx = max(mx,dp[i][K]);
    }
    make(h-m);
    printf("%.12Lf\n",mx/(comb[h-m][K]*pow(n-1,K)));
}



Measured memory_bytes: 7136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
int main(){
    ll n,m,sum=0;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        ll x;cin>>x;
        sum+=x;
    }
    if(sum>n) cout<<-1<<endl;
    else cout<<n-sum<<endl;
}   

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define il inline
#define re register
using namespace std;
ll n,a[205000];
ll read()
{
    ll x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
int main(){
	n=read();
	for(ll i=1;i<=n;i++){
		a[i]=read();
	}
	ll l=1,r=1,sum=0,tmp=0;
	while(r<=n)
    {
        while((a[r]^tmp)==(a[r]+tmp)&&r<=n)
            tmp^=a[r],r++;
        if(r!=n+1)
            sum+=r-l;
        else
            sum+=(ll)(r-l)*(ll)(r-l+1)/(ll)2;
        tmp^=a[l],l++;
    }
    cout<<sum;
	//cout<<n;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int n, K; cin >> n >> K;
   V<int> a(n);
   for (int i = 0; i < n; i++) {
      cin >> a[i];
   }

   V<bool> dp(K+1, false);
   for (int k = 1; k <= K; k++) {
      for (int i = 0; i < n; i++) {
         if (k - a[i] >= 0 && !dp[k - a[i]]) {
            dp[k] = true;
            break;
         }
      }
   }
   cout << (dp[K] == 1 ? "First" : "Second") << endl;

   return 0;
}


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

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if(abs(a-c) <= d) cout << "Yes" << endl;

  else if(abs(a-b) <= d && abs(b-c) <= d) cout << "Yes" << endl;

  else cout << "No" << endl;

  return 0;

}


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

int main() {
    int K; cin >> K;
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[K-1] << '\n';
    return 0;
}


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

int main(){
  int i,j,cnt;
  ll n,m;
  cin>>n>>m;
  m=m-m%2;
  if(2*n>=m){
    cout<<m/2;
    return 0;
  }
  m=m-2*((m-2*n+3)/4);
  cout<<m/2;
}

Measured memory_bytes: 256
def f(n):
    if n <= 48.0:
        print("light fly")
    elif 48< n <=51:
        print("fly")
    elif 51 < n <= 54:
        print("bantam")
    elif 54 < n <= 57:
        print("feather")
    elif 57 < n <=60:
        print("light")
    elif 60 < n <=64:
        print("light welter")
    elif 64 < n <=69:
        print("welter")
    elif 69 < n <=75:
        print("light middle")
    elif 75 < n <=81:
        print("middle")
    elif 81 < n <= 91:
        print("light heavy")
    elif n>91:
        print("heavy")


while True:
    try:
        n = float(input())
    except:
        break
    f(n)



Measured memory_bytes: 5572
from collections import Counter

H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
a = []
for i in range(H):
    a += list(map(int, input().split()))

cost = [10**5]*10
cost[1] = 0
temp = [['1', 0]]

while temp:
    p = temp.pop()
    if len(p[0]) < 10:
        for s in '0123456789':
            if s in p[0]:continue
            else:
                nxt = p[1] + c[int(s)][int(p[0][-1])]
                if cost[int(s)] > nxt:
                    temp.append([p[0] + s, nxt])
                    cost[int(s)] = nxt
        
d = Counter(a)
ans = 0
for i in range(10):
    ans += d[i]*cost[i]
print(ans)

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

int main()
{
	
	
	int w,s;
	
    cin>>s;
    cin>>w;
	
	if(w>=s){
		
		printf("unsafe");
		
	}
	else{
		
		printf("safe");
		
	}
	
	return 0;
}


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

int A, B;

void input()
{
    cin >> A >> B;
}

int main()
{
    input();

    int ans = -1;

    for (int i = 1; i <= 1009; i++) {
        int b = i * 0.1;
        int a = i * 0.08;
        if (a == A && b == B) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

long long MOD = 1000000007LL;

vector<long long> fact(long long N) {
    vector<long long> a;
    for (long long i = 2; i * i <= N; i++) {
        if (N % i == 0) {
            long long count = 0;
            while (N % i == 0) count++, N /= i;
            a.push_back(count);
        }
    }
    if (N != 1) a.push_back(1);
    return a;
}

long long pow_mod(long long n, long long p, long long M) {
    long long ret = 1;
    while (p > 0) {
        if (p & 1) ret = (ret * n) % M;
        n = (n * n) % M;
        p >>= 1;
    }
    return ret;
}

long long ncr_mod(long long n, long long r, long long M) {
    long long numerator = 1;
    long long denominator = 1;
    if (r > n / 2) r = n - r;
    for (long long i = 0; i < r; i++) {
        numerator = (numerator * (n - i)) % M;
        denominator = (denominator * (i + 1)) % M;
    }
    return (numerator * pow_mod(denominator, M - 2, M)) % M;
}

int main() {

    long long N, M;
    cin >> N >> M;

    auto res = fact(M);
    long long ans = 1;

    for (int i = 0; i < res.size(); i++) {
        ans *= ncr_mod(res[i] + (N - 1), N - 1, MOD);
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}











































































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

int main(){
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	try (Scanner sc = new Scanner(System.in)) {
    		int strLen = Integer.parseInt(sc.next());
    		char[] S = sc.next().toCharArray();
    		int K = Integer.parseInt(sc.next());
    		
    		char targChar = S[K - 1];
    		
    		for (int i = 0; i < strLen; i++) {
    			if (S[i] != targChar) {
    				S[i] = '*';
    			}
    			System.out.print(S[i]);
    		}
    		System.out.println();
    		
    		
    	} catch (Exception e) {
			// TODO: handle exception
		}
    	
    }
    
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007LL;


const int MAX = 510000;
///////combination///////
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
////////////////////////

ll n,m;
map<ll,ll> pf;


void prime_factors(ll n){
    ll cnt=2;
    while(n!=1&&cnt*cnt<=n){ 
        while(n%cnt==0){
            pf[cnt]++;
            n/=cnt;
        }
        cnt++;
    }
    if(n!=1)pf[n]=1;
    return;
}

int main(void) {
    cin >> n >> m;
    COMinit();
    prime_factors(m);
    DEBUG{
        for(auto x:pf){
            printf("n : %lld, t : %lld\n",x.first, x.second);
        }
    }
    ll res=1;
    for(auto x:pf){
        res *= COM(x.second+n-1,n-1);
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

int main() {
	vector<int> input;
	int f;
	
	for (int i = 0; i < 3; i++) {
		cin >> f;
		input.push_back(f);
	}

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

	cout << input[0] * input[1] / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
x = input()
count = 0
for i in range(len(x)):
  if i % 2 == 0:
    if x[i] == "R" or x[i] == "U" or x[i] == "D":
      count += 1
    else:
      print("No")
      break
  if i % 2 == 1:
    if x[i] == "L" or x[i] == "U" or x[i] == "D":
      count += 1
    else:
      print("No")
      break
if count == len(x):
  print("Yes")

Measured memory_bytes: 3060
H,W = map(int,input().split())
a = [input() for i in range(H)]

H_idx=[]
for i in range(H):
    count = 0
    for j in range(W):
        if a[i][j]=='.':
            count +=1
    if count != W:
        H_idx.append(i)

W_idx=[]
for i in range(W):
    count = 0
    for j in range(H):
        if a[j][i]=='.':
            count +=1
    if count != H:
        W_idx.append(i)

for i in H_idx:
    ans = ''
    for j in W_idx:
        ans +=a[i][j]
    print(ans)

Measured memory_bytes: 67748
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    string str[50];
    for (int i = 0; i < n; ++i) {
        cin >> str[i];
    }
    map<char, int> charMap[50];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < str[i].length(); ++j) {
            charMap[i][str[i][j]] = charMap[i][str[i][j]] + 1;
        }
    }
    for (int i = 1; i < n; ++i) {
        vector<char> eraseList;
        auto itr = charMap[0].begin();
        for (; itr != charMap[0].end(); ++itr) {
            if (charMap[i][itr->first] == 0) {
                eraseList.push_back(itr->first);
            } else {
                charMap[0][itr->first] = min(charMap[0][itr->first], charMap[i][itr->first]);
            }
        }
        for (int j = 0; j < eraseList.size(); ++j) {
            charMap[0].erase(eraseList[j]);
        }
    }
    for (auto itr = charMap[0].begin(); itr != charMap[0].end(); ++itr) {
        for (int i = 0; i < itr->second; ++i) {
            cout << itr->first;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  ll ans=0;
  for(ll i=-1;i<n;i++) {
    if(i==-1) {
      ans+=abs(a[i+1]);
    }
    else if(i==n-1) {
      ans+=abs(a[i]);
    }
    else {
      ans+=abs(a[i+1]-a[i]);
    }
  }
  for(ll i=0;i<n;i++) {
    ll tans=ans;
    if(i==0) {
      tans-=(abs(a[i])+abs(a[i+1]-a[i])-abs(a[i+1]));
    }
    else if(i==n-1) {
      tans-=(abs(a[i])+abs(a[i-1]-a[i])-abs(a[i-1]));
    }
    else {
      tans-=(abs(a[i+1]-a[i])+abs(a[i]-a[i-1])-abs(a[i+1]-a[i-1]));
    }
    cout << tans << endl;
  }
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
string s;
int sum,sum1,n;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='C'&&sum==0)
		{
			sum1=1;
		}
		if(s[i]=='F'&&sum1==1)
		{
			sum=1;
		}
		
	}
    n=sum+sum1;
    if(n==2)cout<<"Yes";
    else cout<<"No";

    return 0;
}


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

using namespace std;

const int INF = 2e9;
const int MAX_N = 1e5 + 5;

int n;

int h[MAX_N];

int dp[MAX_N];

int main() {
  // dp[i] = the minimum cost to get a stone i
  // I can here to stone i from stone i - 1 and i - 2, so i gonna chose from those two
  // So, dp[i] = dp[i - 1] + dp[i - 2]
  // I am at stone 1, so dp[1] = 0, no cost to get here
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> h[i];
    dp[i] = INF;
  }
  dp[1] = 0;
  for (int i = 1; i < n; ++i) {
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
    if (i + 2 <= n) {
      dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }
  }
  cout << dp[n] << "\n";
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

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

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

int P[5555], K, N;
ll C[5555];
bool vis[5555];

void populate(int s) {
  int s1 = P[s];
  int s2 = P[P[s]];

  while(s1 != s2) {
    s1 = P[s1];
    s2 = P[P[s2]];
  }

  s2 = P[s2];
  vis[s2] = 1;
  while(s1 != s2) {
    s2 = P[s2];
    vis[s2] = 1;
  }
}

ll ans = LONG_LONG_MIN;
void max_score(int s, ll k) {
  s = P[s];
  ll tans = C[s];k--;
  ans = max(ans, tans);

  while(vis[s] == false && k > 0) {
    k--;
    s = P[s];
    tans += C[s];
    ans = max(ans, tans);
  }

  if(k == 0) return;

  int sd = P[s];
  ll cost = C[sd];
  int len = 1;
  while(s != sd) {
    sd = P[sd];
    cost += C[sd];
    len++;
  }

  sd = P[s];
  k--;
  tans += C[sd];
  ans = max(ans, tans);
  ans = max(ans, tans + (k/len)*cost);

  while(s != sd && k > 0) {
    sd = P[sd];
    k--;
    tans += C[sd];
    ans = max(ans, tans);
    ans = max(ans, tans + (k/len)*cost);
  }

}

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 cin>>N>>K;
 rep(i,N) {cin>>P[i];P[i]--;}
 rep(i,N) {cin>>C[i];}

 rep(i, N) populate(i);
 rep(i, N) max_score(i, K);

 cout << ans << endl;

 return 0;
}


Measured memory_bytes: 3728
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    print(input().strip()[:3])


if __name__ == "__main__":
    main()



Measured memory_bytes: 9824
#include <stdio.h>

int main(void){

	int A,B;

	scanf("%d %d",&A,&B);

	A = A * 3;
	B = B * 3;

	if(A%2==1 && B%2==1){
		printf("Yes\n");
		}
	else {
		printf("No\n");
		}

	return 0;
	}


Measured memory_bytes: 128
N,M = map(int,input().split())
X=[int(i) for i in input().split()]
X.sort()

if N==1:
  print(X[M-1]-X[0])
else:
  Y=list()
  [Y.append(X[i]-X[i-1]) for i in range(M)[1:]]
  Y.sort()
  print(sum(Y[:-(N-1)]))


Measured memory_bytes: 13832
n = int(input())
x = [int(x) for x in input().split()]

for i in range(100):
    sum = 0
    for j in range(len(x)):
        sum += (x[j] - i)**2
    if i == 0:
        ans = sum
    else:
        ans = min(ans, sum)
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
int MAX=2e5;
 
int main()
{
	int n;
	
		scanf("%d",&n);
		long a[MAX+1];
		
		for(int i=0;i<n;i++)
			scanf("%ld",&a[i]);
		
		if(n&1)
        {
            for(int i=n-1;i>=0;i--)
            {
            	if(!(i&1))
            	{
            		printf("%d ",a[i]);
				}
			}
			for(int i=0;i<=n-1;i++)
            {
            	if(i&1)
            	{
            		printf("%d ",a[i]);
				}	
			}
			printf("\n");
        }
		else
        {
            for(int i=n-1;i>=1;i--)
            {
            	if(i&1)
            	{
            		printf("%d ",a[i]);
				}
			}
			for(int i=0;i<=n-1;i++)
            {
            	if(!(i&1))
            	{
            		printf("%d ",a[i]);
				}
			}
			printf("\n");
        }	
	
	
	
	return 0;
}


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

vector<int> adj[100005];
vector<bool> vis(100005, false);

void dfs(int i){
	if(!vis[i]) {
		vis[i] = true;
		for(auto v : adj[i])
			dfs(v);
	}
}

void solve() {
	int n, m;
	cin >> n >> m;
	for(int i=0; i<m; i++) {
		int x, y;
		cin >> x >> y;
		--x;
		--y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	int comp = 0;
	for (int i=0; i<n; i++) {
		if(!vis[i]) {
			comp++;
			dfs(i);
		}
	}
	cout << comp-1;
}

int main() {

	solve();	
	return 0;
}


Measured memory_bytes: 9548
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define boostIO                   \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repn(i, n) for (int i = 1; i <= n; i++)
#define rrep(i, b, a) for (int i = b; i >= a; i--)
#define sz(v) (v.empty() ? 0 : v.size())
#define all(v) v.begin(), v.end()
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define trav(a, x) for (auto &a : x)
#define fi first
#define se second
#define pb push_back
#define int long long
#define mod 1000000007
#define rem 998244353
#define maxn 300005
const int INF = 1e18;
typedef pair<int, int> pii;

int row[maxn], col[maxn];
vector<pii> vis;

signed main() {
    boostIO;
    int h, w, m;
    cin >> h >> w >> m;
    for(int i = 1, x, y; i <= m; i++){
        cin >> x >> y;
        vis.push_back({x, y});
        row[x]++;
        col[y]++;
    }
    int rw = 0, cl = 0;
    for(int i = 1; i < maxn; i++){
        rw = max(rw, row[i]);
        cl = max(cl, col[i]);
    }
    set<int> rr, cc;
    for(int i = 1; i < maxn; i++){
        if(row[i] == rw){
            rr.insert(i);
        }
        if(col[i] == cl){
            cc.insert(i);
        }
    }
    int cnt = 0;
    for(auto x : vis){
        if(rr.count(x.fi) and cc.count(x.se)){
            cnt++;
        }
    }
    if(cnt == sz(rr) * sz(cc)){
        cout << (rw + cl - 1) << endl;
    }
    else{
        cout << (rw + cl) << endl;
    }
    return 0;
}
// XD

Measured memory_bytes: 40724
using System;
using System.Collections.Generic;
using System.Text;

namespace codeTester.contest190720
{
    class ProblemA
    {
        static long value = 0;
        static long answer = 0;

        public static void Main(string[] args)
        {
            Input();
            Logic();
            Output();
        }

        static void Input()
        {
            value = long.Parse(Console.ReadLine());
        }

        static void Logic()
        {
            answer = 3 * value * value;
        }

        static void Output()
        {
            Console.WriteLine(answer.ToString());
        }
    }
}


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

typedef long long ll;

int main () {
    ll N,M; cin >> N >> M;
    ll x[N],y[N],a[M],b[M];

    for(int i=0; i<N; i++) {
	cin >> x[i] >> y[i] ;
    }
    for(int i=0; i<M; i++) {
	cin >> a[i] >> b[i];
    }

    for(int i=0; i<N; i++) {
	ll ans = INT_MAX;
	ll ind = 0;
	for(int j=0; j<M; j++) {
	    if( ans >  abs(x[i] - a[j]) + abs(y[i] - b[j]) ) {
		ans =  abs(x[i] - a[j]) + abs(y[i] - b[j]);
		ind = j;
	    }
	}
	cout << ind+1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
program read
implicit none
integer A, B, C
read *, A, B, C
if ((A == B) .and. (A == C) .and. (B == C)) then 
	print *, 'No'
else if ((A /= B) .and. (A /= C) .and. (B /= C)) then
	print *, 'No'
else     
	print *, 'Yes'
end if
end program read

Measured memory_bytes: 640
import math
def main():

    n = int(input())
    x = list(map(float, input().split()))
    y = list(map(float, input().split()))    

    print(Minkowski(n, x, y, 1))
    print(Minkowski(n, x, y, 2))
    print(Minkowski(n, x, y, 3))
    print(Chebyshev(n, x, y))


def Minkowski(n, x, y, p):
    temp = 0
    for i in range(n):
        temp += abs(y[i] - x[i])**p
    return temp**(1/p)

def Chebyshev(n, x, y):
    temp = 0
    for i in range(n):
        temp = max(temp, abs(y[i] - x[i]))
    return temp

if __name__ == '__main__':
    main()




Measured memory_bytes: 5716
#include<bits/stdc++.h>
#define LL long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define I insert
#define bull bool
#define Max(a,b) ((b<a)?a:b)
#define Min(a,b) ((a<b)?a:b)

const LL N = 200005, mod = 1000000007;

using namespace std;

LL n, m, i, j, k, l, r, t, ans = -mod;
pair < LL, LL > p[N];

LL getint(){
	char c = getchar();
	LL t = 0;
	while(!isdigit(c)) c = getchar();
	while(isdigit(c)){
		t = (t << 3) + (t << 1);
		t += c - '0';
		c = getchar();
	}
	return t;
}


int main(){
	/*/
	freopen ( "detectivein.txt", "r", stdin);
	freopen ( "detectiveout.txt", "w", stdout);
	/**/
	cin >> n >> k;
	for ( i = 0; i < n; ++i ){
		m += i + k;
	}
	for ( i = 0; i < n; ++i ){
		if ( abs(ans - m) > (i + k)){
			ans = m - (i + k);
		}
	}
	cout << ans << endl;
	
	return 0;
}
/**/
//      IIIIIIIII      OOOOO             A          NN        N    EEEEEEEEEE
//          I         O     O           A A         N N       N    E
//          I        O       O         A   A        N  N      N    E
//          I        O       O        A     A       N   N     N    E
//          I        O       O       AAAAAAAAA      N    N    N    EEEEEEEE
//          I        O       O      A         A     N     N   N    E
//          I        O       O     A           A    N      N  N    E
//          I         O     O     A             A   N       N N    E
//      IIIIIIIII      OOOOO     A               A  N        NN    EEEEEEEEEE ___ KAPANADZE

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=2e5+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,m;
ull ans=18e18,s[N];
ull work(int k) {
    ull ret=0;
    for(int j=1,l,r=n;r;r=l-1,j++) {
        l=max(1,r-k+1);
        ret+=1ll*(j==1?5:2*j+1)*(s[r]-s[l-1]);
    }
    return ret+1ll*k*m;
}
int main() {
    n=gi(),m=gi();
    for(int i=1;i<=n;i++) s[i]=s[i-1]+gi();
    for(int i=1;i<=n;i++) chkmin(ans,work(i));
    printf("%llu\n",ans+1ll*n*m);
    return 0;
}


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

using namespace std;

int main(){
	int w[10];
	int k[10];
	int w_point = 0;
	int k_point = 0;

	for(int i=0;i<10;i++){
		cin >> w[i];
	}
	for(int i=0;i<10;i++){
		cin >> k[i];
	}

	sort(w,w+10);
	sort(k,k+10);

	w_point = w[9]+w[8]+w[7];
	k_point = k[9]+k[8]+k[7];

	cout << w_point << " ";
	cout << k_point << endl;

	return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;

int main(){
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}

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

int c[3333], d[3333];
int main() {
    int n, t;
    cin >> n >> t;
    for(int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        for(int j = t; j--;) {
            c[j] = max(c[j], d[j] + b);
            if(j >= a)
                c[j] = max(c[j], c[j - a] + b), d[j] = max(d[j], d[j - a] + b);
        }
    }
    cout << c[t - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
N,W = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(N)]

dp= [[0]*(W+1) for i in range(N+1)] 

for i in range(1,N+1):
    for j in range(1,W+1):
        if j >= wv[i-1][0]:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j - wv[i-1][0]] + wv[i-1][1])
        else:
            dp[i][j] = dp[i-1][j]
print(dp[N][W])

Measured memory_bytes: 150772
N = int(input())
A = [int(zz) for zz in input().split()]
li = []
li2 = []
n = 0
for i in A:
    if i%2 == 0:
        li.append(i%3)
        li2.append(i%5)
        n += 1

for i in range(n):
    if li[i]*li2[i] != 0:
        print('DENIED')
        exit()
print('APPROVED')


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = 1000000000;
        int[] quantity = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            quantity[i] = sc.nextInt();
        }
        long total = 0;
        int last = 1;
        long sum;
        while(last <= n){
            sum = 0;
            while(last <= n && quantity[last] == 0)
                last += 1;
            while(last <= n && quantity[last] != 0){
                sum += quantity[last];
                last += 1;
            }
            total += sum / 2;
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 51712
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin >> N; cin.ignore();

  string str;
  getline(cin, str);
  stringstream ss(str);
  vector<int> a_vec;
  for (int i; !ss.eof();){
    ss >> i;
    a_vec.push_back(i);
  }

  // いずれかのグループへ分かれる
  int divisible_by_four                             = 0;
  int divisible_by_two_excluding_divisiable_by_four = 0;
  int divisible_only_by_one                         = 0;
  for (auto i: a_vec) {
    if (i%4 == 0) {
      divisible_by_four++;
    } else if (i%2 == 0) {
      divisible_by_two_excluding_divisiable_by_four++;
    } else {
      divisible_only_by_one++;
    }
  }

  int required_divisible_by_four =
    divisible_only_by_one
    + (divisible_by_two_excluding_divisiable_by_four % 2 == 1)
    - 1;

  if (divisible_by_four >= required_divisible_by_four) {
    puts("Yes");
  } else {
    puts("No");
  }

  return 0;
}

Measured memory_bytes: 3100
//Robs Code

/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

/***********MACROS***************/
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>

using namespace std;

const int N = 1e5 + 1;
int n,m,i,j,k,l,x,y,z,cnt[3],sum[3];

/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	string s;
	cin >> s;
	int ans = 0,cnt = 0;
	char pre = ';';
	for(auto x : s){
		if(x == 'S'){
			pre = x;
			continue;
		}
		if(x != pre){
			ans = max(cnt,ans);
			cnt = 1;
		}else{
			cnt++;
		}
		pre = x;
	}
	ans = max(ans,cnt);
	cout << ans;
}
//.........

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

using namespace std;

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

    float items[n];
    float sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> items[i];
        sum += items[i];
    }

    long suitable = 0;
    float cutoff = sum / (4 * m);
    for (int i = 0; i < n; i++) {
        if (items[i] >= cutoff) {
            suitable++;
        }
    }

    if (suitable >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

int main(){
	int n;
	cin>>n;
	unordered_map<string, int> mp;
	rep(i,n){
		string s;
		cin>>s;
		sort(s.begin(), s.end());
		mp[s]++;
	}
	ll ans=0;
	for(auto& p:mp){
		int s=p.second;
		ans += (ll)s*(s-1)/2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 10660
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] mount = new int[N];
        
        for(int i = 0 ; i < N ; i++){
            mount[i] = sc.nextInt();
        }
        
        int cnt = 1;
        int max = 0;
        
        for(int m = 1 ; m < N ; m++){
            if((mount[0] <= mount[m]) && max <= mount[m]){
                cnt += 1;
                if(max < mount[m]) {
                	max = mount[m];
                }
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N =  201000;
struct edge{int v,nxt,f;}e[N*8];
int head[N],tot,t,cur[N],b[N],p[N],q[N],n,h1[N],h2[N],cnt1,cnt2;
void add(int x,int y,int f){
	e[++tot]={y,head[x],f};
	head[x]=tot;
	e[++tot]={x,head[y],0};
	head[y]=tot;
}
bool bfs(){
	memset(b,0,sizeof(b));b[0]=1;
	queue<int> q;q.push(0);
	while(!q.empty()){
		int u=q.front();q.pop();
		for(int i=head[u];i;i=e[i].nxt)
			if(e[i].f&&!b[e[i].v]){
				b[e[i].v]=b[u]+1;
				q.push(e[i].v);
			}
	}
	return b[t];
}
int dfs(int x,int flow){
	if(x==t||!flow) return flow;
	int f=flow,tmp;
	for(int&i=cur[x];i;i=e[i].nxt)
		if(e[i].f&&b[e[i].v]==b[x]+1&&(tmp=dfs(e[i].v,min(f,e[i].f)))){
			f-=tmp;
			e[i].f-=tmp;e[i^1].f+=tmp;
			if(!f) break;
		}
	return flow-f;
}
int Dinic(){
	int ans=0;
	while(bfs()){
		memcpy(cur,head,sizeof(head));
		ans+=dfs(0,1e9);
	}
	return ans;
}
int main(){
	read(n);
	for(int i=1;i<=n;i++) read(p[i]),p[i]++;
	for(int i=1;i<=n;i++) read(q[i]),q[i]++;
	for(int i=1;i<=n;i++)
		if(!h1[i]){
			++cnt1;
			int x=i;
			while(!h1[x]) h1[x]=cnt1,x=p[x];
		}
	for(int i=1;i<=n;i++)
		if(!h2[i]){
			++cnt2;
			int x=i;
			while(!h2[x]) h2[x]=cnt2,x=q[x];
		}
	tot=1;t=cnt1+cnt2+1;
	int ans=0;
	for(int i=1;i<=n;i++){
		if(p[i]==i&&q[i]==i) continue;
		ans++;
		if(p[i]==q[i]){
			ans++;
			add(0,h1[i],1);add(h2[i]+cnt1,t,1);
			add(h1[i],h2[i]+cnt1,2);
		}
		else{
			if(p[i]==i) add(0,h2[i]+cnt1,1);
			else if(q[i]==i) add(h1[i],t,1);
			else add(h1[i],h2[i]+cnt1,1);
		}
	}
	cout<<ans-Dinic()<<'\n';
	return 0;
}


Measured memory_bytes: 11824
#include <iostream>
#include <string>
#include <sstream>
#include <math.h>
#include<string>
using namespace std;

int main(){
    int k,n;
    cin >> k >> n;
    int a[n + 1];
    for (int i = 0; i < n; i ++)    cin >> a[i];
    a[n] = k + a[0];
    int longest = 0;
    for (int i = 0; i < n ; i ++){
        if(longest < a[i + 1] - a[i])   longest = a[i + 1] - a[i];
    }
    cout << k - longest << endl;
}


Measured memory_bytes: 1024
n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]
sc = {i : 0 for i in range(1, n+1)}
sc[0] = 0

for s in a:
  sc[s] += 1

del sc[0]
for s in sc.values():
  print("Yes" if (k-q+s)>0 else "No")

Measured memory_bytes: 19084
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//227
	int a,b;
	cin>>a>>b;
	a*=b;
	if(a&1)cout<<"Yes";
	else cout<<"No";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3640
# D - Wizard in Maze
import sys
from collections import deque
from typing import List, Tuple


class WarpableMaze:
    __slots__ = ["height", "width", "start", "goal", "road", "wall", "grid"]

    def __init__(
        self,
        height: int,
        width: int,
        start: Tuple[int, int],
        goal: Tuple[int, int],
        grid: List[str],
        road: str = ".",
        wall: str = "#",
    ) -> None:
        # Values of start and goal must be 0-origin.
        self.height = height + 4
        self.width = width + 4
        self.start = self._flatten_coordinate(*start)
        self.goal = self._flatten_coordinate(*goal)
        self.road = road
        self.wall = wall
        self.grid = self._flatten_grid(grid)

    def _flatten_dxy(self, x: int, y: int) -> int:
        return self.width * x + y

    def _flatten_coordinate(self, h: int, w: int) -> int:
        return self._flatten_dxy(h + 2, w + 2)

    def _flatten_grid(self, grid: List[str]) -> str:
        flat_grid = self.wall * self.width * 2
        for row in grid:
            flat_grid += self.wall * 2 + row + self.wall * 2
        flat_grid += self.wall * self.width * 2
        return flat_grid

    def bfs(self) -> int:
        w = self.width
        move_to_warp = (
            (-w, (-2 * w - 2, -2 * w - 1, -2 * w, -2 * w + 1, -w - 1)),
            (w, (w + 1, 2 * w - 1, 2 * w, 2 * w + 1, 2 * w + 2)),
            (-1, (-w - 2, -2, w - 2, w - 1, 2 * w - 2)),
            (1, (-w + 1, -2 * w + 2, -w + 2, 2, w + 2)),
        )

        unsearched = 1 << 30
        dist = [unsearched] * (self.height * self.width)
        dist[self.start] = 0
        queue = deque([self.start])
        while queue:
            x = queue.popleft()
            cur_dist = dist[x]
            if x == self.goal:
                break

            for move, warp in move_to_warp:
                nx = x + move
                if self.grid[nx] == self.road:
                    if dist[nx] > cur_dist:
                        dist[nx] = cur_dist
                        queue.appendleft(nx)
                else:
                    for dx in warp:
                        nx = x + dx
                        if self.grid[nx] == self.wall:
                            continue
                        if dist[nx] > cur_dist + 1:
                            dist[nx] = cur_dist + 1
                            queue.append(nx)

        return dist[self.goal] if dist[self.goal] != unsearched else -1

    def debug(self):
        print(f"<DEBUG>\nstart={self.start}, goal={self.goal}", file=sys.stderr)
        for row in zip(*[iter(self.grid)] * self.width):
            print(*row, file=sys.stderr)


def main():
    H, W, CH, CW, DH, DW, *S = open(0).read().split()
    start, goal = (int(CH) - 1, int(CW) - 1), (int(DH) - 1, int(DW) - 1)
    maze = WarpableMaze(int(H), int(W), start, goal, S)
    # maze.debug()
    print(maze.bfs())


if __name__ == "__main__":
    main()


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

string a;
int d, cr, ans;
int main() {
	cin >> a;
	a = '0' + a;
	for(int i=a.size()-1; i>0; i--) {
		d = a[i] - '0' + cr;
		ans += min(d, 10-d);
		cr = (d>5 || d==5 && a[i-1]>='5');
	}
	cout << ans + cr;
	return 0;
}

Measured memory_bytes: 2308
import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;


public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String a = Integer.toString(n);
		char[] b = a.toCharArray();
		if(b[0]=='7'||b[1]=='7'||b[2]=='7') {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35740
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000000000000



int main(){
	
	long long N,H;
	cin>>N>>H;
	
	vector<long long> a(N),b(N);
	
	for(int i=0;i<N;i++){
		cin>>a[i]>>b[i];
	}
	
	sort(a.begin(),a.end(),greater<long long>());
	sort(b.begin(),b.end(),greater<long long>());
	
	long long ans = 0;
	for(int i=0;i<N;i++){
		if(H<=0)break;
		if(b[i]<=a[0])break;
		ans++;
		H-=b[i];
	}
	H = max(H,(long long)0);
	ans += (H+a[0]-1)/a[0];
	
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}
vector<int>v(maxn),adj[maxn];

void solve(){
    // int n;
    // cin >> n;
    // FOR(i,1,n+1)cin >> v[i];
    // FOR(i,1,n){
    //     int u,v;
    //     cin >> u >> v;
    //     adj[u].pb(v);
    //     adj[v].pb(u);
    // }
    int n,k;
    cin >> n >> k;
    vector<int>cnt(n+5);
    FOR(i,1,k+1){
        int d;
        cin >> d;
        FOR(j,1,d+1){
            int x;
            cin >> x;
            cnt[x]++;
        }
    }
    int ans = 0;
    FOR(i,1,n+1)if(!cnt[i])ans++;
    cout << ans;
}

signed main()   
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
        solve();
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...


Measured memory_bytes: 9472
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

i64 gcd (i64 a, i64 b) {
  i64 r = a % b;
  while (r > 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int cond (i64 a, i64 b, i64 c, i64 d) {
  if (b > a) return 0;
  if (b > d) return 0;
  if (c >= b) return 1;
  //b <= a, b <= d, c < b
  if (d % b == 0) {
    a -= (a - c + b - 1) / b * b;
    return a >= 0;
  }
  //b <= a, b < d, c < b
  //F(n) = a + (d - b) * m - b * n >= c ?
  i64 g = gcd (b, d);
  return (b - 1) / g == c / g;
}

void run (void) {
  i32 t;
  scanf ("%" SCNi32, &t);
  while (t--) {
    i64 a, b, c, d;
    scanf ("%" SCNi64 "%" SCNi64 "%" SCNi64 "%" SCNi64, &a, &b, &c, &d);
    puts (cond (a, b, c, d) ? "Yes" : "No");
  }
}

int main (void) {
  run ();
  return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    X, K, D = map(int, readline().split())

    if X < 0:
        X *= -1

    if X - K * D > 0:
        ans = X - K * D
    else:
        K -= X // D
        X -= X // D * D
        
        if K % 2 == 0:
            ans = X
        else:
            ans = abs(D - X)

    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;
 
public class Main {
	//static final long MOD = 998244353L;
	//static final long INF = -1000000000000000007L;
	static final long MOD = 1000000007L;
	//static final int INF = 1000000007;

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		int A = sc.ni();
		int B = sc.ni();
		int diff = Math.abs(A-B);
		if (diff % 2 == 0) {
			pw.println(Math.min(A,B)+(diff/2));
		} else {
			pw.println("IMPOSSIBLE");
		}
		pw.close();
	}
	
	//Find the GCD of two numbers
	public static long gcd(long a, long b) {
		if (a < b) return gcd(b,a);
		if (b == 0)
			return a;
		else
			return gcd(b,a%b);
	}
	
	//Fast exponentiation (x^y mod m)
	public static long power(long x, long y, long m) { 
		long ans = 1;
		x %= m;
		while (y > 0) { 
			if(y % 2 == 1) 
				ans = (ans * x) % m; 
			y /= 2;  
			x = (x * x) % m;
		} 
		return ans; 
	}
	
	public static int[][] shuffle(int[][] array) {
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		return array;
	}
	
    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)
 
		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
        	  public int compare(int[] arr1, int[] arr2) {
				  return arr1[0]-arr2[0]; //ascending order
	          }
		});
		return array;
	}
    
    public static long[][] sort(long[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    long[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<long[]>() {
			  @Override
        	  public int compare(long[] arr1, long[] arr2) {
				  return 0;
	          }
		});
		return array;
	}
    
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int ni() { 
            return Integer.parseInt(next()); 
        } 
  
        long nl() { 
            return Long.parseLong(next()); 
        } 
  
        double nd() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str;
        }
    }
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;

    map<map<char, ll>, ll> dict;
    rep(_, 0, n) {
        string s;
        cin >> s;

        map<char, ll> d;
        rep(i, 0, s.size()) { ++d[s[i]]; }

        ++dict[d];
    }

    ll ans = 0;
    for (auto elem : dict) { ans += elem.second * (elem.second - 1) / 2; }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 62336
# N,M = map(int, input().split())
N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))

from itertools import accumulate as acm
T = [0] + list(acm(T))
V = V + [0]

nowSp = 0
dis = 0
nowTime = 0
from bisect import bisect_left as bl

while nowTime < T[-1]:
    nowTime += 0.5

    minV = min(T[i] - nowTime + V[i] for i in range(len(T)) if T[i] >= nowTime)    
    idx = bl(T, nowTime)-1
    minV=min(minV,V[idx])
    
    if minV > nowSp:
        minV = min(minV, nowSp + 0.5)
    if minV < nowSp:
        minV = min(minV, nowSp - 0.5)
    dis += (nowSp + minV) / 2 * 0.5
    nowSp = minV

print(dis)

Measured memory_bytes: 62940