akhauriyash/Code-Regression huggingface dataset:
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long ll;
ll a[10];
int n;
ll lcm(ll P, ll Q) {
    ll p = P, q = Q;
    if (p < q) swap(p, q);
    while (q) {
        ll r = p % q;
        p = q;
        q = r;
    }
    return (P * Q) / p;
}

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

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

pair<int, int> dfs_Farthest(int v, vector<vector<pair<int, int> > > &adjlist, int dist, int parent){
  pair<int, int> max(dist, v), tmp;
  for(int i = 0; i < adjlist[v].size(); i++){
    if(adjlist[v][i].second == parent){ continue; }
    tmp = dfs_Farthest(adjlist[v][i].second, adjlist, dist + adjlist[v][i].first, v);
    if(tmp.first > max.first){ max = tmp; }
  }
  return max;
}

int main(void){
  while(true){
    int n;
    cin >> n;
    if(n == 0){ break; }

    // ???????????±???????????????
    int sum = 0;
    vector<int> p(n-1), d(n-1);
    for(int i = 0; i < n-1; i++){ cin >> p[i]; }
    for(int i = 0; i < n-1; i++){
      cin >> d[i];
      sum += d[i];
    }

    // ??£??\?????????????§????
    int a, b;
    vector<vector<pair<int, int> > > adjlist(n);
    for(int i = 0; i < n-1; i++){
      a = i + 1;
      b = p[i] - 1;
      adjlist[a].push_back(make_pair(d[i], b));
      adjlist[b].push_back(make_pair(d[i], a));
    }

    // ?????\: ?????¨??? * 2 - ?????¨?????????????????????????????¨?????°???????????´??? + ??¨???

    // ????????¨?????¨????????????????¨????
    int leaves = 0;
    vector<bool> IamLeaf(n, false);
    for(int i = 0; i < n; i++){
      if(adjlist[i].size() == 1){
        IamLeaf[i] = true;
        leaves += adjlist[i][0].first;
      }
    }
    int inners = sum - leaves;
    
    // ??¨??¨???????????£???????????¨????????????????????????
    if(inners == 0){
      cout << sum << endl;
      continue;
    }

    // ?????¨?????????????????????????????¨?????°???????????????
    vector<vector<pair<int, int> > > innerlist(n);
    for(int i = 0; i < n-1; i++){
      if(IamLeaf[i]){ continue; }
      for(int j = 0; j < adjlist[i].size(); j++){
        if(!IamLeaf[adjlist[i][j].second]){
          innerlist[i].push_back(adjlist[i][j]);
        }
      }
    }

    // ?????¨?????????????????????????????¨?????°???????????´???????±???????
    // ???????????§???????????????1????±???????
    int v;
    for(v = 0; v < n; v++){
      if(!IamLeaf[v]){ break; }
    }
    
    // ?????§??????????????????dfs??????????????????????????????????±???????
    // ??????????????????dfs???????????????????????????????????§????????¢(=??´???)????±???????
    pair<int, int> farthest = dfs_Farthest(v, innerlist, 0, -1);
    int diam = dfs_Farthest(farthest.second, innerlist, 0, -1).first;
    
    // ???????????????
    int result = inners * 2 - diam + sum;
    cout << result << endl;
  }

  return 0;
}

Measured memory_bytes: 1364
s = input()
a = ''
if s == 'SUN':
    a = 7
elif s == 'MON':
    a = 6
elif s == 'TUE':
    a = 5
elif s == 'WED':
    a = 4
elif s == 'THU':
    a = 3
elif s == 'FRI':
    a = 2
elif s == 'SAT':
    a = 1
    
print(a)

Measured memory_bytes: 2940
#include <cstdio>
#include <math.h>

using namespace std;

int a,b,c,n,m,i,j,k;

int main() {
	scanf("%d%d",&a,&b);
	a = a + b;
	if (a >= 24) {
	    a = a - 24;
	}
	printf("%d\n",a);
}

Measured memory_bytes: 128
program main
  implicit none
  integer :: n, m, i, j, s, p, x
  integer, allocatable :: t(:)
  read (*, *) n
  allocate (t(n))
  read (*, *) t
  s = sum(t)
  read (*, *) m
  do i = 1, m
    read (*, *) p, x
    write (*, "(i0)") s - t(p) + x
  end do
end program main


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;

int main(int argc, const char * argv[]) {

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

	LL a, b, i;

	cin >> a >> b;

	cout << ((b - a) * (b - a + 1) / 2 - b) << endl;

	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	// char型からint型への変換方法？
	// 10倍しながら足していく

	int sum = 0;

	void run() {

		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			//文字を入れることで数字のみでも対応できる。
			char[] c = (sc.next() + "a").toCharArray();

			int res = 0;

			for (int i = 0; i < c.length; i++) {
				//数字
				if ('0' <= c[i] && c[i] <= '9') {
					res = res * 10 + (c[i] - '0');
				}
				//文字
				else {
					sum += res;
					res = 0;
				}
			}
		}

		System.out.println(sum);

	}

	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 17176
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
<url:https://arc079.contest.atcoder.jp/tasks/arc079_c>
問題文============================================================
 長さ N の非負整数列 ai に対し、数列の最大値が N−1 以下になるまで以下の操作を繰り返し行うことを考えます。
 なお、この操作はD問題で考える操作と同一です。
 
 数列のうち最も大きい要素を求める、複数ある場合はどれか 1 つ選ぶ。
 この要素の値を N 減らす。これ以外の要素の値を 1 増やす。
 
 なお、この操作を行い続けると、いつかは数列の最大値が N−1 以下になることが証明できます。
 
 ここで、数列 ai が与えられるので、何回操作を行うことになるかを求めてください。

