akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll x,t; cin >> x >> t;
  cout << max(x-t,0LL) << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] a = new int[n];
        int temp = 0 ;

        for(int i = 0;i < n;i++){
            a[i] = sc.nextInt();
            temp += a[i] - 1;
        }

        Arrays.sort(a);


        System.out.println(temp);
//        int[] ans = new int[temp + 1];
//
//        for(int i = 0;i < temp + 1;i ++){
//            for(int j = 0;j < n;j ++){
//                ans[i] += i % a[j];
//            }
//        }
//
//        Arrays.sort(ans);
//
//        for(int i = 0;i<temp + 1;i++){
//            System.out.print(ans[i]+" ");
//            if(i == n-1)
//                System.out.println("");
//        }
//
//        System.out.println(ans[temp]);
    }
}

Measured memory_bytes: 29020
# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        A, B, C, D, E, F = map(int, input().split())

        sousa1 = 1
        sousa2 = 0
        ans = (0, 100 * A, 0)
        while True:
            if sousa1 * 100 * A > F:
                break
            while True:
                water = sousa1 * 100 * A + sousa2 * 100 * B
                if water > F:
                    sousa2 = 0
                    break

                sugar_limit = water // 100 * E
                sousa3 = 0
                sousa4 = 0
                max_sugar = 0
                while True:
                    if sousa3 * C > sugar_limit:
                        break
                    while True:
                        sugar = sousa3 * C + sousa4 * D
                        if water + sugar > F or sugar > sugar_limit:
                            sousa4 = 0
                            break
                        else:
                            max_sugar = max(max_sugar, sugar)
                        sousa4 += 1
                    sousa3 += 1
                concentration = 100 * max_sugar / (water + max_sugar)
                if ans[0] < concentration:
                    ans = [concentration, water, max_sugar]
                sousa2 += 1
            sousa1 += 1

        print('{} {}'.format(sum(ans[1:]), ans[2]))


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 39664
// Problem : B - Multiplication 2
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_b?lang=en
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
#define mod 1000000007
int lcm(int x,int y){
	return x/__gcd(x,y)*y;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<ll>v(n);
    ll count=0;
    ll s=1000000000000000000;
    for(int i=0;i<n;i++){
    	cin>>v[i];
    }
    for(int i=0;i<n;i++){
    	if(v[i]==0){
    		count++;
    	}else{
    		s/=v[i];
    	}
    }
    if(count>0){
    	cout<<0<<endl;
    	//return 0;
    }else if(s==0){
    	cout<<-1<<endl;
    	//return 0;
    }else{
    	s=1;
    	for(int i=0;i<n;i++){
    		s*=v[i];
    	}
    	cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

vector<ll> ldiff(200006);
vector<ll> rdiff(200006);

ll solve_roughly(ll n, ll lnum2){
    ll lnum = n-lnum2;
    ll rnum = lnum2;
    ll tmpans = 0;
    ll lcnt = 1;
    for(int j = lnum-1; j >= 0; j--){
        tmpans += (min(2*lcnt-1,2*rnum+1))*ldiff[j];
        lcnt++;
    }
    ll rcnt = rnum;
    for(int j = 0; j < rnum; j++){
        tmpans += (min(2*rcnt,lnum*2))*rdiff[j];
        rcnt--;
    }
    return tmpans;

}

ll solve_roughly2(ll n, ll lnum2){
    ll lnum = n-lnum2;
    ll rnum = lnum2;
    ll tmpans = 0;
    ll lcnt = 1;
    for(int j = lnum-1; j >= 0; j--){
        tmpans += (min(2*lcnt,2*rnum))*ldiff[j];
        lcnt++;
    }
    ll rcnt = rnum;
    for(int j = 0; j < rnum; j++){
        tmpans += (min(2*rcnt-1,lnum*2+1))*rdiff[j];
        rcnt--;
    }
    return tmpans;
}

int main(){
    ll l, n;
    cin >> l >> n;
    vector<ll> x(n);
    vector<ll> left(n);
    vector<ll> right(n);
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    for(int i = 0; i < n; i++){
        left[i] = l - x[n-1-i];
        right[i] = x[i];
    }
    ldiff[0] = left[0];
    rdiff[0] = right[0];
    for(int i = 0; i < n-1; i++){
        ldiff[i+1] = left[i+1]-left[i];
        rdiff[i+1] = right[i+1]-right[i];
    }
    ll ans = 0;

    ll ok = 0, ng = n;
    ll mid = (ok+ng)/2;
    while(abs(ok-ng)>200){
        ll t1 = solve_roughly(n,mid);
        ll t2 = solve_roughly(n,mid+50);
        if(t2-t1>0){ok = mid;}
        else{ng = mid;}
        mid = (ok+ng)/2;
    }

    for(int i = max(0LL,mid-1300LL); i <= min(n,mid+1300LL); i++){
        ll lnum = n-i;
        ll rnum = i;
        ll tmpans = 0;
        ll lcnt = 1;
        for(int j = lnum-1; j >= 0; j--){
            tmpans += (min(2*lcnt-1,2*rnum+1))*ldiff[j];
            lcnt++;
        }
        ll rcnt = rnum;
        for(int j = 0; j < rnum; j++){
            tmpans += (min(2*rcnt,lnum*2))*rdiff[j];
            rcnt--;
        }
        ans = max(ans, tmpans);
    }

    ok = 0, ng = n;
    mid = (ok+ng)/2;
    while(abs(ok-ng)>200){
        ll t1 = solve_roughly2(n,mid);
        ll t2 = solve_roughly2(n,mid+50);
        if(t2-t1>0){ok = mid;}
        else{ng = mid;}
        mid = (ok+ng)/2;
    }

    for(int i = max(0LL,mid-1300LL); i <= min(n,mid+1300LL); i++){
        ll lnum = n-i;
        ll rnum = i;
        ll tmpans = 0;
        ll lcnt = 1;
        for(int j = lnum-1; j >= 0; j--){
            tmpans += (min(2*lcnt,2*rnum))*ldiff[j];
            lcnt++;
        }
        ll rcnt = rnum;
        for(int j = 0; j < rnum; j++){
            tmpans += (min(2*rcnt-1,lnum*2+1))*rdiff[j];
            rcnt--;
        }
        ans = max(ans, tmpans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

    public static void main(String[] args) {

        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);

        String strN[] = new String[5];

        PrintWriter out = new PrintWriter(System.out);
        try {

        	for (int i=0 ; i < 5 ; i++) {
        		strN[i] = br.readLine();
        	}

        	int intN[] = new int[5];
        	int intMod[] = new int[5];

        	int intSum=0;
        	for (int i=0 ; i < 5 ; i++) {
        		intN[i] = Integer.parseInt(strN[i]);
        		intMod[i] = intN[i] % 10;
        		intSum += intN[i] - intMod[i];
        		if (intMod[i] != 0) intSum +=10;

        	}

        	int intMin = intMod[0];
        	if (intMin == 0)	intMin = 9;

        	int j= 0;
        	for (int i=1 ; i<5 ; i++) {
        		if (intMin > intMod[i] && intMod[i] !=0) {
        			intMin = intMod[i];
        			j = i;
        		}
        	}

        	if (intMod[j] != 0) intSum -= (10 - intMod[j]);

    		System.out.println(intSum);


            out.flush();


        } catch (IOException e) {

        }


    }

}

Measured memory_bytes: 21844
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# 全部Aから選んでみる
minutes_a = 0
count_a = 0
for i in range(N):
    if minutes_a + A[i] > K:
        break
    minutes_a += A[i]
    count_a += 1

ans = count_a
minutes_b = 0
count_b = 0

for i in range(M):
    if minutes_a + minutes_b + B[i] > K:
        found = False
        while count_a > 0:
            minutes_a -= A[count_a - 1]
            count_a -= 1
            if minutes_a + minutes_b + B[i] <= K:
                minutes_b += B[i]
                count_b += 1
                found = True
                break
        if not found:
            break
    else:
        minutes_b += B[i]
        count_b += 1
    ans = max(ans, count_a + count_b)

print(ans)


Measured memory_bytes: 40964
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 3004
#define B 100
#define dpb push_back
#define fi first
#define se second
typedef pair<int, int> P;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
//__gcd(a,b), __builtin_popcount(a);

int sum = 0, ans = 0, ky, kx, a[12][12], f[12][12];
int dy[4] = {0, 0, -1, 1}, dx[4] = {-1, 1, 0, 0};

void dfs(int y, int x, int cnt){
	for(int i = 0;i < 4;i++){
		int yy = y;
		int xx = x;
		while(1){
			yy += dy[i];
			xx += dx[i];
			if(a[yy][xx] == -1)break;
			if(a[yy][xx] == 1 && f[yy][xx] == 0){
				f[yy][xx] = 1;
				dfs(yy, xx, cnt+1);
				f[yy][xx] = 0;
				break;
			}
			if(a[yy][xx] == 2){
				if(cnt == sum){
					ans++;
					return ;
				}
			}
		}
	}
	return ;
}

int main(){
	int w, h;
	while(1){
		scanf("%d%d",&w, &h);
		if(w == 0)break;
		fill((int*)a, (int*)(a+12), -1);
		fill((int*)f, (int*)(f+12), 0);
		sum = ans = 0;
		rrep(i,h)rrep(j,w){
			scanf("%d", &a[i][j]);
			if(a[i][j] == 2){ky = i;kx = j;}
			if(a[i][j] == 1)sum++;
		}
		
		dfs(ky, kx, 0);
		printf("%d\n", ans);
	}
	return 0;
}



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

int main()
{
	int n;
	scanf("%d",&n);
	int a[n],b[n-1];
	for(int i=0;i<n-1;i++){
		cin>>b[i];
	}
	a[0]=b[0];int s=a[0]+b[n-2];
	for(int i=0;i<n-1;i++){
		a[i+1]=min(b[i],b[i-1]);s+=a[i+1];
	}
	cout<<s;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    int a,b;cin>>a>>b;
    if(a%b==0)cout<<"-1"<<endl;
    else{
	cout<<a<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
s = input()

if len(s) != a + b + 1:
    print('No')
elif s[a] != '-':
    print('No')
elif s[0:a].isdecimal() == False:
    print('No')
elif s[(a + 1):].isdecimal() == False:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 9112
use std::io;

fn main() {
    let mut cnt = 1;
    loop {
        let n = input();
        if n == 0 {
            break;
        }

        println!("Case {}: {}", cnt, n);
        cnt += 1;
    }
}

fn input() -> i32 {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");

    s.trim().parse().unwrap()
}



Measured memory_bytes: 5052
import sys
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
s=set(a)
if len(s)<=k:
    print(0)
    sys.exit()
lst=[0]*n
ind=0
lst[0]=1
for i in range(n-1):
    if a[i+1]==a[i]:
        lst[ind]+=1
    else:
        ind+=1
        lst[ind]+=1
lst.sort()
ans,cou=0,0
for i in range(n):
    if lst[i]!=0 and cou<len(s)-k:
        ans+=lst[i]
        cou+=1
print(ans)

Measured memory_bytes: 25716
a,b,k=map(int,input().split())
check=[]
for i in range(k):
  if a+i<=b:
    print(a+i)
    check.append(a+i)
for i in range(k):
  if b-k+i+1>=a:
    if b-k+i+1 in check:
      continue
    else:
      print(b-k+i+1)

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

int main()
{
    int n;

    while (cin >> n, n){
        int cnt = 0;

        string before;
        bool up = false;
        bool lu = false;
        bool ru = false;
        while (n-- > 0){
            string step;
            cin >> step;

            if (step == "lu"){
                lu = true;
                if (ru && !up){
                    cnt++;
                    up = true;
                }
            }
            else if (step == "ru"){
                ru = true;
                if (lu && !up){
                    cnt++;
                    up = true;
                }
            }
            else if (step == "ld"){
                lu = false;
                if (!ru && up){
                    cnt++;
                    up = false;
                }
            }
            else if (step == "rd"){
                ru = false;
                if (!lu && up){
                    cnt++;
                    up = false;
                }
            }
        }

        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>

 
 
int main()
 {
	int a,b,c,k;

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

	int count=0;

	
			if(a>=k){
				count=k;
				
			}

		else{
			count=a;
			k=k-a-b;
			
			if(k>0){
				for(int i=0;i<k;i++){
					count--;
				}
			}
		}
		

printf("%d",count);
	return 0;
}

Measured memory_bytes: 1732
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin >> N;

    vll a(N);
    REP(i,N) cin >> a[i];


    //本文
    sort(ALL(a));
    ll ans = a[N-1]-a[0];
    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
using mat = vector<vector<ll>>;

inline void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];

double a[3002];
double dp[3002][3002] = {};

signed main(){
	IOS();
	ll n;
	cin >> n;
	for (int i = 1;i <= n;++i) {
		cin >> a[i];
	}	
	dp[0][0] = 1;
	for (int i = 1;i <= n;++i) {
		for(int j = 0;j <= n;++j) {
			dp[i][j] += dp[i - 1][j] * (1 - a[i]);
			if(j >= 1)dp[i][j] += dp[i - 1][j - 1] * a[i];
		}
	}
	double ans = 0;
	for (int i = 0;i <= n;++i) {
		if(i * 2 > n)ans += dp[n][i];
	}
	cout << setprecision(10) << fixed;
	cout << ans << endl;
	
}

Measured memory_bytes: 70656
#include <stdio.h>
#include <algorithm>
int main(){
  int a[3],ans=0,i;
  for (i=0;i<3;i++) scanf("%d",&a[i]);
  std::sort(a,a+3);
  ans=a[2]-a[0];
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    int n,d,x;
    int sum=0;
    std::cin >> n >> d >>x;
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        for (int j = 0; j*a+1 <= d; j++) {
            sum+=1;
        }
    }
    std::cout << sum+x << std::endl;
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int Maxn = 10010;
char s[Maxn];
int main()
{
    scanf("%s",s);
    for (int i = 0; i < strlen(s) - 8;i++)
        printf("%c",s[i]);
    printf("\n");
    return 0;
}

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

typedef long long ll;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> v(n + 1);
	for (int i = 0; i < k; ++i) {
		int x, y;
		cin >> x >> y;
		v[x]++;
		v[y]++;
	}
	for (int i = 1; i <= n; ++i) {
		cout << v[i] << endl;
	}
}



















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

int main(){
    ll n;cin>>n;
    ll ans=0;
    
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=n;j++){
            if(i*j<n){
                ans++;
            }
            else if(i*j >= n)break;
        }
    }
        
    cout<<ans;
    return 0;
}

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

int main(){
    string S;cin>>S;
    int A[4];char op[3];
    for(int i=0;i<4;i++){
        A[i]=S.at(i)-'0';
    }for(int j=0;j<4;j++){
        if(A[0]==A[1]&&A[1]==A[2]){
            cout<<"Yes"<<endl;
            break;
        }else if(A[1]==A[2]&&A[2]==A[3]){
            cout<<"Yes"<<endl;
            break;
        }else{
            cout<<"No"<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
vector <ll> ans;
void dfs(ll n){
  ans.push_back(n);
  if(n<1000000000){
    if(n%10 == 0){
      dfs(n*10);
      dfs(n*10+1);
    }
    else if(n%10 == 9){
      dfs(n*10+9);
      dfs(n*10+8);
    }
    else {
      int kk = n%10;
      dfs(n*10+kk);
      dfs(n*10+kk-1);
      dfs(n*10+kk+1);
    }
  }
  else{
    return ;
  }
}






int main(){
  for(int i = 1;i<10;i++){
    dfs(i);
  }
  sort(ans.begin(),ans.end());
  ll K;
  cin>>K;
  cout << ans[K-1] << endl;
  return 0;
}

Measured memory_bytes: 2420
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	set := make(map[string]struct{}, n)
	for i := 0; i < n; i++ {
		var temp string
		fmt.Scan(&temp)
		set[temp] = struct{}{}
	}
	fmt.Println(len(set))
}

Measured memory_bytes: 15348
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    vin a(n);rep(i,n)cin>>a[i];
    vin boll(n+1);int sum;
    queue<int> one;
    for(int i=n;i>0;i--){
        sum=0;
        for(int j=2*i;j<=n;j+=i)sum+=boll[j];
        if(a[i-1]%2==sum%2)boll[i]=0;
        else{
            boll[i]=1;
            one.push(i);
        }
    }
    cout<<one.size()<<endl;
    while(one.size()>1){
        cout<<one.front()<<" ";
        one.pop();
    }
    if(one.size())cout<<one.front()<<endl;
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <stack>
#include <cmath>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <math.h>
#include <cstdlib>
#include <stdlib.h>
#include <set>
#include <unordered_set>
#include <cassert>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forn1(i, n) for (int i = 1; i <= n; ++i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll p = 997;
const ll base = 1e9 + 7;
const ll MAXN = 5e5;
const ll INF = 1e9;
const ll MOD = 1e9;
const double PII = 3.14159265358979323846264338327950288419716939937510;
const double Epsilon = 1.19209e-9;
const ld fi = 1.6180339887498948482;
const ll one = 2147483647;
const ll two = 1e9 + 7;
void print_vector(vector<int> & a) {
	forn(i, (int)a.size()) {
		cout << a[i] << " ";
	}
	cout << "\n";
}
void read_vector(vector<ll> & a, ll n) {
	ll h;
	forn(i, n) {
		cin >> h;
		a.pb(h);
	}
}
bool check_four(int a){
  int sum = 0;
  while(a){
    sum += a % 10;
    a /= 10;
  }
  return sum % 4 == 0;
}
void upd_max(int & a, int b){
  a = max(a, b);
}
void upd_min(int & a, int b){
  a = min(a, b);
}
//#define DEBUG
int main(){
	FastIO;
	#ifdef DEBUG
		freopen("input.txt", "r", stdin);
	#endif // DEBUG
	int n, d;
	cin >> n >> d;
	int po[n][d];
	forn(i, n){
		forn(j, d){
			cin >> po[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < n - 1; ++i){
		for (int j = i + 1; j < n; ++j){
			int dis = 0;
			for (int k = 0; k < d; ++k){
				dis += (po[i][k] - po[j][k]) * (po[i][k] - po[j][k]);
			}
			int z = 1;
			while(z * z < dis){
				++z;
			}
			if (z * z == dis)++ans;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, k = LI()
p = LI()
c = LI()
C = []
S = []
for i in range(n):
    lst = [-1]*n
    cnt = 0
    idx = i
    s = 0
    while lst[idx] == -1:
        lst[idx] = cnt
        s += c[idx]
        cnt += 1
        idx = p[idx] - 1
    C.append(cnt)
    S.append(s)

if n >= k:
    ans = -10**10
    for i in range(n):
        cnt = 0
        ret = 0
        idx = p[i]
        while cnt < k:
            ret += c[idx-1]
            idx = p[idx-1]
            cnt += 1
            ans = max(ans, ret)
    print(ans)
else:
    ans = -10**10
    for i in range(n):
        if S[i] > 0:
            tmp = S[i] * (k // C[i])
            r = k % C[i]
            cnt = 0
            ret = 0
            idx = p[i]
            tmp -= S[i]
            r += C[i]
            while cnt < r:
                ret += c[idx-1]
                idx = p[idx-1]
                cnt += 1
                ans = max(ans, tmp + ret)
        else:
            cnt = 0
            ret = 0
            idx = p[i]
            while cnt < n:
                ret += c[idx-1]
                idx = p[idx-1]
                cnt += 1
                ans = max(ans, ret)
    print(ans)

Measured memory_bytes: 70552
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if(abs(x-a) > abs(x-b)){
    cout << "B" << endl;
  }else{
    cout << "A" << endl;
  }
  return 0;
}


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

#define int long long

const int N = 2e5 + 10, M = 20 + 2;
int n, ans, ar[N], last[M], last2[M];

int32_t main() {
	memset(last, -1, sizeof last);
	memset(last2, -1, sizeof last2);
	
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> ar[i];
	
	for (int i = 0; i < n; i++) {
		vector <int> v;
		int tmp = ar[i], u = 0;
		
		while (tmp) {
			if (tmp & 1)
				v.push_back(u);
			u++;
			tmp /= 2;
		}
		
		int mx = -1;
		for (int j = 0; j < M; j++)
			mx = max(mx, last2[j]);
		for (int j : v) {
			mx = max(mx, last[j]);
			swap(last[j], last2[j]);
			last[j] = i;
		}
		ans += i - mx;
	}
	cout << ans;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
  int i,j,l=0,m,n=0,o=0;
  scanf("%d",&j);
  for(i=0;i<j;i++){
    scanf("%d",&m);
    if(l>=m){
      n++;
    }else{
      if(n>o){
        o=n;
      }
      n=0;
    }
    l=m;
  }
  if(n>o){
  	o=n;
  }
  printf("%d",o);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  double T,A;
  cin >> T >> A;
  vi H(N);
  rep(i,N) {
    cin >> H[i];
  }
  int ans = 0;
  rep(i,N) {
    double a = T - 0.006 * H[ans];
    double b = T - 0.006 * H[i];
    if(abs(a-A) > abs(b-A)) {
      ans = i;
    }
  }
  cout << ans+1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC100(void);
void ABC101(void);
void ABC102(void);
void ABC103(void);
void ABC104(void);
void ABC105(void);
void ABC106(void);
void ABC107(void);
void ABC108(void);
void ABC109(void);

int main(void){
    ABC104();
}

void ABC104(){
    int i,c=0,d=0;
    string s;
    cin>>s;
    if(s[0]=='A')c++;
    for(i=1;i<s.length();i++){
        if(s[i]=='C'&&i>=2&&i<=s.length()-2){
            c++;
            d++;
        }
        if(s[i]>='a'&&s[i]<='z'&&i>=1)c++;
    }
    cerr<<c<<endl;
    if(c==s.length()&&d==1)cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
}

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

int main(){
    string s;
    cin >> s;
    int min = 2000000000;
    for(int i=0;i<s.size()-2;i++){
        int tmp = (s[i]-'0')*100 + (s[i+1]-'0')*10+(s[i+2]-'0');
        if(abs(tmp-753) < min){
            min = abs(tmp-753);
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

int main(){
    ll n,m,k;

    cin >> n >> m >> k;
    ll suma[n+1], sumb[m+1];
    vector<ll> a(n), b(m);
    suma[0] = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        suma[i+1] = suma[i] + a[i];
    }
    sumb[0] = 0;
    for(int i = 0; i < m; i++){
        cin >> b[i];
        sumb[i+1] = sumb[i] + b[i];
    }
    
    int j = m;
    int ans = 0;
    for(int i = 0; i <= n; i++){
        ll d = suma[i];
        if(d > k) break;
        for(j; j >= 0; j--){
            if(d+sumb[j] <= k) break;
        }
        ans = max(ans, i+j);
    }


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

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

int main() {
	long long x;
	long long cnt = 0;
	cin >> x;
	int min = 6;
	cnt += 2 * (x / 11);
	x -= 11 * (cnt / 2);
	while (x > 0) {
		if (min == 6) {
			x -= min;
			min = 5;
		}
		else if (min == 5) {
			x -= min;
			min = 6;
		}
		cnt++;
	}
	cout << cnt << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if (a==b && c==b) cout << 1 << endl;
	else if (a==b || b==c || c==a) cout << 2 << endl;
	else cout << 3 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int n, m, p;
    int res = 0, divisor = 1;

    scanf ( "%d%d%d", &n, &m, &p );
    if ( !( n | m | p ) ) break ;

    for ( i = 1; i <= n; ++i )
    {
      int t;

      scanf ( "%d", &t );
      if ( i == m ) divisor = t;
      res += t;
    }
    res *= ( 100 - p );

    printf ( "%d\n", ( divisor ? res / divisor : 0 ) );
  }

  return ( 0 );
}

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

int main() {

int s,k;
string a,b,c;
cin >> s >> a;
k = s/2;
b = a.substr(0,k);
c = a.substr(k,s);

if (b==c){
	cout << "Yes";
}
else {
	cout << "No";
}

//cout << b << "\n" << c;
return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            string[] word = new string[] { "A", "C", "T", "G" };
            int length = 0;


            for (int i = 0; i < s.Length; i++)
            {
                int wordlength = 0;

                if (word.Any(s[i].ToString().Contains))
                {
                    wordlength++;

                    for (int j = i+1; j < s.Length; j++)
                    {
                        if (word.Any(s[j].ToString().Contains))
                        {
                            wordlength++;
                        }
                        else
                        {
                            break;
                        }
                    }

                }

                if (wordlength > length)
                {
                    length = wordlength;
                }
            }

            Console.WriteLine(length);
           

        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N,K;
    cin >> N >> K;
    map<int, int> sumlist;
    for ( int i = 0; i<N; i++) {
        int tmp = 0;
        cin >> tmp;
        sumlist[tmp]++;
    }

    int sortlist[sumlist.size()];

    int res = 0;
    int check[sumlist.size()];
    if(K < sumlist.size()) {
        int index = 0;
        for(auto x : sumlist) {
            check[index] = x.second;
            index++;
        }
        sort(check, check + sumlist.size());
        for(int i = 0; i < sumlist.size() - K; i++) {
            res += check[i];
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 10368
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int []a = new int[N];
        for(int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        scan.close();
        long ans = mergeSort(a, N, 0, N);
        System.out.println(ans);
    }
    public static long merge(int []A, int n, int left, int mid, int right) {
    	int i, j, k;
        long cnt = 0;
        int n1 = mid- left;
        int n2 = right - mid;
        int[] L = new int[n1+1];
        int[] R = new int[n2+1];
        for(i = 0; i < n1; i++) {
        	L[i] = A[left + i];
        }
        for(i = 0; i < n2; i++) {
            R[i] = A[mid + i];
        }
        L[n1] = 2000000000;           
        R[n2] = 2000000000;
        i = 0;
        j = 0;
        for(k = left; k < right; k++) {
            if(L[i] <= R[j]) {
                A[k] = L[i++];
            }else {
                A[k] = R[j++];
                cnt += n1 - i;
            }
        }
        return cnt;
    }
    public static long mergeSort(int []A, int n, int left, int right) {
        int mid;
        long v1, v2, v3;
        if(left + 1 < right) {
            mid = (left + right) / 2;
            v1 = mergeSort(A, n, left, mid);
            v2 = mergeSort(A, n, mid, right);
            v3 = merge(A, n, left, mid, right);
            return v1 + v2 + v3;
        }else {
            return 0;
        }
    }
}


Measured memory_bytes: 101596
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;
    int a, b;
    cin >> a >> b;
    if (b % a == 0)
        cout << a + b;
    else
        cout << b - a;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
            int a = line[0], b = line[1], k = line[2];

            var min = a < b ? a : b;
            var count = 0;

            for (var i = min; i > 0; i--)
            {
                if (a % i == 0 && b % i == 0) count++;

                if (count == k)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
        }

    }
}


Measured memory_bytes: 13268
# coding: utf-8


def solve(*args: str) -> str:
    S = args[0]
    A = [0 for _ in range(len(S)+1)]

    m = 0
    for n in range(1, len(S)+1):
        if 0 < m:
            A[n] = m
            m -= 1
        elif S[n-1] == '<':
            A[n] = A[n-1]+1
        else:
            m = 0
            while n+m < len(S) and S[n+m] == '>':
                m += 1

            A[n-1] = max(m+1, A[n-1])
            A[n] = m
            m -= 1

    # for n in range(0, len(S)):
    #     print('{}{}'.format(A[n], S[n]), end='')
    # print(A[-1])

    return str(sum(A))


if __name__ == "__main__":
    print(solve(*[input() for _ in range(1)]))


Measured memory_bytes: 24092
#include <stdio.h>

int main(){
    int K;
    int A, B;
    scanf("%d", &K);
    scanf("%d %d", &A, &B);
    
    for(int i = 1 ; i < 1000 ; i++){
    	int temp = K;
    	temp *= i; // 7*3 = 21 -> kelipatan k
    	// printf("Temp number: "%d\n", temp);
    	if(temp >= A && temp <= B){ //statement && -> salah 1 false tidak jalan
    		printf("OK\n");
    		// printf("%d\n", i);
    		break;
		}
		else if(temp > B){
			printf("NG\n");
			//printf("%d\n", i);
			break;
		}
    	//balik ke atas
	}
    return 0;
}

Measured memory_bytes: 1648
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int len = strlen(s.c_str()) ;
    for(int i=0; i<len; i++)
    {
        if(i%2 && s[i]=='R')
        {
            cout<<"No"<<endl;
            return 0;
        }
        else if(i%2==0 && s[i]=='L')
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv,
       std.format,
       std.math;

void main()
{
	auto o = readln.chomp;
	auto e = readln.chomp;
	string p;
	if(o.length - e.length == 0){
		foreach(i; 0..e.length){
			p ~= o[i];
			p ~= e[i];
		}
	}else{
		foreach(i; 0..o.length){
			p ~= o[i];
			p ~= e[i];
		}
		p.popBack();
	}
	writeln(p);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int n,m,p[100020],x[100020],y[100020],par[100020];

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 ;
    }
    par[x]=y;
}

bool same(int x, int y){
    if (find(x)==find(y)){
        return true;
    } else {
        return false;
    }
}

int main(void){
    scanf("%d%d",&n,&m);
    for (int i=0; i<n; i++){
        scanf("%d",&p[i]);
        par[i]=i;
    }
    for (int i=0; i<m; i++){
        scanf("%d%d",&x[i],&y[i]);
        unite(x[i]-1,y[i]-1);
    }
    int ans=0;
    for (int i=0; i<n; i++){
        if (same(i,p[i]-1)==true){
            ans++;
        }
    }
    printf("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 1664
S=input()
if len(S)%2==0:
    S_mae=S[:len(S)//2]
    S_ushiro=S[len(S)//2:]
else:
    S_mae=S[:len(S)//2+1]
    S_ushiro=S[len(S)//2:]
ans=0
for i in range(len(S_mae)):
    if S_mae[-i-1]!=S_ushiro[i]:
        ans += 1
print(ans)





Measured memory_bytes: 9052
N, K = map(int,input().split())
ans = 0
# Kが奇遇により処理変化
if K % 2 != 0:
    # 奇数の場合、a,b,cがいずれもKの倍数ならばOK
    ans = (N // K) ** 3

else:
    # 偶数の場合mod K が、K / 2 の倍数　または 0 ならOK
    h = K // 2
    cnt = 0
    ans = (N // K) ** 3
    for i in range(1, N + 1):
        if i % K == h:
            cnt += 1

    ans += cnt ** 3

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int x;
    int a,b;
    cin>>x>>a>>b;
    x-=a;
    cout<<x%b<<endl;
    
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int l=0;
    int ans[10050]={0};
    for (int i=1; i<=100;++i) {
        for (int j=1; j<=100;++j) {
            for (int k=1; k<=100;++k) {
                l = i*i + j*j + k*k + i*j + j*k + k*i;
                if (l <= 10000) ans[l]++;
            }
        }
    }
    for (int i=1; i<=N; ++i){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
using System;

namespace ITP1_1_C
{
    class Program
    {

        static void Main(string[] args)
        {
            int a, b, c, d;
            string[] str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            c = a * b;
            d = (a + b) * 2;
            Console.WriteLine("{0} {1}", c, d);
        }
    }
}

Measured memory_bytes: 9188
<?php

$input = fgets(STDIN);

$ex = explode(' ', $input);

$a = $ex[0];
$b = $ex[1];
$c = $ex[2];
$d = $ex[3];

if (abs($a-$b) <= $d && abs($b-$c) <= $d) {
    echo 'Yes' . PHP_EOL;
} elseif ($a == $b && $b == $c) {
    echo 'Yes' . PHP_EOL;
} elseif (abs($a-$c) <= $d) {
    echo 'Yes' . PHP_EOL;
} else {
    echo 'No' . PHP_EOL;
}



Measured memory_bytes: 3828
/*
Link: 
*/

#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

void Res(){
    int n;
    cin>>n;
    int ans=0;
    if(n%2==0) ans=n/2;
  	else ans=n/2+1;
    cout<<ans;

}
int main(){
    IOS;
    Res();
}

Measured memory_bytes: 256
N,K=map(int, input().split())
d = []
A =[]
s = list(range(1,N+1))

for i in range(K):
  di = int(input())
  d += [di]
  Ai = list(map(int, input().split()))
  A += [Ai]
  #print(Ai)

  for j in Ai:
    if j in s:
      #print(j)
      s.remove(j)
      #print(s)

ans = len(s)
print(ans)

Measured memory_bytes: 9216
#include<cstdio>
#include<algorithm>
#include<cstring>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int maxn=200000+10;
const ll inf=1000000000000000000;
char s[maxn];
ll len[1000],nt[1000],cnt1[1000][27],cnt2[1000][27],o[27],ans[27];
int nxt[maxn];
int i,j,k,t,n,m,tot,top;
ll l,r;
void kmp(){
	j=0;
	fo(i,2,n){
		while (j&&s[j+1]!=s[i]) j=nxt[j];
		if (s[j+1]==s[i]) j++;
		nxt[i]=j;
	}
}
void work(ll n,int f){
	int i,j;
	fd(i,top,1)
		if (n>=len[i]){
			fo(j,0,25) ans[j]+=f*(cnt1[i][j]*2+cnt2[i][j]);
			n-=len[i];
		}
	if (n>=len[0]){
		fo(j,0,25) ans[j]+=f*o[j];
		n-=len[0];
	}
	fo(i,1,n) ans[s[i]-'a']+=f;
}
void solve(ll n,int f){
	int i,j;
	fo(i,0,25) ans[i]+=(ll)f*(n/tot)*o[i];
	n%=tot;
	fo(i,1,n) ans[s[i]-'a']+=f;
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	n/=2;
	kmp();
	if (n%(n-nxt[n])){
		fo(i,1,nxt[n]) cnt1[0][s[i]-'a']++;
		fo(i,nxt[n]+1,n-nxt[n]) cnt2[0][s[i]-'a']++;
		fo(i,1,n) o[s[i]-'a']++;
		len[0]=n;nt[0]=nxt[n];
		if (nxt[n]>=(n+1)/2){
			top++;
			len[top]=len[top-1]*2-nt[top-1];
			nt[top]=len[top-1]-nt[top-1];
			fo(i,1,nt[top]) cnt1[top][s[i]-'a']++;
			fo(i,n-nxt[n]+1,n) cnt2[top][s[i]-'a']++;
		}
		while (len[top]<inf){
			top++;
			len[top]=len[top-1]*2-nt[top-1];
			nt[top]=len[top-1]-nt[top-1];
			fo(i,0,25){
				cnt1[top][i]=cnt1[top-1][i]+cnt2[top-1][i];
				cnt2[top][i]=cnt1[top-1][i];
			}
		}
		scanf("%lld%lld",&l,&r);
		work(r,1);
		work(l-1,-1);
		fo(i,0,25) printf("%lld ",ans[i]);
	}
	else{
		tot=n-nxt[n];
		fo(i,1,tot) o[s[i]-'a']++;
		scanf("%lld%lld",&l,&r);
		solve(r,1);
		solve(l-1,-1);
		fo(i,0,25) printf("%lld ",ans[i]);
	}
}

Measured memory_bytes: 768
#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <iostream>
#include <math.h>
#include <cmath>
#include <iterator>
//#include <unordered_map>
//#include <unordered_set>
#include <functional>
#include <queue>
#include <iomanip>
#include <istream>
#include <map>
#include <list>
#include <stack>
#include <numeric>
#include <ostream>
#include <set>
#include <cassert>
#include <sstream>
#include <string>
#include <utility>
#include <stdio.h>
#include <bitset>
#include <vector>
#include <random>

using namespace std;

#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) (int((x.size())))
#define fi first
#define se second
#define REP(i, a, n) for (int (i)=(a);(i)<(n);(i)++)
#define PER(i, a, n) for (int (i)=(n)-1;(i)>=(a);(i)--)

typedef long double 	ld;
typedef long long 		ll;
typedef vector<int> 	VI;
typedef pair<int, int>	PII;
typedef pair<ll, ll> 	PLL;
typedef vector<ll>		VL;
typedef vector<PLL> 	VPL;
typedef vector<PII> 	VPI;

#ifndef ONLINE_JUDGE
#define dbb(x)		{ cerr << #x << " = " << x << "\t";      }
#define db(x)		{ dbb(x); cerr << endl; }
#define db2(x,y)	{ dbb(x); dbb(y); cerr << endl; }
#define db3(x,y,z)	{ dbb(x); dbb(y); dbb(z); cerr << endl; }
#else
#define dbb(x)		;
#define db(x)		;
#define db2(x,y)	;
#define db3(x,y,z)	;
#endif



const ll  MOD = 1000000007ll;

ll powmod(ll a, ll b) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a%MOD; a = a * a%MOD; }return res; }
template <typename t1, typename t2> inline bool upmax(t1 &a, t2 b) { if (a < (t1)b) { a = (t1)b; return true; } else return false; }
template <typename t1, typename t2> inline bool upmin(t1 &a, t2 b) { if (a > (t1)b) { a = (t1)b; return true; } else return false; }
template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template <typename T> inline T lcm(T a, T b) { return a * (b / gcd(a, b)); }
template <typename T> inline T sqr(T a) { return a * a; }

int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
int dkx[] = { -1, -1, 1, 1, -2, -2, 2, 2 };
int dky[] = { -2, 2, -2, 2, -1,  1,-1, 1 };

const int INF = 1000000404;
const ll  LINF = 4000000000000000404ll;
const ld  PI = 3.14159265358979323846;
const ld  EPS = 1e-9;

int SQ = 318;
int timer = 0;

#define N 200100

VI g[N];

PII get(int v, int p) {
	int maxx = 0;
	
	PII ans = MP(0, v);

	for (auto x : g[v]) {
		if (x == p) continue;
		PII f = get(x, v);
		if (upmax(maxx, f.first + 1)) {
			ans = MP(maxx, f.second);
		}
	}
	return ans;	
}
void solve() {

	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	PII p = get(1, -1);
	db2(p.first, p.second);
	p = get(p.second, -1);
	db2(p.first, p.second);
	
	if ((p.first+1) % 3 == 2) {
		cout << "Second";
	}
	else cout << "First";

}

int main()
{
#ifndef ONLINE_JUDGE	
	///freopen("input.txt", "r", stdin);
	///freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int t = 1;
	//cin >> t;

	while (t--) {

		solve();

	}

	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 26880
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define mm(arr) memset(arr, 0, sizeof(arr))
#define scanArray(a,n) for(int i = 0; i < n; i++){cin >> a[i];}
#define pb push_back
#define PI 3.141592653589793
#define MOD 1000000007

using namespace std;
int main(){
    FAST
    ll n,x; cin >> n >> x;
    ll m[n];
    ll cnt=0,sum=0;
    for(int i=0;i<n;i++){
        cin >> m[i];
        sum+=m[i];
    }
    sort(m,m+n);
    ll i=0;
    if(sum>x){
        while(sum>0){
            sum-=m[i];
            cnt++;
            i++;
        }
    }
    else{
        cnt=n;
        x-=sum;
        while(x>0){
            if(x-m[0]<0){
                break;
            }
            x-=m[0];
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3652
#https://www.youtube.com/watch?v=3gFnZhZlAF8
#【競プロ実況】ABC172 AからD問題【かつっぱ】
#等差数列の和

n=int(input())
ans=0
for i in range(1,n+1):
    N=n//i #項数
    ans+=((i+i*N)*N)//2
print(ans)

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

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

  vector<int> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
    data.at(i)--; // 1-indexed -> 0-indexed
  }

  int ans= 0;
  for(int i=0; i<N; i++){
    if(i < data.at(i) && data.at(data.at(i))==i){
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
int main(void){
    //AとBの差を求める
    int A,B;
    string S;
    bool k=0;
    cin >> A >> B >> S;
    REP(i,S.size()){
        if((i==A&&S[i]=='-')||(i!=A&&'0'<=S[i]&&S[i]<='9')){
        }else{
            k=1;
        }
    }
    if(k==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256