akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		br.readLine();
		List<String> a=Arrays.asList(br.readLine().split(" "));
		int n1=Integer.parseInt(a.get(0));
        int min=n1,max=n1;
        long sum=n1;
        for(Iterator<String> i=a.iterator();i.hasNext();){
			String s=i.next();
        	int n2=Integer.parseInt(s);
            if(n2<min) min=n2;
            if(n2>max) max=n2;
            sum+=n2;
		}
        System.out.println(min+" "+max+" "+(sum-n1));
	}
}

Measured memory_bytes: 25524
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    n, m = [int(x) for x in input().split()]
    d = [0] * (n+1)
    d[0] = 1
    for _ in range(m):
        x = int(input())
        d[x] = -1

    for i in range(1, n+1):
        if d[i] != -1:
            if d[i-1] != -1:
                d[i] = d[i-1]
            if i > 1 and d[i-2] != -1:
                d[i] += d[i-2]
            d[i] %= MOD

    print(d[n]%MOD)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""


Measured memory_bytes: 13584
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
d = {"2":0,"4":0,"other":0}
for i in readInts():
	if i%4==0:
		d["4"]+=1
	elif i%2==0:
		d["2"]+=1
	else:
		d["other"]+=1
if d["2"]>1:
	if d["4"]>=d["other"]:
		print("Yes")
	else:
		print("No")
elif d["2"]==1:
	if d["4"]+1>=d["other"]+d["2"]:
		print("Yes")
	else:
		print("No")
else:
	if d["4"]+1>=d["other"]:
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 20800
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define mod 998244353
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=10001 ;
int main()
{
   fast ;
   ll n ;
   cin>>n ;
   vector<ll>a(n),b(n) ;
   for(ll i=0;i<n;i++)
    cin>>a[i] ;

   for(ll i=0;i<n;i++)
    cin>>b[i] ;

   ll ans=0 ;
   for(ll i=0;i<29;i++)
   {
       vector<ll>na(n),nb(n) ;
       for(ll j=0;j<n;j++)
       {
           na[j]=a[j]%(1<<(i+1)) ;
           nb[j]=b[j]%(1<<(i+1)) ;
       }
       ll cnt=0 ;
       sort(all(na)) ;
       sort(all(nb)) ;

       for(ll j=0;j<n;j++)
       {
            auto it1=upper_bound(all(nb),(1<<(i+1))-1-na[j]) ;
            auto it=lower_bound(all(nb),(1<<i)-na[j]) ;


            ll x=(ll)(it1-it) ;
            x=max(x,(ll)0) ;
            cnt+=x ;


            it1=upper_bound(all(nb),(1<<(i+2))-2-na[j]) ;
            it=lower_bound(all(nb),(1<<(i+1))+(1<<i)-na[j]) ;

            x=(ll)(it1-it) ;
            x=max(x,(ll)0) ;
            cnt+=x ;


       }

       if(cnt%2)
       {
           ans+=(1<<i) ;
       }
   }
   cout<<ans ;


}



Measured memory_bytes: 6572
from itertools import combinations

N, K = map(int, input().split())
points = []
for i in range(N):
    points.append(list(map(int, input().split())))

xl = list(map(lambda p: p[0],
              points))
yl = list(map(lambda p: p[1],
              points))

def contained(point, xmin, xmax, ymin, ymax):
    return (xmin <= point[0] <= xmax) and (ymin <= point[1] <= ymax)

def count_contained(xmin, xmax, ymin, ymax):
    count = 0
    for point in points:
        if contained(point, xmin, xmax, ymin, ymax):
            count += 1
    return count

min_area = 10**20
for xs in combinations(xl, 2):
    xmin = min(xs)
    xmax = max(xs)
    for ys in combinations(yl, 2):
        ymin = min(ys)
        ymax = max(ys)
        if count_contained(xmin, xmax, ymin, ymax) >= K:
            area = (xmax-xmin) * (ymax-ymin)
            min_area = min(area, min_area)
print(min_area)