=================================================================

解説=============================================================

================================================================
*/
ll solve(){
    ll res = 0;
    ll N; cin >> N;
    vector<ll> a(N);
    for(auto &in:a) cin >> in;
    while(
          [&]{
              ll S = 0;
              for(int i = 0; i < N;i++) S += a[i]/N;
              if(S == 0) return false;
              res += S;
              for(int i = 0; i < N;i++){
                  ll cnt = a[i]/N;
                  a[i] -= cnt*N; a[i] += S - cnt;
              }
              return true;
          }()
        );
    return res;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


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

int main() {
  int c=700;
  string s;
  cin>>s;
  rep(i,3){
    if(s[i] == 'o'){
      c+=100;
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
A = sum([[int(n) for n in input().split()] for _ in range(3)], [])
N = int(input())
B = [int(input()) for _ in range(N)]

BINGO = [
    [1, 1, 1, 0, 0, 0, 0, 0, 0,],
    [0, 0, 0, 1, 1, 1, 0, 0, 0,],
    [0, 0, 0, 0, 0, 0, 1, 1, 1,],
    [1, 0, 0, 1, 0, 0, 1, 0, 0,],
    [0, 1, 0, 0, 1, 0, 0, 1, 0,],
    [0, 0, 1, 0, 0, 1, 0, 0, 1,],
    [1, 0, 0, 0, 1, 0, 0, 0, 1,],
    [0, 0, 1, 0, 1, 0, 1, 0, 0,],
]

for bingo in BINGO:
	c = 0
	for b in B:
		if b in A:
			idx = A.index(b)
			c += bingo[idx]
	if c >= 3:
		print('Yes')
		break
else:
	print('No')


Measured memory_bytes: 3188
#include<iostream>
#include<sstream>
#include<string>

using namespace std;

int string_to_int(const string& s){
  int n;
  istringstream iss(s);
  iss >> n;
  return n;
}

bool solve(const string& s, const string& t){
  if(t[0] == '0') return false;
  int x = string_to_int(s);
  int y = string_to_int(t);
  if(x > y) return false;
  return (y-x)%2 == 0;
}

int main(){
  int ans=0;
  string str;
  cin >> str;
  for(int i=0; i<str.size(); ++i){
    string s = str.substr(0, i);
    string t = str.substr(i);
    if(s.size() > t.size()) break;
    if(solve(s, t)) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1224
n = int(input())
ans = 1
b = 0
if n < 105:
  print(0)
elif n == 105:
  print(1)
else:
  for i in range(106,n+1):
    b = 0
    for j in range(1, i+1,2):
      if i % j ==0:
        b +=1
    if b == 8:
      ans += 1
  print(ans)

Measured memory_bytes: 9068
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(m);
    vector<int> d(m);
    rep(i,n) cin >> a[i] >> b[i];
    rep(i,m) cin >> c[i] >> d[i];
    rep(i,n){
        int res = INF;
        int index = 0;
        rep(j,m){
            int cur = abs(a[i]-c[j])+abs(b[i]-d[j]);
            if (res > cur){
                index = j;
                res = cur;
            }
        }
        cout << index+1 << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a,b;
	scanf("%d", &a);
	b = a % 10;
	if (b == 3)
		printf("bon");
	else if (b == 0 || b == 1 || b == 6 || b == 8)
		printf("pon");
	else
		printf("hon");
	return 0;
}


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



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


   int n;
   cin>>n;
   ll a[n];
   ll sum=0;
   ll t = 0;
   for(int i=0;i<n;i++){
       cin>>a[i];
       sum+=a[i];
       t += i+1;
   }
   if(sum%t){
       cout<<"NO"<<endl;
       return 0;
   }
   ll k = sum/t;
   ll cnt = 0;
   for(int i=0;i<n;i++){
       ll s = a[(i+1)%n] - a[i];
       //cerr<<i<<endl;
       if(a[i]<k){
           cout<<"NO"<<endl;
           return 0;
       }
       if(s==k) continue;
       else{
           s = k-s;
           if(s%n){
               cout<<"NO"<<endl;
               return 0;
           }
           else cnt += s/n;
       }
   }
   //cerr<<cnt<<endl;

   if(cnt>k){
       cout<<"NO"<<endl;
       return 0;
   }
   cout<<"YES"<<endl;
}

Measured memory_bytes: 1024
# AOJ 0500: Card Game
# Python3 2018.6.29 bal4u

while True:
	n = int(input())
	if n == 0: break
	sa = sb = 0
	for i in range(n):
		a, b = map(int, input().split())
		if a == b:
			sa += a
			sb += b
		elif a > b: sa += a+b
		else:       sb += a+b
	print(sa, sb)



Measured memory_bytes: 5612
#include <cstdio>
#include <algorithm>
#include <vector>
#include <bitset>
using namespace std;
long long gcd(long long a, long long b) {
	if (a < b) return gcd(b, a);
	if (b == 0) return a;
	return gcd(b, a % b);
}
bitset<1000001> bs;
vector<long long> primes;
void sieve() {
	bs.set();
	bs[0] = bs[1] = 0;
	for (long long i = 2; i <= 1000000; ++i) {
		if (bs[i]) {
			primes.push_back(i);
			for (long long j = i * i; j <= 1000000; j += i) bs[j] = 0;
		}
	}
}
int main() {
	sieve();
	long long A, B, ans = 1;
	scanf("%lld %lld", &A, &B);
	A = gcd(A, B);
	for (long long i: primes) {
		if (A % i == 0) ++ans;
		while (A % i == 0) A /= i;
	}
	if (A != 1) ++ans;
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 1528
import sys
import io, os
input = sys.stdin.buffer.readline
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

n, m = map(int, input().split())
g = [[] for _ in range(n)]
edge = []
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append(b)
    edge.append((a, b))

from collections import deque
INF = 10**18
temp= INF
for a, b in edge:
    q = deque([])
    q.append(b)
    visit = [INF]*n
    visit[b] = 0
    par = [-1]*n
    while q:
        v = q.popleft()
        for u in g[v]:
            if visit[u] == INF:
                visit[u] = visit[v]+1
                par[u] = v
                q.append(u)
    if visit[a]+1 <= temp:
        ans = []
        v = a
        ans.append(v+1)
        while par[v] != -1:
            v = par[v]
            ans.append(v+1)
        temp =  visit[a]+1

if temp == INF:
    print(-1)
else:
    if ans:
        print(len(ans))
        print(*ans, sep='\n')
    else:
        print(-1)


Measured memory_bytes: 75404
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  auto sa = suffix_array(s);
  auto lcp = lcp_array(s, sa);
  ll ans = 0;
  rep(i, s.size()) {
    ans += (int)s.size()-sa[i];
    if(i) ans -= lcp[i-1];
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 15608
class Arrow
  attr_reader :source, :sink, :label
  
  def initialize(source, sink, label)
    @source = source
    @sink = sink
    @label = label
  end
end

class Result
  attr_reader :target, :spell

  def initialize(target, spell)
    @target = target
    @spell = spell
  end
end

def advance(table, n, goes, arrows)
  next_table = [nil] * n
  (0...n).each do |node|
    best = table[node]
    goes[node].each do |arrow|
      result = table[arrow.sink]
      next unless result
      test = arrow.label + result.spell
      if !best || test < best.spell
        best = Result.new(arrow.sink, test)
      end
    end
    next_table[node] = best if best
  end
  next_table
end

def check(table, result, n)
  used = [false] * n
  loop do
    node = result.target
    return true unless node
    return false if used[node]
    used[node] = true
    result = table[node]
  end
end

def work(n, arrows, start, goal)
  goes = (0...n).map{[]}
  arrows.each do |arrow|
    goes[arrow.source] << arrow
  end

  table = [nil] * n
  table[goal] = Result.new(nil, '')

  n.times do
    table = advance(table, n, goes, arrows)
  end

  result = table[start]
  return nil unless result

  (n*5).times do
    table = advance(table, n, goes, arrows)
  end

  result = table[start]
  check(table, result, n) ? result.spell : nil
end

loop do
  n, a, s, g = STDIN.gets.split.map(&:to_i)
  break if n == 0

  arrows = (0...a).map do |i|
    x, y, lab = STDIN.gets.split
    x = x.to_i
    y = y.to_i
    Arrow.new(x, y, lab)
  end

  puts work(n, arrows, s, g) || 'NO'
end

Measured memory_bytes: 23820
import java.util.Scanner;

public class Main {
  static final long INF = Long.MAX_VALUE;
  static int n;
  static long x;
  static long[] a;

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

    n = sc.nextInt(); x = sc.nextInt();
    a = new long[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }

    long sum = 0;
    long[] min = new long[n];
    for(int i = 0; i < n; i++){
      min[i] = a[i];
      sum += a[i];
    }
    for(int d = 1; d < n; d++){
      long s = 0;
      for(int i = 0; i < n; i++){
        min[i] = Math.min(min[i], a[(n + i - d) % n]);
        s += min[i];
      }
      sum = Math.min(sum, x * d + s);
    }

    System.out.println(sum);
  }
}

Measured memory_bytes: 13668
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int n, l;
	cin >> n >> l;
	int sum = 0;
	int itr;
	int _min = INT_MAX;
	for (int i = l; i < n + l; i++)
	{
		sum += i;
		if (_min > abs(i))
		{
			_min = abs(i);
			itr = i;
		}
	}
	cout << sum - itr << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long 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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    ll A,B,C; cin >> A >> B >> C;
    ll a=A/2,b=B/2,c=C/2;
    ll x = abs(A*B*c - A*B*(C-c));
    ll y = abs(a*B*C - (A-a)*B*C);
    ll z = abs(A*b*C - A*(B-b)*C);
    cout << min(x,min(y,z)) << endl;
    return 0;
}


Measured memory_bytes: 256
pi = 3.1415926

############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
n,k = invr()
ans = [0 for i in range(n)]
cnt = 0
for i in range(k):
    d = inp()
    nums = inlt()
    for j in nums:
        ans[j - 1]= 1

for i in ans:
    if i == 0:
        cnt += 1

print(cnt)



Measured memory_bytes: 67652
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
int n;
int cod(int x, int y){
	if(x>y)swap(x,y);
//	cout<<x<<" "<<y<<" "<<x*(n+1)+y<<endl;
	return x*(n+1)+y;
}
const int N = 1100000;
vector<int>v[N];
int dg[N];
int vs[N];
int h[N];
int vis[N],tim;
bool cyc;
void dfs(int x){
	if(cyc)return ;
	vis[x] = 2;
	for(int y:v[x]){
		if(vis[y]==2){
			cyc = true;
			return ;
		}
		if(vis[y]==1)continue;
		dfs(y);
	}
	vis[x] = 1;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n; 
	int x; 
	for(int i=1;i<=n;i++){
		cin>>x; 
		int st = cod(i,x);
		vs[st] = 1;
		int en;
		for(int j=2;j<n;j++){
			cin>>x; 
			en = cod(i,x);
			vs[en] = 1;
			v[st].pb(en);
			dg[en]++;
			st = en;
		}
	}
	queue<int>q;
	cyc = false;
	tim = 1;
	for(int i=1;i<N;i++){
		if(vs[i]==1 and dg[i]==0){
			q.push(i);
			dfs(i);
		}
	}
	for(int i=1;i<N;i++){
		if(vs[i]==1 and vis[i]==0){
			cyc = true;
		}
	}
	if(cyc){
		cout<<-1<<endl;
		return 0;
	}

	int ans = 0;
	while(!q.empty()){
		x = q.front();
		ans = max(ans,h[x]);
		q.pop();
		for(int y:v[x]){
			dg[y]--;
			h[y] = h[x]+1;
			if(dg[y]==0){
				q.push(y);
			}
		}
	}
	cout<<ans+1<<endl;
	return 0;
}


Measured memory_bytes: 58880
X, Y = map(int, input().split())


def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10 ** 9 + 7  # 出力の制限
N = 10 ** 6
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

a = (-X + 2 * Y) / 3
b = (-Y + 2 * X) / 3

if not float.is_integer(a) or not float.is_integer(b):
    print(0)
    exit()

print(cmb(int(a + b), int(a), mod))


Measured memory_bytes: 124096
//
// Created by inoue on 2019-09-28.
//

#include <iostream>
#include <set>

using namespace std;


//bool is_prime[1000010];

bool is_prime2(long long a) {
    if (a <= 1) return false;
    for (long long i = 2; i * i <= a; i++) {
        if (a % i == 0) {
            return false;
        }
    }
    return true;
}


int main() {
    long long a, b;
    cin >> a >> b;

//    for(int i=0; i<1000010; i++) is_prime[i] = true;
//    is_prime[0] = is_prime[1] = false;

//    for(int i=2; i<1000010; i++) {
//        if (!is_prime[i]) continue;
//
//        for(long long j=2*i; j*j <= 1000010; j+=i) {
//            is_prime[j] = false;
//        }
//    }

    set<long long> se;

    for (long long i=2; i*i <= a; i++) {
        if (a % i == 0) {
            if (is_prime2(i)) {
                se.insert(i);
            }
            if (i * i != a && is_prime2(a/i)) {
                se.insert(a/i);
            }
        }
    }

    if (is_prime2(a)) se.insert(a);

    int ans = 1;

    for (long long i=2; i*i <= b; i++) {
        if (b % i == 0) {
            if (se.find(i) != se.end()) {
                ans++;
            }
            if (i*i != b && se.find(b/i) != se.end()) {
                ans++;
            }
        }
    }

    if (se.find(b) != se.end()) {
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (auto& x: a)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), x.end()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e7 + 5;
const double eps = 1e-9;
int fac[N], ifac[N], inv[N];

int mul(int x, int y) { return x * 1ll * y % mod; }
int add(int x, int y) { return x+y < mod ? x+y : x+y-mod; }
int sub(int x, int y) { return x-y < 0 ? x-y+mod: x-y; }
int norm(int x) { return x < 0 ? add(x, mod) : sub(x, mod); }
template<class T, class... O> int mul(T x, O... y) { return mul(x, mul(y...)); }
int ncr(int n, int k) { return n<k ? 0 : mul(fac[n], ifac[k], ifac[n-k]); }
int pw(int x, int y) {
  int r = 1;
  for (; y; y /= 2, x = mul(x, x))
    if (y & 1)
      r = mul(r, x);
  return r;
}

void pr(vector<int>& db) { cerr << "{ "; trav(x, db) cerr << x << " "; cerr << "}\n"; }

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, a; cin >> n >> a;
  fac[0] = 1;
  for (int i = 1; i <= n; i++)
    fac[i] = mul(fac[i-1], i);
  ifac[n] = pw(fac[n], mod - 2);
  for (int i = n-1; ~i; i--) {
    ifac[i] = mul(ifac[i+1], i+1);
    inv[i+1] = mul(fac[i], ifac[i+1]);
  }
  int ans = 0;
  for (int i = 1; i <= a; i++) // [1 .. i-1]
    for (int j = 0; j < i; j++) // j singletons before
      ans = norm(ans + ((j & 1) ? -1 : 1) * mul(ncr(i-1, j), fac[n-j-1], i-1-j, inv[n-a+i-1-j]));
  for (int j = 0; j <= a; j++)
    ans = norm(ans + ((j & 1) ? -1 : 1) * mul(ncr(a, j), fac[n-j], a-j, inv[n-a+a-j]));
  cout << ans << "\n";
  return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) cout << 'A';
    else cout << 'B';
}


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

A.sort()
stop = N
for i in reversed(range(N-1)):
    if A[i]* 2 < A[i+1]:
        if 2 * sum(A[:i+1]) < A[i+1]:
            stop = i
            break

print(len(A[stop+1:]) if stop != N else N)


Measured memory_bytes: 20536
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;
int main() {
	ll i,j,k,l,m,n,t;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	t=1;
	while(t--)
	{
		cin>>n;
		string a[n];
		for(i=0;i<n;i++)
		{
			cin>>a[i];
		}
		sort(a,a+n);
		m=1;
		l=1;
		map<string,ll> b[n+1];
		for(i=1;i<n;i++)
		{
		    if(a[i]==a[i-1])
		    {
		        l++;
		    }
		    else{
		        m=max(m,l);
		        b[l][a[i-1]]=1ll;
		        l=1;
		    }
		}
		m=max(m,l);
		b[l][a[i-1]]=1ll;
		
		for(auto k: b[m])
		{
		    cout<<k.first<<endl;
		}
		
	}
	return 0;
}

Measured memory_bytes: 34816
N = int(input())
pos = []
for n in range(N):
    x, y = map(int, input().split())
    pos.append((x, y))

import math
from itertools import permutations
list = [i for i in range(N)]
per = permutations(list,N)

ans = 0
for i in per:
    for j in range(N-1):
        x1, y1 = pos[i[j]]
        x2, y2 = pos[i[j+1]]
        ans += math.sqrt((x1-x2)**2 + (y1-y2)**2)
        
for n in range(1,N+1):
    ans /= n

print(ans)

Measured memory_bytes: 9136
using System;

class Program {
    static void Main() {
        int[] n = new int[10];
        for (int i = 0; i < 10; i++) {
            n[i] = int.Parse(Console.ReadLine());
        }
        Array.Sort(n);
        Console.WriteLine("{0}\n{1}\n{2}", n[9], n[8], n[7]);
    }
}


Measured memory_bytes: 9384
fun main(args: Array<String>) {
    val (n, aa, bb, cc) = readLine()!!.split(" ").map { it.toInt() }
    val l = (1..n).map { readLine()!!.toInt() }
    val ll = IntArray(1.shl(n)) { bit ->
        l.indices.map { if (bit shr it and 1 == 1) l[it] else 0 }.sum()
    }

    var ans = Int.MAX_VALUE
    for (i in 0 until 1.shl(n)) {
        for (j in 0 until 1.shl(n)) {
            if (i and j > 0) continue
            for (k in 0 until 1.shl(n)) {
                if (i and k >0 || j and k > 0 || i*j*k == 0) continue
                val a = ll[i]
                val b = ll[j]
                val c = ll[k]
                val mp1 = Math.abs(a - aa) + Math.abs(b - bb) + Math.abs(c - cc)
                val mp10 = 10*(Integer.bitCount(i) + Integer.bitCount(j) + Integer.bitCount(k) -3 )
                ans = Math.min(ans, mp1 + mp10)
            }
        }
    }
    println(ans)
}

Measured memory_bytes: 38048
#include <bits/stdc++.h>
using namespace std;
const int Maxn=100005;
int n,m,vis[Maxn];
vector<int>e[Maxn];
void Exit(const char*s){
    puts(s);
    exit(0);
}
void dfs(int x,int fa,int rt,int ban){
    vis[x]=true;
    for(int y:e[x]){
        if(y==fa||y==ban)continue;
        if(y==rt)Exit("Yes");
        if(vis[y])continue;
        dfs(y,x,rt,ban);
    }
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int x,y;scanf("%d%d",&x,&y);
        e[x].push_back(y);
        e[y].push_back(x);
    }
    bool succ=true;
    int cnt=0,a=0,b=0;
    for(int i=1;i<=n;i++)
        if(e[i].size()%2==1)
            Exit("No");
    for(int i=1;i<=n;i++)
        if(e[i].size()>4)
            Exit("Yes");
    for(int i=1;i<=n;i++)
        if(e[i].size()==4)
            cnt++,(a?b:a)=i;
    if(cnt<=1)Exit("No");
    if(cnt>2)Exit("Yes");
    dfs(a,0,a,b);
    Exit("No");
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 200000 + 10;
const int MOD = 2019;
char str[NMAX];

typedef long long ll;
ll num[2019];
int main(int argc, char const *argv[])
{
	scanf("%s",str+1);
	int len = strlen(str+1);
	str[++len] = '0';
	ll ans = 0;
	int index = 0,ten = 1;
	for(register int i = len;i >= 1;i--)
	{
		index = (index + (str[i] - '0')*ten)%MOD;
		ten = ten*10%MOD;
		ans += num[index];
		num[index]++;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3808
n,p = list(map(int,input().split()))
S = input()

if p == 2 or p == 5:
  ans = 0
  for i,s in enumerate(S):
    if int(s)%p == 0:
      ans += i+1
  print(ans)
  exit()

def MS(i,s,pre):
  pre += int(s)*i
  return pre%p
 
M = [0]*p
M[0] = 1
i = 1
pre = 0
for s in S[::-1]:
  pre = MS(i,int(s),pre)
  M[pre] += 1
  i = i*10%p

ans = sum(map(lambda m:(m*(m-1))//2, M))
print(ans)


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  for(int i = 0; i < n; i++){
    cin >> p.at(i);
    p.at(i)--;
  }
  for(int i = 0; i < n; i++){
    cin >> q.at(i);
    q.at(i)--;
  }
  
  map<vector<int>, int> prem;
  int order = 0;
  vector<int> vec(n);
  for(int i = 0; i < n; i++) vec.at(i) = i;
  
  do{
    prem[vec] = order++;
  }while(next_permutation(vec.begin(), vec.end()));
  
  cout << abs(prem[p] - prem[q]) << endl;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll h,w;
  cin >> h >> w;
  vector<string> a(h,"");
  REP(i,h) cin >> a[i];
  queue<pll> que;
  vector<vector<bool>> map(h,vector<bool>(w));
  REP(i,h){
    REP(j,w){
      if(a[i][j]=='#') que.push(make_pair(i,j));
      map[i][j] = a[i][j]=='#';
    }
  }
  ll ans = -1;
  while(!que.empty()){
    ll n = que.size();
    REP(i,n){
      auto tp = que.front();
      que.pop();
      ll x = tp.first;
      ll y = tp.second;
      if(x>0 && !map[x-1][y]) {
        que.push(make_pair(x-1,y));
        map[x-1][y] = true;
      }
      if(y>0 && !map[x][y-1]) {
        que.push(make_pair(x,y-1));
        map[x][y-1] = true;
      }
      if(x<h-1 && !map[x+1][y]) {
        que.push(make_pair(x+1,y));
        map[x+1][y] = true;
      }
      if(y<w-1 && !map[x][y+1]) {
        que.push(make_pair(x,y+1));
        map[x][y+1] = true;
      }
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 17844
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };

int N, M;
int main()
{
	scanf("%d%d", &N, &M);
	//M!*N!
	i64 ans = 1;
	for (int i = 1; i <= N; i++)
	{
		ans *= i;
		ans %= MOD;
	}
	for (int i = 1; i <= M; i++)
	{
		ans *= i;
		ans %= MOD;
	}
	if (abs(N - M) >= 2)
	{
		ans = 0;
	}
	if (N == M)
	{
		ans *= 2;
		ans %= MOD;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
package main

import (
        "fmt"
)

func main() {
        var n int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                area := 0
                for i := n; i < 600; i += n {
                        area += i*i * n
                }
                fmt.Printf("%d\n", area)
        }
}



Measured memory_bytes: 1132
#define _CRT_SECURE_NO_WARNINGS

#define N (1<<17)

#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <deque>
#include <vector>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
using namespace std;

int n, cnt;
pair<int, int> pos[N];
pair<pair<int, int>, int> pos1[N];
pair<pair<int, int>, int> pos2[N];
long long Ans;
int par[N];
pair<int, int> vv[N << 1];

inline int Fnd(int x)
{
	return (x == par[x]) ? (x) : (par[x] = Fnd(par[x]));
}

inline void Mrg(int u, int v)
{
	u = Fnd(u), v = Fnd(v);
	if (u != v)
	{
		par[v] = u;
	}
}

long long dist(int xx, int yy)
{
	return (long long)min((long long)abs(pos[xx].first - pos[yy].first),
		(long long)abs(pos[xx].second - pos[yy].second));
}

bool cmp2(pair<int, int> &x, pair<int, int> &y)
{
	return dist(x.first, x.second) < dist(y.first, y.second);
}

bool cmp(pair<pair<int, int>, int> &x, pair<pair<int, int>, int> &y)
{
	if (x.first.second != y.first.second)
	{
		return x.first.second < y.first.second;
	}
	else if (x.first.first != y.first.first)
	{
		return x.first.first < y.first.first;
	}
	else
	{
		return x.second < y.second;
	}
}

int main()
{
	scanf("%d", &n);
	for (int i = 0;i < n;i++)
	{
		scanf("%d%d", &pos[i].first, &pos[i].second);
		pos2[i].first = pos1[i].first = pos[i];
		pos2[i].second = pos1[i].second = i;
	}
	sort(pos1, pos1 + n);
	sort(pos2, pos2 + n, cmp);
	for (int i = 0;i < n;i++)
	{
		par[i] = i;
	}
	for (int i = 0;i < n - 1;i++)
	{
		vv[cnt++] = make_pair(pos1[i].second, pos1[i + 1].second);
		vv[cnt++] = make_pair(pos2[i].second, pos2[i + 1].second);
	}
	sort(vv, vv + cnt, cmp2);
	for (int i = 0;i < cnt;i++)
	{
		int o1 = Fnd(vv[i].first), o2 = Fnd(vv[i].second);
		if (o1 != o2)
		{
			Mrg(o1, o2);
			Ans += dist(vv[i].first, vv[i].second);
		}
	}
	printf("%lld\n", Ans);
	//system("pause");
	return 0;
}



Measured memory_bytes: 6272
#include <stdio.h>
 
int main(void) {
    int a, b, c, d, X, Y;
    scanf("%d %d %d %d", &a, &b, &c, &d);
  	X = a / d;
  	if (a % d > 0){
	  X += 1;
    }
  	Y = c / b;
  	if (c % b > 0){
      Y += 1;
    }
 	if (X >= Y){
      printf("Yes");
    }else{
      printf("No");
    }
    return 0;
}

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

int main(){
  int n,m;
  int d[100] = {};
  int v[100] = {};
  int count[100] = {0};
  int n_count = 0;

  while(cin >> n >> m){
    if(m == 0 && n == 0){ break; }

    for(int i = 0; i < n; i++){
    cin >> d[i] >> v[i];
    }

    for(int j = 1; j <= m; j++){
      int max = 0;
      for(int t = 0; t < n; t++){
        if(d[t] == j && v[t] > max) max = v[t];
      }
      count[n_count] += max;
    }
    n_count++;
  }

  for(int x = 0; x < n_count; x++){
    cout << count[x] << endl;
  }

  return 0;
}

Measured memory_bytes: 3080
// Problem : A - Nickname
// Contest : AtCoder - Tokio Marine & Nichido Fire Insurance Programming Contest 2020
// URL : https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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


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

    string s;
    cin >> s;
    for (long i = 0; i < 3; i++) cout << s[i];
    cout << "\n";
    
    return 0;
}


Measured memory_bytes: 3612
D, N = map(int, input().split())
if D == 0:
    print(N if N != 100 else 101)
elif D == 1:
    print(N*100 if N != 100 else 101 * 100)
elif D == 2:
    print(N*10000 if N != 100 else 101 * 10000)

Measured memory_bytes: 2940
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
H, W = M()
h, w = M()
print((H-h)*(W-w))

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

#define ll long long
#define ull unsigned long long
#define dbg(args...)    do { cerr << #args << ' ' ; print(args); } while(0); cerr << endl;
#define Max 100005
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PI acos(-1)
#define all(a) a.begin(), a.end()
long long limit = 4294967296;
int MOD = 1000000007;
template <typename T>
void print(const T& x)
{
    cerr<<x<<' ';
}

template <typename T1, typename... T2>
void print(const T1& first, const T2&... anst)
{
    print(first);
    print(anst ...) ;
}

/*direction array*/

/***4 moves***/
/*
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
*/
/***8 moves***/
/*
int dx[] = { 0,  0, -1, -1, -1, +1, +1, +1 } ;
int dy[] = {-1, +1, -1,  0, +1, -1,  0, +1 } ;
*/

/*direction array ends*/

ll gcd(ll a, ll b)
{
    return (b == 0 ? a : gcd(b, a % b));
}

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

int main()
{
    fastIO;
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

    string s, t; cin>>s>>t;
    int l1 = s.size(), l2 = t.size();
    int len = l1 - l2;

    int res = 1000;
    for(int i=0; i<=len; i++)
    {
        int c = 0, k = i;
        for(int j=0; j<l2; j++)
        {
            if(s[k] != t[j])
            {
                c++;
            }
            k++;
        }
        res = min(res, c);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
 
int main() {
    int n,k; cin >> n >> k;
    int ans = 1;
    ll tmp = k;
    while (n >= tmp) {
        tmp *= k;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <sstream>

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

using namespace std;


int main() {
    int n; cin >> n;
    int a, b; cin >> a >> b;
    
    cout << min(a*n, b) << endl;
}



Measured memory_bytes: 764
import java.io.PrintStream;
import java.util.Scanner;
public class Main {
    private static final PrintStream so = System.out;
    private static final Scanner     sc = new Scanner(System.in);

    public static void main(String[] args) {
        long a = sc.nextLong();
        long b = sc.nextLong();
        so.println((a + b == 15) ? "+" : (a * b == 15) ? "*" : "x");
    }
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MOD 1000000007
#define MAX 2000
vector<int> p;
void prime(){
  for(int i=2;i<=MAX;i++){
    vector<bool> pp(MAX+1,true);
    pp.at(0)=false;
    bool flag=true;
    for(int j=2;j<=sqrt(i);j++){
      if(pp.at(i)==false){
        continue;
      }
      if(i%j==0){
        flag=false;
        break;
      }
    }
    if(flag){
      p.push_back(i);
    }
  }
}

int main(){
  int N;
  cin>>N;
  prime();
  int n=p.size();
  vector<ll> count(n,0);
  for(int i=1;i<=N;i++){
    int j=i;
    int k=0;
    while(j>1){
      if(j%p.at(k)==0){
        count.at(k)++;
        j/=p.at(k);
      }else{
        k++;
      }
    }
  }

  ll ans=1;
  for(int i=0;i<n;i++){
    ans*=count.at(i)+1;
    ans%=MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, t; cin >> n >> t;
    vector<ll> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    ll start = 0, l = 0;
    for(int i = 0; i < n; i++)
    {
        l = max(l, h[i]);
        ll tmp = max(0LL, t - start);
        ll res = tmp / l + 1;
        if(h[i] <= tmp % l) res++;
        cout << res << endl;
        start += h[i];
    }
    return 0;
}




Measured memory_bytes: 3636
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  ll M;
  cin >> N >> M;
  llvec A(N);
  llvec S(N);
  map<ll, ll> cnt;
  
  rep(i, N){
    cin >> A[i];
  }
  S[0] = A[0]%M;
  cnt[S[0]]++;
  rep(i, N-1){
    S[i+1] = (S[i]+A[i+1])%M;
    cnt[S[i+1]]++;
  }

  ll ans = cnt[0];
  for(auto i: cnt){
    ans += i.second*(i.second-1)/2;
  }
  cout << ans;
  return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
int inf = 1000000000; //10e9
 
int main() {

    int N;
    cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];

    int scrAlice = 0;
    int scrBob = 0;

    sort(a.begin(),a.end(), greater<int>());

    for(int i=0;i<N;i=i+2){
        scrAlice += a[i];
    }
    for(int i=1;i<N;i=i+2){
        scrBob += a[i];
    }

    int ans = scrAlice - scrBob;

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

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

	ll ans = 0;
	repe(i, A, B) {
		if (i % 10 == i / 10000 && i % 100 / 10 == i % 10000 / 1000) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

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

bool check(string s){
    if(s[0]!='A'){
        return false;
    }
    int count = 0;
    for (int i = 2; i < s.length() - 1; i++)
    {
        if(s[i]=='C'){
            count++;
        }
    }
    if(count!=1){
        return false;
    }
    int upper = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if(s[i]>='A'&&s[i]<='Z'){
            upper++;
        }
    }
    if(upper!=2){
        return false;
    }
    return true;
}
int main()
{
    string s;
    cin >> s;
    if (check(s))
    {
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
}

Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int a,b,c;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	if(a*b<c)printf("%d\n",a*b);
	else printf("%d\n",c);
	return 0;
}

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

 
int main() {
   string s,t;
   cin>>s>>t;
   int count=0;
   rep(i,3)if(s[i]==t[i])count++;
   cout<<count<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

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

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n;
ll x,b[100100],l[100100],u[100100],df=0ll;
vector<int> v;

ll comp(int i, int j){
	ll p,q;
	p = (x-b[i])*u[i]+b[i]*l[i];
	q = (x-b[j])*u[j]+b[j]*l[j];
	return p>q;
}

bool judge(ll p){
	int i;
	ll q,r,tmp=df,d=-INFLL,c,qv;
	q = p/x; r = p%x;
	for(i=0; i<q; ++i){
		tmp += (x-b[v[i]])*u[v[i]]+b[v[i]]*l[v[i]];
	}
	qv = (x-b[v[q]])*u[v[q]]+b[v[q]]*l[v[q]];
	for(i=0; i<n; ++i){
		c = min(r,b[v[i]])*l[v[i]]+max(r-b[v[i]],0ll)*u[v[i]];
		if(i<q){
			c -= (x-b[v[i]])*u[v[i]]+b[v[i]]*l[v[i]];
			d = max(d,tmp+qv+c);
		}else{
			d = max(d,tmp+c);
		}
	}
	return (d>=0ll);
}

int main(void){
	int i;
	ll ok=0ll,ng,mid;
	cin >> n >> x;
	for(i=0; i<n; ++i){
		v.push_back(i);
		cin >> b[i] >> l[i] >> u[i];
		df -= b[i]*l[i];
		ok += b[i];
	}
	if(!ok){
		cout << 0 << endl;
		return 0;
	}
	sort(v.begin(),v.end(),comp);
	ng = 0ll;
	while(ok-ng>1){
		mid = (ok+ng)>>1;
		if(judge(mid)){
			ok = mid;
		}else{
			ng = mid;
		}
	}
	cout << ok << endl;
	return 0;
}


Measured memory_bytes: 3192