akhauriyash/Code-Regression huggingface dataset:
n,m = map(int,input().split())
l = [tuple(map(int,input().split())) for _ in range(m)]
d = [list() for _ in range(n)]
dic = [dict() for _ in range(n)]
for x in l:
  d[x[0]-1].append(x[1])
for r in range(n):
  d[r].sort()
  dic[r] = dict(zip(d[r],range(1,len(d[r])+1)))
for x in l:
  p = x[0]
  y = dic[x[0]-1][x[1]]
  print("{:06}{:06}".format(p,y))

Measured memory_bytes: 67104
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
  int X,Y,Z,K;
  cin>>X>>Y>>Z>>K;
  vector<ll> A(X,0),B(Y,0),C(Z,0);
  for(int i = 0; i < X; i++) cin>>A[i];
  for(int i = 0; i < Y; i++) cin>>B[i];
  for(int i = 0; i < Z; i++) cin>>C[i];
  vector<ll> D;
  for(int i = 0; i < X; i++) {
    for(int j = 0; j < Y; j++) {
      D.push_back(A[i] + B[j]);
    }
  }
  sort(D.begin(), D.end(), greater<ll>() );
  vector<ll> E;
  ll K1;
  K1 = min(K,X*Y);
  for(int i = 0; i < Z; i++) {
    for (int j = 0; j < K1; j++) {
      E.push_back(C[i] + D[j]);
    }
  }
  sort(E.begin(), E.end(), greater<long long>() );
  for(int i = 0; i < K; i++) cout<<E[i]<<endl;
  return 0;
}

Measured memory_bytes: 43240
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt(), temp = t, counter = 0;
        for (int count = 0; count < t; count++) {
            int x = scan.nextInt();
            if(x <= temp) {
                temp = x; counter++;
            }
        }
        System.out.println(counter);
        scan.close();
    }
}

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

#define ll long long

