akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
namespace ITP1_7_A
{
    class Problem
    {

        public static List<string[]> getinputdata (){

            List<string[]> list_temp = new List<string[]>();
            string strdata = Console.ReadLine ();

            while (strdata!=null) {

                string[] s_temp = strdata.Split (' ');

                list_temp.Add (s_temp);

                strdata = Console.ReadLine ();

            }
            return list_temp;

        }


        public static string ScoreCheck(int m ,int f ,int r){

            int mypoint = m + f;
            string score = string.Empty;


            if (m == -1 || f == -1)
            {
               score = "F";
            }
            else if (mypoint >= 80)
            {
                score = "A";
            }
            else if (mypoint >= 65)
            {
                score = "B";
            }
            else if (mypoint >= 50)
            {
                score = "C";
            }
            else if (mypoint >= 30 && r >= 50)
            {
                score = "C";
            }
            else if(mypoint>=30 && r<50)
            {
                score ="D";
            }
            else if(mypoint<30){
                score ="F";
            }


            return score;
        }

        public static void Main (string[] args)
        {
            List<string[]> list_result = new List<string[]>{};

            list_result = getinputdata ();

            for (int i = 0; i < list_result.Count-1; i++)
            {
             
                Console.WriteLine(ScoreCheck(int.Parse(list_result[i][0]), int.Parse(list_result[i][1]), int.Parse(list_result[i][2])));

            }



        }
    }
}

Measured memory_bytes: 9068
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n + 1);
    a[0] = 0;
    int sum = 0;
    rep(i, 1, n + 1){
        cin >> a[i];
        sum += abs(a[i] - a[i - 1]);
    }
    sum += abs(a[n] - a[0]);
    rep(i, 1, n + 1){
        int tmp = sum - abs(a[i - 1] - a[i]) - abs(a[i] - a[(i + 1) % (n + 1)]) + abs(a[i - 1] - a[(i + 1) % (n + 1)]);
        cout << tmp << endl;
    }
}

Measured memory_bytes: 2048
#include <stdio.h>
#include <stdlib.h>

int main() {
	int x, y, yes = 0;
	scanf("%d%d", &x, &y);
	for (int i = 0; i <= x; i++) {
		if (2 * i + 4 * (x - i) == y){
			printf("Yes");
			yes = 1;
		}
	}
	if (yes == 0)printf("No");
}

Measured memory_bytes: 1708
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication15
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(a[0] * a[1]);
        }
    }
}

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

string s;
ll cnt = 0;
void solve(ll left, ll sum) {//何文字見たか
	if (left == s.size()) { cnt += sum; return; }
	for (ll i = left; i < s.size(); i++) {
		solve(i + 1, sum + stoll(s.substr(left, i - left + 1)));
	}
}
int main() {
	cin >> s;
	solve(0, 0);
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <list>
#include <stack>
#include <queue>
#include <utility>

using namespace std;

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

int main()
{
    int n;
    cin >> n;
    int* a;
    a = new int[n+1];
    for (int i = 1; i < n+1; i++)
    {
        cin >>a[i];
    }
    /*for (int i = 1; i < n+1; i++)
    {
        cout << a[i] << endl;
    }*/
    int* b;
    b = new int[n+1];
    for (int i = 1; i < n+1; i++)
    {
        b[i] = 0;
    }
    int temp;
    int index;
    int sum = 0;


    for (int i = n; i > 0 ; i--)
    {
        temp = n/i;
        for (int j = 1; j < temp+1; j++)
        {
            index = i*j;
            sum += b[index];
        }

        if (sum%2==a[i])
        {
            b[i] = 0;
        }else
        {
            b[i] = 1;
        }
        sum = 0;

    }
    int flag = 0;
    int counter = 0;
    
    for (int i = 1; i < n+1; i++)
    {
        if (b[i] == 1)
        {
            counter++;
        }
        
    }

    if (counter != 0)
    {
        cout << counter << endl;
    }
    
    for (int i = 1; i < n+1; i++)
    {
        if (b[i] == 1)
        {
            cout << i << " ";
            flag = 1;
        }
    }
    
    if (flag == 0)
    {
        cout << 0 << endl;
    }else
    {
        cout  << endl;
    }
    
}

Measured memory_bytes: 2432
#include <stdio.h>

int main(){
  double n,t,v,y;
  while(scanf("%lf",&v)!=EOF){
    t=v/9.8;
    y=4.9*t*t;
    n=(y+5)/5;
    printf("%.0lf\n",n+.5);
  }
  return 0;
}

Measured memory_bytes: 652
package main
     
    import (
        "bufio"
        "fmt"
        "os"
        "strconv"
    )
     
    var sc = bufio.NewScanner(os.Stdin)
     
    func nextInt() int {
        sc.Scan()
        i, e := strconv.Atoi(sc.Text())
        if e != nil {
            panic(e)
        }
        return i
    }
     
    func main() {
        sc.Split(bufio.ScanWords)
        a := nextInt()
      if a != 5 && a != 7{
        fmt.Printf("%v\n", "NO")
        return
          }
          b := nextInt()
      if b != 5 && b != 7{
        fmt.Printf("%v\n", "NO")
        return
          }
      c := nextInt()
      if c != 5 && c != 7{
        fmt.Printf("%v\n", "NO")
        return
          }
      if a + b + c != 17 {
        fmt.Printf("%v\n", "NO")
      return
      }
      fmt.Printf("%v\n", "YES")
        
     
    }

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define N 200005
using namespace std;
int n;
char op[N];
int a[N];
int cnt=1,las=1,fa=1;
void connet(int a,int b){
    if(a>b)swap(a,b);
    printf("%d %d\n",a,b);
}
int main(){
scanf("%s",op+1);
n=strlen(op+1);
// cout<<n<<endl;
for(int i=1;i<=n;i++)a[i]=op[i]-'0';
for(int i=1;i<=n;i++){
if(a[i]^a[n-i])return puts("-1"),0;
}
if(!a[1])return puts("-1"),0;
for(int i=2;i<=n/2;i++){
   if(a[i]){
     connet(fa,++cnt);
     int it=cnt;
    //  cout<<"error:"<<it<<endl;
     for(int r=las+2;r<=i;r++)connet(it,++cnt);
     las=i,fa=it;
   }
}
int it=++cnt;
connet(it,fa);
for(int i=cnt+1;i<=n;i++)connet(it,i);
}

Measured memory_bytes: 1920
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Solution sol = new Solution(N);
        for(int i = 0; i < N; ++i)
            sol.addCoin(i, sc.nextDouble());
        System.out.println(sol.solve());
    }
}

