akhauriyash/Code-Regression huggingface dataset:
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     ll n,m,i,j,k;
     cin>>n>>m;
     vector< pair<ll,ll> > v(m);
     for(i=0;i<m;i++) cin>>v[i].F>>v[i].S;
     if(n==1)
     {

       for(i=0;i<10;i++)
       {
         vector<ll> vv;
         vv.pb(i);
         bool ok=true;
         for(j=0;j<m;j++)
         {
           if(vv[v[j].F-1]!=v[j].S)
            ok=false;
         }
         if(ok) return cout<<i,0;
       }
       return cout<<-1,0;
     }
     else if(n==2)
     {
       for(i=10;i<100;i++)
       {
         ll num=i;
         vector<ll> vv;
         while(num!=0)
         {
          vv.pb(num%10);
          num/=10;
         }
         reverse(all(vv));
         bool ok=true;
         for(j=0;j<m;j++)
         {
           if(vv[v[j].F-1]!=v[j].S)
            ok=false;
         }
         if(ok) return cout<<i,0;
       }
       return cout<<-1,0;
     }
     else
     {
      for(i=100;i<1000;i++)
       {
         ll num=i;
         vector<ll> vv;
         while(num!=0)
         {
          vv.pb(num%10);
          num/=10;
         }
         reverse(all(vv));
         bool ok=true;
         for(j=0;j<m;j++)
         {
           if(vv[v[j].F-1]!=v[j].S)
            ok=false;
         }
         if(ok) return cout<<i,0;
       }
       return cout<<-1,0;
     }
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 256
N = int( input())
L = sorted( list( map( int, input().split())))

cnt = 0
for i in range( N ):
  for j in range( i + 1, N ):
    for k in range( j + 1, N ):
      if len( set([ L[i], L[j], L[k] ])) != 3:
        continue
      if L[i] + L[j] > L[k]:
        cnt += 1

print( cnt )

Measured memory_bytes: 9192
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
    char a[3];
    int a1=0,a2=0,a3=0;
    cin>>a;
    for(int i=0;i<3;i++)
    {
        if(a[i]=='a')
            a1++;
        else if(a[i]=='b')
            a2++;
        else if(a[i]=='c')
            a3++;
    }
    //printf("%d %d %d",a1,a2,a3);
    if(a1==1&&a2==1&&a3==1)
        printf("Yes");
    else printf("No");
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

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

