akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

int main() {
    long long n, ret = 1;
    auto mod = 1000000007;
    std::cin >> n;
    std::vector<long long> v(n + 1, 0ll);
    for (auto i = 2ll; i <= n; i++) {
        auto m = i;
        for (auto j = 2ll; j <= m; j++) {
            while (m % j == 0) {
                m /= j;
                v[j]++;
            }
            if (m == 1) break;
        }
    }

    for (auto i = 2ll; i <= n; i++) {
        if (v[i] == 0) continue;
        ret = (ret * (v[i] + 1)) % mod;
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 256
url = "https://atcoder.jp//contests/abc061/tasks/abc061_c"
import heapq


def main():
    n,k = list(map(int, input().split()))
    dic = {}
    for _ in range(n):
        t = list(map(int, input().split()))
        dic.setdefault(t[0], 0)
        dic[t[0]] += t[1]
    dic_sorted = sorted(dic.items(), key=lambda x: x[0])
    count = 0
    for l in dic_sorted:
        count += l[1]
        if count >= k:
            print(l[0])
            exit()



if __name__ == '__main__':
    main()


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

using namespace std;
int main(void){
	int a,b;
	cin>>a>>b;
	if(a+b >= max(a-b,a*b)){
		cout<<a+b;
	}
	else if(a-b >= max(a+b,a*b)){
		cout<<a-b;
	}
	else{
		cout<<a*b;
	}
	return 0;
}


Measured memory_bytes: 256
<?php
while(true){
    list($n,$p) = explode(" ",trim(fgets(STDIN)));
    if($n == 0 && $p == 0) break;
    $person = array_fill(0,$n,0);
    $s = $p;    // stone num in bowl
    $t = 0;     // trun
    while(true){
        if($s > 0){
            $person[$t]++;
            $s--;
        } elseif($s == 0){
            $s = $person[$t];
            $person[$t] = 0;
        }
        if($person[$t] == $p){
            $ans = $t;
            break;
        }
        $t = ($t + 1) % $n; // Circulation
    }
    echo $ans."\n";
}

Measured memory_bytes: 15492
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/bits"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	mask := make([]uint64, n)
	for i := 0; i < n; i++ {
		k := getNextInt(scanner)
		for j := 0; j < k; j++ {
			mask[i] = mask[i] | (1 << uint(getNextInt(scanner)))
		}
	}
	q := getNextInt(scanner)
	b := uint64(0)
	for i := 0; i < q; i++ {
		t := getNextInt(scanner)
		switch t {
		case 0:
			x := getNextInt(scanner)
			fmt.Fprintln(writer, b>>uint(x)&1)
		case 1:
			x := getNextInt(scanner)
			b = b | mask[x]
		case 2:
			x := getNextInt(scanner)
			b = b & (math.MaxUint64 ^ (mask[x]))
		case 3:
			x := getNextInt(scanner)
			b = b ^ mask[x]
		case 4:
			x := getNextInt(scanner)
			if b&mask[x] == mask[x] {
				fmt.Fprintln(writer, 1)
				continue
			}
			fmt.Fprintln(writer, 0)
		case 5:
			x := getNextInt(scanner)
			if b&mask[x] == 0 {
				fmt.Fprintln(writer, 0)
				continue
			}
			fmt.Fprintln(writer, 1)
		case 6:
			x := getNextInt(scanner)
			if b&mask[x] == 0 {
				fmt.Fprintln(writer, 1)
				continue
			}
			fmt.Fprintln(writer, 0)
		case 7:
			x := getNextInt(scanner)
			fmt.Fprintln(writer, bits.OnesCount64(b&mask[x]))
		case 8:
			x := getNextInt(scanner)
			fmt.Fprintln(writer, b&mask[x])
		}
	}
}



Measured memory_bytes: 4880
import math
from decimal import Decimal
a, b = map(Decimal, input().split())
ans = a * b
print(math.floor(ans))

# S = list(input().split())
# a = int(S[0])
# b = S[1].replace('.', '')
# B = int(b)
#
# ans = (a * B) // 100
# print(ans)

# a, b = input().split()
# A = int(a)
# b = b.replace('.', '')
# B = int(b)
# ans = (A * B) // 100
# print(ans)

# S = list(input().split())
# a = int(S[0])
# b = float(S[1])  # 小数点をfloat型にすると限りなく近似された値が2進数として処理されるが厳密に等しくなるわけではない
#
# ans = int((a * b) // 1)
# print(ans)


Measured memory_bytes: 9976
#include<iostream>

using namespace std;

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

int main() {
  int n, m;
  cin >> n;
  string a[300], b;
  rep (i, n) cin >> a[i];
  bool open = false;
  cin >> m;
  rep (i, m) {
    cin >> b;
    rep (j, n) if (a[j]  == b) {
      open = !open;
      if (open) cout << "Opened by ";
      else cout << "Closed by ";
      goto ok;
    }
    cout << "Unknown ";
  ok:;
    cout << b << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
import numpy as np
H,W,K = map(int,input().split())
ll = []
for h in range(H):
    l = []
    for s in input():
        if s == ".":
            l.append(0)
        else:
            l.append(1)
    ll.append(l)
cnt = 0
for bh in range(2 ** H):
    for bw in range(2 ** W):
        nn = np.asarray(ll)
        k = 0
        for h in range(H):
            if (bh & 2 ** h) >> h == 0:
                continue
            nn[h] = np.array([0] * W)
        for w in range(W):
            if (bw & 2 ** w) >> w == 0:
                continue
            nn[:,w] = np.array([0] * H)
        for h in range(H):
            for w in range(W):
                k += nn[h][w]
        if k == K:
            cnt += 1
print(cnt)


Measured memory_bytes: 27016
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <regex>
#include <set>

using namespace std;
int gcd(int a, int b);

int gcd(int a, int b)
{ 
    // Everything divides 0  
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    // base case 
    if (a == b) 
        return a; 
   
    // a is greater 
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 

int main()
{
    int n;
    std::cin >> n;

    int sum = 0;
    for(int i = 1; i <= n; i++)
    for(int j = 1; j <= n; j++)
    for(int k = 1; k <= n; k++)
    {
        sum += gcd(i, gcd(j, k));
    }

    std::cout << sum;

    return EXIT_SUCCESS;
} 


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

void solve()
{
  int a,b;
  cin>>a>>b;
  cout<<6-(a+b)<<endl;
}

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

        solve();

    return 0;
}



Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,mod=1e9+7;
int n,a[N];
ll inv(ll x){return x==1?x:(mod-mod/x)*inv(mod%x)%mod;}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    ll ans=0,s=0;
    for(int i=1;i<n;i++)
    {
        s=(s+inv(i))%mod;
        ans=(ans+s*(a[i+1]-a[i]))%mod;
    }
    for(int i=1;i<=n-1;i++) ans=ans*i%mod;
    printf("%lld\n",ans);
}


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

int main()
{

    long long d,t,s  ; 

    cin>>d>>t>>s; 
    long long dist ; 

     dist  = s*t; 



    if(dist >= d )
    {
        cout<<"Yes"; 
    }
    else 
    {
        cout<<"No" ;
    }


}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i< (n);i++)
#define rep1(i,n) for(int i=1;i<= (n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const static ll MOD = (1e+9)+7;

ll modpow(ll a,ll n){
    if(n==0)return 1;
    if(n%2==1)return a*modpow(a,n-1)%MOD;
    ll t = modpow(a,n/2) % MOD;
    return t*t % MOD;
}

bool com_2(const P a,const P b){
    return a.second > b.second;
}

int main(){
    ll N,H;cin>>N>>H;
    vector<P> lst(N);
    rep(i,N){
        ll a,b;cin>>a>>b;
        lst[i] = make_pair(a,b);
    }
    sort(lst.begin(),lst.end());
    ll ans = 0;
    ll max_a = lst[N-1].first;
    sort(lst.begin(),lst.end(),com_2);
    //まずは最強以外のものを投げつける.
    //最強の奴もどうせ最後には投げるので今のうちに投げておく.
    //ここで、bがデカい順に投げないと損をしてしまう.
    rep(i,N){
        if(lst[i].second >= max_a){
            ans++;
            H-=lst[i].second;
        }
        if(H<=0){
            cout<<ans<<endl;
            return 0;
        }
    }
    ans += H/max_a + (H%max_a == 0 ? 0 : 1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define ll long long

int main() {
	int i,j,k,l,n,m,sum=0,ans=0;
	vector<int> ve;
	cin>>n>>m;
	for(i=0;i<n;i++) {
		cin>>j;
		ve.pb(j);
		sum+=j;
	}
	for(i=0;i<n;i++)
		if(ve[i]*4*m >= sum)
			ans++;
	if(ans>=m)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    cout << N * N * N << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, v := intScanner(), intScanner()
	b, w := intScanner(), intScanner()
	t := intScanner()
	if v > w {
		if abs(a-b) <= t*(v-w) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1760
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		long money = 0;
		long minimum =0;
		int[] moneyInfo = new int[n+1];
		long[] rikaidoInfo = new long[m+1];
		List<long[]> sankoshoInfoList = new ArrayList<long[]>();
		List<long[]> sankoshoInfoListkeisanyo = new ArrayList<long[]>();


		for(int i =0;i <n;i++) {
			moneyInfo[i+1] = sc.nextInt();
			money+=moneyInfo[i+1];
			long[] sankoshoInfo = new long[m+1];
			sankoshoInfo[0] = moneyInfo[i+1];
			for(int j =0;j <m;j++) {
				sankoshoInfo[j +1] = sc.nextInt();
				rikaidoInfo[j +1] += sankoshoInfo[j +1];
			}
			sankoshoInfoList.add(sankoshoInfo);
		}
		for(int i=1;i <=m;i++) {
			if(rikaidoInfo[i] < x) {
				System.out.println(-1);
				return;
			}
		}
		for(int i =0;i <n;i++) {
			List<long[]> sankoshoInfoListkeisanyotmp = new ArrayList<long[]>();
			for(int j =0;j <sankoshoInfoListkeisanyo.size();j++) {
				long[] rikaidoInfox = sankoshoInfoListkeisanyo.get(j).clone();

				for(int k = 0; k <=m;k++) {
					rikaidoInfox[k] += sankoshoInfoList.get(i)[k];
				}
				sankoshoInfoListkeisanyotmp.add(rikaidoInfox);
			}
			sankoshoInfoListkeisanyo.addAll(sankoshoInfoListkeisanyotmp);
			sankoshoInfoListkeisanyotmp.clear();
			sankoshoInfoListkeisanyo.add(sankoshoInfoList.get(i));
		}
		for(long[] info:sankoshoInfoListkeisanyo) {
			boolean flag = true;
			for(int i = 1;i <=m;i++) {
				if(info[i] < x) {
					flag = false;
					break;
				}
			}
			if(flag){
				if(minimum ==0) {
					minimum = info[0];
				}
				if(minimum > info[0]) {
					minimum = info[0];
				}
			}
		}
		System.out.println(minimum);

	}
}

Measured memory_bytes: 28904
import java.util.*;
import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int y = cin.nextInt();
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n - i; j++) {
                int k = n - i - j;
                if (10000 * i + 5000 * j + 1000 * k == y) {
                    out.println(i + " " + j + " " + k);
                    return;
                }
            }
        }
        out.println("-1 -1 -1");
    }
}


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

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


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