Measured memory_bytes: 61344
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  int N, M, C; cin >> N >> M >> C;
  int B[M];
  rep(i,M) cin >> B[i];

  int tot = 0, A, cnt = 0;
  rep(j,N){
    tot = C;
    rep(i,M){
      cin >> A;
      tot += A*B[i];
    }
    if (tot>0) cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


// ***************************CODE**********************//



int main(void){
        //この工夫
        string s = "MARCH";
        ll c[5] = {0};
        ll N;
        cin >> N;
        for(int i=0;i<N;i++){
                string t;
                cin >> t;
                for(int j=0;j<5;j++){
                        if(t[0] == s[j]){
                                c[j]++;
                        }
                }
        }

        ll ans = 0;
        for(int i = 0; i < 5; i++){
                for(int j = i+1; j < 5; j++){
                        for(int k = j+1; k < 5; k++){
                                ans += c[i]*c[j]*c[k];
                        }
                }
        }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

int main() {
    long long n;
    cin >> n;
    vector<int> as(n);
    vector<int> bs(n);
    int sum2 = 0;
    for (int i = 0; i < n; i++) {
        cin >> as[i];
        bs[i] = as[i];
        if (as[i] % 2 == 0) {
            // cout << as[i] << endl;
            int g = 0;
            while (as[i] % 2 == 0 && g < 2) {
                as[i] = as[i] / 2;
                sum2++;
                g++;
            }
        }
    }
    int sum4 = 0;
    if (n % 2 == 1) {
        REP(i, n) {
            if (bs[i] % 4 == 0) {
                sum4++;
            }
        }
        // cout << sum4;
        if (sum4 == 0 && sum2 != n) {
            no();
        }
    }
    // cout << sum2 << " " << 2 * (n / 2) << endl;
    if (sum2 >= 2 * (n / 2)) {
        yes();
    } else {
        no();
    }
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	long long a,b;
	cin>>a>>b;
	if(b-a>=2019)cout<<"0"<<'\n';
	else{
		int ans=2018;
		for(long long i=a+1;i<=b;i++){
			for(long long j=a;j<i;j++){
				if((i*j)%2019<ans)ans=(i*j)%2019;
			}
		}
		cout<<ans<<'\n';
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                           //     #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                  #define VI vector<int>
                                        using namespace std;
                                        
                                  class pas{
                                    	public:
                                    	int x,y;
                                    	pas(int x=0,int y=0):x(x),y(y) {}
                                    	pas operator + (pas p) {return pas(x+p.x,y+p.y);}
                                    	pas operator - (pas p) {return pas(x-p.x,y-p.y);}
                                    	pas operator * (int a) {return pas(x*a,y*a);}
                                    	pas operator / (int a) {return pas(x/a,y/a);}
                                    //	double absv() {return sqrt(norm());}
                                    	int norm() {return x*x+y*y;}
                                    	bool operator < (const pas &p) const{
                                    		return x != p.x ? x<p.x: y<p.y;
                                    	}
                                    	bool operator == (const pas &p) const{
                                    		return x==p.x && y==p.y;
                                    	}
                                    };
int a[60]={0};
           signed main(){
       string s,t;
           	cin>>s>>t;
           	if(s[0]==t[2] && s[1]==t[1]&&t[0]==s[2])cout<<"YES"<<endl;
           	else cout<<"NO"<<endl;
           	
           }
             

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import queue

INF = 10 ** 10

def solve(H: int, W: int, S: list):

    # right, bottom, left, top
    h_move = [0, 1, 0, -1]
    w_move = [1, 0, -1, 0]

    max_distance = 0
    for h_start in range(H):
        for w_start in range(W):
            if  S[h_start][w_start] != ".":
                continue
            distance = []
            for _ in range(H):
                l = [INF] * W
                distance.append(l)
            q = queue.Queue()
            q.put((h_start, w_start)) # スタート地点
            distance[h_start][w_start] = 0

            while not q.empty():
                h, w = q.get()
                for i in range(4):
                    h_next = h + h_move[i]
                    w_next = w + w_move[i]
                    # マップ外・壁・訪問済みを除外
                    if (h_next < 0 or h_next >= H or w_next < 0 or w_next >= W or S[h_next][w_next] != "." or distance[h_next][w_next] != INF):
                        continue
                    q.put((h_next, w_next))
                    distance[h_next][w_next] = min(distance[h][w] + 1, distance[h_next][w_next])
                    max_distance = max(max_distance, distance[h_next][w_next])

    print(max_distance)
    return

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))
    W = int(next(tokens))
    S = [next(tokens) for _ in range(H)]
    solve(H, W, S)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
function Main(input) {
  var tmp = input.trim().split("\n");
  var XYZK = tmp[0].split(/\s/).map(val => parseInt(val, 10));
  var X = XYZK[0];
  var Y = XYZK[1];
  var Z = XYZK[2];
  var K = XYZK[3];
  var AAry = tmp[1].split(/\s/).map(val => parseInt(val, 10));
  var BAry = tmp[2].split(/\s/).map(val => parseInt(val, 10));
  var CAry = tmp[3].split(/\s/).map(val => parseInt(val, 10));

  AAry.sort((a, b) => b - a);
  BAry.sort((a, b) => b - a);
  CAry.sort((a, b) => b - a);

  var ABSumAry = [];
  var ABCSumAry = [];

  for (var i = 0; i < X; i++) {
    for (var j = 0; j < Y; j++) {
      ABSumAry.push(AAry[i] + BAry[j]);
    }
  }

  ABSumAry.sort((a, b) => b - a);

  for (var k = 0; k < Math.min(K, ABSumAry.length); k++) {
    for (var l = 0; l < Math.min(Z, K); l++) {
      if (Math.min(K, ABSumAry.length) < k * l) break;
      ABCSumAry.push(ABSumAry[k] + CAry[l]);
    }
  }
  ABCSumAry.sort((a, b) => b - a);

  for (var m = 0; m < K; m++) {
    console.log(ABCSumAry[m]);
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 94004
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break
    count = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if x - (i + j + k) == 0:
                    count += 1
                if x - (i + j + k) < 0:
                    break
    print(count)

Measured memory_bytes: 6724
n = int(input())
w = []
ans = 'Yes'

for i in range(n):
    w.append(input())

if len(set(w)) < len(w):
    ans = 'No'

for i in range(1, n):
    if w[i][0] != w[i - 1][-1]:
        ans = 'No'

print(ans)

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  int upper = 1e5;
  vector<int> freqs(upper + 5, 0);
  int a;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a);
    ++freqs[a];
  }
  int ans = 0, evens = 0;
  for (int i = 1; i <= upper; ++i) {
    if (freqs[i] == 0) { continue; }
    ++ans;
    if ((freqs[i] & 1) == 0) { ++evens; }
  }
  ans -= (evens & 1);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 640
/**
 *      author  : kyomukyomupurin
 *      created : 2018/08/19
**/
//ABC 103 A

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

int main(){
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;

    cout << max(A1, max(A2, A3)) - min(A1, min(A2, A3));

    return 0;
}

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

#define ll long long int
#define loop(v,n) for(ll v=0;v<n;v++)

using namespace std;

#define MAXN 100000

int main() {
    ll n,a[MAXN],b[MAXN],c[MAXN];
    cin >> n;
    loop(i,n) cin >>a[i];
    loop(i,n) cin >>b[i];
    loop(i,n) cin >>c[i];
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    ll res = 0;
    loop(i,n) {
        auto j = lower_bound(a,a+n,b[i]);
        auto k = upper_bound(c,c+n,b[i]);
        res += (j - a) * (n - (k - c));
    }
    cout << res << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll x,y;
    cin>>x>>y;
    ll a=x;
    int countt=0;
    while(a<=y)
    {
        countt++;
        a*=2;

    }
    cout<<countt<<endl;


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,d,x;
    int A[100];
    
    cin >> n >> d >> x;
    int ans = x;
    
    for(int i=0;i<n;i++){
        int A[i];
        cin >> A[i];
        ans += (d-1)/A[i]+1;
    }
    cout << ans;
        
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 struct Node{
  int key;
 struct Node *next,*prev;
};
 struct Node *nil;
struct Node * listSearch(int key){
struct  Node *cur=nil->next;
  while(cur!=nil&&cur->key!=key){
    cur=cur->next;
  }
  return cur;
}
void init(){
  nil=(struct Node *)malloc(sizeof(struct Node));
  nil->next=nil;
  nil->prev=nil;
}
void print(){
struct  Node *cur=nil->next;
  int isf=0;
  while(1){
    if(cur==nil)break;
    if(isf++>0)printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
  }
  printf("\n");
}
void delete(struct Node *t){
  if(t==nil)return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}
void deletefirst(){
  delete(nil->next);
}void deletelast(){
  delete(nil->prev);
}
void deletekey(int key){
  delete(listSearch(key));
}
void insert(int key){
struct  Node *x=(struct Node *)malloc(sizeof(struct Node));
 x->key=key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}
int main(){
  int key,n,i;
  int size =0;
  char com[20];
  int np=0,nd=0;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%s%d",com,&key);
    if(com[0]=='i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0]=='d'){
      if(strlen(com)>6){
	if(com[6]=='F')deletefirst();
	else if (com[6]=='L')deletelast();
      }else{
	deletekey(key);
	nd++;
      }
      size--;
    }
  }
  print();
  return 0;
}

Measured memory_bytes: 31784
A = []

for i in range(3):
	a = list(map(int, input().split()))
	A.append(a)

N = int(input())

Flag = [[0] * 3 for i in range(3)]

for n in range(N):
	b = int(input())

	for i in range(3):
		for j in range(3):
			if(A[i][j] == b):
				Flag[i][j] = 1

for i in range(3):
	if(Flag[i][0] + Flag[i][1] + Flag[i][2] == 3):
		print('Yes')
		exit(0)

	if(Flag[0][i] + Flag[1][i] + Flag[2][i] == 3):
		print('Yes')
		exit(0)

if(Flag[0][0] + Flag[1][1] + Flag[2][2] == 3):
	print('Yes')
	exit(0)

if(Flag[2][0] + Flag[1][1] + Flag[0][2] == 3):
	print('Yes')
	exit(0)

print('No')

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

// calculate |gcd|.
// if  ether num is 0, return 0
long long GCD(long long left, long long right) {
  if(left == 0 || right == 0) return 0;
  if(left < 0) left *= -1;
  if(right < 0) right *= -1;
  if(left < right) swap(left, right);
  long long nextnum, ansgcd = -1;
  while(ansgcd == -1) {
    nextnum = left % right;
    if(nextnum == 0) ansgcd = right;
    left = right;
    right = nextnum;
  }
  return ansgcd;
}

long long LCM(long long left, long long right) {
  return left / GCD(left, right) * right;
}

long long p, q;

long long solve();

int main() {
  cin >> p >> q;

  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long now = q / GCD(p, q), ans = 1;
  for(long long i = 2; i * i <= now; ++i)
    if(now % i == 0) {
      ans *= i;
      while(now % i == 0) now /= i;
    }
  if(now > 1) ans *= now;
  return ans;
}


Measured memory_bytes: 3088
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
#include <numeric>
#include <stack>
using namespace std;

int D;
long long G;
vector<long long> p, c;

int main() {
	cin >> D >> G;
	p.resize(D); c.resize(D);
	for (int i = 0; i < D; ++i) cin >> p[i] >> c[i];

	long long res = 1 << 29; //大きめのbitをとっておく
	for (int bit = 0; bit < (1 << D); ++bit) {
		long long sum = 0;
		long long num = 0;
		for (int i = 0; i < D; ++i) {
			if (bit&(1 << i)) sum += c[i] + p[i] * 100 * (i + 1), num += p[i]; //フラグが立っているものは全部解く
		}
		if (sum >= G) res = min(res, num);
		else { //全部解いて目標点に達しない場合高得点から順に解いていく
			for (int i = D - 1; i >= 0; --i) {
				if (bit & (1 << i)) continue; // flagが立っているものは飛ばす？
				for (int j = 0; j < p[i]; ++j) {
					if (sum >= G)break;
					sum += 100 * (i + 1);
					++num;
				}
			}
			res = min(res, num);
		}
	}
	cout << res << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vll x(n);
    rep(i,n) cin>>x[i];
    vll y = x;
    sort(all(y));
    ll L = y[n/2-1];
    ll R = y[n/2];
    rep(i,n){
        if (x[i]>=R){
            cout<<L<<endl;
        }else{
            cout<<R<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5376
use std::io::Read;
use std::io::Write;

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let len: usize = it.next().unwrap().parse().unwrap();
    let q: usize = it.next().unwrap().parse().unwrap();
    let d: Vec<usize> = (0..len).map(|_| it.next().unwrap().parse().unwrap()).collect();
    for _ in 0..q {
        let n: usize = it.next().unwrap().parse().unwrap();
        let x: usize = it.next().unwrap().parse().unwrap();
        let m: usize = it.next().unwrap().parse().unwrap();
        let x = x % m;
        let d: Vec<usize> = d.iter().map(|d| *d % m).collect();
        let sum = d.iter().fold(0, |s, a| s + *a);
        let zero = d.iter().filter(|d| **d == 0).count();
        let rep = (n - 1) / len;
        let mut ans = rep * len - zero * rep - (x + rep * sum) / m;
        let mut now = (x + rep * sum) % m;
        for d in d.iter().take((n - 1) % len) {
            let next = (now + *d) % m;
            if next > now {
                ans += 1;
            }
            now = next;
        }
        writeln!(out, "{}", ans).ok();
    }
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include<stdio.h>
#define MAX 5000



int max(int a,int b){
 if(a > b)return a;
return b;
}

int g(int a[],int n){
 int t=a[0];
 for(int k=1;k<n;k++)
  t=max(t+a[k],a[k]);
 return t;
}

int f(int a[],int n){
 int s=a[0];
 for(int k=1;k<n;k++)
  s=max(s,g(a,k+1));
 return s;
}



int main(){

 int n,i,j;
 int A[MAX];
 int ans;
 while(1)
 {

  scanf("%d",&n);
  if(n==0)break;

  for(i=0;i<n;i++)
  {
    scanf("%d",&A[i]);
  }
 ans=f(A,n);
  printf("%d\n",ans);

 }

return 0;
}


Measured memory_bytes: 1984
#include <stdio.h>
 
#define MAX 100000
 
int n, k;
int A[MAX];
 
void exchange(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}
 
int partition(int *A, int p, int r) {
  int x = A[r];
  int i = p - 1, j;
 
  for (j = p; j <= r-1; j++) {
    if (A[j] <= x) {
      i++;
      exchange(&A[i], &A[j]);
    }
  }
  exchange(&A[i+1], &A[j]);
 
  return i+1;
}
 
int main() {
  int i, q;
 
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
 
  q = partition(A, 0, n-1);
  for (i = 0; i < n; i++) {
    if (i == n-1) {
      printf("%d\n", A[i]);
      break;
    } if (i == q) {
      printf("[%d] ", A[i]);
      continue;
    }
    printf("%d ", A[i]);
  }
 
  return 0;
}


Measured memory_bytes: 2116
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
//use proconio::marker::Usize1;
//use proconio::marker::Chars;
//use std::collections::HashSet;
//use std::cmp::*;
fn main() {
    input! {
        N:usize, K:usize,
        mut P:[i32;N]
    }
    P.sort();
    let mut ans = 0;
    for p in P[..K].iter() {
        ans += p;
    }
    println!("{:?}", ans);
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define ll long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        int query[200000];
        ll N,x;
        std::ios::sync_with_stdio(false);
       vll arr;
            
            cin>>N;

            for (int i = 0; i < N; ++i)
            {
                cin>>x;
                arr.push_back(x);

            }

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

            for (int i = 0;i < N-1;i++)
            {
                if(arr[i]==arr[i+1])
                {
                    cout<<"NO";
                    return 0;
                }
            }

            cout<<"YES";
       
        return 0;
    }


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
// cout << "\t" << endl;

int main() {
  lint x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  priority_queue<lint> p, q, r;
  for (int i = 0; i < a; i++) {
    int tmp;
    cin >> tmp;
    p.push(tmp);
  }
  for (int i = 0; i < b; i++) {
    int tmp;
    cin >> tmp;
    q.push(tmp);
  }
  for (int i = 0; i < c; i++) {
    int tmp;
    cin >> tmp;
    r.push(tmp);
  }

  vector<lint> vans;
  for (int i = 0; i < x; i++) {
    vans.push_back(p.top());
    p.pop();
  }
  for (int i = 0; i < y; i++) {
    vans.push_back(q.top());
    q.pop();
  }
  sort(vans.begin(), vans.end());

  lint pos = 0;
  for (int i = 0; i < c; i++) {
    if (r.top() > vans.at(pos)) {
      vans.at(pos) = r.top();
      r.pop();
      pos++;
    } else
      break;
  }

  lint ans = 0;
  for (auto itr = vans.begin(); itr != vans.end(); itr++) {
    ans += *itr;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4852
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define pi  acos(-1)
const int w=2e5+5;
const ll mod=1e9+7;
int main()
{
    int i,j;
    string a;
    cin>>a;
    int ans1=0,ans2=0;
    for(i=0;i<a.size();i++)
    {
        if(a[i]=='A')
            ans1++;
        else
            ans2++;
    }
    if(ans1&&ans2)
        puts("Yes");
    else
        puts("No");
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		for(int i = 1; i <= 9; i++)
		{
			if(N % i == 0 && N / i <= 9)
			{
				Console.WriteLine("Yes");
				return;
			}
		}
		Console.WriteLine("No");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


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

int main(){
  int n;
  cin >> n;
  while(n--){
    string s,t;
    cin >> s >> t;

    list<char> p;
    for(int i=t.length()-1; i>=0; i--){
      p.push_front(t[i]);
    }

    for(int i=s.length()-1; i>=0; i--){
      if(s[i]=='J'){
	p.push_front(p.back());
	p.pop_back();
      }
      else if(s[i]=='C'){
	p.push_back(p.front());
	p.pop_front();
      }
      else if(s[i]=='E'){
	if(t.length()%2==0){
	  for(int j=0; j<t.length()/2; j++){
	    p.push_front(p.back());
	    p.pop_back();
	  }
	}
	else{
	  for(int j=0; j<(t.length()-1)/2; j++){
	    p.push_front(p.back());
	    p.pop_back();
	  }
	  list<char>::iterator it; it=p.begin();
	  for(int j=0; j<(t.length()-1)/2; j++)
	    it++;
	  p.insert(it,p.back());
	  p.pop_back();
	}
      }
      else if(s[i]=='A'){
	p.reverse();
      }
      else if(s[i]=='P'){
	for(list<char>::iterator it=p.begin(); it!=p.end(); ++it){
	  if(isdigit(*it)){
	    int a = *it-'0';
	    a+=9;
	    a%=10;
	    *it = a+'0';
	  }
	}
      }
      else{
	for(list<char>::iterator it=p.begin(); it!=p.end(); ++it){
	  if(isdigit(*it)){
	    int a = *it-'0';
	    a+=11;
	    a%=10;
	    *it = a+'0';
	  }
	}
      }
    }
    
    for(list<char>::iterator it=p.begin(); it!=p.end(); ++it)
      cout << *it;
    cout << endl;
    
  }
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D = 0;
	cin >> A >> B >> C >> D;
  	bool isTakahashiTurn = true;
  	while(A > 0 && C >0){
    	if(isTakahashiTurn){
        	C -= B;
        }else{
        	A -= D;
        }
      isTakahashiTurn = !isTakahashiTurn;
    }
  if(isTakahashiTurn){
  	cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}

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

using namespace std;

int n;
long long arr[200005];

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

    int i;
    long long sum = 0,x=0,ans1,ans2;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
    }
    for(i=0;i<n;i++){
        x+=arr[i];
        if(x*2>=sum){
            ans1 = (x-(sum-x));
            break;
        }
    }
    x = 0;
    for(i=n-1;i>=0;i--){
        x+=arr[i];
        if(x*2>=sum){
            ans2 = (x-(sum-x));
            break;
        }
    }
    cout<<min(ans1,ans2)<<'\n';
	return 0;
}


Measured memory_bytes: 1792
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort()

R = p[:X]
G = q[:Y]
i = X - 1
j = Y - 1
con = True
while con and len(r) > 0:
    rr = r.pop()
    if R[i] < G[j]:
        if R[i] < rr:
            R[i] = rr
            i -= 1
            continue
        else:
            con = False
    else:
        if G[j] < rr:
            G[j] = rr
            j -= 1
            continue
        else:
            con = False

print(sum(R) + sum(G))

Measured memory_bytes: 22720
fn solve() {
    let (n, q): (usize, usize) = (read::<usize>(), read::<usize>());
    let mut bb = n;
    let mut rb = n;
    let mut confirmed_c: HashMap<usize, usize> = HashMap::new();
    let mut confirmed_r: HashMap<usize, usize> = HashMap::new();
    let mut res = (n - 2) * (n - 2);
    for i in 0..q {
        let (c, x): (usize, usize) = (read::<usize>(), read::<usize>());

        if c == 1
        // 縦flip
        {
            if x < rb {
                res -= bb - 2;
                for j in x + 1..rb {
                    confirmed_c.insert(j, bb - 2);
                }
                rb = x;
            } else {
                res -= confirmed_c.get(&x).expect("somethong wrong");
            }
        } else
        // 横flip
        {
            if x < bb {
                res -= rb - 2;
                for j in x + 1..bb {
                    confirmed_r.insert(j, rb - 2);
                }
                bb = x;
            } else {
                res -= confirmed_r.get(&x).expect("somethong wrong");
            }
        }
    }
    println!("{}", res);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 998_244_353;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 14072
#include<stdio.h>

int main(void){
  int n;
  scanf("%d",&n);
  long long ans = 0;  
  long long a[n];
  
  for(int i = 0;i < n;i ++){
    scanf("%lld",&a[i]);
    ans += (a[i]-1); 
  }
  
  printf("%lld\n",ans);
  
  return 0;
}

  

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if(i % 2 == 0 && a[i] % 2 != 0) cnt++;
  }
  cout << cnt;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long A, B, C; cin >> A >> B >> C;
    if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
        cout << 0 << endl;
    } else {
        cout << min({ B*C, C*A, A*B }) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int h, w;
    cin >> h >> w;
    vector<int> cnt(26, 0);
    rep(i, h) {
        string s;
        cin >> s;
        for ( char c: s ) {
            ++cnt[c-'a'];
        }
    }
    if ( (h*w) % 2 == 1 ) {
        rep(i, 26 ) {
            if ( cnt[i] % 2 == 1 ) {
                --cnt[i];
                break;
            }
        }
    }
    rep(i, 26) {
        if ( cnt[i] % 2 == 1 ) {
            cout << "No" << endl;
            return 0;
        }
    }
    int k2 = 0;
    if ( h % 2 == 1 ) {
        k2 += w / 2;
    }
    if ( w % 2 == 1 ) {
        k2 += h / 2;
    }
    int have2 = 0;
    rep(i, 26) {
        have2 += (cnt[i] % 4 == 2);
    }
    if ( have2 > k2 ) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    ans = 0
    tmp = -1
    for i in range(n):
        if tmp == a[i]:
            ans += 1
            tmp = -1
        else:
            tmp = a[i]

    print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <sstream>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define rei(n) for(int i=0;i<(int)n;i++)
#define rel(n) for(int l=0;l<(int)n;l++)
#define al(s) s.begin(),s.end()

typedef pair<int, int> pi;
typedef pair<pi, pi> ppi;
typedef pair<int, ppi> pipp;


int main()
{
	int n;
	while (cin >> n&&n)
	{
		int ans = 0;
		vector<string> v;
		rei(n)
		{
			string s;
			cin >> s;
			v.push_back(s);
		}

		rei(n)
		{
			int j = 0;
			rel(n)
			{
				if (v[i][l] == '1')
				{
					j++;
				}
				else
				{
					j = 0;
				}
				ans = max(ans, j);
			}
		}
		rei(n)
		{
			int j = 0;
			rel(n)
			{
				if (v[l][i] == '1')
				{
					j++;
				}
				else
				{
					j = 0;
				}
				ans = max(ans, j);
				
			}
		}

		for (int i = 0; i < n; i++)
		{
			int j = 0;
			for (int l = 0; l < n - i; l++)
			{
				if (v[l][i + l] == '1')
				{
					j++;
				}
				else
				{
					j = 0;
				}
				ans = max(j, ans);
			}
			j = 0;
			for (int l = 0; l < n - i; l++)
			{
				if (v[i + l][l] == '1')
				{
					j++;
				}
				else
				{
					j = 0;
				}
				ans = max(j, ans);
			}
			j = 0;
			for (int l = 0; l <= i; l++)
			{
				if (v[i - l][l] == '1')
				{
					j++;
				}
				else
				{
					j = 0;
				}
				ans = max(ans, j);
			}
			j = 0;
			for (int l = 0; l <n- i; l++)
			{
				if (v[n-1-l][l+i] == '1')
				{
					j++;
				}
				else
				{
					j = 0;
				}
				ans = max(ans, j);
			}
		}
			
			
			
		cout << ans << endl;




	}
}

Measured memory_bytes: 1292
#include <stdio.h>
#include <string.h>
 
void roll_N(void);
void roll_E(void);
void spin(void);
int now;
int dice[6],temp;
int men[24][2];
 
int main(void)
{
    int i,j;
    int q;
 
    for(i = 0; i < 6; i++)
    {
        scanf("%d", &dice[i]);
    }
 
    scanf("%d", &q);
    for(i = 0; i < q; i++)
    {
        scanf("%d %d", &men[i][0], &men[i][1]);
    }
 
 
 
    for(i = 0; i < q; i++)
    {
        for(j = 0; j < 4; j++)
        {
            roll_N();
            if (dice[0] == men[i][0] )
            {
                break;
            }
 
        }
 
        if (dice[0] != men[i][0])
        {
            for(j = 0; j < 4; j++)
            {
                roll_E();
 
                if (dice[0] == men[i][0] )
                {
                    break;
                }
 
            }
        }
 
        for(j = 0; j < 4; j++)
        {
            spin();
            if (dice[1] == men[i][1])
            {
                printf("%d\n", dice[2]);
                break;
            }
        }
 
    }
 
 
    return 0;
}
 
 
 
void roll_N(void)
{
    temp = dice[4];
    dice[4] = dice[0];
    dice[0] = dice[1];
    dice[1] = dice[5];
    dice[5] = temp;
 
}
 
void roll_E(void)
{
    temp = dice[2];
    dice[2] = dice[0];
    dice[0] = dice[3];
    dice[3] = dice[5];
    dice[5] = temp;
}
 
 
void spin(void)
{
    temp = dice[3];
    dice[3] = dice[1];
    dice[1] = dice[2];
    dice[2] = dice[4];
    dice[4] = temp;
 
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll mod = 1000000007;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	ll n,k;cin>>n>>k;
	ll sum=0;
	for(ll i=k;i<=n+1;i++){
		sum = (sum + (i*(n-i+1))%mod + 1)%mod;
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 3652
/*
ID:wmj20041
TASK:
LANG:C++
*/
#include<functional>
#include<algorithm>
#include<exception>
#include<stdexcept>
#include<streambuf>
#include<iterator>
#include<string.h>
#include<stdlib.h>
#include<typeinfo>
#include<valarray>
#include<iostream>
#include<sstream>
#include<istream>
#include<stdio.h>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<ctype.h>
#include<cassert>
#include<cstdlib>
#include<utility>
#include<cstring>
#include<numeric>
#include<ostream>
#include<cwctype>
#include<fstream>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cctype>
#include<string>
#include<vector>
#include<limits>
#include<locale>
#include<memory>
#include<cerrno>
#include<time.h>
#include<iosfwd>
#include<cfloat>
#include<cstdio>
#include<cwchar>
#include<cmath>
#include<ctime>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<ios>
#include<map>
#include<set>
#include<new>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define FILLBIG(a) FILL(a,0x7f)
#define ALL(a) (a).begin(),(a).end()
#define Inf ((int)0x7f7f7f7f)
#define Mod 1000000007
#define foreach(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define MASK(a) (1<<(a))
#define MASKX(x,a) ((x)<<(a))
#define BIT(a,b) ((a>>b)&1)
#define cddx(a) priority_queue<a >
#define cxdd(a) priority_queue<a,vector<a >,greater<a > >
#define deval(a) {cerr<<#a<<" = "<<a<<endl;}
#define dearr(be,en) {cerr<<#be;cerr<<" = {";for(auto i=be;i!=en;i++)cerr<<' '<<*i;cerr<<" }\n";}
#define reg register
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int uint;
typedef long long INT;
typedef long double ldouble;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef priority_queue<int> pqi;
typedef priority_queue<INT> PQI;
typedef priority_queue<pii> pqp;
typedef priority_queue<PII> PQP;
typedef priority_queue<int,vint,greater<int> > xqi;
typedef priority_queue<INT,VINT,greater<INT> > XQI;
typedef priority_queue<pii,vpii,greater<pii> > xqp;
typedef priority_queue<PII,VPII,greater<PII> > XQP;
const int INF=1e9+7;
using namespace std;
long long n,m;
int main()
{
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n>>m;
	long long x=n,k=0;
	while(x<=m)
	{
		x*=2;
		k++;
	}
	cout<<k;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define in(e,l) (std::find(l.begin(), l.end(), e) != l.end())
#define asort(l) (std::sort(l.begin(), l.end()))
#define dsort(l) (std::sort(l.rbegin(), l.rend()))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;

int main() {
  long long N, K;
  cin >> N >> K;
  set<int> a;
  for (int i = 0; i < N; ++i) {
    a.insert(i + 1);
  }
  for (int i = 0 ; i < K; ++i) {
    int d;
    cin >> d;
    for (int j = 0; j < d; ++j) {
      int t;
      cin >> t;
      a.erase(t);
    }
  }
  cout << a.size() << endl;
  return 0;
}



Measured memory_bytes: 3632
#include <stdio.h>

static int A[100000];
static int NP[100000] = { 0 };

int main( void ) {
    int N, K, Q;
    int i;
    int tmp;

    scanf("%d %d %d", &N, &K, &Q);
    Q = Q > 100000 ? 100000 : Q;

    for (i=0;i<Q;++i) {
        scanf("%d", &A[i]);
    }

    for (i=0;i<Q;++i) {
        NP[ A[i]-1 ]++;
    }

    for (i=0;i<N-1;++i) {
        tmp = K - Q + NP[i];
        // printf("%d: %d\n", i, tmp);
        if ( tmp > 0 ) {
            printf("Yes");
        } else {
            printf("No");
        }
        puts("");
    }
    tmp = K - Q + NP[N-1];
    if ( tmp > 0 ) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << max({a * c, a * d, b * c, b * d});
}

Measured memory_bytes: 3636
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;

const int MNUM = 12, leapMNUM = 12;
const int ML[] = {31,28,31,30,31,30,31,31,30,31,30,31};      //day/month in usual year
const int leapML[] = {31,29,31,30,31,30,31,31,30,31,30,31};  //day/month in leap year
const string days[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};

struct date{
  int y,m,d;

  date(void):y(0),m(1),d(1){}
  date(int a,int b,int c):y(a),m(b),d(c){}
  
  bool isLeap(void){
    if(y%400==0)return true;
    if(y%100==0)return false;
    if(y%4==0)return true;
    return false;
  }

  date next(void){
    d++;
    if(isLeap()){
      if(leapML[m-1]<d){ d=1; m++; }
      if(leapMNUM<m){ m=1; y++; }
    }else{
      if(ML[m-1]<d){ d=1; m++; }
      if(MNUM<m){ m=1; y++; }
    }
    return *this;
  }

  bool operator==(const date x)const{return (y==x.y && m==x.m && d==x.d);}

  bool operator<(const date x)const{
    if(y!=x.y)return y<x.y;
    if(m!=x.m)return m<x.m;
    return d<x.d;
  }

  bool operator<=(const date x)const{return (*this==x || *this<x); }
  bool operator>(const date x)const{return !(*this<=x);}
  bool operator>=(const date x)const{return !(*this<x);}

  ll dayCount(void)const{
    date tmp;
    for(ll res=0;;res++){
      if(tmp==*this)return res;
      tmp.next();
    }
    return 0;
  }

  ll operator-(const date x)const{
    return dayCount() - x.dayCount();
  }

  //calculate days from Julian Day(-4713/01/01) using Fliegel's formula.
  ll Fliegel(void){
    int a = (14-m)/12, Y = y+4800-a, M = m+12*a-3;
    return (ll)d + (153*M+2)/5 + 365*Y + Y/4 - Y/100 + Y/400 - 32045;
  }

  //calculate day of week using Zeller congruence.
  int Zeller(void){
    int Y = y, M = m;
    if(M<3){ Y--; M+=12; }
    return (Y + Y/4 - Y/100 + Y/400 + (13*M+8)/5 + d)%7;
  }
};

int main(){
  int y1,m1,d1,y2,m2,d2;
  while(cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2,y1>=0)
    cout << date(y2,m2,d2)-date(y1,m1,d1) << endl;
}

Measured memory_bytes: 1200
#include<stdio.h>
int main()
{
    int a,i;
    double sum=0;
    scanf("%d",&a);
    for (i=1;i<=a;i++)
    {
        if (i%3==0 && i%5==0)
        {
            continue;
        }
        else if (i%3==0 || i%5==0)
        {
            continue;
        }
        sum=sum+i;
    }
    printf("%.0lf",sum);
    return 0;
}


Measured memory_bytes: 1748