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

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();

            if(m == -1 && f == -1 && r == -1 ) break;

            if( m == -1 || f == -1 ){
                System.out.println("F");
            } else if(m+f >= 80){
                System.out.println("A");
            } else if(m+f >= 65){
                System.out.println("B");
            } else if(m+f >= 50 || r >= 50){
                System.out.println("C");
            } else if(m+f >= 30){
                System.out.println("D");
            } else {
                System.out.println("F");
            }
        }
    }
}



Measured memory_bytes: 26248
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define mdn 1000000007
#define N 100010
#include<stack>
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
int ksm(int bs,int mi)
{
	int ans=1;
	while(mi)
	{
		if(mi&1)	ans=1ll*ans*bs%mdn;
		bs=1ll*bs*bs%mdn; mi>>=1;
	}
	return ans;
}
struct edge{int to,lt;}e[N<<1];
int in[N],cnt,fac[N],inv[N];
void add(int x,int y)
{
	e[++cnt].to=y; e[cnt].lt=in[x]; in[x]=cnt;
	e[++cnt].to=x; e[cnt].lt=in[y]; in[y]=cnt;
}
int dfn[N],low[N],tms,col[N],cl,tot[N],edg[N]; ll mas[N];
stack<int> stk;
void tarjan(int x)
{
	dfn[x]=low[x]=++tms; stk.push(x);
	for(int i=in[x];i;i=e[i].lt)
	{
		int y=e[i].to;
		if(dfn[y])
			low[x]=min(low[x],dfn[y]);
		else
		{
			tarjan(y), low[x]=min(low[x],low[y]);
			if(low[y]>=dfn[x])
			{
				int w=0,p=0; ++cl;
				do
				{
					w=stk.top(); stk.pop(); mas[w]|=1ll<<cl; p++;
				}while(w!=y);
				tot[cl]=p+1; mas[x]|=1ll<<cl;
			}
		}
	}
}
int C(int n,int m){return n<m?0:1ll*fac[n]*inv[m]%mdn*inv[n-m]%mdn;}
int ans=1,u[N],v[N],n,m,k;
void solve()
{
	fac[0]=1;
	for(int i=1;i<=m+k;i++)	fac[i]=1ll*fac[i-1]*i%mdn;
	inv[m+k]=ksm(fac[m+k],mdn-2);
	for(int i=m+k;i;i--)	inv[i-1]=1ll*inv[i]*i%mdn;
	for(int i=1;i<=n;i++)	if(!dfn[i])	tarjan(i);
	for(int i=1;i<=m;i++)
	{
		if(!(mas[u[i]]&mas[v[i]]))	ans=1ll*ans*k%mdn;
		else
		{
			ll ms=mas[u[i]]&mas[v[i]];
			for(int j=1;j<=cl;j++)	if(ms>>j&1)
				edg[j]++;
		}
	}
	for(int i=1;i<=cl;i++)	if(edg[i]>=tot[i])
	{
		if(edg[i]==tot[i])
		{
			int val=0;
			for(int j=1;j<=edg[i];j++)
			{
				val+=ksm(k,__gcd(j,edg[i]));
				if(val>=mdn)	val-=mdn;
			}
			ans=1ll*ans*ksm(edg[i],mdn-2)%mdn*val%mdn;
		}
		else	ans=1ll*ans*C(edg[i]+k-1,k-1)%mdn;
	}
	else	ans=1ll*ans*k%mdn;
	printf("%d\n",ans);
}
int main()
{
	n=read(),m=read(),k=read();
	for(int i=1;i<=m;i++)	add(u[i]=read(),v[i]=read());
	solve();
	return 0;
}


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