class Solution {
    double[] probs;
    int N;
    double[] dp;
    
    Solution(int N){
        this.N = N;
        this.dp = new double[N+1];
        this.probs = new double[N];
    }
    
    void addCoin(int i, double prob){
        probs[i] = prob;
        if(i == 0){
            dp[1] = probs[0];
            dp[0] = 1 - dp[1];
            return;
        }
        for(int j = N; j >= 1; --j){
            dp[j] = (dp[j]*(1-prob)) + (dp[j-1]*prob);
        }
        dp[0] *= (1 - prob);
    }
    
    double solve() {
        double res = 0;
        for(int i = (N+1)>>1; i <= N; ++i)
            res += dp[i];
        return res;
    }
}

Measured memory_bytes: 35308
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int K; string S; cin >> K >> S;
    if (S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
def ceil(x):
    k = x % 10
    if k == 0:
        return x
    else:
        return x + (10 - k)
d = []
for i in range(5):
    d.append(int(input()))
d_min = []
min = 124
sum = 0
index = -1
for i in range(5):
    d_min.append((d[i]) % 10)
for i in range(5):
    if d_min[i] != 0:
        if min > d_min[i]:
            min = d_min[i]
            index = i
if index == -1:
    index = 0
for i in range(5):
    if i != index:
        sum = sum + ceil(d[i])
sum += d[index]
print(sum)


Measured memory_bytes: 3064
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#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 if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
#define X first
#define Y second

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */

/** Union-Find **/
const int MAX_N = 10000;
const int MAX_E = 10000;

class UnionFind {
public:
	int par[MAX_N];
	int rank[MAX_N];
	
	void init(int n)
	{
		rep(i, n) {
			par[i]=i;
			rank[i]=0;
		}
	}
	
	int find(int x)
	{
		if (par[x] == x) {
			return x;
		} else {
			return par[x] = find(par[x]);
		}
	}
	
	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);
		if (x == y) return;
		
		if (rank[x] < rank[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
	}
	
	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
};

/** 最小全域木 kruskal法 O(|E|log|V|) **/
struct edge {int u, v, cost;};

bool comp(const edge& e1, const edge& e2)
{
	return e1.cost < e2.cost;
}

edge es[MAX_E];
int V, E;

int kruskal()
{
	UnionFind UF;
	sort(es, es+E, comp);
	UF.init(V);
	int res=0;
	for (int i=0; i<E; i++) {
		edge e = es[i];
		if (!UF.same(e.u, e.v)) {
			UF.unite (e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}

int main()
{
	while (cin>>V>>E, V) {
		rep(i, E) {
			cin >> es[i].u >> es[i].v >> es[i].cost;
		}
		cout << kruskal() << endl;
	}
}

Measured memory_bytes: 1192
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<par<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

class DisjointSet{
    public:
    vi rank, p;
    
    DisjointSet(){}
    DisjointSet(int size){
        rank.resize(size,0);
        p.resize(size,0);
        rep(i,size)makeSet(i);
    }
    
    void makeSet(int x){
        p[x]=x;
        rank[x]=0;
    }
    
    bool same(int x,int y){
        return findSet(x)==findSet(y);
    }
    
    void unite(int x,int y){
        link(findSet(x),findSet(y));
    }
    
    void link(int x,int y){
        if(rank[x]>rank[y]){
            p[y]=x;
        }
        else{
            p[x]=y;
            if(rank[x]==rank[y]){
                rank[y]++;
            }
        }
    }
    
    int findSet(int x){
        if(x!=p[x]){
            p[x]=findSet(p[x]);
        }
        return p[x];
    }
};

void run(){
    int n,m;
    cin>>n>>m;
    vi a(n);
    rep(i,n)cin>>a[i];
    rep(i,n-1)a[i+1]+=a[i];
    map<int,int> map;
    rep(i,n){
        map[a[i]%m]++;
    }
    map[0]++;
    int ans=0;
    for(pi p:map){
        int x=p.se;
        ans+=x*(x-1)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4992
//ABC152 A

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

int a,b;
long long ans = 0;

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

  if(a > b){
    for(int i=0;i<a;i++){
      cout << b;
    }
  }
  else{
    for(int i=0;i<b;i++){
      cout << a;
    }
  }
  cout << endl;

}


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

using namespace std;

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

    long long ans = 0;
    int maxnum = 0;
    for(int i = 0; i < N; i++){
        maxnum = max(maxnum, A[i]);
        ans += maxnum - A[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4056
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include<algorithm>

using namespace std;

int f(int n) {
  return (n%2==0 ? n/2 : 3*n+1);
}

vector<int> a;

int main() {
  char str[100];
  int s;

  // printf(">>");
  fgets(str,100,stdin);
  sscanf(str,"%d",&s);

  int n=1;
  while ( 1 ) {
    int c = count(a.begin(),a.end(),s);
    /* printf(" %d : %d (%d)\n",n,s,c); */
    if( c>0 ) break;
    a.push_back(s);
    s = f(s);
    n++;
  }
  printf("%d",n);

  return 0;
}


Measured memory_bytes: 256
/*_BELIEVE_*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     __gcd((a),(b))
#define     lcm(a,b)     ((a)*(b))/gcd((a),(b))
#define     pb           push_back
#define     ins          insert
#define     F            first
#define     S            second

const int inf=1e18,M=1e9+7;

void solve()
{
 string s;
 cin>>s;

 if((s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]) || (s[0]==s[2] && s[1]==s[3] && s[1]!=s[2])
    || (s[0]==s[3] && s[2]!=s[3] && s[1]==s[2]))
 cout<<"Yes";
 else
 cout<<"No";
}

int32_t main()
{
 fast();

 int t=1;
 //cin>>t;
 while(t--)
 {
  solve();
 }

 return 0;
}



Measured memory_bytes: 256
m, d = map(int, input().split())
count = 0
for i in range(1, m+1):
  for j in range(22, d+1):
    d1 = j % 10
    if d1 <= 1:
      continue
    d2 = int(j / 10)
    if d1 * d2 == i:
      count += 1
      #print(str(i) + " " + str(j))
print(count)

Measured memory_bytes: 3060
/*
 * main.c
 *
 *  Created on: 2020/07/27
 *      Author: 113896
 */
#include <stdio.h>

int main() {

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

	if (a == b) {
		printf("a == b\n");
	} else if (a > b) {
		printf("a > b\n");
	} else {
		printf("a < b\n");
	}

	return 0;
}




Measured memory_bytes: 2116
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;cin>>N;
	string s;int p;
	vector<pair<string,pair<int,int>>> vec;
	for(int i=0;i<N;i++){
		cin>>s>>p;
		vec.push_back(make_pair(s,make_pair(-p,i)));
	}sort(vec.begin(),vec.end());
	for(int i=0;i<N;i++){
		cout<<vec[i].second.second+1<<endl;
	}
}

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

#define FOR(i, s, e)   for(int i = (s); i < (e); i++)
#define FOR64(i, s, e) for(ll  i = (s); i < (e); i++)
#define ALL(x)         (x).begin(), (x).end()
#define SORT(b, e)     sort((b), (e))
#define REV(b, e)      reverse((b), (e))
#define VSORT(v)       sort((v).begin(), (v).end())
#define VREV(v)        reverse((v).begin(), (v).end())
#define pb(a)          push_back(a)
#define INF            999999999

typedef long long ll;

// 最大公約数を計算する (※ユークリッドの互除法)
template <class T> T gcd(T a, T b)
{
	if(a < b){
		T t = a;
		a = b;
		b = t;
	}

	T r = a % b;

	while(r != 0){
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

// 最大公約数を計算する(vector)
template <class T> T gcd(const std::vector<T> &v)
{
	if(v.size() == 0)
		throw "Don't use empty vector in gcm().";

	if(v.size() == 1)
		return v[0];

	auto r = v[0];

	for(auto i = 1; i < v.size(); i++){
		r = gcd(r, v[i]);
	}

	return r;
}

int main()
{
	int N, X;
	cin >> N >> X;
	vector<int> V(N);
	for(int &x : V) cin >> x;

	for_each(ALL(V), [X](auto &x){ x = abs(x - X); });

//	FOR(i, 0, V.size()){
//		cout << V[i] << endl;
//	}

	int r = gcd(V);

	cout << r << endl;

	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

int main(){
	vector<int> h,w;
	int temph,tempw;
	do{
		cin>>temph>>tempw;
		h.push_back(temph);
		w.push_back(tempw);
	}while(temph!=0||tempw!=0);
	for (vector<int>::size_type i=0;i<h.size()-1;i++){
		for (int j=0;j<h[i];j++){
			for (int k=0;k<w[i];k++){
				cout<<"#";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<cmath>
using namespace std;
int N_MAX = 100000;
int main()
{
  int k,i;
  long long ma=2,mi=2,t;
  long long a[N_MAX];
  cin >> k;
  for(i=0;i<k;i++)
    cin >> a[i];
  for(i=k-1;i>=0;i--){
    t=ma/a[i];
    if(t*a[i]<mi){
      cout << "-1" << endl;
      return 0;
    }
    ma=(t+1)*a[i]-1;
    mi=(long long)ceil((double)mi/a[i])*a[i];
  }
  cout << mi << " " << ma << endl;
  return 0;
}

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

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;

#define endl '\n'
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;

void test()
{
	int k;
	cin>>k;

	ll ans=0;

	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=k;j++)
		{
			for(int l=1;l<=k;l++)
			{
				ans+=__gcd(__gcd(i,j),l);
			}
		}
	}
	
	cout<<ans;
}

int main()
{   
fast_io();
cout << fixed << setprecision(15);
int t = 1;

//cin>>t;

for(int i = 0; i < t; i++)
{
	test();
}
return 0;
}

Measured memory_bytes: 3612
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

constexpr int bm = 2500;
ll BIT[50][bm];
int zero[50];
priority_queue<ll> PQ;
inline ll query(int A, int gin) {
	ll kotae = 0;
	while (gin < bm) {
		kotae = max(BIT[A][gin], kotae);
		gin += gin & -gin;
	}
	return kotae;
}
inline void query2(int A, int gin, ll ti) {
	int tmp = gin;
	while (gin < bm) {
		if (BIT[A][gin] >= ti) return;
		gin += gin & -gin;
	}
	gin = tmp;
	while (gin > 0) {
		if (BIT[A][gin] >= ti) break;
		BIT[A][gin] = ti;
		gin -= gin & -gin;
	}
	PQ.push(ti << 18 | A << 12 | tmp);
}

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


	int N, M, S;
	cin >> N >> M >> S;
	if (S >= 2460) S = 2460;

	vector<ll> E[50];
	rep(i, M) {
		int u, v, a;
		ll b;
		cin >> u >> v >> a >> b;
		u--;
		v--;
		b = a << 8 | b << 16;
		E[u].pb(v | b);
		E[v].pb(u | b);
	}
	int C[50], D[50];
	rep(i, N) {
		cin >> C[i] >> D[i];
	}

	query2(0, S + 1, 4e12);
	ll zenbu = 0;
	ll owari = (1ll << N) - 1;

	while (PQ.size()) {
		auto p = PQ.top();
		PQ.pop();
		ll ti = p >> 18;
		int i = p >> 12 & 63;
		int gin = p & 4095;

		if (ti < query(i, gin)) continue;

		ll ti2 = ti - D[i];
		int gin2 = gin + C[i];
		if (gin2 > 2460) gin2 = 2460;
		query2(i, gin2, ti2);

		for (auto pp : E[i]) {
			int to = pp & 255;
			ti2 = ti - (pp >> 16);
			gin2 = gin - (pp >> 8 & 255);
			if (gin2 > 0) query2(to, gin2, ti2);
		}
		zenbu |= 1ll << i;
		if (zenbu == owari) break;
	}

	for (int i = 1; i < N; i++) {
		co(ll(4e12 - query(i, 1)));
	}



	Would you please return 0;
}

Measured memory_bytes: 4624
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  long long t[2];
  long long a[2];
  long long b[2];
  cin>>t[0]>>t[1];
  cin>>a[0]>>a[1];
  cin>>b[0]>>b[1];
  long long c[2];
  c[0] = a[0] - b[0];
  c[1] = a[1] - b[1];
  long long d = c[0]*t[0] + c[1]*t[1];
  if(c[0]*t[0] >= 0 && c[0]*t[0] + c[1]*t[1] > 0){
    cout<<0<<endl;
    return 0;
  }
  if(c[0]*t[0] <= 0 && c[0]*t[0] + c[1]*t[1] < 0){
    cout<<0<<endl;
    return 0;
  }
  if(d == 0){
    cout<<"infinity"<<endl;
    return 0;
  }
  if(c[0] == 0){
    cout<<0<<endl;
    return 0;
  }
  if(c[1] == 0){
    cout<<0<<endl;
    return 0;
  }
  if(c[0] > 0){
    c[0] = 0LL- c[0];
    c[1] = 0LL- c[1];
    d = -d;
  }
  long long ans = 0;
  long long temp = 0LL - c[0]*t[0];
  if(temp%d == 0){
    ans = 1 + 2*(temp/d - 1) + 1;
  }else{
    ans = 1 + 2*(temp/d);
  }
  cout<<ans<<endl;
  return 0; 
}


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

ll mod=1e9+7;
ll dp[2][55];
ll n;
string s1,s2;

int main(){
    cin >> n;
    cin >> s1 >> s2;
    if(s1[0]==s2[0]){
        dp[0][0]=3;
        dp[1][0]=3;
        for(ll i=1;i<n;i++){
            if(s1[i]==s2[i]&&s1[i-1]==s2[i-1]){
                dp[0][i]=dp[0][i-1]*2%mod;
                dp[1][i]=dp[1][i-1]*2%mod;
            }
            else if(s1[i]!=s2[i]&&s1[i-1]==s2[i-1]){
                dp[0][i]=dp[0][i-1]*2%mod;
                dp[1][i]=dp[1][i-1]*2%mod;
                dp[0][i+1]=dp[0][i-1]*2%mod;
                dp[1][i+1]=dp[1][i-1]*2%mod;
                i++;
            }
            else if(s1[i]==s2[i]&&s1[i-1]!=s2[i-1]){
                dp[0][i]=dp[0][i-1];
                dp[1][i]=dp[1][i-1];
            }
            else if(s1[i]!=s2[i]&&s1[i-1]!=s2[i-1]){
                dp[0][i]=dp[0][i-1]*3%mod;
                dp[1][i]=dp[1][i-1]*3%mod;
                dp[0][i+1]=dp[0][i-1]*3%mod;
                dp[1][i+1]=dp[1][i-1]*3%mod;
                i++;
            }
        }
    }
    else{
        dp[0][0]=6;
        dp[0][1]=6;
        dp[1][0]=6;
        dp[1][1]=6;
        for(ll i=2;i<n;i++){
            if(s1[i]==s2[i]&&s1[i-1]==s2[i-1]){
                dp[0][i]=dp[0][i-1]*2%mod;
                dp[1][i]=dp[1][i-1]*2%mod;
            }
            else if(s1[i]!=s2[i]&&s1[i-1]==s2[i-1]){
                dp[0][i]=dp[0][i-1]*2%mod;
                dp[1][i]=dp[1][i-1]*2%mod;
                dp[0][i+1]=dp[0][i-1]*2%mod;
                dp[1][i+1]=dp[1][i-1]*2%mod;
                i++;
            }
            else if(s1[i]==s2[i]&&s1[i-1]!=s2[i-1]){
                dp[0][i]=dp[0][i-1];
                dp[1][i]=dp[1][i-1];
            }
            else if(s1[i]!=s2[i]&&s1[i-1]!=s2[i-1]){
                dp[0][i]=dp[0][i-1]*3%mod;
                dp[1][i]=dp[1][i-1]*3%mod;
                dp[0][i+1]=dp[0][i-1]*3%mod;
                dp[1][i+1]=dp[1][i-1]*3%mod;
                i++;
            }
        }
    }
    cout << dp[0][n-1] << endl;
    return 0;
}  


Measured memory_bytes: 3648
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<string>
#include<time.h>
#include<random>
using namespace std;




//最大公約数
template<typename T>
constexpr T gcd(T a, T b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd<T>(b, a % b));
	}
}

//最小公倍数
template<typename T>
constexpr T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

//素因数pの数
template<typename T>
constexpr long long prime_factor_count(T a, long long p) {
	long long c = 0;
	T aa = a;
	while (true)
	{
		if (aa % p != 0) return c;

		aa /= p;
		++c;
	}
}

int main() {

	long long n;
	cin >> n;

	long long m;
	cin >> m;

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

	if (n == 1) {
		if (a[0] % 2 == 1) {
			cout << 0 << endl;
		}
		else {
			cout << (long long)floor(((double)m / (double)a[0]) - 0.5) + 1 << endl;
		}
		return 0;
	}

	for (long long i = 0; i < n - 1; ++i) {
		if (prime_factor_count(a[i], 2) != prime_factor_count(a[i + 1], 2)) {
			cout << 0 << endl;
			return 0;
		}
	}

	long long beta = a[0] / 2;
	for (long long i = 1; i < n; ++i) {
		beta = lcm(beta, a[i] / 2);
	}

	double M = m;

	long long ret = floor((m * 0.5 / beta) - 0.5);

	cout << (ret) + 1<< endl;

	return 0;
}

Measured memory_bytes: 1024
N=int(input())
p=list(map(int,input().split()))
count=0
pair=[]
for i in range(N):
  if p[i]== i+1:
    continue
  else:
    if count<2:
      count+=1
      pair.append(i)
    else:
      print("NO")
      exit(0)
      
print("YES")
      

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define pb push_back
using namespace std;


const int mod = 1000000007, E = 26, maxN = 200042;

inline void add_mod(long long& a, long long b)	{   a = (a + b) % mod;  }
inline void mult_mod(long long& a, long long b)	{   a = a * b % mod;    }

long long dp[maxN], sum[maxN];
int col[maxN];
int main()
{
	dp[0] = 1;
	int n;
	scanf ("%d", &n);
	FOR(i, 1, n+1)
		scanf ("%d", col+i);
		
	FOR(i, 1, n+1)
	{
		dp[i] = dp[i - 1];
		if (col[i] == col[i - 1])
			continue;
		add_mod(dp[i], sum[col[i]]);
		add_mod(sum[col[i]], dp[i - 1]);
	}
	
	printf("%lld\n", dp[n]);
    return 0;
}


Measured memory_bytes: 4096
#include<iostream>
#include<vector>
#include<queue>
#include <cmath>
using namespace std;

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


  if (a == b){
  cout << "=";
  }else if (a>b){
  cout << ">";
  }else{
    cout << "<";
  }
    return 0;
}






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

const int INF = 1e9;
vector<int> g[200000];

void dfs(int cur, int p, vector<int> &cost) {
  for (int to: g[cur]) {
    if (to == p) {
      continue;
    }
    cost[to] = cost[cur] + 1;
    dfs(to, cur, cost);
  }
}
int main() {
  int n;
  cin>>n;
  for (int i=0; i<n-1; i++) {
    int a, b;
    cin>>a>>b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int> cost(n);
  dfs(0, -1, cost);
  int i_max = 0;
  for (int i=0; i<n; i++) {
    if (cost[i] > cost[i_max]) {
      i_max = i;
    }
  }
  vector<int> cost2(n);
  dfs(i_max, -1, cost2);
  int max_cost = 0;
  for (int i=0; i<n; i++) {
    max_cost = max(cost2[i], max_cost);
  }
  if (max_cost % 3 == 1) {
    cout<<"Second"<<endl;
  } else {
    cout<<"First"<<endl;
  }
}

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

const int INF = 1e+9; // 10^9 を表す.
int n, a[21], ans;

// diff は パーティAとBの戦闘力の差
void dfs(int diff, int k){
    if( k == n ){ //  n 個全部調べ終わったとき
        ans = min( ans , abs(diff) );
    }else{
        dfs(diff + a[k], k+1 );
        dfs(diff - a[k], k+1 );
    }
}
 
int main(){
    while( cin >> n , n ){
        for(int i=0 ; i < n ; i++ ){
            cin >> a[i];
        }
        ans = INF; // 適当に大きな数を代入する
        dfs(0,0);
        cout << ans << endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <iterator>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <math.h>
#define vi vector<int>
#define vvi vector<vector<int> > 
#define vl vector<long long>
#define vpi vector<pair<int,int> >
#define ll long long 
#define all(x) x.begin(),x.end()
#define vpl vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pci pair<char,int>
#define un unsigned
# define M_PI           3.14159265358979323846  /* pi */
// #define mod 998244353
#define mod 1000000007
#define MAXN  1000001
using namespace std; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)



void solve()
{  
    int x,y;
    cin>>x>>y;
    int t,c;
    if(y%2 == 0)
    {
        t = y/2-x;
        c = 2*x - y/2;
        if(t >= 0 && c >= 0)
        {
            cout<<"Yes"<<endl;
            return;    
        }
    }
    cout<<"No"<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t;
    // cin>>t;
    t = 1;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>

int main()
{
	int n=0, i, j;
	char c[4];
	scanf("%s", c);
	for (i = 0; i < 4; i++)
	{
		for (j = 0; j < 4; j++)
		{
			if (c[i] == c[j])
			{
				n++;
			}
		}
	}
	if (n == 8)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(){
  int max_n = 100000;
  int P[max_n];

  int N;
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> P[i];
  }
  int swap = 0;
  for(int i=0; i<N; i++){
    if(P[i] == i+1){
      int tmp = P[i];
      P[i] = P[i+1];
      P[i+1] = tmp;
      swap++;
    }
  }

  cout << swap << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int N;
    cin>>N;
    cout<<"ABC"<<N<<endl;
    return 0;
}

//a=97,z=122

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

public class Main {

    public static void main(String[] args) throws Exception{
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String [] info = br.readLine().split(" ");
	    int a = Integer.parseInt(info[0]), b = Integer.parseInt(info[1]);

        System.out.println(a*b);
    }
}


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

void solve(){
    vector<int> A;
    int a;
    while(cin >> a,a){A.emplace_back(a);}
    int s=A.size(),n=0;
    for (int i=0;i<s;++i) n+=(A[i]>0);
    vector<vector<int>> G(n);
    vector<int> d,rest(n),p(n);
    d.emplace_back(0); rest[0]=A[0]; p[0]=-1;
    int now=0;
    for (int i=1;i<s;++i){
        if (A[i]>0){
            int nxt=d.size(); rest[nxt]=A[i];
            d.emplace_back(d[now]+1);
            G[now].emplace_back(nxt);
            G[nxt].emplace_back(now);
            --rest[now]; --rest[nxt];
            p[nxt]=now; now=nxt;
        } else {
            for (int j=0;j<d.size();++j){
                if (d[now]+A[i]==d[j]&&rest[j]){
                    G[now].emplace_back(j);
                    G[j].emplace_back(now);
                    --rest[now]; --rest[j];
                    break;
                }
            }
        }
        while(~now&&!rest[now]) now=p[now];
    }
    for (int v=0;v<n;++v){
        cout << v+1;
        sort(G[v].begin(),G[v].end());
        for (int u:G[v]) cout << ' ' << u+1;
        cout << '\n';
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t; cin >> t;
    for (;t--;){
        solve();
    }
}


Measured memory_bytes: 3156
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

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

    if((1<=A && A<=9) &&(1<=B&&B<=9))
    {
        cout<<A*B<<endl;
    }
    else
    {
        cout<<-1<<endl;
    }
    
    
}

Measured memory_bytes: 256
o = input()
e = input()
lo = len(o)
le = len(e)

if lo == le: l = lo
elif lo >= le: l = le
else: l = lo

s = ""
for i in range(l):
        s += o[i]
        s += e[i]
if lo - le == 1:
    s += o[-1]
print(s)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f3f3f3f3f
#define pi 3.1415926535898
#define N 500050
using namespace std;
char s[N];
set<int > a[26];
int n,q;
int main()
{
    cin>>n>>s>>q;
    for(int i=0; i<n; i++)
    {
        a[s[i]-'a'].insert(i+1);
    }
    while(q--)
    {
        int x,y;
        cin>>x;
        if(x==1)
        {
            char t;
            cin>>y>>t;
            a[s[y-1]-'a'].erase(y);
            s[y-1]=t;
            a[t - 'a'].insert(y);
        }
        else
        {
            int l,r;
            cin >> l >> r;
            int ans = 0;
            for(int i = 0; i < 26; i++)
            {
                set<int>::iterator it;
                it = a[i].lower_bound(l);
                if(it != a[i].end() && *it <= r)
                    ans++;
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 27552
N=int(input())

t=[]
x=[]
y=[]

for _ in range(N):
	tt,xx,yy=map(int,input().split())
	t.append(tt)
	x.append(xx)
	y.append(yy)

t_=0
x_=0
y_=0

for i in range(N):
	tmp1=x[i]-x_ + y[i]-y_ 
	tmp2=t[i]-t_
	t_=t[i]
	x_=x[i]
	y_=y[i] 
	if tmp1<=tmp2 and tmp1%2==tmp2%2:
		pass
	else:
		print("No")
		break

else:
	print("Yes")
	

Measured memory_bytes: 11772
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

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

    T = "";
    T += S.substr(0, 5);
    T += " ";
    T += S.substr(6, 7);
    T += " ";
    T += S.substr(14, 5);

    cout << T << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll Dist[1000], Cost[2000];
Pii Graph[2000];


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

  for (int i = 0; i < M; i++){
    int A, B; ll C; cin >> A >> B >> C;
    A--; B--; C *= -1;
    Graph[i] = make_pair(A, B);
    Cost[i] = C;
  }
  fill(Dist, Dist + N, 1e18);
  Dist[0] = 0;
  bool flag = false;
  for (int k = 0; k < N; k++){
    for (int i = 0; i < M; i++){
      int now = Graph[i].first, next = Graph[i].second;
      if (Dist[now] != 1e18 && Dist[next] > Dist[now] + Cost[i]){
        Dist[next] = Dist[now] + Cost[i];
        if (k == N - 1 && next == N - 1) flag = true;
      }
    }
  }

  if (flag == true){
    cout << "inf" << endl;
  }else{
    cout << -1 * Dist[N - 1] << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <vector>
    #include <algorithm>
    using namespace std;
     
    int main(){
        int N;
        cin >> N;
        vector<int> A(N);
        for (int i = 0; i < N; i++)
        {
            cin >> A[i];
        }
     
        long long ans = 0;
        int MaxNum = 0;
        for (int i = 0; i < N; i++)
        {
            //Use common MaxNum to reduce the compuation time
            MaxNum = max(MaxNum, A[i]);
            int Bi = MaxNum;
            ans += Bi - A[i];
        }
     
        cout << ans << endl;
    }

Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a, b;
  cin >> a >> b;
  
  string year = "181010110101";
  
  cout << (year[a-1]==year[b-1] ? "Yes" : "No") << endl;
  
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  int x,t;
  cin >> x >> t;
  if(x-t < 0){
    cout << 0 << endl;
  } else {
    cout << x-t << endl;
  }

  return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

int N, K, D, S;
bitset<105> have;

void solve() {
    have.reset();
    cin >> N >> K;
    for (int i = 0; i < K; i++) {
        cin >> D;
        for (int j = 0; j < D; j++) {
            cin >> S;
            have[S] = 1;
        }
    }
    
    int ans = 0;
    for (int i = 1; i <= N; i++) ans += !have[i];
    cout << ans;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 3660
import sys
from collections import deque


def bfs(s):
    color_list[s] = 0
    flag_list[s] = 1
    q.append(s)
    while len(q) > 0:
        u = q.popleft()
        for v, w in m_list[u]:
            if flag_list[v] == 0:
                flag_list[v] = 1
                if w%2 == 0:
                    color_list[v] = color_list[u]
                else:
                    color_list[v] = (color_list[u]+1)%2
                q.append(v)
        flag_list[u] = 2


if __name__ == "__main__":
    input = sys.stdin.readline
    n = int(input())
    m_list = [[]*n for _ in range(n)]
    color_list = [0]*n
    flag_list = [0]*n
    q = deque([])
    for _ in range(n-1):
        u, v, w = map(int, input().split())
        m_list[u-1].append([v-1, w])
        m_list[v-1].append([u-1, w])
    bfs(0)
    for color in color_list:
        print(color)


Measured memory_bytes: 46140
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
//ノート　isupperで大文字の判定　islowerで小文字の判定
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int x;
    std::cin >> x;
    std::vector<int> p;
    p.pb(1);
    rrep(i,2,35){
        rrep(j,2,100){
            if(pow(i,j)<=1500)p.pb(pow(i,j));
            else break;
        }
    }
    irep(i,x+1){
        if(find(all(p),i)!=p.end()){
            std::cout << i<< std::endl;
            exit(0);
        }
    }
}

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

#define endl '\n';
typedef long long ll;

void solve() {
	int n;
	cin >> n;
	vector<int> v(n), c(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int profit = v[i] - c[i];
		if (profit >= 0) {
			ans += profit;
		}
	}
	cout << ans;
}

int main() {
	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf()); 
	#endif
	solve();
}

Measured memory_bytes: 256
import math
lis = list(map(int, input().split()))
a = lis[0]
b = lis[1]
h = lis[2]
m = lis[3]
if(h / 12 == 0 and
   m / 60 == 0):
  len = abs(a-b)
else:
  hdeg = 30 * h + m / 2
  mdeg = 6 * m
  deg = abs(hdeg - mdeg)
  len = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(deg)))
print(len)

Measured memory_bytes: 9464
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
           
#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
    int n;
    while (scanf("%d", &n), n)
    {
	int a[32];
	rep (i, n)
	    scanf("%d", a + i);

	int res = 1 << 26;
	for (int i = 0; i < 1 << n; ++i)
	{
	    int t = 0;
	    for (int j = 0; j < n; ++j)
	    {
		if (i >> j & 1)
		    t += a[j];
		else
		    t -= a[j];
	    }
	    min_swap(res, abs(t));
	}
	printf("%d\n", res);
    }
}

Measured memory_bytes: 876
#include <stdio.h>

int main(void) {
	int i, j;
	int H, W;
	for(; ; ) {
		scanf("%d%d", &H, &W);
		if(H==0 && W==0) break;
		for(i=0; i<H; i++) {
			if(i%2) {
				for(j=0; j<W; j++) {
					if(j%2) printf("#");
					else printf(".");
				}
				putchar('\n');
			}
			else {
				for(j=0; j<W; j++)  {
					if(j%2) printf(".");
					else printf("#");
				}
				putchar('\n');
			}
		}
		putchar('\n');
	}
	return 0;
}



Measured memory_bytes: 2036
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC098A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,b,max;

            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            max = a + b;

            if (max < a - b) max=a-b;
            if (max < a * b) max = a * b;

            Console.WriteLine(max);
            Console.ReadKey();              


        }
    }
}


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

int main(){
   int A, B, C;
   cin >> A >> B >> C;
   vector<int> vec = {A, B, C};
   sort(vec.begin(), vec.end());
   if ((vec.at(0) == vec.at(1) && vec.at(1) != vec.at(2)) || vec.at(0) != vec.at(1) && vec.at(1) == vec.at(2))
      cout << "Yes" << endl;
   else
      cout << "No" << endl;

}



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

int m[51][51];
bool v[51][51];
int h,w;
int dx[8]={-1,-1,0,1,1,1,0,-1};
int dy[8]={0,-1,-1,-1,0,1,1,1};
void dfs(int x,int y){
    if(v[y][x])return;
    v[y][x]=1;
    for(int i=0;i<8;i++){
        int nx=x+dx[i];
        int ny=y+dy[i];
        if(nx>=0&&nx<w&&ny>=0&&ny<h&&!v[ny][nx]&&m[ny][nx]){
            dfs(nx,ny);
        }
    }
}
int main(){
    while(cin>>w>>h,h){
        int c=0;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>m[i][j];
                v[i][j]=0;
            }
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(!v[i][j]&&m[i][j]){
                    dfs(j,i);
                    c++;
                }
            }
        }
        cout<<c<<endl;
    }
}

Measured memory_bytes: 1240