int main() {
    int k, s;
    cin >> k >> s;

    int cnt = 0;

    rep3(x, k) {

        rep3(y, k) {
            int z = s - x - y;
            if (0 <= z && z <= k) cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}



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

long long int knapsack(int W, int wt[], long long int val[], int n){
	long long int k[n+1][W+1];
	for(int i=0; i<=n; i++){
		for(int j=0; j<=W; j++){
			if(i==0 ||j==0){
				k[i][j]=0;
			}
			else if(j>=wt[i-1]){
				k[i][j]= max(val[i-1]+k[i-1][j-wt[i-1]],k[i-1][j]);
			}
			else{
				k[i][j]=k[i-1][j];
			}
		}
	}
	return k[n][W];
}

int main(){
	int n,w;
	cin>>n>>w;
	int wt[n];
	long long int val[n];
	for(int i=0; i<n; i++){
		cin>>wt[i]>>val[i];
	}
	long long int res = knapsack(w, wt, val, n);
	cout<<res;
}

Measured memory_bytes: 82464
#include<stdio.h>

int main(){
 int a,b,c;
 scanf("%d",&a);
 scanf("%d",&b);
 scanf("%d",&c);

 if(a <= b && a <= c){
  printf("%d ",a);
  if(b <= c){
   printf("%d %d\n",b,c);
  }
  else{
   printf("%d %d\n",c,b);
  }
  return 0;
 }
 
 else if(b <= a && b <= c){
  printf("%d ",b);
  if(a <= c){
   printf("%d %d\n",a,c);
  }
  else{
   printf("%d %d\n",c,a);
  }
  return 0;
 }

 else{
  printf("%d ",c);
  if(b <= a){
   printf("%d %d\n",b,a);
  }
  else{
   printf("%d %d\n",a,b);
  }
  return 0;
 }
}


Measured memory_bytes: 2044
#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 n = 0;
  cin >> n;
  ll free = 0;
  map<ll,ll> mp;
  for(int i = 0;i < n;i++){
    ll r = 0;
    cin >> r;
    if(r >= 3200)free++;
    else mp[r / 400]++;
  }
  cout << max((ll)mp.size(),(ll)1) << " " << (ll)mp.size() + free << endl;
}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    ll ans=2*n;
    rep(i,1,n+1){
        if(s.substr(n-i,i)==t.substr(0,i)) ans=2*n-i;
    }
    cout<<ans<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n
a1 ... an

n 10000
ai 10^9
 */
int n, a[10000];

int main(){
  cin>>n;
  int ans=0;
  REP(i,n){
    cin>>a[i];
    while(a[i]%2==0){
      a[i] /= 2;
      ans++;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main() {
	int a=0,b=0;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		int n = s.size();
		a += s[i] - '0';
		b += pow(10, n-1-i) * (s[i] - '0');
	}
	if (b % a == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-

N = int(input())
X = list(map(int, input().split()))

min = 100*100*100
for i in range(1, 101):
    sum = 0
    for j in range(N):
        val = (X[j]-i)*(X[j]-i)
        sum += val
    if min > sum:
        min = sum
print(min)


Measured memory_bytes: 2940
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    unused_imports,
    dead_code
)]
//use proconio::fastout;
use proconio::input;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
//use std::collections::VecDeque;

fn main() {
    input! {
       T:usize
    }

    for _ in 0..T {
        input! {
            N:usize,
            KLR:[(usize,i64,i64);N]
        }
        let mut ans = 0;
        let mut KL = Vec::with_capacity(N);
        let mut KR = Vec::with_capacity(N);
        for &(K, L, R) in KLR.iter() {
            if L >= R {
                KL.push((K, L, R));
            } else {
                KR.push((N - K, R, L));
            }
        }
        let n = KL.len();
        let ans1 = camel(KL);
        let ans2 = camel(KR);
        let ans = ans1 + ans2;
        println!("{}", ans);
    }
}

fn camel(mut KLR: Vec<(usize, i64, i64)>) -> i64 {
    let mut ans = 0;
    let minimum = KLR.iter().fold(0, |s, (_, _, a)| s + a);
    KLR.sort(); // Kの順
    let n = KLR.len();
    let mut s = BinaryHeap::new();
    let mut j = n;
    for i in (1..=n).rev() {
        while j > 0 {
            //println!("K{:?}", KLR[j - 1]);
            if i <= KLR[j - 1].0 {
                s.push(KLR[j - 1].1 - KLR[j - 1].2);
                j -= 1
            } else {
                break;
            }
        }
        //println!("{:?}", s);
        if let Some(v) = s.pop() {
            ans += v;
        }
    }
    return minimum + ans;
}


Measured memory_bytes: 16132
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int a,b;
signed main()
{
	cin>>n>>a>>b;
	int ans1=n/(a+b)*a,ans2=n/(a+b)*b;
	if(n%(a+b)<=a)
		ans1+=n%(a+b);
	else
		ans1+=a,ans2+=n%(a+b)-a;
	printf("%lld",ans1);
	return 0;
}


Measured memory_bytes: 256
n = int(input())
A = [list(map(int,input().split())) for i in range(n-1)]
q, k = map(int,input().split())
X = [list(map(int,input().split())) for i in range(q)]

M = [[] for i in range(n+1)]
V = [0] * (n+1)
D = [0] * (n+1)

for i in range(n-1):
    M[A[i][0]].append([A[i][1], A[i][2]])
    M[A[i][1]].append([A[i][0], A[i][2]])

#print(M)

def d(x, dist):
    V[x] = 1
    D[x] = dist
    #print(M[x])
    for i in range(len(M[x])):
        #print(M[x][i][0])
        if V[M[x][i][0]] == 0:
            #print("V")
            Q.append([M[x][i][0], dist+M[x][i][1]])

Q = [[k, 0]]

st = 0
while st < len(Q):
    #print(st)
    d(Q[st][0], Q[st][1])
    st += 1

for i in range(q):
    print(D[X[i][0]] + D[X[i][1]])

Measured memory_bytes: 127704
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0;i < N;i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end(),greater<int>());
    int ans = 0;
    for(int i = 0;i < N;i++){
        ans += (i & 1 ? -A[i] : A[i]); 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	maximumProfit()
}

var sc = bufio.NewScanner(os.Stdin)

//func nextLine() string {
//	sc.Scan()
//	return sc.Text()
//}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maximumProfit() {
	n := nextInt()

	s := make([]int, n)
	for i := range s {
		v := nextInt()
		s[i] = v
	}

	maxV := -2000000000
	minV := 2000000000
	for _, v := range s {
		if m := v - minV; maxV < m {
			maxV = m
		}
		if v < minV {
			minV = v
		}
	}
	//for i := 1; i < n; i++ {
	//	if m := s[i] - minV; maxV < m {
	//		maxV = m
	//	}
	//	if s[i] < minV {
	//		minV = s[i]
	//	}
	//}

	fmt.Println(maxV)
}


Measured memory_bytes: 5384
import java.util.*;
import java.io.*;

public class Main {

    private static int solver(int a, int b, int t){
        return b * (t / a);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        System.out.println(solver(in.nextInt(), in.nextInt(), in.nextInt()));
    }
}


Measured memory_bytes: 22612
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


ll f(int n){
    ll sum = 0;
    while(n > 0){
        sum += n%10;
        n /= 10;
    }
    ret sum;
}

int main(){
    int n;
    cin >> n;
    
    (n % f(n) == 0) ? Yes : No;

    
	return  0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int gcd(int a, int b){
	if (a < b) swap(a, b);
	return (b == 0) ?  a :  gcd(b, a%b);

}
int main(){
	int a, b; scanf("%d%d", &a, &b);
	printf("%d\n", gcd(a, b));
}


Measured memory_bytes: 3188
#include <cstdio>

int main(){
	int n;
	while(scanf("%d",&n),n){
		int ans = 0;
		for(int i = 1; i < n; i++){
			int t = i;
			for(int j = 1;;j++){
				t += (i+j);
				if(t >= n){
					if(t == n) ans++;
					break;
				}
			}
		}
		printf("%d\n", ans);
	}
}

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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMinimum(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMaximum(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */

int main() {
    string O, E;
    cin >> O >> E;
    int M;
    bool f = false;
    if (O.length() == E.length()) {
        M = O.length();
    } else {
        M = O.length() - 1;
        f = true;
    }

    for (int i = 0; i < M; ++i) {
        cout << O[i];
        cout << E[i];
    }
    if (f) { cout << O[M]; }
    cout << endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm, std.range;
void main() {
	int n;
	while ("%d\n".readf(&n))
		format("%b",n).retro.map!(to!int).map!"a-48".enumerate.map!"2^^a[0]*a[1]".filter!"a>0".map!(to!string).join(" ").writeln;
}

Measured memory_bytes: 2552
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    cout << (a > 0 ? b / x - (a - 1) / x : b / x + 1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

int main(){
  int n,pay;
  int m[4],p[5]={10,50,100,500,9999999},cm[4];
  bool b=true;
  while(1){
    
    cin>>n;
   
    pay=0;
    if(n==0) break;
     if(b) b=false;
    else cout<<endl;
    rep(i,4){
      cm[i]=0;
      cin>>m[i];
      pay+=m[i]*p[i];
    }
    pay-=n;
    //cout<<pay<<endl;
    repn(i,3){
      while(pay>=p[i] && pay%p[i+1]){
	pay-=p[i];
	m[i]--;
	//cout<<pay<<endl;
      }
    }
    rep(i,4){
      if(m[i]>0) cout<<p[i]<<" "<<m[i]<<endl;
    }
    //cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 2984
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
 
int main(void){
   int n;
   cin >> n;
   int a[n];
   int b[n];
   for(int i = 0; i < n; i++)
    cin >> a[i];
   int count = 0;
   int check=0;
    while(count<n){
        if(count%2==0)
            check=count/2;
        else if(count%2!=0)
            check=(n-1)-(count/2);
        b[check]=a[(n-1)-count];
        count++;
    }
    for(int i = 0; i < n; i++)
        cout << b[i] << ' ';
    cout << endl;
    return 0;
}

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

using namespace std;

int a[200005][20], b[200005][20];
int n, k;
int lg2[200005];
int f[200005];
int qmin(int l, int r){
	int len = r - l + 1;
	return min(a[l][lg2[len]], a[r - (1 << lg2[len]) + 1][lg2[len]]);
}

int qmax(int l, int r){
	int len = r - l + 1;
	return max(b[l][lg2[len]], b[r - (1 << lg2[len]) + 1][lg2[len]]);
}
int main(){
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; i ++){
		scanf("%d", &a[i][0]);
		b[i][0] = a[i][0];
		if(a[i][0] >= a[i - 1][0]) f[i] = f[i - 1] + 1;
		else f[i] = 1;
	}
	int N = 2, t = 0;
	for(int i = 1; i <= n; i ++){
		if(i >= N){
			t ++; N <<= 1;
		}
		lg2[i] = t;
	}
	for(int j = 1; (1 << j) <= n; j ++){
		for(int i = 1; i + (1 << j) - 1 <= n; i ++){
			a[i][j] = min(a[i][j - 1], a[i + (1 << (j - 1))][j - 1]);
			b[i][j] = max(b[i][j - 1], b[i + (1 << (j - 1))][j - 1]);
			
		}
	}
	int t1 = 1, tn = 1;
	int ct = 0;
	int flag = 1;
	for(int i = 1; i + k - 1 <= n; i ++){
		int mn = qmin(i, i + k - 1);
		int mx = qmax(i, i + k - 1);
		int r1 = mn == a[i][0] ? 0 : 1;
		int rn = mx == a[i + k - 1][0] ? 0 : 1;
		if(t1 || rn){
			if(rn || f[i + k - 1] < k || flag){	
				ct ++;
			}
			if(f[i + k - 1] == k){
				flag = 0;
			}
		}
		t1 = r1; tn = rn;
	}
	printf("%d\n", ct);
	return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,m;cin>>n>>m;
  vector<vector<char>> a(n,vector<char>(m));
  int i,j;
  rep(i,n)rep(j,m)cin>>a[i][j];
  vector<vector<char>> b(n,vector<char>(m));
  rep(i,n)rep(j,m)cin>>b[i][j];
  int ans=0;
  rep(i,n)rep(j,m)
  {
    if(a[i][j]!=b[i][j])ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 10760
#include<bits/stdc++.h>
using namespace std;
int main(){
  int d,g;
  cin>>d>>g;
  int m=0;
  vector<int> p(d);
  vector<int> c(d);
  for(int i=0;i<d;i++){
    cin>>p.at(i)>>c.at(i);
    m+=p.at(i);
  }
  for(int i=0;i<(1<<d);i++){
    int x=i;
    vector<int> b(d);
    for(int j=0;j<d;j++){
      b.at(j)=x%2;
      x/=2;
    }
    int n=0;
    int s=0;
    for(int j=0;j<d;j++){
      n+=p.at(j)*b.at(j);
      s+=(100*(j+1)*p.at(j)+c.at(j))*b.at(j);
    }
    for(int j=d-1;j>=0&&s<g;j--){
      if(b.at(j))
        continue;
      if(s+100*(j+1)*p.at(j)<=g){
        n+=p.at(j);
        s+=100*(j+1)*p.at(j)+c.at(j);
        continue;
      }
      n+=(g-s+100*(j+1)-1)/(100*(j+1));
      s+=(g-s+100*(j+1)-1)/(100*(j+1))*100*(j+1);
    }
    if(s<g)
      continue;
    m=min(m,n);
  }
  cout<<m<<endl;
}

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

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

  int m[N];
  int min_need = 1001;
  int sum = 0;
  for ( int i = 0; i  < N; i++ ){
    cin >> m[i];
    min_need = min(min_need, m[i]);
    sum += m[i];
  }

  int ans = (X - sum) / min_need + N;
  
  cout << ans << endl;
  

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

unsigned long long int a = 0, b = 0, c = 1, x = 0, y = 0, z = 0, maxy = -1, mini = 9999, counter = 0, startp = 0, endp = 0, checker = 0;
std::vector<std::string> vec{}, vecsec{};
int iremono[100001];
std::vector<long long int>kinds{}, ans{}, kaku{};
char moji, moji2;
bool okada = false, okada2 = false;
std::string output, output2, input, one, two;
char cutcount[201];
int kakunou2[50][50] = {};
unsigned long long int M, A, R, C, H;

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int main()
{

	cin >> a;
	for (int i = 6; i <= 55555; i += 5) {
		x = 0;
		for (int j = 1; j <= i; j++) {
			if (i%j == 0) {
				x++;
			}
		}
		if (x == 2) {
			cout << i << " ";
			counter++;
		}
		if (counter == a) {
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<queue>
#include<string.h>
#include<cstring>
#include<vector>
#include<time.h>
#include<stdlib.h>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define FIN freopen("input.txt","r",stdin)
#define mem(x,y) memset(x,y,sizeof(x))
typedef unsigned long long ULL;
typedef long long LL;
#define MX 11111111
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
typedef pair<pair<int,int>,int> PIII;
typedef pair<int,int> PII;
int n;
char s[MX],ss[MX],p[2]= {'S','W'};
bool check(char *ss)
{
    ss[n]=0;
    for(int i=0; i<2; i++)
        for(int j=0; j<2; j++)
        {
            ss[0]=p[i];
            ss[1]=p[j];
            for(int k=1; k<n-1; k++)
            {
                if(ss[k]=='S')
                {
                    if(s[k]=='o')
                    {
                        if(ss[k-1]=='S')ss[k+1]='S';
                        else ss[k+1]='W';
                    }
                    else
                    {
                        if(ss[k-1]=='S')ss[k+1]='W';
                        else ss[k+1]='S';
                    }
                }
                else
                {
                    if(s[k]=='o')
                    {
                        if(ss[k-1]=='S')ss[k+1]='W';
                        else ss[k+1]='S';
                    }
                    else
                    {
                        if(ss[k-1]=='S')ss[k+1]='S';
                        else ss[k+1]='W';
                    }
                }

            }
            int cnt=0;
            if(ss[n-1]=='S')
            {
                if(s[n-1]=='o')
                {
                    if(ss[n-2]==ss[0])cnt++;
                }
                else
                {
                    if(ss[n-2]!=ss[0])cnt++;
                }
            }
            else
            {
                if(s[n-1]=='o')
                {
                    if(ss[n-2]!=ss[0])cnt++;
                }
                else
                {
                    if(ss[n-2]==ss[0])cnt++;
                }
            }
            if(ss[0]=='S')
            {
                if(s[0]=='o')
                {
                    if(ss[n-1]==ss[1])cnt++;
                }
                else
                {
                    if(ss[n-1]!=ss[1])cnt++;
                }
            }
            else
            {
                if(s[0]=='o')
                {
                    if(ss[n-1]!=ss[1])cnt++;
                }
                else
                {
                    if(ss[n-1]==ss[1])cnt++;
                }
            }
            if(cnt==2) return 1;
        }
    return 0;
}
int main()
{
    //freopen("output2.txt","w",stdout);

    scanf("%d",&n);
    {
        scanf("%s",&s);
        if(check(ss)) printf("%s\n",ss);
        else puts("-1");

    }
    return 0;
}


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

int main(){
  int H,N,sum=0;
  cin>>H>>N;
  
  int A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
    sum+=A[i];
  }
  if(sum>=H){
    cout<<"Yes";
  }else{cout<<"No";}
}

Measured memory_bytes: 640
n, m = map(int, input().split())
par = list(range(n))
size = [1] * n
def find(x):
    """ 根のノードの値を見つけて返す """
    if x != par[x]:
        par[x] = find(par[x])
    return par[x]

def unite(x, y):
    rootx = find(x)
    rooty = find(y)

    if rootx == rooty:
        return False
    else:
        if size[rootx] < size[rooty]:
            par[rootx] = rooty
            size[rooty] += size[rootx]
        else:
            par[rooty] = rootx
            size[rootx] += size[rooty]
        return True

def same(x, y):
    """ xとyが同じ集合に属しているか """
    return find(x) == find(y)

for _ in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    unite(a, b)

print(max(size))


Measured memory_bytes: 76464
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int a, b, c, d;
	cin >>a >> b >> c >> d;
	if (abs(c - a) <= d || (abs(b - a) <= d && abs(c - b) <= d))print("Yes");
	else print("No");
}

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

using namespace std;

int arr[100010];

int main()
{
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);

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

    sort(arr, arr + n);

    vector<pair<int, int>> v;
    int p = 0;
    for(i = 0; i < n; i++)
    {
        if(i == n - 1 || arr[i] != arr[i + 1])
        {
            v.push_back({ arr[i], i - p + 1 });
            p = i + 1;
        }
    }

    int sz = v.size();
    int t = n - sz;
    int r;
    if(t % 2 == 0)
        r = sz;
    else
        r = sz - 1;

    printf("%d\n", r);
    return 0;
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

ll acum[4][110];

int main() {
    int n; ll W;
    cin >> n >> W;
    vector<vector<ll>> t(4);

    ll w0;
    rep(i, n) {
        ll w, v; cin >> w >> v;
        if (i == 0) {
            w0 = w;
            t[0].push_back(v);
        } else {
            t[w-w0].push_back(v);
        }
    }

    rep(i, 4) sort(all(t[i]), greater<ll>());
    rep(i, 4) rep(j, t[i].size()) acum[i][j+1] = acum[i][j] + t[i][j];

    ll ans = -1;
    rep(i, t[0].size()+1) {
        rep(j, t[1].size()+1) {
            rep(k, t[2].size()+1) {
                rep(l, t[3].size()+1) {
                    if (w0*i + (w0+1)*j + (w0+2)*k + (w0+3)*l > W) continue;
                    ll sum = acum[0][i] + acum[1][j] + acum[2][k] + acum[3][l];
                    chmax(ans, sum);
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
//単語を読みとる　小文字化　照合 cntを＋＋

int main(){
    char w[10]={};
    char end[11]="END_OF_TEXT";
    scanf("%s",w);
    int i,cnt=0;
    while(1){
        char t[1000]={};
        scanf("%s",t);
        
        if(strcmp(t,"END_OF_TEXT") == 0)break;
        if (strcmp(t, "END_OF_TEXT\n") == 0) break;
        for(i=0;i<strlen(t);i++)
            t[i]=tolower(t[i]);
        
        if(strcmp(t,w)==0)
            cnt++;

    }
    printf("%d\n",cnt);
    
}



Measured memory_bytes: 2072
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	int n; cin >> n;
	set<string> dic; dic.clear();
	rep (i, n ){
		string com = "", val = "";
		cin >> com >> val; 
		if (com == "insert" ){
			dic.insert (val );
		}else{	// if (com == "find" )
			if (dic.count (val ) ){
				cout << "yes" << endl;
			}else{
				cout << "no" << endl;
			} // end if
		} // end if
	} // end loop
		
	return 0;
}

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

pt = [[0] * (M+100) for i in range(70)]
to = [[0] * (M+100) for i in range(70)]
for i in range(M+1):
    to[0][i] = (i*i) % M
    pt[0][i] = i

for i in range(65):
    for j in range(M+1):
        to[i+1][j] = to[i][to[i][j]]
        pt[i+1][j] = pt[i][j] + pt[i][to[i][j]]

ans = 0
for i in range(60):
    if (N>>i)&1:
        ans += pt[i][X]
        X = to[i][X]

print(ans)


Measured memory_bytes: 341488
#abc101d

def f(n):
 s=0
 for t in str(n):
  s+=int(t)
 return 1.0*int(n)/s

k=int(raw_input())
x,y=1,1
for i in xrange(k):
 print x
 if f(x+10**(y-1))>f(x+10**(y)):
  y+=1
 x+=10**(y-1)


Measured memory_bytes: 2568
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a+b<10)cout<<a+b<<"\n";
    else cout<<"error"<<"\n";
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        double sum = 0;
        for (int i = 0; i < n; i++) {
            sum += 1.0 / sc.nextDouble();
        }

        System.out.print(1 / sum);
    }
}

Measured memory_bytes: 25172
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>
#include <numeric>

using namespace std;

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

    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    vector<int> ans(N, 0);
    int cnt = 0;
    for (int i = N; i > 0; i--) {
        int sum = 0;
        for (int j = 1; i*j <= N; j++) {
            // cout << "i*j: " << i*j << endl;
            sum += ans[(i*j)-1];
        }
        // cout << endl;
        if (a[i-1] != sum%2) {
            cnt++;
            ans[i-1] = 1;
        }
    }

    cout << cnt << endl;
    if (cnt != 0) {
        for (int i = 0; i < N; i++) {
            if (ans[i] == 1) {
                cout << i+1 << " ";
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 2560
#include<iostream>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
inline ll qpow(ll a,ll n){
    ll res=1;
    while(n){
        if(n&1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

int n,m;
ll ans,f[500005]={1},inv[500005]={1};

int main(){
    for(int i=1;i<=5e5;i++){
        f[i]=f[i-1]*i%mod;
        inv[i]=qpow(f[i],mod-2);
    }
    cin>>n>>m;
    for(int i=0;i<=n;i++){
        ans=(ans+f[n]*inv[i]%mod*inv[n-i]%mod*((i&1)?-1:1)*f[m-i]%mod*inv[m-n]%mod)%mod;
    }
    for(int i=m-n+1;i<=m;i++)ans=ans*i%mod;
    cout<<(ans+mod)%mod<<endl;

    return 0;
}

Measured memory_bytes: 11444
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int n, k; cin >> n >> k;

    int d[k];
    for(int i=0; i<k; i++){
        cin >> d[i];
    }

    vector<int> vgood;
    for(int i=0; i<10; i++){
        for(int j=0; j<k; j++){
            if(i == d[j]){
                break;
            }
            if(j == k-1){
                vgood.push_back(i);
            }
        }
    }

    int ngood = vgood.size();

    int ntemp = n;
    int nprice = 0;
    vector<int> price;
    while(ntemp > 0){
        nprice++;
        price.push_back(ntemp%10);
        ntemp /= 10;
    }

    reverse(price.begin(), price.end());

    vector<int> ans;
    bool same = true;
    bool ngflag = false;
    for(int i=0; i<nprice; i++){
        if(same == false){
            ans.push_back(vgood[0]);
            continue;
        }
        for(int j=0; j<ngood; j++){
            if(price[i] == vgood[j]){
                ans.push_back(vgood[j]);
                break;
            }
            if(price[i] < vgood[j]){
                ans.push_back(vgood[j]);
                same = false;
                break;
            }
            if(j == ngood-1){
                ngflag = true;
                break;
            }
        }
        if(ngflag){
            break;
        }
    }

    if(ngflag){
        ans.clear();
        if(vgood[0] == 0){
            ans.push_back(vgood[1]);
        }
        else{
            ans.push_back(vgood[0]);
        }
        
        for(int i=0; i<nprice; i++){
            ans.push_back(vgood[0]);
        }
    }

    for(auto x : ans){
        cout << x;
    }

    return 0;
}

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

int main() {
    string S;
    cin >> S;
    int value = 99999999;
    for(int i = 0; i < S.length()-2; i++) {
        int tmp =  abs(753-((int(S[i])-48)*100 + (int(S[i+1]) - 48)*10 + int(S[i+2])-48));
        value = min(value, tmp);
    }
    cout << value << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val k = sc.nextInt                 // 入力Aを受け付けて、aに格納する
  val a = sc.nextInt                 // 入力Bを受け付けて、bに格納する
  val b = sc.nextInt                 // 入力Cを受け付けて、cに格納する
  //println(((k+a-1)/a)*a)
  val res = if((k+a-1)/k*k>b)"NG"else"OK"

  println(res)                       // 結果を出力する
}

Measured memory_bytes: 55416
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <numeric>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    ll p=1;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for(int i=0;i<n;i++){
        if(a[i]==0||p==0){
            p=0;
        }
        else if(1e18/p>=a[i]){
            p*=a[i];
        }
        else{
            printf("-1\n");
            return 0;
        }
    }
    if(p>(ll)1e18){
        printf("-1\n");
        return 0;
    }
    printf("%lld\n",p);
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sgn(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;

    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, H, W;
int A[1100], B[1100];
signed main() {
    cin >> N >> H >> W;
    int ans = 0;
    rep(i, N) {
        cin >> A[i] >> B[i];
        if (A[i] >= H && B[i] >= W) { ans++; }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
#include<stdio.h>
int main(void)
{
	int t,n,i,wa[5];
	for(i=1;i<=4;i++){
		scanf("%d %d",&t,&n);
		if(t==1){
			wa[i]=6000*n;
		}
		else if(t==2){
			wa[i]=4000*n;
		}
		else if(t==3){
			wa[i]=3000*n;
		}
		else if(t==4){
			wa[i]=2000*n;
		}
	}
	for(i=1;i<=4;i++){
		printf("%d\n",wa[i]);
	}
	return 0;
}

Measured memory_bytes: 600
import java.io.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        int x=sc.nextInt();
        int y=sc.nextInt();
        //int x=3,y=4;
        int h=sc.nextInt();
        int m=sc.nextInt();
        double ans=Math.abs(30*h+m/2.0-6*m);
        if(ans>180)
            ans=360-ans;
        //System.out.println(ans);
        if(ans==180)
            System.out.println(x+y);
        else if(ans==0)
            System.out.println(Math.abs(x-y));
        else{
            double a = Math.toRadians(ans);
            //System.out.println(Math.cos(a));
            double p=x*x+y*y-2*x*y*Math.cos(a);
            //System.out.println(p);
            p=Math.sqrt(p);
            System.out.println(p);
        }




    }
}


Measured memory_bytes: 36000
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

int main(){
	int a,b;
	
	cin >> a >> b;
	
	if(9 >= a && 9 >= b){
		cout << a*b << endl;
	}else cout << -1 << endl;
	
	
	return 0;
}

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

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

  ll N;
  cin >> N;
  vector<pair<ll,ll>> A(N);
  for(ll i=0; i<N; ++i) {
    cin >> A[i].first;
    A[i].second = i;
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  
  vector<vector<ll>> dp(N+1, vector<ll>(N+1));
  
  for(ll i=0; i<=N-1; ++i) for(ll j=0; j<=i+1; ++j){
    if(j<=i) dp[i+1][j] = max(dp[i+1][j], dp[i][j] + A[i].first * (N-1-i+j - A[i].second));
    if(j>=1) dp[i+1][j] = max(dp[i+1][j], dp[i][j-1] + A[i].first * (A[i].second - (j-1)));
  }
  
  ll ans = dp[N][0];
  for(ll i=1; i<=N; ++i) ans = max(ans, dp[N][i]);
  
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 34588
#include <stdio.h>

#define MAX_REG 30

int main()
{
  int w, n;
  int i;
  int ver[MAX_REG] = {};

  scanf("%d", &w);
  scanf("%d", &n);

  for(i = 0; i < w; i++)
    ver[i] = i + 1;

  for(i = 0; i < n; i++)
    {
      int sw1, sw2;
      int tmp;

      scanf("%d,%d", &sw1, &sw2);
      tmp = ver[sw1 - 1];
      ver[sw1 - 1] = ver[sw2 - 1];
      ver[sw2 - 1] = tmp;
    }
  for(i = 0; i < w; i++)
    printf("%d\n", ver[i]);
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <ctime>
#include <queue>
#include <vector>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <stdio.h>
#include <assert.h>  
#include <unordered_map>  
#include <string.h>
#include <algorithm>
 
using namespace std;
 
typedef long long ll;
 
#define y1 needtrainharder
#define f first
#define s second
#define gg exit(0)
#define sz() size()
#define pb push_back
#define mp make_pair
#define skip continue
#define all(x) x.begin(), x.end()
#define alln(x, y) x, x + y
#define boost ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define file(s) if(fopen(task".in", "r"))freopen(s".in","r",stdin),freopen(s".out","w",stdout);
#define task "sorting"    
 
const int inf = 1e9 + 5;  
const ll infll = 1e18 + 5ll;  
const long double eps = 1e-9;
const long double pi = acos(-1);
const int maxn = 3e5;
const ll maxlog = 21;
const int P = 97;
const int mod = 1e9 + 7;   
const int block = 707;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

int n, a[maxn], dp[maxn], k;

int main() {
  file(task); 
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    dp[i] = inf;
  }
  dp[1] = 0;
  dp[0] = inf;
  for (int i = 2; i <= n; ++i) {
    for (int j = 1; j <= min(i, k); ++j) {
      dp[i] = min({dp[i], dp[i - j] + abs(a[i - j] - a[i])});
    }
  }
  cout << dp[n];
  return 0;
}
/*





*/

Measured memory_bytes: 1024
void main(){
	int x,n;
	bool[int] p;
	readf("%d %d\n", &x, &n);
	foreach(elm; _scanln()){
		p[elm] = true;
	}
	int min = 100000; // ある整数とansの差
	int ans = 0;

	foreach(i; 0..102){
		if(min > abs(i-x) && !p.get(i, false)){
			min = abs(i-x);
			ans = i;
		}
	}
	writeln(ans);
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

int main(){
    long long a,v,b,w,t; cin >> a >> v >> b >> w >> t;
    if (w-v >= 0)
    {
        cout << "NO" << endl;
    }
    
    else if ((abs(a-b)+abs(v-w)-1)/abs(v-w)<=t)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
    
}

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

int main(){
	ll k,now=7;
	cin>>k;
	for(int i=0;i<k;i++){
		if(now%k==0){
			cout<<i+1<<endl;
			return 0;
		}else{
			now=(10*now+7)%k;
			continue;
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 3592
N = int(input())
A = [int(i) for i in input().split()]

d = {
    "4":0,
    "2":0,
    "1":0
}

for i in A:
  if i%4==0:
    d["4"] += 1
  elif i%2==0:
    d["2"] += 1
  else:
    d["1"] += 1

if d["1"] == 0:
  print("Yes")
elif d["1"] <= d["4"]:
  print("Yes")
elif d["1"] + -(-d["2"]//2) - 1 <= d["4"]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14252
#include<stdio.h>
int main(){
  int m=0,s=0,a,n;
  scanf("%d",&n);
  while(n--){
    scanf("%d",&a);
    if(m<a)m=a;
    s+=a;
  }
  printf("%s\n",s>m+m?"Yes":"No");
  return 0;
}


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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mod 1000000007
#define endl "\n"
#define all(a) (a).begin(),(a).end()
#define lp(i,a,b) for(i=a;i<b;i++)
#define lpr(i,a,b) for(i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;

int main(){

  /*#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif*/

  fast;
  int i,j,q,n,k,x,m,a,b,tc;
  
  cin>>n>>m;
  int count=0,sum=0,arr[n];
  lp(i,0,n){ 
    cin>>arr[i];
    sum+=arr[i];
  }
  double score=(1.0/(4.0*m))*sum;
  lp(i,0,n){
    if(arr[i]>=score){
      count++;
    }
  }
  cout<<( (count>=m)?"Yes":"No" )<<endl;
  return 0;
}  


Measured memory_bytes: 256