int main(){
	string s;
	cin >> s;
	
	int same = 1;
	int index;
	
	for(int i = 1; i < 4; i++){
		if( s.at(0) == s.at(i) ){
			same ++;
			index = i;
		}
	}
	
	if( same == 2){
		if( index == 1 && s.at(2) == s.at(3) ) cout << "Yes" << endl;
		else if( index == 2 && s.at(1) == s.at(3) ) cout << "Yes" << endl;
		else if( index == 3 && s.at(1) == s.at(2) ) cout << "Yes" << endl;
		else cout << "No" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <utility>
#include <vector>
#include <queue>

using namespace std;

int main(int argc, const char *argv[])
{
  int n, m;
  cin >> n >> m;
  
  using Job = pair<int, int>;
  using JobQueue = priority_queue<Job, vector<Job>, greater<Job>>;
  JobQueue jobs;
  for (int i = 0; i < n; i++) {
    Job job;
    cin >> job.first >> job.second;
    jobs.push(job);
  }
  
  long long ans = 0;
  priority_queue<int> q2;
  for (int i = 1; i <= m; i++) {
    while (!jobs.empty() && jobs.top().first <= i) {
      q2.push(jobs.top().second);
      jobs.pop();
    }

    if (!q2.empty()) {
      ans += q2.top();
      q2.pop();
    }
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll n,m;
  cin >> n >> m;
  vector<P>vec(m+1);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    vec[i]=P(b,a);
  }
  vec[m]=P(INF,INF);
  sort(vec.begin(),vec.end());
  ll cnt=0;
  ll now=0;
  rep(i,m){
    if(now<=vec[i].second){
      cnt++;
      now=vec[i].first;
    }
  }
  cout << min(cnt,n-1) << endl;
        
  return 0;     
}


Measured memory_bytes: 1920
//g++  7.4.0
 
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <map>
 
using namespace std;
int main()
{
    int h,w;
    cin >> h >> w;
    
    std::vector<std::pair<int, int>> roads;
    char c[h+1][w+1];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> c[i+1][j+1];
            if(c[i+1][j+1] == '.'){ // 道の座標を記録
                roads.push_back(std::make_pair(i+1, j+1));
            }
        }
    }
    
    int ans = 0;
    std::vector<std::pair<int, int>>::iterator itr = roads.begin();
    while(itr != roads.end()){
       
    int sx = itr->first;
    int sy = itr->second;
    //cout << "start: " << sx << ", " << sy << endl;
    std::queue<std::pair<int, int>> q;
    q.push(std::make_pair(sx, sy));
    
    std::vector<std::vector<int>> d; // スタート地点からの距離
    d = std::vector<std::vector<int>>(h+1, std::vector<int>(w+1, -1));
    d[sx][sy] = 0;
    
    while(!q.empty()){
        std::pair<int, int> p = q.front();
        q.pop();
        
        //cout << "-----" << endl << "now  : " << p.first << ", " << p.second << endl;
        //if(p.first == gx && p.second == gy) break;
        
        for(int i=-1; i<=1; i++){
            for(int j=-1; j<=1; j++){
                if(std::abs(i+j)%2 == 0) continue; // 斜め移動
                int dx = p.first+i;
                int dy = p.second+j;
                //cout << "check: " << dx << ", " << dy << endl;
                //if(c[dx][dy] == '.' && d[dx][dy] == -1){
                if(1 <= dx && dx <= h && 1 <= dy && dy <= w && c[dx][dy] == '.' && d[dx][dy] == -1){
                    //cout << "push !" << endl;
                    q.push(std::make_pair(dx, dy));
                    d[dx][dy] = d[p.first][p.second] + 1;
                    if(ans < d[dx][dy]) ans = d[dx][dy];
                    //cout << dx << ", " << dy << " " << d[dx][dy] << endl;
                }
            }
        }
    }
    
    ++itr;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
#define mod 1000000007
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;

    int i;
    vector <bool> broken(n + 1, false);
    vector <int> dp(n + 1, 0);
    dp[0] = 1;

    int step;
    for(i = 0; i < m; i ++)
    {
    	cin >> step;
    	broken[step] = true;
    } 

    for(i = 1; i <= n; i ++)
    {
    	if(i == 1 && broken[i] == false)
    	{	
    		dp[i] = 1;
    	}
    	else if(broken[i] == false)
    		dp[i] += (dp[i - 1] % mod + dp[i - 2] % mod) % mod;
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int ac=0,wa=0,tle=0,re=0;
	while(n--)
	{
		string s;
		cin>>s;
		if(s=="AC")
		 ac++;
		else if(s=="WA")
		 wa++;
		else if(s=="RE")
		 re++;
		else
		 tle++;
	}
	cout<<"AC x "<<ac<<"\n";
	cout<<"WA x "<<wa<<"\n";
	cout<<"TLE x "<<tle<<"\n";
	cout<<"RE x "<<re<<"\n";
	return 0;	
}

Measured memory_bytes: 3616
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int N = cin.ReadInt;
            int[] X = cin.ReadIntArray(N);
            int minSum = int.MaxValue;
            for(int i = 0; i < 100; i++)
            {
                int sum = 0;
                for(int j = 0; j < N; j++)
                {
                    sum += (int)Pow(X[j]-(i+1), 2);
                }
                if (minSum > sum)
                {
                    minSum = sum;
                }
            }
            Console.WriteLine(minSum);
            
            
        }


    }
            


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

int vec[50];

int main() {
	int n;
	scanf("%d", &n);

	int miv = 1e9, mivi, mav = -1e9, mavi;
	for (int i = 0; i < n; i++) {
		scanf("%d", &vec[i]);
		if (miv > vec[i]) {
			miv = vec[i];
			mivi = i;
		}
		if (mav < vec[i]) {
			mav = vec[i];
			mavi = i;
		}
	}

	printf("%d\n", n + n - 1);
	if (abs(miv) > abs(mav)) {
		for (int i = 0; i < n; i++) {
			vec[i] += miv;
			printf("%d %d\n", mivi + 1, i + 1);
		}

		for (int i = n - 2; i >= 0; i--) {
			vec[i] += vec[i + 1];
			printf("%d %d\n", i + 2, i + 1);
		}
	}

	else {
		for (int i = 0; i < n; i++) {
			vec[i] += mav;
			printf("%d %d\n", mavi + 1, i + 1);
		}

		for (int i = 1; i < n; i++) {
			vec[i] += vec[i - 1];
			printf("%d %d\n", i, i + 1);
		}
	}
}

