akhauriyash/Code-Regression huggingface dataset:
M,D = map(int,input().split())
if D < 22:
  print(0)
  exit()
ans = 0
for i in range(22,D+1):
  d1 = i % 10
  d10 = i // 10
  if d1 >= 2 and d10 >= 2 and M >= d1 * d10:
    ans += 1
    #print(M,d1,d10)
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
//Fast io
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
//Class shorthands
#define ll long long
#define db long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
//Function Shorthands
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair
#define po pop_back
#define eb emplace_back
//Code Shorthands
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
//Constants
#define hell 1000000007
#define PI acos(-1.0)
using namespace std;
int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b, a%b);
}
void solve(){
    vector<vector<int>> pf(1000005,vi(0));
    rep(i,2, 1000001){
        if(pf[i].empty()){
            for(int j=i;j<=1000004;j+=i){
                pf[j].pb(i);
            }
        }
    }
    int n;
    cin>>n;
    int a[n];
    rep(i,0,n) cin>>a[i];
    int ans = gcd(a[0], a[1]);
    for(int i=2;i<n;i++) ans = gcd(ans, a[i]);
    map<int, int> m;
    for(int i=0;i<n;i++){
        for(auto j: pf[a[i]]){
            m[j]++;
        }
    }
    int f = 0;
    for(auto i: m){
        if(i.se>1) f = 1;
    }
    if(f){
        if(ans==1){
            cout<<"setwise coprime\n";
        }
        else{
            cout<<"not coprime\n";
        }
    }
    else cout<<"pairwise coprime\n";
}

int main(){
    io;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 66140
package main

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

type Pair struct {
	v int
	d int
}

type Queue []Pair

func (q *Queue) push(v Pair) {
	*q = append(*q, v)
}

func (q *Queue) pop() Pair {
	v := (*q)[0]
	*q = (*q)[1:]
	return v
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	nVerts := scanInt(sc)
	graph := make([][]int, nVerts+1)

	for i := 0; i < nVerts; i++ {
		u := scanInt(sc)
		nDegrees := scanInt(sc)

		graph[u] = make([]int, nDegrees)
		for d := 0; d < nDegrees; d++ {
			graph[u][d] = scanInt(sc)
		}
	}

	paths := make([]int, nVerts+1)

	queue := Queue(make([]Pair, 0))
	queue.push(Pair{1, 1})
	paths[1] = 1

	for len(queue) > 0 {
		p := queue.pop()
		d := p.d + 1
		for _, v := range graph[p.v] {
			if paths[v] == 0 {
				paths[v] = d
				queue.push(Pair{v, d})
			}
		}
	}

	w := bufio.NewWriter(os.Stdout)
	for i := 1; i <= nVerts; i++ {
		fmt.Fprintf(w, "%d %d\n", i, paths[i]-1)
	}
	w.Flush()
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}



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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string str;
    cin >> str;
    
    while(true)
    {
        str.pop_back();
        if(str.substr(0,str.size()/2) == str.substr(str.size()/2))
        {
            
            cout << str.size() << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] -= i + 1;
  }
  sort(a, a + n);
  int Tmp = a[n / 2];
  int Ans = 0;
  for (int i = 0; i < n; i++) {
    Ans += abs(a[i] - Tmp);
  }
  cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 1792
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())
    A = list(map(int,input().split()))
    Q = int(input())
    BC = [list(map(int,input().split())) for i in range(Q)]

    cnt = [0 for i in range(10**5)]
    tot = sum(A)

    for i in range(N):
        cnt[A[i]-1] += 1

    for i in range(Q):
        temp = BC[i]
        tot += cnt[temp[0]-1] * (temp[1] - temp[0])
        cnt[temp[1]-1] += cnt[temp[0]-1]
        cnt[temp[0]-1] = 0
        print(tot)



main()