unsigned euclidean_gcd(unsigned a, unsigned b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

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

	vector<int> v(n*n);
	int idx = 0;
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j){
			v[idx] = euclidean_gcd(i, j);
			idx++;
		}
	}

	ll ans = 0;
	for(int i = 0; i < n*n; ++i){
		for(int j = 1; j <= n; ++j) { 
			ans += euclidean_gcd(v[i], j);
		}
	}

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


Measured memory_bytes: 3684
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons;

void main() {
  int B = readln.chomp.to!int;
  foreach(i; 1..10) {
    foreach(k; 1..10) {
      if(B == i*k) {
        "Yes".writeln;
        return;
      }
    }
  }
  "No".writeln;
}


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(LL (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename T1,typename T2> using M = map< T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

const int MOD = 1000000007;

int main(){
    LL N,M;
    cin>>N>>M;
    
    LL ans = 1;
    for(LL i=1LL; i*i<=M; i++){
        if(M%i == 0){
            if(N*i<=M) ans = max(ans,i);
            if(N*(M/i)<=M) ans = max(ans,M/i);
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,P> pip;
const int inf=(1<<31)-1;

int W,N,num=0;
char t;
vi v,w,dp;

int main(){
	while(1){
		cin>>W;
		if(!W) break;
		num++;
		cin>>N;
		v=vi(N);
		w=vi(N);
		dp=vi(W+1,0);
		for(int i=0;i<N;i++){
			cin>>v[i]>>t>>w[i];
		}
		for(int i=0;i<N;i++){
			for(int j=W;j>=0;j--){
				if(j-w[i]<0) continue;
				else dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
			}
		}
		cout<<"Case "<<num<<':'<<endl;
		for(int i=W;i>0;i--){
			if(dp[i]!=dp[i-1]){
				cout<<dp[i]<<endl;
				cout<<i<<endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1236
#include <stdio.h>

int main(){
  int i,j,N,k;
  int key;
  scanf("%d",&N);
  int A[N];
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

    for(k=0;k<N-1;k++)
      printf("%d ",A[k]);
    printf("%d",A[k]);
    printf("\n");

  for(j=1;j<N;j++){
    key=A[j];
    i=j-1;
    while(i>=0&&A[i]>key){
      A[i+1]=A[i];
      i=i-1;
    }
    A[i+1]=key;
    for(k=0;k<N-1;k++)
      printf("%d ",A[k]);
    printf("%d",A[k]);
    printf("\n");
    
  }
  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#define IOS                      \
    ios_base::sync_with_stdio(0);\
    cin.tie(0);                  \
    cout.tie(0);
#define eps 1e-6
#define ll long long
//#define int long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
const int mod=1000000007;
using namespace std;
//typedef pair<int ,int> P;
int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[5]==s[4])
        cout<<"Yes";
    else
        cout<<"No";
}


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

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

vector<ll> A(200);

int main(){
    ll x;
    cin >> x;
    ll a,b;


    A[0]= 0;
    for(a = 1; a < 200; a++){
        A[a] = a*a;
        A[a] = A[a]*a;
        A[a] = A[a]*a;
        A[a] = A[a]*a;
    }
    for(a = 0; a < 200; a++){
        ll diff = x-A[a];
        for(b = 0; b < 200; b++){
            if(abs(diff) == A[b]){
                if(diff<0){
                    b = b;
                } else {
                    b = -b;
                }
                break;
            }
        }
        if(b < 0){
            if(A[a] + A[abs(b)] == x) break;
        } else {
            if(A[a] - A[abs(b)] == x) break;
        }
    }
    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 3588
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

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

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i,0,n){
        cin >> A.at(i);
    }
    rep(i,0,n){
        if(A.at(i)%2==0 && A.at(i)%3!=0 && A.at(i)%5!=0){
            cout << "DENIED" ENDL;
            return 0;
        }
    }
    cout << "APPROVED" ENDL;
    
    return 0;
}

Measured memory_bytes: 3640
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N, a[100];

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) { cin >> a[i]; }
    double avr = 0;
    for (int i = 0; i < N; ++i) { avr += a[i]; }
    avr /= N;
    int idx = 0;
    for (int i = 0; i < N; ++i) {
        if (abs(a[i] - avr) < abs(a[idx] - avr)) {
            idx = i;
        }
    }

    cout << idx << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
long long const mod = 998244353;
long long mod_fact(int x){
    static vector<long long> fact = {1, 1};
    if(x < 0)return 0; //
    if(x < fact.size())return fact[x];
    for(int i = fact.size(); i <= x; i++){
        fact.push_back((fact[i-1] * i) % mod);
    }
    return fact[x];
}

long long mod_pow(long long a, long long b){
    long long res = 1;
    a %= mod;
    while(b > 0){
        if(b%2 == 1) res = (res * a) % mod;
        a = (a * a) % mod;
        b /= 2;
    }
    return res;
}

long long mod_div(long long a){
    return mod_pow(a, mod-2);
}

long long mod_comb(int a, int b){
    if(b < 0 || a < b)return 0;
    if(b > a/2)return mod_comb(a, a-b);
    return (((mod_fact(a) * mod_div(mod_fact(a-b))) % mod) * mod_div(mod_fact(b))) % mod;
}

int main(void){
    long long n, al, ng = 0;
    cin >> n;
    al = mod_pow(3, n);
    for(int i=0;i<n/2;i++){
        ng += mod_comb(n, i) * mod_pow(2, i);
        ng %= mod;
    }
    cout << (al - ng*2 + mod*2) % mod << endl;
}


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

vector<pair<long long, long long>> divisor_pair(long long n) {
	vector<pair<long long, long long>> v;
	for (long long i = 1; i * i <= n; ++i) {
		if (n % i == 0) v.emplace_back(i, n/i);
	}
	return v;
}

vector<long long> divisor(long long n) {
	vector<pair<long long, long long>> div_pair = divisor_pair(n);
	vector<long long> v(div_pair.size()*2);
	if (div_pair.back().first == div_pair.back().second) v.pop_back();
	for (int i = 0, j = v.size()-1; i < div_pair.size(); i++, j--) {
		v[i] = div_pair[i].first;
		v[j] = div_pair[i].second;
	}
	return v;
}

int main() {
	bool b[1000001];
	fill (b, b+1000001, false);
	int n;
	cin >> n;
	vector<int> A(n);
	for (int i = 0; i < n; i++) cin >> A[i];
	sort(A.begin(), A.end());
	bool a[n];
	fill(a, a+n, false);
	for (int i = 0; i < n; i++) {
		if (i >= 1 && A[i] == A[i-1]) a[i-1] = false;
		vector<long long> v = divisor(A[i]);
		bool ok = true;
		for (long long e : v) {
			if (b[e]) {
				ok = false;
			}
		}
		if (ok) a[i] = true;
		b[A[i]] = true;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

zoro_cnt = 0
for _ in range(N):
  D1, D2 = map(int,input().split())
  if D1 == D2:
    zoro_cnt += 1
    if zoro_cnt == 3:
      break
  else:
    zoro_cnt = 0
    
if zoro_cnt == 3:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define all(n)      (n).begin(), (n).end()
#define ll long long
#define ull unsigned long long int
void solve() {
   ll k; cin >> k;
    ll total = 0;
    for(int i = 1;i  <= 1e7; i++){
        total = (total*10+7)%k;
        if(total==0){
            cout << i ;return;
        }
    }
    cout << "-1" << endl;
}
int main(){
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    //Starts here , 
                
   
        solve();
    return 0;
            
}

Measured memory_bytes: 3528
N,K = map(int,input().split())

ans = 0
if(K <= N+1):
 for i in range(K, N+1 +1):
  # 0 ~ N から k個選んだ時の最小値min = 0+1+...+(k-1) = (k-1)*k//2
  # 0 ~ N から k個選んだ時の最大値max = N-K+1+...+N = (2N-k+1)*k//2
  # k個選んだ時の場合の数 : max-min+1 = k*(N-k+1)+1個(min:0 max:3なら0,1,2,3の4個)
  tmp = i*(N-i+1)+1 % (10**9 + 7) 
  ans += tmp
  ans = ans % (10**9 + 7)  
    
print(ans)    

Measured memory_bytes: 9188
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long m,n,z=0;
    cin>>n>>m;
    if(2*n<=m)
    {
        z+=n;
        if(m%2==0)
            m-=2*n;
        else
            m-=2*n;
        while(m>=4)
        {
            z++;m-=4;
        }
    }
    else if(2*n>m)
    {
        z+=m/2;
    }
    cout<<z<<endl;
    return 0;
}

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

int BubSort(int *x, int n);
void ShowData(int *x, int n);  

int main() {

  int *p;
  int i;
  int n;
  int num;

  scanf("%d",&n);
  
  p = (int *)malloc(n * sizeof(int)); //メモリ領域の確保

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

  num = BubSort(p,n);
  ShowData(p,n);
  printf("%d\n",num);

  return 0;
}

int BubSort(int *x, int n){

  int i,j;
  int tmp;
  int num = 0;

  for(i=0; i<n-1; i++){
    for(j=n-1; j>i; j--){
      if(x[j-1] > x[j]){
	tmp = x[j];
	x[j] = x[j-1];
	x[j-1] = tmp;
	num++;	
      }
    }
  }
  return num;
}

void ShowData(int *x, int n){

  int i;

  for(i=0; i<n; i++){
    if(i!=n-1) printf("%d ",x[i]);
    else printf("%d",x[i]);
  }

  printf("\n");
}



Measured memory_bytes: 2072
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x; cin >> x;
    cout << (1000LL * (x / 500)) + 5LL * ((x % 500) / 5) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char ** argv)
{
  const int eom[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int m1, d1, m2, d2;
  std::cin >> m1 >> d1 >> m2 >> d2;

  std::printf("%d\n", eom[m1 - 1] == d1 ? 1 : 0);
  return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		String s,t,u;
		int a,b;
		Scanner scanner = new Scanner(System.in);

		s = scanner.next();
		t = scanner.next();
		a = scanner.nextInt();
		b = scanner.nextInt();

		u = scanner.next();

		if (s.equals(u)){
			a--;
		}else {
			b--;
		}

		System.out.println(a + " " + b);
	}

}

Measured memory_bytes: 21972
#include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int n,m;

int C[200][200];
int T[200][200];
int d[200];


int dijk(int s,int g,int r){
    bool used[200];
    rep(i,200)used[i]=false;
    rep(i,200)d[i]=999999999;
    
    d[s]=0;
    
    while(1){
        int v=-1;
        rep(u,m){
            if( !used[u]&&(v==-1||d[u]<d[v]) )v=u;
        }
        if(v==-1)break;
        
        used[v]=true;
        
        rep(u,m){
            if(r==0)
                d[u] = min(d[u],d[v]+C[v][u]);
            else
                d[u] = min(d[u],d[v]+T[v][u]);
        }
    }
    return d[g];
}

int main(){
    while(cin>>n>>m){
        if(n==0&&m==0)break;
        
        rep(i,200)rep(j,200){
            C[i][j]=999999999;
            T[i][j]=999999999;
        }
        rep(i,n){
            int a,b,c,t;
            cin>>a>>b>>c>>t;
            a--,b--;
            C[a][b]=c;
            C[b][a]=c;
            T[a][b]=t;
            T[b][a]=t;
        }
        
        int k;
        cin>>k;
        rep(i,k){
            int s,g,r;
            cin>>s>>g>>r;
            s--,g--;
            cout<<dijk(s,g,r)<<endl;
        }
    }
}

Measured memory_bytes: 1472
/*
	Name: None
	Copyright: zhangjingcanËùÓÐ£¬Î´¾­ÔÊÐí²»µÃ×ªÔØ
	Author: zhangjingcan
	Date:
	Description: C++ÎÄ¼þ
*/
#include <bits/stdc++.h>
using namespace std;
string s;
int main(int argc, char** argv) {
	ios::sync_with_stdio(false);
	cin>>s;
	if(s[0]=='9'||s[1]=='9'){
		cout<<"Yes\n";
	}
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>//printf("%.9f\n",*********);
#include<vector>//文字列.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字) to_string,string,char
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int SED(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}//stringのほうが効率よくないか？

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;
	
	string s;
	cin >> s;

	Yes((s[0] == s[1] && s[1] == s[2]) 
		|| (s[1] == s[2] && s[2] == s[3]));

	please AC;
}

Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    const int INF = 1000000000;
    int h, n;
    cin >> h >> n;
    vector<int> dp(20010, INF), a(n), b(n);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    int ans = INF;
    for (int i = 0; i <= h; i++) {
        for (int j = 0; j < n; j++) {
            int k = i + a[j];
            dp[k] = min(dp[k], dp[i] + b[j]);

            if (h <= k) {
                ans = min(ans, dp[k]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int int64_t
#define all(x) begin(x),end(x)

const int maxn = 2e2 + 7;



signed main() {
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    int ans = 0;
    while(ans < n && a[ans] <= x) {
        x -= a[ans];
        ans++;
    }
    cout << ans - (ans == n && x > 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
typedef long long ll;
typedef pair<int,int> P;
ll a, b, c;
bool isin(int x, int y, int z){
    return x >= 0 && y >= 0 && z >= 0 && x < a && y < b && z < c;
}
int main() {
    int n;
    cin >> a >> b >> c >> n;
    ll ans = 2 * (a*b + b*c + c*a) + 6 * n;
    set<pair<int, P> > st;
    REP(i,n){
        int x, y, z;
        cin >> x >> y >> z;
        st.insert(make_pair(x, P(y, z)));
    }
    int dx[] = {1,-1,0,0,0,0}, dy[] = {0,0,1,-1,0,0}, dz[] = {0,0,0,0,1,-1};
    for (auto p : st){
        int x = p.first, y = p.second.first, z = p.second.second;
        REP(k,6){
            int xx = x + dx[k], yy = y + dy[k], zz = z + dz[k];
            if (!isin(xx,yy,zz)) ans -= 2;
            else if (st.find(make_pair(xx, P(yy, zz))) != st.end()) ans -= 1;
        }
    }
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 3088
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            if (N < 1000)
                Println("ABC");
            else
                Println("ABD");
        }


        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define N (int) 2000
using namespace std;
int n, m, p;
int a[20][N];

int b[20];
int cnt[20];

int calc (int x) {
	int ret = 0;
	while (x) ret += (x & 1), x >>= 1;
	return ret;
}

int main () {
	cin >> n >> m >> p;
	for (int i = 1; i <= n; i ++) {
		string s;
		cin >> s;
		for (int j = 0; j < m; j ++) a[i][j+1] = s[j] == '1';
	}

	int ans = INF;
	for (int st = 0; st < (1 << (n-1)); st ++) {
		memset (cnt, 0, sizeof (cnt));
		int tmp = calc (st);
		
		int id = 1;
		for (int j = 1; j <= n; j ++) {
			b[j] = id;
			if (st & (1 << (j-1))) id ++;
		}
		
		for (int i = 1; i <= m; i ++) {
			int flg = false;
			for (int j = 1; j <= n; j ++) cnt[b[j]] += a[j][i];
			for (int j = 1; j <= id; j ++) if (cnt[j] > p) flg = true;
			
			if (flg) {
				tmp ++;
				int flgg = false;
				memset (cnt, 0, sizeof (cnt));
				for (int j = 1; j <= n; j ++) cnt[b[j]] += a[j][i];
				for (int j = 1; j <= id; j ++) if (cnt[j] > p) flgg = true;
				if (flgg) {tmp = INF; break;}
			}
		}
//		cout << tmp << endl;
		ans = min (ans, tmp);
//		cout << endl;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
import bisect

def nearlr(l, x):
    n = bisect.bisect(l, x)
    return n-1, n

A, B, Q = map(int, input().split())
s = []
t = []
x = []
for _ in range(A):
    s.append(int(input()))
for _ in range(B):
    t.append(int(input()))
for _ in range(Q):
    x.append(int(input()))

for _x in x:
    s_1, s_2 = nearlr(s, _x)
    t_1, t_2 = nearlr(t, _x)
    s_cand = []
    t_cand = []
    if s_1 < 0:
        s_cand = [s[s_2] - _x]
    elif s_2 >= len(s):
        s_cand = [s[s_1] - _x]
    else:
        s_cand = [s[s_1] - _x, s[s_2] - _x]
    if t_1 < 0:
        t_cand = [t[t_2] - _x]
    elif t_2 >= len(t):
        t_cand = [t[t_1] - _x]
    else:
        t_cand = [t[t_1] - _x, t[t_2] - _x]
    ans = float('inf')
    for _s in s_cand:
        for _t in t_cand:
            if _t * _s < 0:
                ans = min(ans, abs(_s) * 2 + abs(_t), abs(_s) + abs(_t) * 2)
            else:
                ans = min(ans, max(abs(_s), abs(_t)))
    print(ans)

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

int main() {

	ll n, h, w; cin >> n >> h >> w;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ll a, b; cin >> a >> b;
		if (h <= a && w <= b) ans++;
	}
	cout << ans << endl;
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N);
  vector<int> C(N-1);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  int sum=0;
  for(int i=0;i<N;i++){
    cin>>B.at(i);
    sum+=B.at(i);
  }
  for(int i=0;i<N-1;i++){
    cin>>C.at(i);
  }
 for(int i=0;i<N-1;i++){
   if(A.at(i+1)==A.at(i)+1){
     sum+=C.at(A.at(i)-1);
   }
 }
  cout<<sum<<endl;
}

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

using namespace std;

int n,q;
vector<int> a;
long long mi[100000],ma[100000];

void solvei(){
    int x;
    cin >> x;
    int l = 1,r = n;
    while(r-l > 1){
        int m = (r+l)/2;
        int ca = a[n-m];
        if(n-m-m+1 < 0){
            r = m;
            continue;
        }
        int ci = a[n-m-m+1];
        if(ca-x >= x-ci) l = m;
        else r = m;
    }
    if(n-l-l < 0) cout << ma[n-l] << endl;
    else cout << ma[n-l]+mi[n-l-l] << endl;
}

void solve(){
    int i,j;
    string str;
    cin >> n >> q;
    a.resize(n);
    for(i = 0;i < n;i++) cin >> a[i];
    if(n%2){
        mi[0] = a[0];
        for(i = 1;i < n;i++){
            if(i%2) mi[i] = mi[i-1];
            else mi[i] = mi[i-1] + a[i];
        }
    }
    else{
        mi[0] = 0;
        for(i = 1;i < n;i++){
            if(i%2) mi[i] = mi[i-1] + a[i];
            else mi[i] = mi[i-1];
        }
    }
    ma[n-1] = a[n-1];
    for(i = n-2;i >= 0;i--) ma[i] = a[i] + ma[i+1];
    for(i = 0;i < q;i++) solvei();
}

int main(){
    solve();
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,q;
  cin >> a >> b >> q;
  vector<ll> s(a);
  vector<ll> t(b);
  for(int i = 0;i < a;i++)cin >> s[i];
  for(int i = 0;i < b;i++)cin >> t[i];
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  for(int i = 0;i < q;i++){
    ll x = 0;
    cin >> x;
    ll ls,lt,rs,rt;
    rs = lower_bound(s.begin(),s.end(),x) - s.begin();
    rt = lower_bound(t.begin(),t.end(),x) - t.begin();
    ls = rs - 1;
    lt = rt - 1;
    if(rs >= a)rs = pow(10,18);
    else rs = s[rs];
    if(rt >= b)rt = pow(10,18);
    else rt = t[rt];
    if(ls < 0)ls = -1 * pow(10,18);
    else ls = s[ls];
    if(lt < 0)lt = -1 * pow(10,18);
    else lt = t[lt];
    ll res = 0;
    res = pow(10,18);
    res = min(res,abs(min(ls,lt) - x));
    res = min(res,abs(max(rs,rt) - x));
    res = min(res,min(abs(x - ls),abs(x - rt)) * 2 + max(abs(x - ls),abs(x - rt)));
    res = min(res,min(abs(x - lt),abs(x - rs)) * 2 + max(abs(x - lt),abs(x - rs)));
    cout << res << endl;
  }
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define PI pair<int,int>
#define ff first
#define ss second
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)

const int M=1e9+7;
const int N=2*1e5+5;

int mod(int n){
	n%=M;
	n+=M;
	return n%M;
}

int power(int a,int b){
	int ans=1;
	while(b>0){
		if(b&1)
			ans=mod(ans*a);
		a=mod(a*a);
		b/=2;
	}
	return ans;
}

int inv(int n){
	return power(n,M-2);
}

vector<int>g[N];
int sz[N],dp[N],f[N],invf[N],ans[N];
int n;
void factorial(){
	f[0]=f[1]=1;
	for(int i=2;i<N;i++)
		f[i]=mod(f[i-1]*i);
	invf[N-1] = inv(f[N-1]);
	for(int i=N-1;i>0;i--){
		invf[i-1] = mod(invf[i]*i);
	}
}

void dfs1(int u,int p){
	sz[u]=1;
	dp[u]=1;
	for(int v:g[u]){
		if(v==p)continue;
		dfs1(v,u);
		sz[u]+=sz[v];
		dp[u] = mod(dp[u]*dp[v]);
		dp[u] = mod(dp[u]*invf[sz[v]]);
	}
	dp[u] = mod(dp[u]*f[sz[u]-1]);
}


void dfs2(int u,int p){
	ans[u]=dp[u];
	for(int v:g[u]){
		if(v==p)
			continue;
		dp[u] = mod(dp[u]*inv(dp[v]));
		dp[u] = mod(dp[u]*f[sz[v]]);
		dp[u] = mod(dp[u]*invf[sz[u]-1]);
		dp[v] = mod(dp[v]*invf[sz[v]-1]);

		sz[u]-=sz[v];
		sz[v]+=sz[u];
		dp[u] = mod(dp[u]*f[sz[u]-1]);
		dp[v] = mod(dp[v]*f[n-1]);
		dp[v] = mod(dp[v]*dp[u]);
		dp[v] = mod(dp[v]*invf[sz[u]]);
		
		dfs2(v,u);
		
		dp[v] = mod(dp[v]*f[sz[u]]);
		dp[v] = mod(dp[v]*inv(dp[u]));
		dp[v] = mod(dp[v]*invf[n-1]);
		dp[u] = mod(dp[u]*invf[sz[u]-1]);
		sz[v]-=sz[u];
		sz[u]+=sz[v];
		dp[v] = mod(dp[v]*f[sz[v]-1]);
		dp[u] = mod(dp[u]*f[sz[u]-1]);
		dp[u] = mod(dp[u]*invf[sz[v]]);
		dp[u] = mod(dp[u]*dp[v]);
	}
}

int32_t main() { 
    boost;
    factorial();
    cin>>n;
    for(int i=1,u,v;i<n;i++){
    	cin>>u>>v;
    	g[u].push_back(v);
    	g[v].push_back(u);
    }
    dfs1(1,0);
    //print(sz,n+1);
    //print(dp,n+1);
    dfs2(1,0);
   	//print(sz,n+1);
    //print(dp,n+1);
   
    for(int i=1;i<=n;i++)
    	cout<<ans[i]<<endl;
}	

Measured memory_bytes: 22512
import random
import math
N = int(input())
X = list(map(int, input().split()))
M = int(input())
A = list(map(int, input().split()))


for i in range (M):
    if A[i] == N and (X[A[i]-1] != 2019): 
        X[A[i]-1]=1+X[A[i]-1]
    elif  X[A[i]-1]==2019:
        continue 
    elif X[A[i]-1]+1 != X[A[i]] :
        X[A[i]-1]+=1


for i in range (N):
    print(X[i])


Measured memory_bytes: 8184
def main()
  n = gets.chomp.to_i
  x = gets.chomp.split(' ').map(&:to_i)
  table = Array.new(8,0)
  free = 0
  for i in 0..n-1
    case x[i]
    when 1..399
      table[0] = 1
    when 400..799
      table[1] = 1
    when 800..1199
      table[2] = 1
    when 1200..1599
      table[3] = 1
    when 1600..1999
      table[4] = 1
    when 2000..2399
      table[5] = 1
    when 2400..2799
      table[6] = 1
    when 2800..3199
      table[7] = 1
    else
      free = free + 1
    end
  end
  ans_min = [table.select{|t| t == 1}.size, 1].max
  ans_max = table.select{|t| t == 1}.size + free
  puts "#{ans_min} #{ans_max}"
end

main()

Measured memory_bytes: 1788
n, l = [int(i) for i in input().split()]
ans = n*l + n * (n+1)//2 - n

# apples are l, l+1, ... l+n-1
# when does 0 in them? when l<=0 and 0 <= l+n-1
if l <= 0 and 0<= l+n-1:
    print(ans)
elif l > 0:
    print(ans - l)
else:
    print(ans - (l+n-1))

Measured memory_bytes: 3060
N = int(input())
t = [0]
x = [0]
y = [0]
for i in range(N):
  a,b,c = map(int, input().split())
  t.append(a)
  x.append(b)
  y.append(c)

def helper():
  for i in range(N):
    dt = t[i+1] -t[i] 
    dx = abs(x[i+1] - x[i])
    dy = abs(y[i+1] - y[i])

    if dt < (dx+dy) or dt%2 != (dx+dy)%2:

      return False
  return True

a = helper()  
print('Yes') if a else print('No')


Measured memory_bytes: 17360
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();
		boolean flag = false;
		StringBuilder sb = new StringBuilder();
		for (int i = Math.max(x - k + 1, -1000000); i <= Math.min(x + k - 1, 1000000); i++) {
			if (flag) {
				sb.append(" ");
			}
			flag = true;
			sb.append(i);
		}
		System.out.println(sb);
	}
}


Measured memory_bytes: 21844
# n = int(input())
# list_a = []

# for i in range(n):
#   list_a.append(input())

# d = {}
# for i in list_a:
#   if i in d:
#     d[i] = d[i] + 1
#   else:
#     d[i] = 1

# key = sorted([k for k, v in d.items() if v == d[max(d)]])
# for i in key:
#   print(i)

  
n = int(input())
list_a = []

d = {}
for _ in range(n):
    i = input()
    if i in d:
        d[i] += 1
    else:
        d[i] = 1

max_value = max(d.values())
key = sorted([k for k, v in d.items() if v == max_value])
for i in key:
    print(i)


Measured memory_bytes: 32988