Measured memory_bytes: 256
function Main(input) {
  const numbers = input.split(' ').map(n => Number(n));
  const a = numbers[0];
  const b = numbers[1];
  const c = numbers[2];

  if (a === b) {
    console.log(c);
  } else if (b === c) {
    console.log(a);
  } else {
    console.log(b);
  }
}

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

Measured memory_bytes: 21064
import math

def isPrime(x):
    if x == 2:
        return True
    
    if x<2 or x%2==0:
        return False

    i = 3
    while i<=math.sqrt(x):
        if x%i==0:
            return False
        i += 2
    return True

n = int(input())
numlist = []
count = 0

for i in range(n):
    numlist.append(int(input()))

for elem in numlist:
    if isPrime(elem):
        count += 1

print(count)


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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()  
{ 
    FAST_INP;
    int h,w,n;
    cin >> n >> h >> w;
    cout << (n-h+1)*(n-w+1);
    return 0;
} 

Measured memory_bytes: 3660
#include<stdio.h>
int main(void)
{
	int n;
	int suu;
	int a,b,c;
	int i,j,k,temp;
	int dai[9],syo[9];
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&suu);
		for(j=0;j<8;j++){
			dai[j]=suu%10;
			syo[j]=suu%10;
			suu=suu/10;
		}
		for(j=0;j<7;j++){
			for(k=j+1;k<8;k++){
				if(dai[j]<dai[k]){
					temp=dai[j];
					dai[j]=dai[k];
					dai[k]=temp;
				}
				if(syo[j]>syo[k]){
					temp=syo[j];
					syo[j]=syo[k];
					syo[k]=temp;
				}
			}
		}
		c=10000000;
		a=b=0;
		for(j=0;j<8;j++){
			a+=dai[j]*c;
			b+=syo[j]*c;
			c=c/10;
		}
	//	printf("%08d\n",b);
	//	printf("%08d\n",a);
		printf("%d\n",a-b);
	}
	return 0;
}

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

#define ll long long
#define ar array

const int mxN=1e5,INF=999999999;
int  a[mxN], c[2*100*mxN+1];

/* 1. If you can't keep solution in mind, then visualize it on a paper.
 * 2. Try to identify the type of problem - DP, Greedy, Graph, Constructive, 
 * 	  Prefix/Suffix, Difference Array, BIT/Segment Tree, etc.
 * 3. Look at the problems from different perspectives - reverse the problem, 
 * 	  add instead of delete (maybe?)
 * 4. Divide difficult solutions into cases and/or sequences.
 * 5. Use math rules to solve Nested Summation.
 * 6. Optimisation problems are generally solved with DP, greedy, binary search or brute-force.
 * ------------------------------------------------------------------ 
 */

void solve() {
    float m,n,x;
	cin >> n>>m >>x;
	float tp=n/x;
	if(tp<=m)cout<<"Yes";
	else cout<<"No";
}

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

	int t=1;

	for(int i=1; i<=t; ++i) {
	//	cout << "Case #" << i << ": ";
		solve();
	}
}



Measured memory_bytes: 3732
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

bool isUsed(int N,vector<int>D) {
    while (N != 0) {
        auto itr = find(D.begin(), D.end(), N % 10);
        if (itr != D.end())return true;
        N /= 10;
    }
    return false;
}

int main() {

    int N, K;
    cin >> N >> K;
    vector<int>D(K);
    for (int i = 0; i < K; i++)cin >> D[i];

    for (int i = N;; i++) {
        if (!isUsed(i, D)) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

R = INT()
print(2*pi*R)


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

using namespace std;

int main(){
    long int a, b, c, k, ans=0;
    cin >> a >> b >> c >> k;
    if(a <= k){
        ans = a;
        if(k-a <= b){
            cout << ans;
        }
        else{
            if(k-a-b <= c){
                cout << ans-(k-a-b);
            }
            else{
                cout << ans-c;
            }
        }
    }
    else{
        cout << k;
    }
    return 0;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int[] A = new int[n];

            for (int i = 0; i < n; i++)
            {
                A[i] = int.Parse(Console.ReadLine());
            }

            Console.WriteLine(GetLIS(A));
        }

        static int GetLIS(int[] A)
        {
            const int INFTY = int.MaxValue;
            int n = A.Length;

            int[] L = Enumerable.Repeat(INFTY, n).ToArray();
            int[] id = new int[n];

            for (int i = 0; i < n; i++)
            {
                id[i] = LowerBound(L, A[i]);
                L[id[i]] = A[i];
            }

            return id.Max() + 1;
        }

        static int LowerBound(int[] arr, int value)
        {
            int low = 0;
            int high = arr.Length;
            int mid;

            while (low < high)
            {
                mid = ((high - low) >> 1) + low;        // (low + high) / 2
                if (arr[mid] < value) low = mid + 1;
                else high = mid;
            }
            return low;
        }
    }
}