Measured memory_bytes: 31980
#include<bits/stdc++.h>
using namespace std;
int main(){
int i,n,k;
  cin >> n >> k;
  int p[1010];
  for(i=0;i<n;i++){
    cin >> p[i];
  
}
  sort(p,p+n);
  int sum=0;
  for(i=0;i<k;i++){
    sum+=p[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 3612
import numpy as np

S = np.array([int(i) for i in list(input())])
N = len(S)

def zebra(A):
    for i in range(N-1):
        if A[-1] == 0:
            A.append(1)
        elif A[-1] == 1:
            A.append(0)
    return A

A0 = np.array(zebra([0]))
A1 = np.array(zebra([1]))

dis0 = np.count_nonzero(S - A0)
dis1 = np.count_nonzero(S - A1)

print(min(dis0, dis1))

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    set<int> st;
    vector<int> a(n);
    st.insert(-1);
    st.insert(n);
    ll ans = 0;
    for (int i = 0;i < n;++i) {
        int p;
        cin >> p;
        a[p-1] = i;
    }
    st.insert(a[n-1]);
    for (int i = n-2;i >= 0;--i) {
        auto it = st.upper_bound(a[i]);
        if (*it != n) {
            ++it;
            int r = *it;
            --it;
            int c = *it;
            --it;
            int l = *it+1;
            ans += (ll)(i+1)*(a[i]-l+1)*(r-c);
            ++it;
        }
        --it;
        if (*it > -1) {
            --it;
            int l = *it+1;
            ++it;
            int c = *it;
            ++it;
            int r = *it;
            ans += (ll)(i+1)*(r-a[i])*(c-l+1);
        }
        st.insert(a[i]);
    }
    cout << ans << endl;
}

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

int main(){
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    int sum_pens1 = 0;
    int sum_pens2 = 0;
    int sum_money1 = 0;
    int sum_money2 = 0;
    while(sum_pens1 < N){
        sum_pens1 += A;
        sum_money1 += B;
    }

    while(sum_pens2 < N){
        sum_pens2 += C;
        sum_money2 += D;
    }

    cout << min(sum_money1, sum_money2) << endl;
}


Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n,l[202];
	scanf("%d",&n);
	rep(i,2*n)scanf("%d",&l[i]);
	sort(l,l+2*n);
	int ret = 0;
	rep(i,n)ret += l[2*i];
	cout << ret << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	map<string, int> m;
	int n; cin >> n;
	rep(i, n){
		string s; cin >> s;
		sort(all(s));
		m[s]++;
	}
	ll ans = 0;
	for(auto i : m) ans += (i.second - 1ll) * i.second / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,strt,end) for(long long i = strt;i < end;i++)

int main(){
    long n;
    cin >> n;
    long long member[n+1];
    rep(i,0,n+1){
        member[i] = 0;
    }
    rep(i,0,n-1){
        int boss;
        cin >> boss;
        member[boss]++;
    }
    rep(i,1,n+1){
        cout << member[i] << endl;
    }
    //--------------
    return 0;
}

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

#define ll long long int
#define debug(c) cout << #c << " = " << c << endl;

int main()
{
  ll k,s=0,a,b,c;
  cin>>k;
  for(a=1;a<=k;a++)
  {
      for(b=1;b<=k;b++)
    {
          ll gcd=__gcd(a,b);

      for(c=1;c<=k;c++)
      {
          s=s+__gcd(gcd,c);
      }
    }

  }
  cout<<s;
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int main() {
    int n;

    cin >> n;

    long long count[1010] = {0};

    for (int i = 1; i <= n; i++) {
        int tmp = i;
        for (int j = 2; j < 1010; ) {
            if (tmp % j == 0) {
                count[j]++;
                tmp /= j;
            } else {
                j++;
            }
        }
    }

    long long ans = 1;

    for (int i = 2; i < 1010; i++) {
        ans *= count[i] + 1;
        ans %= 1000000007;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e;
    while(cin>>a)
    {

     vector<int>v1,v2;
     for(b=1;b<=a;b++)
     {
         cin>>c;
         v1.push_back(c);
         v2.push_back(c);
     }
     sort(v1.begin(),v1.end());
     for(b=0;b<a;b++)
     {
         c=v1[a-1];
         if(v2[b]==c)
         {
             cout<<v1[a-2]<<endl;
         }
         else
         {
             cout<<v1[a-1]<<endl;
         }

     }
     v1.clear();
     v2.clear();


    }







    return 0;
}


Measured memory_bytes: 3436
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,X=mp()
x=lmp()
ans=abs(X-x[0])
for i in range(0,n-1):
    ans=fractions.gcd(ans,abs(x[i]-x[i+1]))
print(ans)

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

int main(){
	int n,m,i,j;
	cin>>n>>m;
	int a[n][m],b[m],c[n]={0};
	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			cin>>a[i][j];
		}
	}
	for(j=0; j<m; j++){
		cin>>b[j];
	}
	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			c[i]+=a[i][j]*b[j];
		}
	}
	for(i=0; i<n; i++){
		cout<<c[i]<<"\n";
	}
	return 0;
}


Measured memory_bytes: 3120
from time import time

def change(before_tax,after_tax,previous_price):
    #change z from taxrate x to taxrate y
    original_price = 0
    for i in range(1, previous_price+1):
        if i * (100 + before_tax) // 100 == previous_price:
            original_price = i
            break
        else:
            pass
    return original_price * (100 + after_tax) // 100

#l = []

while True:
    x,y,s = [int(x) for x in input().split()]
    if x == 0:
        break
    else:
        ans = 0
        for i in range(1,s):
            price1, price2 = i, s - i
            afterprice = change(x,y,price1) + change(x,y,price2)
            if afterprice > ans:
                ans = afterprice
            else:
                continue
        #l.append(ans)
        print(ans)