bool isPrime(ll x) {
    for (ll i = 2; i * i <= x; ++i) {
        if (x % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
	ll a, b;
    scanf("%lld %lld", &a, &b);
    const int N = 1000100;
    vector<ll> div(N);
    int ind = 0;
    for (ll i = 1; i * i <= a; ++i) {
        if (a % i == 0) {
            if (i * i != a) {
                if (isPrime(a / i)) {
                    div[ind++] = a/i;
                }
            }
            if (isPrime(i)) {
                div[ind++] = i;
            }
        }
    }
    unordered_map<ll,int> cnt;
    for (int i = 0; i < ind; ++i) {
        cnt[div[i]]++;
    }
    ind = 0;
    for (ll i = 1; i * i <= b; ++i) {
        if (b % i == 0) {
            if (i * i != b) {
                if (isPrime(b / i)) {
                    div[ind++] = b / i;
                }
            }
            if (isPrime(i)) {
                div[ind++] = i;
            }
        }
    }
    for (int i = 0; i < ind; ++i) {
        cnt[div[i]]++;
    }
    int ans = 0;
    for (auto el : cnt) {
        ans += el.second == 2;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 8064
e=Hash.new []
n=gets.to_i
i=0
a=$<.map{|s|s.split.map{|v|e[v.to_i]+=[i]}
!i+=1}
(1..n).map{|w|i=0
u={}
e[w].reject{|j|u[x=a[j]]=x}.map{|j|0while u[a[j]=i+=1]}}
p a.max,*a

Measured memory_bytes: 180344
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;

int main() {
  int N;
  cin >> N;
  int c_o = 0;
  for (int i = 0; i < N; ++i) {
    ll ai;
    cin >> ai;
    if (ai % 2 != 0) {
      ++c_o;
    }
  }
  if (c_o % 2 == 1) {
  	cout << "NO" << endl;  
  } else {
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
  let stdin = 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")
}

fn main() {
  let mut tran = vec![];
  let n = read::<i64>();
  for _ in 0..5 {
    let a = read::<i64>();
    tran.push(a);
  }

  let min_v = tran.iter().min().unwrap();

  let mut dev = n / min_v;
  dev += if n % min_v > 0 { 1 } else { 0 };

  println!("{:?}", dev + 4);
}



Measured memory_bytes: 4352
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                    \
    sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
    {
sim > struct rge
{
    c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
    ~debug()
    {
        cerr << endl;
    }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c &)
    {
        ris;
    }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 10;
bool fun(ll mid, ll k, ll arr[], ll x)
{
    for (int i = 0; i < x; i++)
    {
        k -= (arr[i] / mid);
        if (k <= 0)
            return true;
    }
    return false;
}
ll arr[26];
int main()
{
    fastio
    ll x;
    cin>>x;
    ll c1=0,c2=0;
    for (int i = 0; i < x; i++)
    {
        string h;
        cin>>h;
        arr[h[0]-'A']++;
      
    }
   vector<ll>v;
   for (ll i = 0; i < 26; i++)
   {
        if(arr[i]!=0 && ((char)(i+'A')=='M' || (char)(i+'A')=='A' ||(char)(i+'A')=='R' ||(char)(i+'A')=='C' ||(char)(i+'A')=='H'))
        v.push_back(arr[i]);
   }
   if(v.size()!=5)
   {
       for (int i = v.size(); i < 5; i++)
       {
           v.push_back(0);
       }
       
   }
   debug()<<imie(v);
   ll sum=0;
   for (int i = 0; i < 3; i++)
   {
       for (int j = i+1; j < 4; j++)
       {
           for (int k = j+1; k < 5; k++)
           {
               sum+=(v[i]*v[j]*v[k]);
           }
           
       }
       
   }
   cout<<sum<<endl; 
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, s, n) for (signed i = (s); i < signed(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(c) (c).begin(), (c).end()


const int INF = 1 << 29;


using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

int dr[] = { -1, 0, 1, 0 };
int dc[] = { 0, -1, 0, 1 };
const int MOD = 1000000007;

signed main() {
	auto tax = [](int p, int x) { return p * (100 + x) / 100; };
	int x, y, s; 
	while (cin >> x >> y >> s && x) {
		int ans = 0;
		REP(i, 1, s) REP(j, i, s) {
			if (tax(i, x) + tax(j, x) != s) continue;
			ans = max(ans, tax(i, y) + tax(j, y));
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3032
A, B = map(int, input().split())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


A = set(make_divisors(A))
B = set(make_divisors(B))
C = A & B

cnt = 0
for i in C:
    if len(make_divisors(i)) == 1 or len(make_divisors(i)) == 2:
        cnt += 1
print(cnt)

Measured memory_bytes: 43484
from fractions import gcd

def factrize(n):
    b = []
    while n % 2 == 0:
        b.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            b.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        b.append(n)
    return b

a, b = map(int, input().split())
d = gcd(a, b)
p = factrize(d)
p_unique = set(p)
print(len(p_unique) + 1)


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

void printArray(int S[], int n){
    for(int i=0; i<n; i++){
        printf("%d ",S[i]);
    }
    printf("\n");
}

void bubbleSort(int S[], int n){
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            if(S[i] < S[j]){
                int buffer = S[i];
                S[i] = S[j];
                S[j] = buffer;
            }
        }
    }
}

int linearSearch(int S[], int T[], int n, int q){
    int counter=0;
    bubbleSort(S,n);
    for(int i=0; i<n; i++){
        if(i!=n-1 && S[i]==S[i+1]) continue;
        for(int j=0; j<q; j++){
            if(S[i] == T[j]){
                counter++;
                break;
            }
        }
    }
    return counter;
}

int main(){
    // Input n
    int n;
    scanf("%d",&n);
    // Input S
    int S[n];
    for(int i=0; i<n; i++){
        scanf("%d",&S[i]);
    }
    // Inpupt q
    int q;
    scanf("%d",&q);
    // Input T
    int T[q];
    for(int i=0; i<q; i++){
        scanf("%d",&T[i]);
    }
    // Execution
    printf("%d\n",linearSearch(S,T,n,q));
    return 0;    
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll zero = 0;
ll INF = 10000000000;

int main(){
    int A,B,C,D;
    cin >> A>>B>>C>>D;
    if((A-1)/D >= (C-1)/B){
        printf("Yes");
    }
    else{
        printf("No");
    }
    //printf("%d\n", );
    
}

Measured memory_bytes: 3660
n,m = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(n)]
ans = [0] * n
for i in range(m):
    b = int(input())
    for j in range(n):
        ans[j] += A[j][i] * b
for i in ans:
    print(i)


Measured memory_bytes: 6012
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int a;
	cin >> a;
	if (a >= 30)
	{
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

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

ll N;
vector<P> AB;

void input() {
    cin >> N;
    AB.resize(N);
    for (auto& v : AB) {
        cin >> v.first >> v.second;
    }
}

ll solve() {
    struct ABRef {
        ll p, t;
        ll v() {
            return t == 0 ? AB[p].first : AB[p].second;
        }
    };
    ll sumA = 0, sumB = 0;
    for (auto& v : AB) {
        sumA += v.first;
        sumB += v.second;
    }
    
    vector<ABRef> abrs(N * 2);
    for (ll i = 0; i < N; i++) for (ll j = 0; j < 2; j++) {
        abrs[i * 2 + j] = ABRef{i, j};
    }
    sort(abrs.begin(), abrs.end(), [](ABRef l, ABRef r) {
       return l.v() < r.v();
    });
    
    ll cw[N * 2];
    cw[0] = abrs[0].v();
    for (int i = 1; i < N * 2; i++)
        cw[i] = cw[i - 1] + abrs[i].v();
    
    vector<bool> used(N, false);
    bool useFrontNth = false;
    for (int i = 0; i < N; i++) {
        if (used[abrs[i].p]){
            useFrontNth = true;
            break;
        }
        used[abrs[i].p] = true;
    }
    
    ll sumN = 0;
    if (useFrontNth) {
        sumN = cw[N - 1];
    } else {
        for (int unuse = 0; unuse < N; unuse++) {
            ll sum = cw[N - 1] - abrs[unuse].v();
            ll unuseI = abrs[unuse].p;
            if (abrs[N].p != unuseI)
                sum += abrs[N].v();
            else
                sum += abrs[N + 1].v();
            sumN = unuse == 0 ? sum : min(sumN, sum);
        }
    }
    return min(min(sumA, sumB), sumN);
}

int main() {
    input();
    
    cout << solve() << endl;
    
    
    return 0;
}



Measured memory_bytes: 6528
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());//long.Parseはstringをlongに変換。
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
		long answer = 0;

    for(long i = 0; i < n; i++)
    {
      if(nums[i] == i+1)
      {
        answer++;
        i++;
      }
    }

		Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}

Measured memory_bytes: 17248
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		int n,k;
		string s;
		cin >> n >> s >> k;
		string ans;
		for (int i=0 ; i<n ; i++)
		{
			if(s[i]!=s[k-1])
			//ans[i]=s[i];
			//else
			s[i]='*';
		//	cerr << imie(ans[i]);
		}
		cout << s << endl;
		//for (auto c:ans)
		//cout << c;
		//cout << endl;
		return 0;  
}  


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

int main(){
    long long x;
    cin >> x;

    long long r = x /100;
    long long amari = x % 100;

    if(amari <= 5*r){
        printf("1\n");
    }
    else{
        printf("0\n");
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		long[] abc = new long[3];
		for (int i = 0; i < abc.length; i++) {
			abc[i] = sc.nextLong();
			if (abc[i] % 2 == 0) {
				System.out.println(0);
				return;
			}
		}

		System.out.println(Math.min(Math.min(abc[0] * abc[1], abc[0] * abc[2]), abc[1] * abc[2]));

		sc.close();
	}
}


Measured memory_bytes: 9428
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=3e3+10;
const ll MOD=1e9+7;

ll factm[200010];
void fact_init(){
  int k=2e5+5;
  factm[0]=1;
  rep1(i,k)factm[i]=(factm[i-1]*(ll)i)%MOD;
}
template<typename T>
T extgcd(T a,T b,T& x, T& y){
	T d=a;
	if(b!=0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	}
	else{
		x = 1; y = 0;
	}
	return d;
}
template<typename T>
T mod_inv(T a,T m){
	T x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}
ll ifm[200010];
void ifm_init(){
    rep(i,200006){
        ifm[i]=mod_inv(factm[i],MOD);
    }
}
ll B(int r, int c){
  if(r<0 || c<0) return 0;
  ll tmp=(factm[r+c]*ifm[r])%MOD;
  tmp=(tmp*ifm[c])%MOD;
  return tmp;
}

int H,W,N;
vector<int> h,w;
vector<P> t;
void input(){
    cin>>H>>W>>N;
    H--;W--;
    t.pb(mp(0,0));
    rep(_,N){
        int r,c;
        cin>>r>>c;
        r--;c--;
        t.pb(mp(r,c));
    }
    t.pb(mp(H,W));
    sort(all(t));
    rep(i,N+2){
        h.pb(t[i].fi);
        w.pb(t[i].se);
    }
  	
	fact_init();
    ifm_init();
}

ll dp[MAX];
void solve(){
    rep1(i,N+1){
        dp[i]=B(h[i], w[i]);
        rep1(j,i-1){
            ll tmp=(dp[j]*B(h[i]-h[j], w[i]-w[j]))%MOD;
            dp[i]=(dp[i]-tmp+MOD)%MOD;
        }
    }
}

void output(){
    cout<<dp[N+1]<<endl;
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 3456
function Main(input) {
  input = input.split("\n");
  s = input[0].split(" ");
  var ans =""; 
  if (s=="Sunny"){
    ans = "Cloudy";
  }else if(s=="Cloudy"){
    ans = "Rainy";
  }else{
    ans = "Sunny";
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
using System;
        using System.Linq;
        using static System.Math;

        public class Program
        {
            public static void Main(string[] args)
            {
            int[] num = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int count = 0;

            while(num[0] > 0)
            {
                if (count == 0)
                {
                    num[0] -= num[1];
                    count++;
                }
                else
                {
                    num[0] -= num[1] - 1;
                    count++;
                }
            }

            Console.WriteLine(count);
            }
        }

Measured memory_bytes: 20064
#include<iostream>
#include<string>

using namespace std;

int main(){
    string s, _s, a = "yes";
    cin >> s;
    for(int i : s){
        if(_s.find(i) == string::npos){
            _s += i;
        }else{
            a = "no";
            break;
        }
    }
    cout << a << endl;
}

Measured memory_bytes: 3592
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

def get(i):
    #if i==-n: return 0
    if i <= 0: return 1
    else: return a[i]


n, = map(int,readline().split())

MOD = 10**9+7

a = [1,n,n*n]
for i in range(3,n+1):
    res = -get(i-n-2) + get(i-3) - get(i-2) + 2*get(i-1)
    a.append(res%MOD)

#print(a)
print(a[-1])













Measured memory_bytes: 138820
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007


#A
"""
def check(n):
    n = list(map(int,list(str(n))))
    s = 0
    for i in n:
        s += f[i]
    return s == 0
n,k = LI()
d = LI()
f = [0 for i in range(10)]
for i in d:
    f[i] = 1
while 1:
    if check(n):
        print(n)
        quit()
    n += 1
"""
#B
def f(x,y):
    return fact[x-1+h-y]*fact[y-1+w-x]*inv_fact[x-1]*inv_fact[y-1]*inv_fact[w-x]*inv_fact[h-y]%mod
h,w,a,b = LI()
fact = [1]*(h+w+1)
for i in range(h+w):
    fact[i+1] = fact[i]*(i+1)%mod
inv_fact = [0]*(h+w+1)
inv_fact[h+w] = pow(fact[-1],mod-2,mod)
for i in range(h+w)[::-1]:
    inv_fact[i] = inv_fact[i+1]*(i+1)%mod
ans = 0
for i in range(1,min(w-b,h-a)+1):
    ans += f(b+i,a+i)
    ans %= mod
print(ans)
#C

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 44524
#include<iostream>
#include<set>
using namespace std;
struct A{
	int is = 0;
	int num;
}pp[500000];
int main(){
	pp[1].is = 1;
	int n, i, y = 0;
	cin >> n;
	for(i = 1; i <= n; i++){
		cin >> pp[i].num;
	}
	int Count = 0, t = 1;
	while(pp[2].is!=1){
		pp[t].is = 1;
		t = pp[t].num;
		Count++;
		if(Count>200000){
			cout << -1 << endl;
			y = 1;
			break;
		}
	} 
	if(!y){
		cout << Count-1 << endl;
	}
	return 0;
} 

Measured memory_bytes: 4096
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var one = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var two = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(two[1] == 1 ? 1 : 0);

        }
    }
}


Measured memory_bytes: 13268
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vector<int> table(1000001);
  vector<bool> ok(1000001, true);
  for (int i = 0; i < n; ++i) {
    if (0 < table[a[i]]) {
      ok[a[i]] = false;
      continue;
    }
    for (int j = 1; a[i] * j <= 1000000; ++j) {
      table[a[i] * j]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (ok[a[i]]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8008
#include <stdio.h>

int main(void)
{
	int a, b, c, i, x = 0;
	
	scanf("%d%d%d", &a, &b, &c);
	for(i = a; i <= b; i++) {
		if((c % i) == 0) x++;
	}
	
	printf("%d\n", x);
	
	return 0;
}




Measured memory_bytes: 2096
n=int(input())
tou=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for _ in range(n):
    b,f,r,v=map(int, input().split())
    tou[b-1][f-1][r-1]+=v
  
for i in range(4):
    for j in range(3):
        print(' ', end='')
        print(*tou[i][j])
    if i!=3: print('#'*20)


Measured memory_bytes: 5628
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    String b = sc.next();

    char[] c = b.toCharArray();

    // for (int i = 0; i < 4; i++) {
    //   System.out.println(c[i]);
    // }

    long k = (c[0]-'0')*100+(c[2]-'0')*10+(c[3]-'0');

    long ans = a*k/100;

    System.out.println(ans);
  }

}


Measured memory_bytes: 35900
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<bitset>
#define LL long long
#define mod 1e9+7
#define INF 0x3f3f3f3f
using namespace std;

namespace FastIO {
	template<typename tp> inline void read(tp &x) {
		x=0; register char c=getchar(); register bool f=0;
		for(;c<'0'||c>'9';f|=(c=='-'),c = getchar());
		for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c = getchar());
		if(f) x=-x;
	}
	template<typename tp> inline void write(tp x) {
		if (x==0) return (void) (putchar('0'));
		if (x<0) putchar('-'),x=-x;
		int pr[20]; register int cnt=0;
		for (;x;x/=10) pr[++cnt]=x%10;
		while (cnt) putchar(pr[cnt--]+'0');
	}
	template<typename tp> inline void writeln(tp x) {
		write(x);
		putchar('\n');
	}
}
using namespace FastIO;
#define N 100010
int d[N],zheng[N],fu[N],n,k,n1=0,n2=0;
inline bool cmp(int a,int b){return a>b;}
int main(){
	read(n);read(k);
	for(int i=1;i<=n;++i) scanf("%d",&d[i]);
	sort(d+1,d+n+1);
	for(int i=1;i<=n;++i) if(d[i]<0) fu[++n1]=d[i];else zheng[++n2]=d[i];
	sort(fu+1,fu+n1+1,cmp);
	for(int i=1;i<=n1;++i) fu[i]=-fu[i];
	int ans=INF;
	for(int i=1;i<=n1&&i<=k;++i) if(k-i<=n2) ans=min(ans,fu[i]+zheng[k-i]+(i==k? 0:fu[i]));
	for(int i=1;i<=n2&&i<=k;++i) if(k-i<=n1) ans=min(ans,zheng[i]+fu[k-i]+(i==k? 0:zheng[i]));
	writeln(ans);
	return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

/*-----------Main-----------*/

func main() {
	n := readI()
	p := make(map[int][]int)

	for i := 1; i <= n; i++ {
		a := readI()
		if _, ok := p[a+i]; !ok {
			p[a+i] = make([]int, 2)
		}
		p[a+i][0]++

		if _, ok := p[i-a]; ok {
			p[i-a][1]++
		}
	}

	ans := 0
	for _, v := range p {
		ans += v[0] * v[1]
	}
	fmt.Println(ans)
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}


Measured memory_bytes: 23828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7,INF=1e17;
int main(){
    ll l,r,ans=INF;
    cin>>l>>r;
    if(r-l+1>=2019)cout<<0<<endl;
    else{   
        for(ll i=l;i<r;i++){
            for(ll j=l+1;j<=r;j++){
                ans=min(ans,(i*j)%2019);
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Monad
import Control.Monad.ST
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
data Suit = S | H | C | D deriving (Eq, Show, Read, Enum)

data Card = Card Suit Int

instance Enum Card where
    fromEnum (Card s i) = 13*fromEnum s + i
    toEnum n = let (s,i) = n `divMod` 13 in
        Card (toEnum s) i

instance Show Card where
    show (Card s i) = unwords [show s, show (i+1)]

fromStr :: String -> Card
fromStr s = let [c,n] = words s
                in
                    Card (read c) (read n -1)

mkList :: [Card] -> V.Vector Bool
mkList cs = runST $ do
    v <- VM.replicate 52 False
    forM_ cs $ \c -> VM.write v (fromEnum c) True
    V.unsafeFreeze v

cardsNotIn :: V.Vector Bool -> [Card]
cardsNotIn = map (toEnum . fst) . filter (not . snd) . zip [0..] . V.toList

main = do
    _ <- getLine
    getContents >>= mapM_ print . cardsNotIn . mkList . map fromStr . lines

Measured memory_bytes: 5016
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

fn main() {
    input! {
    n:i64,a:i64,b:i64,}
    println!("{}", max(0, (b * (n - 1) + a) - (a * (n - 1) + b) + 1));
}


Measured memory_bytes: 2096
import java.util.*;

public class Main{
//public class abc165_b{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		long x = scan.nextLong();
		int con = 0;
		long a = 100;

		while(true){
			con++;
			a += a/100;
			if(a >= x){
				System.out.println(con);
				break;
			}

		}
	}

}

Measured memory_bytes: 27068
#include<iostream>
#include<vector>
#include<map>
#include<stack>
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
vector<vector<int>> getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
using namespace std;

int main(){
	string s;
	cin >> s;
	int pa,pz;
	int len = s.length();
	bool flag = false; //初めてのAを未発見
	rep(i,len){
		if(s[i]=='A' && !flag){
			pa = i;
			flag = true;
		}
		if(s[i]=='Z') pz = i;
	}
	cout << pz-pa+1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  n %= 10;
  string o;
  if(n == 3) o = "bon";
  else if(n == 0 || n == 1 || n == 6 || n == 8) o = "pon";
  else o = "hon";
  cout << o << endl;
  return 0;
}

Measured memory_bytes: 3628
import numpy as np #numpyの練習がてら
n = int(input())
tmp = list(map(int,input().split()))

mod = 10**9 + 7
a = np.array(tmp,np.int64)

ans = 0
for i in range(60 + 1):
    b = (a >> i) & 1 #すべてのaについて2**n乗目のビットが1か否か
    iti = np.count_nonzero(b) #すべてのaのうち2**n乗目が1であるものの個数
    zero = n - iti #同様に0であるものの個数
    ans += (iti * zero) * pow(2,i,mod) % mod#片方1で片方0なら1なので1の個数×0の個数
ans %= mod
print(ans)


Measured memory_bytes: 68756
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if(s[0] == s.back())
		cout << "No";
	else
		cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void){
  int N,D;
  int i,ans=0;
  int X[200000],Y[200000];
  long x,y;
  scanf("%d%d",&N,&D);
  for(i=0;i<N;i++)
    scanf("%d%d",&X[i],&Y[i]);
  for(i=N;i<200000;i++){
    X[i]=0;
    Y[i]=0;
  }
  for(i=0;i<N;i++){
    x=X[i];
    y=Y[i];
    if(sqrt(x*x+y*y)<=D){
      ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
using ll = long long;

constexpr i64 INF = 1010000000000000017LL;

constexpr i64 MOD = 1000000007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

ll mod_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        return mod_pow(x * x % MOD, n / 2) % MOD;
    } else {
        return x * mod_pow(x, (n - 1)) % MOD;
    }
}

ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;

    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n /= 2;
    }
    return ret;
}

ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) {
        ret *= (i + 1);
        ret %= MOD;
    }
    return ret;
}

ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);

    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}

void solve() {
    ll x; cin >> x;
    ll fh = x/500;
    ll f = (x-fh*500)/5;
    cout << fh*1000 + f*5;
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
// @author: arch_

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

int main(void) {
    int h, w;
    vector<array<int, 2>> a;
    while (cin >> h >> w, h | w) {
        array<int, 2> i{h, w};
        a.emplace_back(i);
    }
    for (auto&& i : a) {
        for (int y = 0; y < i[0]; y++) {
            for (int x = 0; x < i[1]; x++)
                cout << "#";
            cout << "\n";
        }
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 3148
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
for i in range(M):
    xi = list(map(int, input().split()))
    c.append(a[xi[0]-1]+b[xi[1]-1]-xi[2])
print(min(min(a)+min(b), min(c)))

Measured memory_bytes: 18740
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

vector<int>d(1000000+10);
void era(){
    rep(i, d.size()){
        d[i] = i;
    }
    int n = d.size()-1;
    for(int i = 2; i*i<= n; i++){
        if(d[i] != i)   continue;
        for(int j = i*2; j <= n; j+=i){
            if(d[j] != j)   continue;
            d[j] = i;
        }
    }
}

int main(){
    int n;   cin>>n;
    ll ans = 0;
    era();
    for(int c = 1; c < n; c++){
        int m = n-c;
        int tmp = 1;
        int before = 0;
        vector<int>p;
        while(m > 1){
            if(d[m] != before){
                p.push_back(1);
                before = d[m];
            }else{
                p[p.size()-1]++;
            }
            m /= d[m];
        }
        rep(i, p.size()) tmp *= (p[i]+1);
        ans += tmp;
    }
    cout<<ans<<endl;
}


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


typedef long long ll;

using namespace std;

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

    vector<ll> arr(N+1,0);

    ll ans=3*100000+1;
    ll count=0;


    for(int i=1;i<=N;++i){

        if(s[i-1]=='E'){
            ++count;
        }
        arr[i]=count; 
    }
/*
    for(int i=0;i<=N;++i){
        cout<<arr[i]<<" ";
    }
    cout<<endl;
    */

    for(int i=1;i<=N;++i){
        ll cnt=0;
        cnt=i-1-arr[i-1];
        //cout<<"i:"<<i<<":"<<cnt<<endl;
        //cout<<"N-i "<<N-i<<endl;
        cnt+=(arr[N]-arr[i]);
        //cout<<cnt<<endl;
        ans=min(ans,cnt);
        
    }



    cout<<ans<<endl;

}


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

int main()
{
	int n;
	cin >> n;
	int A[n];

	int max,min;
	for(int i = 0; i < n; i++){
		cin >> A[i];
		if(i == 0){
			max = A[0];
			min = A[0];
		}else{
			if(max < A[i])
				max =A[i];
			if(min > A[i])
				min = A[i];
		}
	}

	cout << max-min << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>


int main() {
	int a,b,h, m;
	scanf("%d%d%d%d", &a, &b, &h, &m);
	double ans, x, y,pi=3.141592653;
	x = fabs(h*30.00-m*5.5);
	y = 1.0*a * a + 1.0*b * b - 2.0 * a * b * cos(x*pi/180);
	ans = sqrt(y);

	printf("%.11f", ans);

	return 0;
}

Measured memory_bytes: 2600
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int h,w;
	cin >> h >> w;
	vector<vector<char>> a(h+2,vector<char>(w+2));
	for (int i = 0; i < h+2; i++){
		for (int j = 0; j < w+2; j++){
			if (i == 0 || i == h + 1|| j == 0 || j == w+1){
				a[i][j] = '#';
			}
			else{
				char l;
				cin >> l;
				a[i][j] = l;
			}
		}
	}

	for (int i = 0; i < h+2; i++){
		for (int j = 0; j < w+2; j++){
			cout << a[i][j];
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,d,a,sz;
ll data[800005];
ll lazy[800005];
pair<int,int> mon[200005];
void build(int bk,int l,int r){
    if(l==r){
        if(l<=n)data[bk]=mon[l].second;
        return;
    }
    build(bk<<1,l,(l+r)>>1);
    build(bk<<1|1,((l+r)>>1)+1,r);
    data[bk]=data[bk<<1]+data[bk<<1|1];
}
void upd(int bk,int l,int r,int ql,int qr,ll val){
    if(qr<l||r<ql)return;
    if(ql<=l&&r<=qr){
        lazy[bk]+=val;
        data[bk]+=val*(r-l+1);
        return;
    }
    lazy[bk<<1]+=lazy[bk];
    data[bk<<1]+=lazy[bk]*((r-l+1)>>1);
    lazy[bk<<1|1]+=lazy[bk];
    data[bk<<1|1]+=lazy[bk]*((r-l+1)>>1);
    lazy[bk]=0;
    upd(bk<<1,l,(l+r)>>1,ql,qr,val);
    upd(bk<<1|1,((l+r)>>1)+1,r,ql,qr,val);
    data[bk]=data[bk<<1]+data[bk<<1|1];
}
ll qry(int bk,int l,int r,int ql,int qr){
    if(qr<l||r<ql)return 0;
    if(ql<=l&&r<=qr)return data[bk];
    lazy[bk<<1]+=lazy[bk];
    data[bk<<1]+=lazy[bk]*((r-l+1)>>1);
    lazy[bk<<1|1]+=lazy[bk];
    data[bk<<1|1]+=lazy[bk]*((r-l+1)>>1);
    lazy[bk]=0;
    return qry(bk<<1,l,(l+r)>>1,ql,qr)+qry(bk<<1|1,((l+r)>>1)+1,r,ql,qr);
}
ll ans;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n>>d>>a;
    sz=1;while(sz<n)sz<<=1;
    for(int i=1;i<=n;i++)cin>>mon[i].first>>mon[i].second;
    sort(mon+1,mon+1+n);
    build(1,1,sz);
    int l=1,r=1;
    while(l<=n){
        while(mon[r+1].first-mon[l].first<=d+d&&r<n)r++;
        ll lft=qry(1,1,sz,l,l);
        if(lft<=0){l++;continue;}
        ll tms=(lft+a-1)/a;ans+=tms;
        upd(1,1,sz,l,r,(-tms)*a);l++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 12544
#include <iostream>

using namespace std;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	int n;
	cin>>n;
	while(n){
		if(n%10==7){
			cout<<"Yes\n";
			return 0;
		}
		n/=10;
	}
	cout<<"No\n";
	
	return 0;
}

Measured memory_bytes: 3044
N,K=map(int,input().split())
A=[0 for i in range(N)]
for _ in range(K):
  d=int(input())
  B=map(int,input().split())
  for j in B:
    A[j-1]+=1

sum=0
for i in range(N):
  if A[i] == 0:
    sum+=1

print(sum)

Measured memory_bytes: 9188
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        (n, k): (usize, u128),
        aa: [usize; n]
    };

    let mut v = vec![0; n + 1];
    v[1] = 1;
    let mut bs = 0; // ループ開始
    let mut sa = 0; // ループの開始町
    let mut loopc = 0;
    let mut a = 1;
    for i in 1.. {
        a = aa[a - 1];
        if v[a] > 0 {
            bs = i;
            sa = a;
            loopc = i - v[a] + 1;
            break;
        }

        v[a] = i + 1;
    }

    let mut c = 0;

    if k > bs {
        c = (k - bs) % loopc;
        a = sa;
    } else {
        c = k;
        a = 1;
    }

    for _ in 0..c {
        a = aa[a - 1];
    }

    println!("{}", a);
}


Measured memory_bytes: 8068
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 2*(int)1e5 + 10;

int n, a[N], dp[N][5];
int till = 0;

bool bad = false;

int solve(int idx, int removed){
   if (removed < 0){
      return -inf;
   }
   if (idx >= n){
      if (bad and n%2 and removed == 2){
         return -inf;
      }
      return 0;
   }
   int &ans = dp[idx][removed];
   if (ans != -1){
      return ans;
   }
   ans = -inf;
   smax(ans, solve(idx+1, removed-1));
   smax(ans, a[idx] + solve(idx+2, removed));
   return ans;
}

int32_t main(){_
   
   cin>>n;

   for (int i = 0; i < n; ++i)
   {
      cin>>a[i];
   }
      
   int ans = -inf;

   memset(dp, -1, sizeof dp);
   smax(ans, solve(1, n%2));

   if (n%2){
      bad = true;
      memset(dp, -1, sizeof dp);
      smax(ans, solve(0, 2));
   }
   else{
      memset(dp, -1, sizeof dp);
      smax(ans, solve(0, 1));
   }
   
   cout<<ans;  

   return 0;
}

Measured memory_bytes: 17712
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = input[0];
            var M = input[1];
            var mod = 1000000007;

            var ans = new Ans[N + 1];
            for (int i = 1; i <= N; i++)
            {
                ans[i] = new Ans() { Count = 0, Available = true };
            }

            for (int i = 0; i < M; i++)
            {
                ans[int.Parse(Console.ReadLine())].Available = false;
            }

            if (ans[1].Available) ans[1].Count = 1;
            if (N >= 2 && ans[2].Available) ans[2].Count = ans[1].Count + 1;

            for (int i = 3; i <= N; i++)
            {
                if (ans[i].Available) ans[i].Count = (ans[i - 1].Count + ans[i - 2].Count) % mod;
            }

            Console.WriteLine(ans[N].Count);
        }

        class Ans
        {
            public long Count { get; set; }
            public bool Available { get; set; }
        }
    }
}


Measured memory_bytes: 21212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int A,B,C;
  cin >> A >> B >> C;
  YesNo(C>=A && C<=B);
  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
#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)
 
using ll = long long;
#define INF 1e9
 
 
int main(){
  int N;
  cin >> N;
  vector<string> s(N);
  unordered_map<string, int> mp;
  REP(i, N){
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
    mp[s[i]]++;
  }
  ll ans = 0;
  for(auto itr = mp.begin(); itr!=mp.end(); ++itr){
      ll add = 0;
      FOR(i, 1, itr->second){
        ans+=i;
      } 
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 17700
#include <iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stdio.h>
#include<string>
#include <map>
using namespace std;

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

	long H[200010];
	for (int i = 0; i < N; ++i) {
		cin >> H[i];
	}
	sort(H, H + N,greater<>());
	long long sum = 0;
	for (int i = K; i < N; ++i) {
		sum += H[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
	int n,i=0,j=1;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	for(i=0;i<n;i++){
		if(a[i]==j) ++j;
	}
	if(j==1) printf("-1\n");
	else 
		printf("%d\n",n-j+1);
}


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

using namespace std;

int main() {
    int x, y;

    // Main loop
    for (int i = 1; ; i++) {
        // input
        cin >> x >> y;

        // process
        if (x == 0 && y == 0) break;

        // output
        if (x < y){
            cout << x << " " << y << endl;
        } else {
            cout << y << " " << x << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3052
#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<stack>
#include<cstring>
#define inf 2147483647
#define ls rt<<1
#define rs rt<<1|1
#define lson ls,nl,mid,l,r
#define rson rs,mid+1,nr,l,r
#define N 1000010
#define For(i,a,b) for(int i=a;i<=b;i++)
#define p(a) putchar(a)
#define g() getchar()

using namespace std;
int n;
int a[N],b[N];
int ans=1;
void in(int &x){
    int y=1;
    char c=g();x=0;
    while(c<'0'||c>'9'){
        if(c=='-')y=-1;
        c=g();
    }
    while(c<='9'&&c>='0'){
        x=(x<<1)+(x<<3)+c-'0';c=g();
    }
    x*=y;
}
void o(int x){
    if(x<0){
        p('-');
        x=-x;
    }
    if(x>9)o(x/10);
    p(x%10+'0');
}
int main(){
    in(n);
    For(i,1,n)
    	in(a[i]);
    b[a[1]]=1;
    For(i,2,n){
    	b[a[i]]=b[a[i]-1]+1;
    	ans=max(ans,b[a[i]]);
    }
    o(n-ans);
    return 0;
}


Measured memory_bytes: 5120