Measured memory_bytes: 11716
N,A,B=map(int,input().split())
answer=0

def tasu(i):
  k=0
  s=0
  while 10**k<i:
    k+=1
  for a in range(k+1)[::-1]:
    s+=i//(10**a)
    i-=10**a*(i//(10**a))
  return(s)
    

for i in range(N):
  if A<=tasu(i+1)<=B:
    answer+=i+1
  
print(answer)

Measured memory_bytes: 3064
N, M = map(int, input().split())

AB = []
for _ in range(N):
    A, B = map(int, input().split())
    AB.append([A, B])

AB.sort()

gelt = 0
drink = 0
for i in range(len(AB)):
    if drink + AB[i][1] <= M:
        drink += AB[i][1]
        gelt += AB[i][0] * AB[i][1]
    else:
        gelt += (M - drink) * AB[i][0]
        break
        
print(gelt)

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum[600][600],pos,q,ma[ohara];
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n>>m>>q;

      map<ll,ll> kazu;
      rep(i,m){
        cin>>a>>b;
        if(ma[a]<=b)ma[a]=b;
        kazu[a]++;
        sum[a][b]++;
      }

      rep(i,n){
        rep(j,n){
          sum[i][j+2]+=sum[i][j+1];
        }
      }
      
      rep(i,q){
        cin>>a>>b;
        cnt=0;
        rrep(j,a,n+1){
          if(ma[j]<=b){ans+=kazu[j];}
          else{
           cnt=sum[j][n]-sum[j][b];
            ans+=kazu[j]-cnt;
          }
        }
        Cout(ans);
        ans=0;
      }
     

       
return 0;
}


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

using namespace std;

#define sz(v) (int)v.size()
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
typedef vector<long long> vi;
const long long inf = 1e17;
struct Node {
	Node *l = 0, *r = 0;
	long long lo, hi, mset = inf, madd = 0, val = -inf;
	Node(int lo,int hi):lo(lo),hi(hi){} // Large interval of -inf
	Node(vi& v, int lo, int hi) : lo(lo), hi(hi) {
		if (lo + 1 < hi) {
			int mid = lo + (hi - lo)/2;
			l = new Node(v, lo, mid); r = new Node(v, mid, hi);
			val = max(l->val, r->val);
		}
		else val = v[lo];
	}
	long long query(int L, int R) {
		if (R <= lo || hi <= L) return -inf;
		if (L <= lo && hi <= R) return val;
		push();
		return max(l->query(L, R), r->query(L, R));
	}
	void set(int L, int R, long long x) {
		if (R <= lo || hi <= L) return;
		if (L <= lo && hi <= R) mset = val = x, madd = 0;
		else {
			push(), l->set(L, R, x), r->set(L, R, x);
			val = max(l->val, r->val);
		}
	}
	void add(int L, int R, long long x) {
		if (R <= lo || hi <= L) return;
		if (L <= lo && hi <= R) {
			if (mset != inf) mset += x;
			else madd += x;
			val += x;
		}
		else {
			push(), l->add(L, R, x), r->add(L, R, x);
			val = max(l->val, r->val);
		}
	}
	void push() {
		if (!l) {
			int mid = lo + (hi - lo)/2;
			l = new Node(lo, mid); r = new Node(mid, hi);
		}
		if (mset != inf)
			l->set(lo,hi,mset), r->set(lo,hi,mset), mset = inf;
		else if (madd)
			l->add(lo,hi,madd), r->add(lo,hi,madd), madd = 0;
	}
};