'''
for x in l:
    print(x)
'''


Measured memory_bytes: 5640
import math

N, K = map(int, input().split())
ans = 0

def prob(a, n, k):
    c = math.ceil(math.log(k/a,2))
    return (1/n)*(1/2)**c

if N >= K:
    ans += (N-K)/N

for i in range(1,min(N,K)+1):
    ans += prob(i, N, K)

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
    int a;
    int ans[100001];
    int turn[100001];
    int num=1;
    int flag=0;

    scanf("%d",&a);

    for(int i=0;i<a;i++){
        scanf("%d",&turn[i]);
    }
    for(num=1;num<=a;num++){
        flag=0;
        int n=0;
    while(flag==0){
        if(turn[n]==num){
            ans[num-1]=n+1;
            flag=1;
        }
        n++;
    }
    }
    for(int m=0;m<a-1;m++){
        printf("%d ",ans[m]);
    }
    printf("%d\n",ans[a-1]);
    return 0;
}

Measured memory_bytes: 1536
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    Scanner sc = new Scanner(System.in);

    void run() {
        int n = sc.nextInt();
        int[] t = new int[n];
        int s = 0;
        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt();
            s += t[i];
        }
        boolean[][][] dp = new boolean[n + 1][s + 1][s + 1];
        dp[0][0][0] = true;
        int min = s;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < s + 1; j++) {
                for (int k = 0; k < s + 1; k++) {
                    dp[i + 1][j][k] |= dp[i][j][k];
                    if (j + t[i] <= s) dp[i + 1][j + t[i]][k] |= dp[i][j][k];
                    if (k + t[i] <= s) dp[i + 1][j][k + t[i]] |= dp[i][j][k];
                    if (dp[n][j][k]) min = Math.min(min, Math.max(j, Math.max(k, s - (j + k))));
                }
            }
        }
        System.out.println(min);
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 321080
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e9
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}

int h, n;

int dp[20001];
vector<pii> v;

int get(int val)
{
	if (dp[val] != -1)
		return dp[val];

	int ans = inf;

	if (val == 0)
		return dp[val] = 0;

	for (int i = 0; i < n; ++i)
		if (v[i].ff <= val)
			ans = min(ans, v[i].ss + get(val - v[i].ff));

	return dp[val] = ans;
}

int32_t main()
{
	c_p_c();
	cin >> h >> n;
	memset(dp, -1, sizeof(dp));
	v.resize(n);

	int mx = 0;

	for (int i = 0; i < n; ++i)
	{
		cin >> v[i].ff >> v[i].ss;
		mx = max(mx, v[i].ff);
	}

	int ans = inf;

	for (int i = 0; i < mx; ++i)
		ans = min(ans, get(h + i));

	cout << ans << '\n';



	return 0;
}

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

int main() {
  int A, B, count = 0;
  cin >> A >> B;
  for(int i = A; i <= B; ++i) {
    string num_str = to_string(i);
    if(num_str[0] == num_str[4] && num_str[1] == num_str[3]) count++;
  }
  cout << count << endl;
}


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

edge = [list(map(int,input().split())) for _ in range(M)]

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

for e in edge:
    graph[e[0]-1].append((e[1]-1,e[2]))
    graph[e[1]-1].append((e[0]-1,-e[2]))

level = [None for _ in range(N)]

inconsistent = False

for i in range(N):
    if level[i] is None:
        level[i] = 0
        stack = [i]
        while stack:
            node = stack.pop()
            for adj,cost in graph[node]:
                if level[adj] is None:
                    level[adj] = level[node] + cost
                    stack.append(adj)
                else:
                    if level[adj] != level[node] + cost:
                        inconsistent = True
                        break
    if inconsistent:
        break

if inconsistent:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 112728
N = int(input())
X = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
ans = []
for i in range(N):
  tme = X[i + 1][0] - X[i][0]
  cor = abs(X[i + 1][1] - X[i][1]) + abs(X[i + 1][2] - X[i][2])
  ans.append(max(tme - cor, -1) % 2 == 0)
print('Yes' if all(ans) else 'No')

Measured memory_bytes: 28148
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE TypeApplications #-}
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8 as BS
import           Data.Char             (isSpace)
import           Data.Int              (Int64)
import           Data.List             (unfoldr)
import           Data.Ratio
import qualified Test.QuickCheck       as QC
import Control.Exception (assert)

-- comb2 n = n * (n - 1) `quot` 2 without undue overflow
-- n even: comb2 n = (n `quot` 2) * (n - 1)
-- n odd: comb2 n = n * (n `quot` 2)
comb2 :: (Integral a, Bits a) => a -> a
comb2 n = (n `shiftR` 1) * ((n - 1) .|. 1)

prop_comb2 :: Integer -> QC.Property
prop_comb2 n = comb2 n QC.=== n * (n - 1) `quot` 2

-- floorSum n m a b
-- n: non-negative, m: positive
floorSum :: Int64 -> Int64 -> Int64 -> Int64 -> Int64
floorSum n m a b | assert (n >= 0 && m > 0) False = undefined
floorSum n m 0 b = n * floor (b % m)
floorSum 0 m a b = 0
floorSum n 1 a b = a * comb2 n + n * b
floorSum n m a b
  | a < 0 = floorSum n m (- a) (b + a * (n - 1))
  | let m2 = m `quot` 2
  , abs a > m2 = case (a + m2) `divMod` m of
                   (q, a') ->
                     q * comb2 n + floorSum n m (a' - m2) b
  | b >= m || b < 0 = case b `divMod` m of
                        (q, b') -> q * n + floorSum n m a b'
  | n > m = case n `quotRem` m of
              (q, n') -> (q * n - comb2 (q + 1) * m) * a + q * floorSum m m a b + floorSum n' m a b
  | otherwise = -- 0 < a < m, 0 <= b < m, 0 < n <= m
      let t = floor ((toInteger a * (toInteger n - 1) + toInteger b) % toInteger m)
      in n * t + floorSum t a (- m) (b - m)

floorSum_naive :: Int64 -> Int64 -> Int64 -> Int64 -> Integer
floorSum_naive n m a b = sum [ floor ((fromIntegral a * fromIntegral i + fromIntegral b) % fromIntegral m) | i <- [0..n-1] ]

prop_floorSum :: QC.NonNegative (QC.Small Int64) -> QC.Positive Int64 -> Int64 -> Int64 -> QC.Property
prop_floorSum (QC.NonNegative (QC.Small n)) (QC.Positive m) a b = QC.within (100 * 1000) $ toInteger (floorSum n m a b) QC.=== floorSum_naive n m a b

prop_floorSum_r :: QC.Property
prop_floorSum_r = QC.forAllShrink (QC.choose (1, 10^4)) QC.shrink $ \n -> n >= 1 QC.==>
  QC.forAllShrink (QC.choose (1, 10^9)) QC.shrink $ \m -> m >= 1 QC.==>
  QC.forAllShrink (QC.choose (0, m - 1)) QC.shrink $ \a ->
  QC.forAllShrink (QC.choose (0, m - 1)) QC.shrink $ \b ->
  QC.within (100 * 1000) $ toInteger (floorSum n m a b) QC.=== floorSum_naive n m a b

main = do
  t <- readLn @Int
  replicateM_ t $ do
    [n,m,a,b] <- map fromIntegral . unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    print $ floorSum n m a b


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

int main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  
  int res = 0;
  
  for(int A = 0;A <= a;++A){
    for(int B = 0; B <= b;++B){
      for(int C = 0;C <= c;++C){
        int total = 500*A + 100*B + 50*C;
        if(total == x) ++res;
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const int MX= 1000005;

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,n) a[i]=0;
  int k;
  rep(i,n-1){
    cin>>k;
    k--;
    a[k]++;
  }
  rep(i,n) cout<<a[i]<<endl;
}

Measured memory_bytes: 4416
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b,re;
    cin>>a;
    if(a=="Rainy")
    {
        cout<<"Sunny"<<endl;
    }
    else if(a=="Sunny"){
        cout<<"Cloudy"<<endl;
    }
    else{
        cout<<"Rainy"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,a1=0,a2=0,a3=0,a4=0,a5=0,a6=0;
  double high[100];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> high[i];
    if(high[i]<165.0){
      a1++;
    }
    else if(high[i]<170.0){
      a2++;
    }
    else if(high[i]<175.0){
      a3++;
    }
    else if(high[i]<180.0){
      a4++;
    }
    else if(high[i]<185.0){
      a5++;
    }
    else{
      a6++;
    }
  }
  cout << "1:";
  for(int i=0;i<a1;i++){
    cout << "*";
  }
  cout << endl;

  cout << "2:";
  for(int i=0;i<a2;i++){
    cout << "*";
  }
  cout << endl;

  cout << "3:";
  for(int i=0;i<a3;i++){
    cout << "*";
  }
  cout << endl;

  cout << "4:";
  for(int i=0;i<a4;i++){
    cout << "*";
  }
  cout << endl;

  cout << "5:";
  for(int i=0;i<a5;i++){
    cout << "*";
  }
  cout << endl;

  cout << "6:";
  for(int i=0;i<a6;i++){
    cout << "*";
  }
  cout << endl;
  return (0);
}

Measured memory_bytes: 1228
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

struct edge {
	int from, to, cost;
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, m, p;
	cin >> n >> m >> p;
	vector<edge> graph;
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		graph.pb({ a,b,p - c });
	}
	vector<int> dis(n, inf);
	dis[0] = 0;
	set<int> st;
	rep(cnt, 3 * n) {
		bool update = false;
		rep(i, m) {
			edge e = graph[i];
			if (dis[e.from] != inf && dis[e.to] > dis[e.from] + e.cost) {
				dis[e.to] = dis[e.from] + e.cost;
				update = true;
				if (cnt >= n - 1) st.insert(e.to);
			}
		}
		if (!update) break;
	}
	queue<int> que;
	vector<bool> ok(n);
	que.push(0); ok[0] = true;
	while (!que.empty()) {
		int q = que.front(); que.pop();
		for (edge i : graph) {
			if (i.from == q) {
				if (!ok[i.to]) {
					ok[i.to] = true;
					que.push(i.to);
				}
			}
		}
	}
	queue<int> que2;
	vector<bool> ok2(n);
	que2.push(n - 1); ok2[n - 1] = true;
	while (!que2.empty()) {
		int q = que2.front(); que2.pop();
		for (edge i : graph) {
			if (i.to == q) {
				if (!ok2[i.from]) {
					ok2[i.from] = true;
					que2.push(i.from);
				}
			}
		}
	}
	rep(i, n) {
		if (ok[i] && ok2[i] && st.count(i)) {
			cout << -1 << '\n';
			return 0;
		}
	}
	cout << max(-dis[n - 1], 0) << '\n';
}

Measured memory_bytes: 512
#include <numeric>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <iostream>
#include <sstream>
#include <vector>
#include <cstdio>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <string>
#include <bitset>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <tuple>
#include <sstream>

using namespace std;

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; for (auto& e : a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; for (auto& e : a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; for (auto& r : a) { for (auto& e : r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; for (auto& e : a) { cerr << e.field << " ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

#define forn(a, e) for (int a = 0; a < (int)(e); a++)
#define forr(a, s, e) for (int a = s; a < (int)(e); a++)

using i64 = long long;

template<typename T>
using Pair = array<T, 2>;

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

    int n, m;
    while (cin >> n >> m) {
        vector<pair<int, int>> a(n);
        forn(i, n) {
            cin >> a[i].first >> a[i].second;
        }

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

        priority_queue<int> q;
        i64 ans = 0;
        int p = 0;
        forr(i, 1, m + 1) {
            while (p < a.size() && a[p].first == i) {
                q.push(a[p].second);
                p++;
            }
            if (!q.empty()) {
                ans += q.top();
                q.pop();
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 1660
n = 0
while 1:
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        break
    else:
        for i in range(1, a+1):
            for j in range(1, i):
                for k in range(1, j):
                    if i + j + k == b:
                        n += 1
        print(n)
    n = 0
        


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007

int main()
{
    FASTIO;
    string s;
    long long n,ans=0;
    cin>>s>>n;

    if(s.size() == 1)
    {
        if(n != 1) ans = n/2;
    }
    else
    {
        string temp = s+s;
        string temp3 =s+s+s;
        long long ans1=0,ans2=0,ans3=0;
        for(int j=1; j<s.size(); j++)
        {
            if(s[j] == s[j-1])
            {
                s[j] = 'A';
                ans1++;
            }
        }
        for(int j=1; j<temp.size(); j++)
        {
            if(temp[j] == temp[j-1])
            {
                temp[j] = 'A';
                ans2++;
            }
        }
        for(int j=1; j<temp3.size(); j++)
        {
            if(temp3[j] == temp3[j-1])
            {
                temp3[j] = 'A';
                ans3++;
            }
        }
        ans = (ans2-ans1)*(n-1) + ans1;
        if(n>=3 && ans3!=(ans2-ans1)*2+ans1 && n%2==1)
        {
            ans-=((n-1)/2);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
import Foundation

func main() {
    let nk = readLine()!.split(separator: " ").map { Int($0)! }
    let A = readLine()!.split(separator: " ").map { Double($0)! }
    let N = nk[0]
    let K = nk[1]
    
    for i in 0...N-K-1 {
        if A[K+i]/A[i] > 1 { print("Yes") }
        else { print("No") }
    }
}

main()


Measured memory_bytes: 27556
#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;

int main() {
    long N, K;
    cin>>N>>K;
    map<int, vector<long> > sushimap;
    vector<int> sushiarr;
    long t, d;
    for(int i=0;i<N;++i){
        cin>>t>>d;
        if(sushimap[t].size()==0)sushiarr.push_back(t);
        sushimap[t].push_back(d);
    }
    for(int i=0;i<sushiarr.size();++i){
        sort(sushimap[sushiarr[i]].begin(), sushimap[sushiarr[i]].end());
    }
    vector<long> diffsushis;
    vector<long> sushis;
    priority_queue<long, vector<long>, greater<long> >eat;
    for(int i=0;i<sushiarr.size();++i){
        diffsushis.push_back(sushimap[sushiarr[i]][sushimap[sushiarr[i]].size()-1]);
        for(int j=0;j<sushimap[sushiarr[i]].size()-1;++j){
            sushis.push_back(sushimap[sushiarr[i]][j]);
        }
    }
    sort(diffsushis.begin(), diffsushis.end());
    sort(sushis.begin(), sushis.end(), greater<long>());
    long ans = 0;
    if(diffsushis.size()>=K){
        for(int i=0;i<K;++i){
            eat.push(diffsushis[diffsushis.size()-1-i]);
            ans += diffsushis[diffsushis.size()-1-i];
        }
        ans += K*K;
        long bonus = K;
        for(int i=0;i<sushis.size();++i){
            if(ans < ans - bonus*bonus - eat.top() + (bonus-1)*(bonus-1) + sushis[i]){
                ans = ans - bonus*bonus - eat.top() + (bonus-1)*(bonus-1) + sushis[i];
                eat.pop();
                eat.push(sushis[i]);
                bonus--;
            }
            else break;
            if(bonus == 1)break;
        }
    }
    else{
        for(int i=0;i<diffsushis.size();++i){
            eat.push(diffsushis[i]);
            ans += diffsushis[i];
        }
        int index = K - diffsushis.size();
        for(int i=0;i<index;++i){
            ans += sushis[i];
        }
        long bonus = diffsushis.size();
        ans += bonus * bonus;
        for(int i=index;i<sushis.size();++i){
            if(ans < ans - bonus*bonus - eat.top() + (bonus-1)*(bonus-1) + sushis[i]){
                ans = ans - bonus*bonus - eat.top() + (bonus-1)*(bonus-1) + sushis[i];
                eat.pop();
                eat.push(sushis[i]);
                bonus--;
            }
            else break;
            if(bonus == 1)break;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 13300
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solver();
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		while (true) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			long p = sc.nextLong();
			if (a == 0 && b == 0 && p == 0)
				break;
			long[] dp = new long[111111];
			dp[0] = 1;
			long ans = 0;
			for (long i = a; i <= b; i++) {
				if (i > a) {
					dp[(int) (i - a)] += dp[(int) (i - a - 1)];
				}
				ans += dp[(int) (i - a)];
				ans %= p;
				for (long j = i; j <= b; j *= 10) {
					long t = 1;
					while (t <= j)
						t *= 10;
					long l = Math.max(i - a + 1, j - a), r = Math.min(b - a + 1, t - a);
					dp[(int) l] += dp[(int) (i - a)];
					dp[(int) r] -= dp[(int) (i - a)];
					dp[(int) l] %= p;
					dp[(int) r] %= p;
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 57584
def main():
    a, b, c = (int(i) for i in input().split())
    for k in range(c):
        if k % 2 == 0:
            b += a//2
            a //= 2
        else:
            a += b//2
            b //= 2
    print(a, b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#!/usr/bin/env python3
import sys
def read(): return sys.stdin.readline() # 標準入力
def fbit(i, j=-1): return format(i, 'b').zfill(j) # bit 表示
def popcount(x): # ビットカウント
    x=x-((x>>1)&0x5555555555555555)
    x=(x&0x3333333333333333)+((x>>2)&0x3333333333333333)
    x=(x+(x>>4))&0x0f0f0f0f0f0f0f0f;x=x+(x>>8);x=x+(x>>16);x=x+(x>>32)
    return x&0x0000007f


def solv(N:int, A, x, y):
    ans = 0
    for bits in range(1<<N):
        ok = True
        count = 0
        for i in range(N):
            if not (bits & 1<<i): continue
            count+=1
            for j in range(A[i]):
                if (bits >> (int(x[i][j])-1) & 1) ^ int(y[i][j]): ok = False
        if ok: ans = max(ans, count);


    print(ans)
def main():
    N = int(read())
    A = []
    x = []
    y = []
    for i in range(N):
        A.append(int(read()))
        _x=[]
        _y=[]
        for j in range(A[-1]):
            [a,b] = list(read().rsplit())
            _x.append(a)
            _y.append(b)
        x.append(_x)
        y.append(_y)


    solv(N, A, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 74132
#include <stdio.h>

int main (void)

{


  int a,b;


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


  if(a<b){


              printf("a < b\n");


             }


  else if(a>b){


             printf("a > b\n");


             }


  else{


            printf("a == b\n");


         }


         return 0;


}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
   char a[51];
   int n;
   while(cin>>n)
   {
       int counttt=0;
       for(int i=1;i<=n;i++)
       {

           cin>>a[i];
       }
       for(int i=1;i<=n;i++)
       {

           if(a[i]=='A')
           {
               if(i==(n-1)||i==n)
               {
                   break;
               }
               else
               {

                   if(a[i+1]=='B')
                   {

                       if(a[i+2]=='C')
                       {

                           counttt++;
                       }
                   }
               }

           }
       }
       cout<<counttt<<'\n';
   }

}


Measured memory_bytes: 256
while True:
    inp = input().split()
    a = int(inp[0])
    b = int(inp[2])
    op = str(inp[1])
    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)
    else:
        break

Measured memory_bytes: 7656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    ll N,H,W;
    cin>>N>>H>>W;
    ll ans=0;
    vector<ll>A(N);
    vector<ll>B(N);
    rep(i,N){
        cin>>A[i];
        cin>>B[i];
        ans+=min(A[i]/H,B[i]/W);
    }
    cout<<ans<<endl;
}


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

const int N = 30;
const int dx[] = { 0, 0, 1, -1 };
const int dy[] = { 1, -1, 0, 0 };


char mp[N][N];
int dis[N][N];
queue< pair<int, int> > q;

int solve (int x, int y, int n, int m) {
	if (mp[x][y] == '#') return -1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			dis[i][j] = -1;
	dis[x][y] = 0;
	int ret = 0;
	q.push({ x, y });
	while (!q.empty()) {
		int ii = q.front().first;
		int jj = q.front().second;
		q.pop();
		ret = max(ret, dis[ii][jj]);
		for (int k = 0; k < 4; k++) {
			int i = ii + dx[k];
			int j = jj + dy[k];
			if (i < 1 || i > n || j < 1 || j > m || mp[i][j] == '#' || ~dis[i][j])
				continue;
			dis[i][j] = dis[ii][jj] + 1;
			q.push({ i, j });
		}
	}
	return ret;
}

int main (void) {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%s", mp[i] + 1);

	int ans = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			ans = max(ans, solve(i, j, n, m));
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void main_sub(void);
int main(int argc, char* argv[]) {
    main_sub();
    return 0;
}
// int を int64_t にする
// g++ に -DUSE_STRICT_INT をつけるか、
// 下のコメントアウトを外すと無効化
// #define USE_STRICT_INT
using i64 = int64_t;
#ifndef USE_STRICT_INT
#define int i64
#endif
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF = (1 << 30);
constexpr i64 INFL = (1LL << 62);
constexpr i64 MOD = 1000000007;
int n, u;
vector<int> w;
vector<int> v;
int dp[110][100100];
int search(int i, int ui) {
    if (i == n) {
        return 0;
    }
    if (dp[i][ui] != -1) {
        return dp[i][ui];
    }
    if (ui < w[i]) {
        return dp[i][ui] = search(i + 1, ui);
    } else {
        return dp[i][ui] =
                   max(search(i + 1, ui), search(i + 1, ui - w[i]) + v[i]);
    }
}

void main_sub(void) {
    cin >> n >> u;
    w.resize(n);
    v.resize(n);
    rep(i, n + 1) {
        rep(j, u + 1) { dp[i][j] = -1; }
    }
    rep(i, n) { cin >> w[i] >> v[i]; }
    cout << search(0LL, u) << endl;
    return;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int N, K; cin >> N >> K;
  vector<int> L(N);
  for (auto& l : L) { cin >> l; }
  std::sort(L.begin(), L.end(), std::greater<int>());
  auto ans = std::accumulate(L.begin(), L.begin()+std::min(N, K), 0LL);
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>

using namespace std;

double EPS = 1e-10;
const double PI = acos(-1);

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }

  point operator / (double d){
    return point(x/d,y/d);
  }
  
  bool operator == ( const point &p ) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

struct segment{
  point a,b;
};

double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

double cross(point a, point b) {
  return (a.x * b.y - a.y * b.x);
}

double dist(point a,point b){
  return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}

int is_point_on_line(point a, point b, point c) {
  return cross(b-a, c-a)==0.0 &&
         (dot(b-a, c-a) > -EPS) &&
         (dot(a-b, c-b) > -EPS);
}

int is_intersected_ls(point a1, point a2, point b1, point b2) {

  if(cross(a1-a2,b1-b2)==0){
    return is_point_on_line(a1,a2,b1) || is_point_on_line(a1,a2,b2) 
        || is_point_on_line(b1,b2,a1) || is_point_on_line(b1,b2,a2);
  }
  else {
    return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
           ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
  }
}

point intersection_ls(point a1, point a2, point b1, point b2) {
  point b = b2-b1;
  double d1 = abs(cross(b, a1-b1));
  double d2 = abs(cross(b, a2-b1));
  double t = d1 / (d1 + d2);

  return a1 + (a2-a1) * t;
}

int main(void){
  segment s[3];

  while(true){
    for(int i=0;i<3;i++){
      cin >> s[i].a.x >> s[i].a.y >> s[i].b.x >> s[i].b.y;
      if( s[i].a.x==0 && s[i].a.y==0 && s[i].b.x==0 && s[i].b.y==0)return 0;
      }
    
    int fg[3]={0};
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
	if(i!=j)
	  fg[i]+=is_intersected_ls(s[i].a,s[i].b,s[j].a,s[j].b);
      }
    }

    if(fg[0]==2 && fg[1]==2 && fg[2]==2){
      point p[3];
      for(int i=0;i<2;i++)
	    p[i]=intersection_ls(s[i].a,s[i].b,s[i+1].a,s[i+1].b);
      p[2]=intersection_ls(s[2].a,s[2].b,s[0].a,s[0].b);

      double z=(dist(p[0],p[1])+dist(p[1],p[2])+dist(p[2],p[0]))/2;
      double res=sqrt(z*(z-dist(p[0],p[1]))*(z-dist(p[1],p[2]))*(z-dist(p[2],p[0])));

      if(res>=1900000)cout <<"dai-kichi"<<endl;
      else if(res>=1000000 && res <1900000)cout <<"chu-kichi"<<endl;
      else if(res>=100000 && res<1000000)cout <<"kichi"<<endl;
      else if(res>0 && res<100000)cout << "syo-kichi"<<endl;
      else cout <<"kyo"<<endl;
    }
    else cout <<"kyo"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <tuple>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

using T = tuple<ll,ll>;
using Graph = vector<vector<T>>;

void bfs(Graph& g, T& start, vector<ll>& dist)
{
    queue<T> que;

    dist[get<0>(start)] = 0;
    que.push(start);

    while (que.size())
    {
        T t = que.front(); que.pop();
        int v = get<0>(t);
        for (T i : g[v])
        {
            int nv = get<0>(i);
            if (dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            que.emplace(i); 
        }
    }
}

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

    Graph g(4);
    rep(i,0,3)
    {
        ll from, to, w (0);
        cin >> from >> to;
        from--, to--;
        g[from].emplace_back(to, w);
        g[to].emplace_back(from, w);
    }

    T root;
    for (size_t i=0; i<g.size(); i++)
    { 
        if (g[i].size() == 1)
            root = T(i,0);
        break;
    }

    vector<ll> dist(g.size(), -1);
    bfs(g, root, dist);

    ll accm(0);
    for (auto i: dist)
        accm += i;

    if (accm != 0+1+2+3)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;

    return 0;
}


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

typedef long long ll;
typedef int ii;
//typedef vector<ll> vi;

#define INF 1000000007

#define pi 3.141592654

#define T while(t--)
#define for2(i,a,b) for(i=a;i>=b;i--)
#define for3(i,a,b) for(i=a;i<=b;i=i+2)
#define for1(i,a,b) for(i=a;i<=b;i++)
#define pb push_back
#define mp make_pair

#include<sstream>

#define si set<ll>
#define se multiset<ll>

typedef long double ld;

typedef vector<ll> vi;

#define bb(arr,nn,xx) upper_bound(arr,arr+nn,xx)-arr
#define aa(arra,nna,xxa) lower_bound(arra,arra+nna,xxa)-arra

#define all(v) sort(v.begin(),v.end())
 
#define all1(v) sort(v.rbegin(),v.rend())

ii main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);

    ll n,i; cin>>n; ll x,y; ll f=0,g=0;
    
    for1(i,1,n)
    {
    
        cin>>x>>y;
        
        if(x==y) f++;
      
        else f=0;
        
        if(f>=3) g++;
        
    }
    
    if(g>0) cout<<"Yes"<<"\n";
    
    else cout<<"No"<<"\n";
    
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

const int dx[]={0,-1,1,0},dy[]={-1,0,0,1};

int main(){

  ll n,k;cin>>n>>k;
  if((n-1)/2>=k-1)out("YES");
  else out("NO");


  return 0;
}


Measured memory_bytes: 256
mod=10**9+7
N,M=map(int,input().split())
A=[int(input()) for m in range(M)]
L=[1 for n in range(N+1)]
for a in A:
    L[a]=0
Block=[0,1]
for n in range(1,N+1):
    if L[n]:
        Block=Block[1:]+[sum(Block)%mod]
    else:
        Block=Block[1:]+[0]
print(Block[-1])

Measured memory_bytes: 7832
#include <bits/stdc++.h>
#include <atcoder/segtree>

using namespace std;

int op(int a, int b){
    return max(a, b);
}

int e(){
    return 0;
}

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> A(n);
    copy_n(istream_iterator<int>(cin), n, A.begin());

    const int m = 3e5;
    atcoder::segtree<int, op, e> seg(m + 1);

    for (auto &a: A){
        seg.set(a, seg.prod(max(0, a - k), min(m + 1, a + k + 1)) + 1);
    }

    cout << seg.all_prod() << endl;
}

Measured memory_bytes: 9596