int main() {
  // W is a tricky segtree (RMQ) problem
  // dp[i] = max value for prefix of 0 through i with ith
  // position on, and then the recurrence is:
  // and then dp[i] = max over all j<i of dp[j] + the total
  // reward of all intervals starting in [j+1, i] and ending in
  // [i, ...]

  cin.tie(0);
  cin.sync_with_stdio(0);
  int n, m; cin >> n >> m;
  priority_queue<pair<int, pair<long long, int> > > start, end;
  for(int i = 0; i<m; ++i) {
    int l, r; long long a;
    cin >> l >> r >> a;
    //l--; r--;
    start.push(make_pair(-l, make_pair(a, r)));
    end.push(make_pair(-r, make_pair(a, l)));
  }
  vector<long long> v(n+1, 0);
  Node rmq(v, 0, n+1);

  long long ret = 0;
  for(int i = 1; i<=n; ++i) {
    while(start.size() && start.top().first == -i) { // lots of dots
      // Entering an interval
      long long a = start.top().second.first;
      int l = -start.top().first;
      start.pop();
      rmq.add(0, l, a);
    }

    ret = max(ret, rmq.query(0, i));
    rmq.set(i, i+1, rmq.query(0, i));

    while(end.size() && end.top().first == -i) { // lots of dots
      // Exiting an interval
      long long a = end.top().second.first;
      int l = end.top().second.second;
      end.pop();
      rmq.add(0, l, -a);
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 38428
import java.util.Scanner;

public class Main {

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

		int n = Integer.parseInt(sc.next());
		
		int []a = new int [n];
		
		for(int i = 0; i < n ;i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		
		boolean flag = true;

		for(int i = 0 ; i < n ;i++) {
			if(a[i] % 2 == 0) {
				if(a[i] % 3 != 0 && a[i] % 5 != 0) {
					flag = false;
					break;
				}
			}
		}
		
		if(flag) {
			System.out.println("APPROVED");
		}
		else {
			System.out.println("DENIED");
		}
	}

}


Measured memory_bytes: 21972
//shara's here
//私は大きな男の子
//SPEEEEEEEEEED IS KEEEEEEEEEEY
#include <bits/stdc++.h>
using namespace std;
//fold
typedef double w;
typedef string s;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 + 10;
const ll MINF = -(1e18 + 10);
#if defined(BANYANYA)
#include "/home/xsharawi/Desktop/cpp/debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
//endfold
int main(){
	int x=0,n,nax=0;
	s ss;
	cin>>n>>ss;
	for(int i=0;i<n;i++){
		if(ss[i]=='I')x++;
		if(ss[i]=='D')x--;
		nax=max(nax,x);
		}
	cout<<nax<<endl;
return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define Z 1000000
void insertionsort(int *,int,int);
void shellsort(int *,int);
void swap(int *,int *);

int cnt=0;
int g[Z];
int main(){

  int A[Z],i,j,n;

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

  shellsort(A,n);
  printf("\n%d\n",cnt);
  for(i=0;i<n;i++){
    printf("%d\n",A[i]);
  }


  return 0;
}
void insertionsort(int a[],int n,int g){
  int i,v,j;
  
  for(i=g;i<n;i++){
    v=a[i];
    j=i-g;
    while(j>=0&&a[j]>v){
      a[j+g]=a[j];
      j=j-g;
      cnt++;

    }  
    a[j+g]=v;
  }
  
}


void shellsort(int a[],int n){
  int i,j,m=0,c=2;
  cnt=0;
  g[0]=1;    
  for(i=1;g[i-1]<=n;i++){
    g[i]=g[i-1]*3+1;
    m++;
  }
  printf("%d\n",m);
  for(j=0;j<m;j++){
    printf("%d",g[m-1-j]);
    if(j<m)printf(" ");
  }

  for(i=0;i<m;i++)
    insertionsort(a,n,g[m-i-1]);
}




Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
#define int long long
#define P pair<int,int>

signed main() {
   vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
   int k;
   cin >> k;

   cout << a[k-1] << endl;

}



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

int main(){
    int n,k;
    cin >>n>>k;
    int p[n],sum=0;
    rep(i,n) cin >>p[i];
    int ss=0;
    rep(i,k) ss+=p[i];
    int ans=ss;
    for(int i=1;i+k-1<n;i++){
        ss += p[i+k-1]-p[i-1];
        ans = max(ans,ss);
    }
    printf("%.7lf\n",(double)(ans+k)/2.0);
    //cout << (double)(ans+k)/2.0 <<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
long long gcd(long long a,long long b){
  if(a<b){
	long long w=a;
    a=b;
    b=w;
  }
  if(a%b!=0)return gcd(b,a%b);
  else return b;
}
long long lcm(long long a,long long b){
long long max=gcd(a,b);		//max:最大公約数
  //printf("最大公約数は%lld\n",max);
  //printf("最小公倍数は%lld\n",a*b/max);
  return a/max*b;			//最小公倍数
}
long long calc(long long b,long long c,long long d){
  long long ans=b-b/c-b/d+b/lcm(c,d);
  return ans;
}
  
int main(void){
  long long a,b,c,d;
  scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
  long long x=calc(a-1,c,d);
  long long y=calc(b,c,d);
  printf("%lld",y-x);
  return 0;
}

Measured memory_bytes: 128
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7


a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = I()
print(a[K -1 ])

Measured memory_bytes: 38584
#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    int data[n + 1];
    for (int i = 1; i <= n; ++i) cin >> data[i];
    int dp[n + 1], pref[n + 1];
    for (int i = 0; i <= n; ++i) {
        pref[i] = 0;
        dp[i] = 0;
    }
    dp[1] = 0;
    pref[1] = data[1];
    for (int i = 3; i <= n; i += 2) pref[i] = pref[i - 2] + data[i];
    for (int i = 2; i <= n; ++i) {
        if (i & 1) dp[i] = max(dp[i - 1], dp[i - 2] + data[i]);
        else dp[i] = max(data[i] + dp[i - 2], pref[i - 1]);
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 8344
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			if (a == 0 && b == 0)
				break;
			int sum = 0;
			for (int i = 1; i <= a - 2; i++) {
				if(i>b)
					break;
				for (int j = i + 1; j <= a - 1; j++) {
					if (i + j > b)
						break;
					for (int k = j + 1; k <= a; k++) {
						if (i + j + k > b)
							break;
						if (i + j + k == b)
							sum++;
					}
				}
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 19780
#include<iostream>
#include <functional>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int a,e=0;
  cin>>a;
  int b[a],c[a],d[a];
  for(int i=0;i<a;i++)
    cin>>b[i];
  for(int i=0;i<a;i++)
    cin>>c[i];
  for(int i=0;i<a;i++)
    d[i]=b[i]-c[i];
  sort(d,d+a,greater<int>());
  for(int i=0;i<a;i++){
    if(d[i]>0)
      e+=d[i];
  }
    cout<<e<<endl;
}

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

using ll = long long;

#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll X, ll N, std::set<ll> p) {
  ll d = LINF;
  ll idx = 0;

  for (ll i = -1; i <= 101; i++) {
    if (!p.count(i)) {
      if (abs(X - i) < d) {
        d = min(abs(X - i), d);
        idx = i;
      }
    }
  }

  cout << idx << endl;
}

int main() {
  ll X;
  scanf("%lld", &X);
  ll N;
  scanf("%lld", &N);
  std::set<ll> p;
  for (int i = 0; i < N; i++) {
    ll v;
    cin >> v;
    p.insert(v);
  }
  solve(X, N, p);
  return 0;
}


Measured memory_bytes: 3704
s = gets.chomp
s = s[0..s.size-3]
a = s[0..(s.size/2-1)]
b = s[(s.size/2)..(s.size-1)]

while a != b
    s = s[0..s.size-3]
    a = s[0..(s.size/2-1)]
    b = s[(s.size/2)..(s.size-1)]
end

puts s.size

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
using namespace std;
typedef struct edge{
  int to, cost;
}edge;

int main(){
  int n, m, s, a, b, from, to, cost;
  while(cin >> n >> m >> s >> a >> b, n){
    s--, a--, b--;
    vector<vector<edge> > g(n);
    for(int i = 0; i < m; i++){
      cin >> from >> to >> cost;
      from--, to--;
      g[from].push_back(edge{to, cost});
    }
    vector<vector<int> > dp(n, vector<int>(n, 1e8));
    dp[s][s] = 0;
    for (int i = 0; i < g[s].size(); i++) dp[s][g[s][i].to] = dp[g[s][i].to][s] = g[s][i].cost;
    
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        for (int k = 0; k < n; k++) {
          for (int l = 0; l < g[j].size(); l++) {
            if(k == g[j][l].to)dp[k][g[j][l].to] = dp[g[j][l].to][k] = min(dp[k][g[j][l].to], dp[j][k]);
            else dp[k][g[j][l].to] = dp[g[j][l].to][k] = min(dp[k][g[j][l].to], dp[j][k] + g[j][l].cost);
          }
          for (int l = 0; l < g[k].size(); l++) {
            if(j == g[k][l].to)dp[j][g[k][l].to] = dp[g[k][l].to][j] = min(dp[j][g[k][l].to], dp[j][k]);
            else dp[j][g[k][l].to] = dp[g[k][l].to][j] = min(dp[j][g[k][l].to], dp[j][k] + g[k][l].cost);
          }
        }
      }
    }
    // for (int i = 0; i < n; i++) {
    //   for (int j = 0; j < n; j++) {
    //     std::cout << dp[i][j] << " ";
    //   }
    //   std::cout << std::endl;
    // }
    std::cout << dp[a][b] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL //デバッグ出力系
#define dout(s) cout<<s<<"\n";
#define debug() if(true)
#else
#define dout(s)
#define debug() if(false)
#endif//
#define next asdnext
#define prev asdprev
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define vout(v) for(auto &i:v){cout<<i<<" ";}cout<<"\n"; //配列出力
#define vin(v) for(auto &i:v)cin>>i; //配列入力
#define vec(v,n) vector<int> v(n);
typedef long long ll;
typedef unsigned long long ull;

void Main() {
	int N;
	cin >> N;
	bool YY=false, MM=false;
	if (N<1300 && N>=100) {
		MM = true;
	}
	if ((N%100)<=12 && (N % 10)!=0) {
		YY = true;
	}
	if (MM) {
		if (YY) {
			cout << "AMBIGUOUS\n";
		}
		else {
			cout << "MMYY\n";
		}
	}
	else {

		if (YY) {
			cout << "YYMM\n";
		}
		else {
			cout << "NA\n";
		}
	}
	return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


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

int main(void) {
    int n, k, ans = 0;
    vector<int> l;
    cin >> n >> k;
    l.resize(n);
    for (int i = 0; i < n; i++) cin >> l[i];
    sort(l.begin(), l.end(), greater<int>());
    for (int i = 0; i < k; i++) ans += l[i];
    cout << ans << endl;
}


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

bool compare(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.second != b.second) return a.second > b.second;
  return a.first < b.first;
}

int main() {
  int n;
  scanf("%d", &n);

  map<int, int> om;
  map<int, int> em;
  for (int i = 0; i < n / 2; i++) {
    int o, e;
    scanf("%d%d", &o, &e);
    om[o]++;
    em[e]++;
  }

  if (om.size() == 1 && em.size() == 1) {
    int key1, key2;
    for (auto e : om) key1 = e.first;
    for (auto e : em) key2 = e.first;
    if (key1 == key2) {
      printf("%d", n / 2);
    } else {
      printf("0");
    }
    return 0;
  }

  vector<pair<int, int>> ov;
  for (auto e : om) ov.push_back(make_pair(e.first, e.second));
  vector<pair<int, int>> ev;
  for (auto e : em) ev.push_back(make_pair(e.first, e.second));
  sort(ov.begin(), ov.end(), compare);
  sort(ev.begin(), ev.end(), compare);

  int ans = 0;
  int O1_key = ov.at(0).first;
  int O1 = ov.at(0).second;
  int E1_key = ev.at(0).first;
  int E1 = ev.at(0).second;
  ans = n - O1 - E1;
  if (O1_key == E1_key) {
    int O2 = ov.at(1).second;
    int E2 = ev.at(1).second;
    ans = min((n - O1 - E2), (n - O2 - E1));
  }

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


Measured memory_bytes: 6136
str = gets().split(" ")
a = str[0].to_i
b = str[1].to_i

if(a%3==0)
	puts("Possible\n")
elsif(b%3==0)
	puts("Possible\n")
elsif((a+b)%3==0)
	puts("Possible\n")
else
	puts("Impossible\n")
end


Measured memory_bytes: 1788
L,R=map(int, input().split())
LR = range(L,R+1)
from itertools import permutations, combinations,combinations_with_replacement,product
if (R+1-L)<2019:
  C = combinations(LR, 2)
  Ret = 2019
  for i in list(C):
    Ret = min(Ret,(i[0]*i[1])%2019)
else:
  Ret = 0
print(Ret)

Measured memory_bytes: 148260
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i<n;i++)
using ll = long long;
using P = pair<ll,ll>;
 
int main(){
  ll n;cin>>n;
  ll sum = 0,i = 0;
  sum+= n/11;
  sum*=2;
  if (n%11 <=6 && n%11 != 0){
    sum++;
  }
  else if (n%11 >= 7){
    sum+=2;
  }
  cout << sum << endl;
}

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



int main(){

int n;
cin >> n;

vector<int>a;
vector<int>b(n-1);
rep(i,n-1){
    cin >> b[i];
} 
int ans = 0;
rep(i,n){
    if(i==0){
        ans += b[0];
        continue;
    }
    if(i==n-1){
        ans += b[i-1];
        continue;
    }
    ans += min(b[i],b[i-1]);

}
cout << ans << endl;
}

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

int main() {
    long long n,k;
    cin >> n >> k;
    vector<long long> data(n);
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
    }
    for (int i = 0; i < n-k; i++){
            if(data.at(i) < data.at(i+k))
            cout << "Yes" << endl;
            else cout << "No" << endl;
    }
}

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

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

    int ans = 0;
    for(int i = 1; i <= N; i += 2){
        int cnt = 0;
        for(int j = 1; j <= i; j++){
            if(i % j == 0) cnt++;
            if(cnt == 8) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, t = map(int, input().split())
s = list(map(int, input().split()))
ans = 0
for i in range(n-1):
	if (s[i+1] - s[i]) > t:
		ans += t
	else:
		ans += s[i+1] - s[i]
ans += t
print (ans)


Measured memory_bytes: 25196
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=200005, INF=2000000000000000000;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n,k;
    cin>>n>>k;
    int ar[n+1];
    fill(ar, 0);
    for(int i=0;i<k;i++)
    {
        int m;
        cin>>m;
        while(m--)
        {
            int a;
            cin>>a;
            ar[a]=1;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(ar[i]==0)
        ans++;
    }
    cout<<ans;
}

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

using namespace std;

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

int main(){
  int64_t a;
  long double b;/*
  double b_int;
  double b_fra;
*/
  cin >> a;
  cin >> b;

//  b_fra = modf(b, &b_int);

  int64_t inb = b * 100 + 0.5;

  int64_t Ans = ((a*inb)/100);

  cout << Ans << endl;
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N;
  cin>>N;
  string S,T;
  cin>>S>>T;
  for(ll i=0;i<N;i++) {
cout<<S[i]<<T[i];
  }
  cout<<endl;
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main(){
	int N, X, L[100], sum = 0;
	cin >> N >> X;
	for (int i = 0; i < N; i++){
		cin >> L[i];
		sum += L[i];
		if (sum > X){
			cout << i + 1 << endl;
			return 0;
		}
	}

	cout << N + 1 << endl;
	return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
INF = float("inf")


# https://tjkendev.github.io/procon-library/python/string/rolling_hash.html

base = 37
mod = 10**9 + 9
pw = None


def rolling_hash(s):
    l = len(s)
    h = [0]*(l + 1)
    v = 0
    for i in range(l):
        h[i+1] = v = (v * base + s[i]) % mod
    return h


def setup_pw(l):
    global pw
    pw = [1]*(l + 1)
    v = 1
    for i in range(l):
        pw[i+1] = v = v * base % mod


def get(h, l, r):
    return (h[r] - h[l] * pw[r-l]) % mod


def solve(N: int, a: "List[int]", b: "List[int]"):

    c = [a[i] ^ a[(i+1) % N]for i in range(N)]
    d = [b[i] ^ b[(i+1) % N]for i in range(N)]*2
    i = -1
    a1 = [0]*N
    a2 = [0]*N
    b1 = [0]*(2*N)
    k_cand = [True]*N
    setup_pw(2*N)
    # 周期性を考慮すべきだが、二週分をとっていないのは何で対応しているのか
    # 一致パターンと、真逆パターンがあるはずだが、どこで見ているのか
    for keta in range(30):
        mask = 1 << keta
        for i, aa in enumerate(a):
            a1[i] = (aa & mask) >> keta
            a2[i] = (~aa & mask) >> keta
        for i, bb in enumerate(b):
            b1[i] = (bb & mask) >> keta
            b1[i+N] = (bb & mask) >> keta
        P = rolling_hash(a1)
        Q = rolling_hash(a2)
        R = rolling_hash(b1)
        for i in range(N):
            if k_cand[i]:
                if not ((get(P, 0, N) == get(R, i, i+N)) or
                        (get(Q, 0, N) == get(R, i, i+N))):
                    k_cand[i] = False
        # k_cand1 = zfindall(b1, a1, separator=[-1])
        # k_cand2 = zfindall(b1, a2, separator=[-1])
        # for i in range(N):
        #     k_cand[i] = k_cand[i] & ((i in k_cand1) or (i in k_cand2))

    ans = []
    if len(k_cand) == 0:
        return
    if k_cand[0] == True:
        print(0, b[0] ^ a[0])
        for i, k in enumerate(k_cand[:0:-1], start=1):
            if k:
                print(i, b[0] ^ a[i])
    else:
        for i, k in enumerate(k_cand[::-1], start=1):
            if k:
                print(i, b[0] ^ a[i])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N - 1 - 0 + 1)]  # type: "List[int]"
    b = [int(next(tokens)) for _ in range(N - 1 - 0 + 1)]  # type: "List[int]"
    solve(N, a, b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 145964
N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

L = [[] for _ in range(N)]

for a, b in AB:
  a -= 1
  b -= 1
  L[a].append(b)
  L[b].append(a)

D = [False] * N
D[0] = True
t = 0
Ans = [1]
while True:
  for x in L[t]:
    if not D[x]:
      t = x
      D[x] = True
      Ans.append(x + 1)
      break
  else:
    break

t = 0
Ans = Ans[::-1]

while True:
  for x in L[t]:
    if not D[x]:
      t = x
      D[x] = True
      Ans.append(x + 1)
      break
  else:
    break

print(len(Ans))
print(" ".join(list(map(str, Ans))))



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

int main() 
{
	int n,x,cb,ans=1,b=0;
	cin>>n>>x;
	while(true)
	{
		cin>>cb;
		b+=cb;
		if(b<=x)
			ans++;
		else
			break;
		if(ans==n+1)
			break;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<queue>
#include<cstring> 
#include<algorithm>
using namespace std;


int main()
{ 	long long  n,m,s;
	cin>>n>>m;
	priority_queue<int,vector<int>,less<int> > q;
	for(int i=0;i<n;i++){
	cin>>s;
	q.push(s);}

	while(m--){
	int t=q.top();
	q.pop();
	t=t/2;
	
	q.push(t);
    }
    long long sum=0;
    for(int i=0;i<n;i++){
	sum+=q.top();
	q.pop();
	}
    cout<<sum<<endl;
	
}

Measured memory_bytes: 892
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int n, p; cin>>n>>p;
    long long o = 0, e = 0;
    for(int i = 0; i < n; ++i){
        int a; cin>>a;
        if(a%2)++o;
        else ++e;
    }
    long long x = pow(2, e+o-1);
    if(p%2 && o==0)cout<<0<<endl;
    else if(!p%2 && o==0)cout<<x*2<<endl;
    else cout<<x<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int W, a, b;
  cin >> W >> a >> b;
  
  int answer = 0;

  if (a + W < b) {
    answer = b - (a + W);
  } else if (b + W < a) {
    answer = a - (b + W);
  }

  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    V<ll> imos(1e5 + 10, 0);
    ll N, M;
    cin >> N >> M;
    for(ll i = 0; i < M; i++) {
        ll L, R;
        cin >> L >> R;
        imos[L]++;
        imos[R + 1]--;
    }
    for(ll i = 0; i < imos.size() - 1; i++) imos[i + 1] += imos[i];
    ll ans = 0;
    for(ll i = 1; i <= N; i++) ans += (imos[i] == M);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024