akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int x;
    cin >> x;
    int lb = 0, ub = x;
    while(ub - lb > 1){
        int mid = (lb + ub) / 2;
        ll foo = (ll)mid * (mid + 1) / 2;
        if(foo >= x)    ub = mid;
        else    lb = mid;
    }
    cout << ub << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k; cin >> n >> k;
  vector<ll> a(n);
  ll sum = 0;
  rep(i,n){
      cin >> a[i];
      sum += a[i];
  }
  vector<ll> mo;
  FOR(i,1,sum){
      if(i*i>sum)break;
      if(sum%i==0){
          mo.push_back(i);
          if(sum!=i*i) mo.push_back(sum/i);
      }
  }
  sort(all(mo));
  reverse(all(mo));
  rep(i,mo.size()){
      ll tmp = mo[i];
      ll mod= 0;
      rep(j,n){
          mod += a[j]%tmp;
      }
      if(mod%tmp!=0){
          continue;
      }else{
          priority_queue<ll> q;
          rep(j,n){
              if(a[j]%tmp!=0)q.push(-(tmp-a[j]%tmp));
          }
          ll sumtmp = 0;
          rep(j,mod/tmp){
              sumtmp -=q.top();
              q.pop();
          }
          if(sumtmp<=k){
              cout << tmp << endl;
              return 0;
          }
      }
  }

}

Measured memory_bytes: 256
#include "stdio.h"
int main(void) {
  int N;
  int i;
  int MAX, MIN;
  scanf("%d", &N );
  int a[N + 1];
  for (i = 1; i <= N; i++) {
    scanf("%d", &a[i] );
  }
  MAX = a[1];
  MIN = a[1];
  for (i = 2; i <= N; i++) {
    if (MAX < a[i]) MAX = a[i];
    if (MIN > a[i]) MIN = a[i];
  }
  printf("%d\n", MAX - MIN);
  return 0;
}


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

#define PI 3.141592653589
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector
int MOD=1e9+7;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll min(ll a,ll b){return (a>b)?b:a;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime[1000001];
vi primes;
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for(int p=2;p<1000001;p++)
        if(prime[p])
            primes.pb(p);
}
ll fact[1001];
void factorial(int n){
    fact[0]=1;
    for(int i=1;i<=n;i++)
        fact[i]=fact[i-1]*i,fact[i]%=MOD;
}
ll ncr(ll n,ll r)
{
    if(n<r)
        return -1;
    else{
        ll x=fact[r]*fact[n-r]%MOD;
        return fact[n]*fermat_inv(x)%MOD;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int t=1;
    //cin>>t;
    //SieveOfEratosthenes(1000000);
    //factorial(1000);
    while(t--){
        int n,m,k;
        cin>>n>>m>>k;
        ii a[k];
        map<ii,int>pts;
        map<int,int>r,c;
        for(int i=0;i<k;i++){
            cin>>a[i].ff>>a[i].ss;
            pts[a[i]]++;
            r[a[i].ff]++;
            c[a[i].ss]++;
        }
        ll ans=0;
        int mx=0,my=0;
        vi ri,ci;
        for(auto a:r){
            if(a.ss>mx){
                mx=a.ss;
                ri.clear();
                ri.pb(a.ff);
            }
            else if(a.ss==mx)
                ri.pb(a.ff);
        }
        for(auto a:c){
            if(a.ss>my){
                my=a.ss;
                ci.clear();
                ci.pb(a.ff);
            }
            else if(a.ss==my)
                ci.pb(a.ff);
        }
        bool b=false;
        for(int i:ri){
            for(int j:ci){
                if(!pts[{i,j}]){
                    b=true;
                    break;
                }
            }
            if(b)
                break;
        }
        if(b)
            cout<<mx+my;
        else
            cout<<mx+my-1;
    }
}

Measured memory_bytes: 56656
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    A = LIST()

    ans = [0] * (N - 1)
    for a in A:
        ans[a-1] += 1

    ans.append(0)
    print(*ans,  sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 33836
X, N = [int(n) for n in input().split()]

P = set(int(n) for n in input().split())

closest = float('inf')
diff = float('inf')

for p in range(-1,102):
    if not p in P and abs(X - p) < diff:
        closest = p
        diff = abs(X - p)

print(closest)

Measured memory_bytes: 9184
#include<stdio.h>
int main()
{
	long long int n,m;
	scanf("%lld %lld",&n,&m);
	long long int sum;
	sum = n;
	if(m == 1|| m == 2 && n == 0)
	{
		printf("0\n");
	}
	else
	{
		if(n * 2 < m)
		{
			m = m - sum * 2;
			if(m >= 4)
			{
			sum += m / 4;
			printf("%lld\n",sum);
			}
			else
			{
				printf("%lld\n",sum);
			}
		}
		else if(n * 2 >= m)
		{
			printf("%lld\n",m / 2);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
using namespace std;
int r[86401], n, h1, m1, s1, h2, m2, s2;
int main() {
	while (~scanf("%d", &n)) {
		if (n == 0) break;
		for (int i = 0; i <= 86400; i++) r[i] = 0;
		for (int i = 0; i < n; i++) {
			scanf("%02d:%02d:%02d %02d:%02d:%02d", &h1, &m1, &s1, &h2, &m2, &s2);
			r[h1 * 3600 + m1 * 60 + s1]++;
			r[h2 * 3600 + m2 * 60 + s2]--;
		}
		int ret = 0, sum = 0;
		for (int i = 0; i <= 86400; i++) {
			sum += r[i];
			ret = max(ret, sum);
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 3088
#include <iostream>
using namespace std;
int main(void) {
  int n, x, y, h, w;
  int sum;
  while(cin >> n, n!=0) {
    sum = 0;
    for(int i = 0 ; i < n ; i++) {
      cin >> x >> y >> h >> w;
      int size = x + y + h;
      if(size <= 60 && w <= 2) sum += 600;
      else if(size <= 80 && w <= 5) sum += 800;
      else if(size <= 100 && w <= 10) sum += 1000;
      else if(size <= 120 && w <= 15) sum += 1200;
      else if(size <= 140 && w <= 20) sum += 1400;
      else if(size <= 160 && w <= 25) sum += 1600;
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

const int INF = 1001001001;

void Main() {
	int h, w;
	cin >> h >> w;
	
	/*
    (f) a | b | c
    (g) a | b 
    　　　-
          | c
	*/
	
	auto f = [&] (ll x, ll y){
	    if(x < 3) return (ll)INF;
	    if(x%3 == 0) return (ll)0;
	    return y;
	};
    
    auto g = [&] (ll x, ll y){
        ll res = INF;
        if(y%2 == 0){
            rep3(a, 1, x-1){
                res = min(res, abs(a * y - (x-a) * (y / 2)));
            }
            return res;
        }
        rep3(a, 1, x-1){
            ll mx = max({a * y, (x-a) * ((y/2)+1)});
            ll mn = min({a * y, (x-a) * (y/2)});
            res = min(res, mx - mn);
        }
        return res;
    };
    
    // cout << f(h, w) << " " << f(w, h) << " " << g(h, w) << " " << g(w, h) << endl;
    int ans = min({f(h, w), f(w, h), g(h, w), g(w, h)});	
	cout << ans << endl; 
    return;
}

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

Measured memory_bytes: 256
def test2(a, b):
  cnt = 1
  if(b == 1):
    return 0
  if(a >= b):
    return cnt
  limit = 10**10
  for i in range(1, limit):
    cnt += 1
    if((a + ((a-1) * i)) >= b):
      return cnt
a,b=map(int,input().split())
print(test2(a,b))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <bits/stdc++.h>
#include <math.h>
#include <stack>
#define pb push_back
// #define pop pop_back
#define ll long long int
#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep2(i, a, b) for (ll i = a; i <= b; i++)
#define repr(i, a, b) for (ll i = a; i >= b; i--)
#define I long_max
#define pii pair<int, int>
#define pll pair<long, long>
#define vpair vector<pair<int, int>>
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define fir first
#define sec second
#define d (int)1e9 + 7
#define INF (int)2e9 + 1
#define el "\n"
#define fs fastscan

#define vrep(vec) for (const auto &value : vec)
#define arep(arrat) for (const auto &value : array)
using namespace std;

bool sortinrev(const pair<int, int> &a,
               const pair<int, int> &b)
{
    return (a.first > b.first);
}
void swap(int *a, int *b)
{
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}

//over

bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}

int dfs(int n, vector<vector<int>> &adj, vector<bool> &check, vector<vector<ll>> &final1, int last)
{
    // if (n == target)
    // {
    //     check[target] = true;
    //     return final;
    // }
    for (int j = 0; j < adj[last].size(); j++)
    {
        if (adj[last][j] != 0 && !check[j])
        {
            check[j] = true;
            final1[n][j] = final1[n][last] + adj[last][j];
            dfs(n, adj, check, final1, j);
        }
        // if (check[target])
        // {
        //     return a;
        // }
    }
    return 0;
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //use auto instead of data types
    // int t;
    // cin >> t;
    // while (t--)
    {
     int n, k;
     cin>>n>>k;
     vector<int> a(n);
     rep(i,n){
         cin>>a[i];
     }
     vector<int> dp(n,0);
     for(int i = 1;i<n;i++){
        //  dp[i] = dp[0] + abs(a[i] - a[0]);
        dp[i] = INT_MAX;
        for(int x = max(i-k,0);x<i;x++){
        dp[i] = min(dp[i], dp[x] + abs(a[x] - a[i]));
        }
        // if(i>=2){
        //  dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]),dp[i-2] + abs(a[i] - a[i-2]));
        // }
        // else{
        //     dp[i] = dp[i-1] + abs(a[i] - a[i-1]);
        // }
     }
     cout<<dp[n-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc =new Scanner(System.in);

	long n=sc.nextLong();
	long ans = n*(n-1)/2;
	System.out.println(ans);







	}


}




Measured memory_bytes: 22868
#include <stdio.h>
#include <string.h>
#include <algorithm>

int n, m, field[92][92];
int field_copy[92][92], ans = -1;

int dp(int finish_x, int finish_y) {
	int res = 0;
	if (field[finish_x][finish_y] == 0) { return 0; }
	field[finish_x][finish_y] = 0;
	if (field[finish_x][finish_y - 1] == 1) { res = std::max(res, dp(finish_x, finish_y - 1)); }
	if (field[finish_x][finish_y + 1] == 1) { res = std::max(res, dp(finish_x, finish_y + 1)); }
	if (field[finish_x - 1][finish_y] == 1) { res = std::max(res, dp(finish_x - 1, finish_y)); }
	if (field[finish_x + 1][finish_y] == 1) { res = std::max(res, dp(finish_x + 1, finish_y)); }
	field[finish_x][finish_y] = 1;
	return res + 1;
}

int main(void) {
	while (true) {
		scanf("%d%d", &n, &m);
		if (n == 0 && m == 0) { break; }
		for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { scanf("%d", &field[i + 1][j + 1]); } }

		ans = 0;
		for (int x = 0; x < n; ++x) { for (int y = 0; y < m; ++y) { field_copy[x + 1][y + 1] = field[x + 1][y + 1]; } }
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				ans = std::max(ans, dp(i + 1, j + 1));
				for (int x = 0; x < n; ++x) { for (int y = 0; y < m; ++y) { field[x + 1][y + 1] = field_copy[x + 1][y + 1]; } }
			}
		}

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

Measured memory_bytes: 2752
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int A,B,C;
int main() {
	cin>>A>>B>>C;

	int S=0;
	int T=0;
	if(A==5)S++;
	if(B==5)S++;
	if(C==5)S++;
	if(A==7)T++;
	if(B==7)T++;
	if(C==7)T++;

	if(S==2 && T==1)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll h, w;
  cin >> h >> w;

  vector<string> mp(h);
  rep(i, h) cin >> mp[i];

  vvll dp(h, vll(w, INF));
  rep(i, h) {
    rep(j, w) {
      if (i == 0 && j == 0)
        dp[i][j] = (mp[i][j] == '#') + 1;
      else {
        if (i > 0) dp[i][j] = dp[i - 1][j] + (mp[i - 1][j] != mp[i][j]);
        if (j > 0) chmin(dp[i][j], dp[i][j - 1] + (mp[i][j - 1] != mp[i][j]));
      }
    }  // j
  }    // i

  ll ans = dp[h - 1][w - 1]/2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
import math


def solve(N, CSFs):
    ans = []
    for k in range(0, len(CSFs)):
        t = 0
        for c, s, f in CSFs[k:]:
            if t < s:
                t = s
                t += c
            else:
                t = f * math.ceil(t / f)
                t += c
        ans.append(t)
    ans.append(0)
    return "\n".join([str(t) for t in ans])

if __name__ == "__main__":
    N = int(input())
    CSFs = [tuple(map(int, input().split(" "))) for _ in range(N - 1)]
    print(solve(N, CSFs))


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<ll> a(n);
  vector<ll> b(n);
  vector<ll> c(m);
  vector<ll> d(m);
  
  rep(i,n) cin >> a.at(i) >> b.at(i);
  rep(i,m) cin >> c.at(i) >> d.at(i);
  map<int, ll> mp;
  
  rep(i,n){
    ll dis = 1e9;
    rep(j,m){
      ll temp = abs(a.at(i)-c.at(j))+abs(b.at(i)-d.at(j));
      dis = min(dis,temp);
    }
    mp[i] = dis;
  }
  
  rep(i,n){
    rep(j,m){
      if( abs(a.at(i)-c.at(j))+abs(b.at(i)-d.at(j)) == mp[i]){
        cout << j+1 << endl;
        break;
      }
    }
  }
}


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

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<int> a;
  int tmp;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(), a.end());

  int now = 0;
  int now_cnt = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (now == a[i]) {
      now_cnt++;
    } else if (now != a[i]) {
      if (now_cnt >= now) {
        ans += now_cnt - now;
      } else {
        ans += now_cnt;
      }
      if (a[i] > n - i) {
        ans += n - i;
        break;
      }
      // ans += abs(now - now_cnt);
      now = a[i];
      now_cnt = 1;
    }
    if (i == n - 1) {
      if (now_cnt >= now) {
        ans += now_cnt - now;
      } else {
        ans += now_cnt;
      }
      // ans += abs(now - now_cnt);
      break;
    }
    // cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if((a+d-1)/d < (c+b-1)/b)
		cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long unsigned int n;
  cin>>n;
  vector<long long unsigned int>input(n);
  for(int i=0;i<n;i++)
    cin>>input[i];
  long long unsigned int check=1;
  long long unsigned int del=0;
  for(int i=0;i<input.size();i++)
  {
    if(input[i]==check)
      check++;
    else
      del++;
  }
   if(del==n)
   cout<<-1<<endl;
   else
  cout<<del<<endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
template<typename T>
struct edge {
  int to, from;T cost;
  edge(int to) : from(-1), to(to), cost(-1) {}
  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template<typename T>
using edges = vector<edge<T>>;
template<typename T>
using graph = vector<edges<T>>;
template<typename T>
using matrix = vector<vector<T>>;

template<typename T>
bool compByCost(const edge<T>& left, const edge<T>& right){
  return left.cost < right.cost; 
}

template<typename T>
vector<vector<T>> warshall(matrix<T> &g){
  vector<vector<T>> dist(g.size());
  rep(i,g.size()){
    dist[i].resize(g.size());
    rep(j,g.size())dist[i][j] = (i == j ? 0 : g[i][j]);
  }
  rep(k,g.size()){
    rep(i,g.size()){
      rep(j,g.size()){
        if(dist[i][k] == INF || dist[k][j] == INF)continue;
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  return dist;
}

#define warshall warshall<int>// matの初期化でINFを詰めておく



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

int n,c,d[31][31],a[31][3];
signed main(){
  cin>>n>>c;
  rep(i,c)rep(j,c)cin>>d[i][j];
  rep(i,n)rep(j,n){
    int t;cin>>t;t--;
    a[t][(i+j)%3]++;
  }
  int ans = INF;
  rep(i,c){
    rep(j,c){
      if(i == j)continue;
      rep(k,c){
        if(i == k || j == k)continue;
        int cost = 0;
        rep(l,c){
          cost += (d[l][i]*a[l][0]);
          cost += (d[l][j]*a[l][1]);
          cost += (d[l][k]*a[l][2]);
        }
        chmin(ans, cost);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    cout.precision(18);

    string s;
    cin >> s;

    for(long long i = 0; i < s.size(); i++){
      if(s[i] == '?')
        cout << 'D';
      else 
        cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 3752
main = getContents >>= mapM_ (putStrLn . fout . integers . fin) . lines
fin = read
fout = show 
integers n = length [(a,b,c,d) | a<-[0..9], b<-[0..9], c<-[0..9], d<-[0..9], a+b+c+d==n]

Measured memory_bytes: 3992
using System;

class Program
{  
	static void Main(string[] args)
    {
    	var n = int.Parse(Console.ReadLine());
        var k = int.Parse(Console.ReadLine());
        var kPrice = int.Parse(Console.ReadLine());
        var nPrice = int.Parse(Console.ReadLine());
        if (n <= k)
        {
          Console.WriteLine(kPrice*n);
          return;
        }
        Console.WriteLine(kPrice*k + (n-k)*nPrice);
    }
}

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

using namespace std;

int main() {
    int n;
    vector<string> v;
    string s;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s;
        v.push_back(s);
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    cout << v.size() << endl;
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


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



int main() {
    int H,W,K; cin >>H>>W>>K;
    pair<int,int> start, goal;
    cin >>start.first>>start.second>>goal.first>>goal.second;
    
    vector<vector<char>> pond(H+2, vector<char>(W+2, '@'));
    vector<vector<int>> G(H+2, vector<int>(W+2, -1));
    FOR(i,1,H+1){
        string S;
        cin >> S;
        FOR(j,1,W+1){
            pond[i][j] = S[j-1];
        }
    }
    G[start.first][start.second] = 0;

    queue<pair<int,int>> q;
    q.push(start);

    while(!q.empty()){
        auto pos = q.front();
        q.pop();

        if (pos == goal){
            cout << G[pos.first][pos.second] << endl;
            return 0;
        }
        REP(i,4){
            FOR(k,1,K+1){
                int next_x = pos.first + k*dx[i];
                int next_y = pos.second + k*dy[i];
                if(pond[next_x][next_y]=='.' && G[next_x][next_y]==-1){
                    //水上かつ未探索なら
                    G[next_x][next_y] = G[pos.first][pos.second] + 1;
                    q.push(make_pair(next_x, next_y));
                }else if(pond[next_x][next_y]=='@' || G[next_x][next_y]<=G[pos.first][pos.second]){
                    break;
                }
            }
        }
    }

    cout << -1 << endl;
    return 0;
}

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

using ll=long long; 

void solve(){
	int n,l;
	cin>>n>>l;
	int mini=-1;
	int minv=1000;
	int sum=0;
	int ans=0;
	for(int i=0; i<n; i++){
		int aji=l+i;
		sum+=aji;
		if(abs(aji)<minv){
			mini=i;
			minv=abs(aji);
			ans=aji;
		}
	}
	cout<<sum-ans<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e14 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long n, curMin = INF, ans = 0; cin >> n;

    vector<long long> a(n);

    for(long long i = 0; i < n; i++) {
        cin >> a[i];
        curMin = min(curMin, a[i]);
        if(curMin >= a[i]) ans++;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 4760
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int N = S.length();
		int mod[] = new int[N];
		int cur = 0;
		int base = 1;
		for(int i = S.length() - 1 ; i >= 0 ; --i){
			cur = cur + (S.charAt(i) - '0') * base;
			cur = cur % 2019;
			mod[i] = cur;
			base = (base * 10) % 2019;
 		}
		Map<Integer, Integer> m  = new HashMap<Integer, Integer>();
		m.put(0, 1);
		long ret = 0;
		for(int i = mod.length - 1 ; i >= 0 ; --i){
			int v = mod[i];
			if(m.containsKey(v)){
				int g = m.get(v);
				ret += g;
//				System.out.println(g);
				m.put(v, g + 1);
			}else{
				m.put(v, 1);
			}
		}
//		System.out.println(Arrays.toString(mod));
		System.out.println(ret);
	}
}


Measured memory_bytes: 44128
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <memory>
//#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);


int main() {
    int N, M;
    std::cin >> N >> M;
    long long T = 100 * N + 1800 * M;
    std::cout << T * std::pow(2, M) << std::endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define mod 1000000007
#define MX 100001
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
ll h[MX][3], dp[MX][3];
ll solve(ll n, ll i, ll prev){
    if(i == n)  return 0;
    if(prev >= 0 && dp[i][prev] != -1) return dp[i][prev];
    ll ans = INT_MIN;
    for(ll k = 0; k < 3; k++){
        if(k == prev)   continue;
        ans = max(ans, h[i][k] + solve(n, i+1, k));
    }
    dp[i][prev] = ans;
    return ans;
}
int main(){
    boost;
    ll n;   cin>>n;
    memset(dp, -1, sizeof(dp));
    for(ll i = 0; i < n; i++)   cin>>h[i][0]>>h[i][1]>>h[i][2];
    cout<<solve(n, 0, -1);
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,ans="";
	int w;
	cin>>s>>w;
	for(int i=0;i<s.length();i++){
		if(i%w==0){
			ans+=s.substr(i,1);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;//d, v
const int max_n = 300;
const int INF = 1e6;
struct edge{
  int from,to,cost;
};
bool comp(const edge& e1, const edge& e2){
  return e1.cost < e2.cost;
}
int n,ml,md,k;
vector<edge> G[max_n];
int dist[max_n];
int dist2[max_n];
edge es[max_n];
int a,b,c;
int main(){
  cin >> n >> k;
  for(int i=0 ; i<n ; i++){
    int x;  cin >> x;
  }
  ll ans = 1 + (n-k+k-2)/(k-1);
  cout << ans << endl;
  return 0;
}


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


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

  int n;
  cin >> n;
  int l[n];
  rep(i,n) cin >> l[i];
  sort(l,l+n);
  int sum=0;
  rep(i,n-1) sum+=l[i];
  if(l[n-1]<sum) cout << "Yes" << endl;
  else cout << "No" << endl;

  
  return 0;
    

}


Measured memory_bytes: 256
package main

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

func floorSum(n, m, a, b int) int {
	result := 0
	if a >= m {
		result += (n - 1) * n * (a / m) / 2
		a %= m
	}
	if b >= m {
		result += n * (b / m)
		b %= m
	}

	yMax := (a*n + b) / m
	xMax := yMax*m - b
	if yMax == 0 {
		return result
	}
	result += (n - (xMax+a-1)/a) * yMax
	result += floorSum(yMax, a, m, (a-xMax%a)%a)
	return result
}

func main() {
	defer flush()

	T := readInt()
	for i := 0; i < T; i++ {
		N := readInt()
		M := readInt()
		A := readInt()
		B := readInt()
		println(floorSum(N, M, A, B))
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


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

int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    for (int i=0;i<n;i++){
        cin>>a.at(i);
        // cout<<a.at(i)<<endl;
    }
    sort(a.begin(),a.end(),greater<int>());
    // for (int i=0;i<n;i++){
    //     cout<<a.at(i)<<endl;
    // }
    int alice=0,bob=0;
    for (int i=0 ;i<n;i+=2){
        bob+=a.at(i);
        // cout<<bob<<endl;
    }
    for (int i=1; i<n;i+=2){
        alice+=a.at(i);
        // cout<<alice<<endl;
    }
    cout<<max(bob-alice,alice-bob)<<endl;
    
    return 0;
}


Measured memory_bytes: 3612
#include <algorithm>
#include <fstream>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#include <cmath>
#include <climits>
#include <queue>

using namespace std;

int main() {
    int n; cin >> n;
    vector<long long> vec(n);
    long long ans = 0;
    long long minnum = 1LL << 60;
    int count = 0;
    for(int i = 0; i < n; ++i){
        long long a; cin >>a;
        if(a < 0){
            a = abs(a);
            ++count;
        }
        ans += a;
        minnum = min(minnum, a);
    }
    if(count % 2 != 0){
        ans -= 2 * minnum;
    }

    cout << ans << endl;
}

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

int main(){
int n=0;
int x=0;

cin>>n;
  int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
  int t=0;
 for(int i=0;i<n;i++){
   t=a[i];
   x=x^t;
}
  
for(int i=0;i<n;i++){
a[i]=x^a[i];
}

cout<<a[0];
for(int i=1;i<n;i++){
cout<<" ";
cout<<a[i];
}
return 0;

}


Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define LIMIT 1000000007 //10^9+7
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define all(v) (v).begin(), (v).end()

namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&vt){int i=0;for(auto x:vt)++i!=vt.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>init){int i=0;for(auto x:init)++i!=init.size()?show(x):showendl(x);} //初期化子リスト出力
}

int main(){
	int H,W,h,w;
  cin>>H>>W>>h>>w;
  cout<<(H-h)*(W-w)<<endl;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
int a[105];
int b[105];
ll now_color;
ll ans_color = 9e18;
ll ans_leaf = 9e18;
bool visited[105];
vector<int> pathes[105];
vector<int> now;
ll ones = 0;

void solve() {
    if(now.empty()) return;
    now_color++;
    /*
    cout << now_color << " " << ones << endl;
    for(int i = 0; i < now.size(); i++) {
        cout << now[i] << " ";
    }
    cout << endl;
    */
    vector<int> NEXT;
    for(int i = 0; i < now.size(); i++) visited[now[i]] = true;
    int max_size = 1;
    for(int i = 0; i < now.size(); i++) {
        int from = now[i];
        int now_size = 0;
        for(int j = 0; j < pathes[from].size(); j++) {
            int to = pathes[from][j];
            if(visited[to]) continue;
            NEXT.push_back(to);
            now_size++;
        }
        max_size = max(max_size, now_size);
    }
    ll NEW_ones = ones * max_size;
    for(int i = 0; i < now.size(); i++) {
        int from = now[i];
        int now_size = 0;
        for(int j = 0; j < pathes[from].size(); j++) {
            int to = pathes[from][j];
            if(visited[to]) continue;
            now_size++;
        }
        NEW_ones += max_size - now_size;
    }
    ones = NEW_ones;
    swap(now, NEXT);
    solve();
}

int main() {
    //cout.precision(10);
    cin >> N;
    /*
    if(N == 1) {
        cout << "1 2" << endl;
        return 0;
    }
    */
    for(int i = 1; i < N; i++) {
        cin >> a[i] >> b[i];
        pathes[a[i]].push_back(b[i]);
        pathes[b[i]].push_back(a[i]);
    }
    for(int i = 1; i <= N; i++) {
        now_color = 0;
        for(int j = 1; j <= N; j++) visited[j] = false;
        now.clear();
        now.push_back(i);
        ones = 0;
        //cout << i << endl;
        solve();
        if(pathes[i].size() == 1) ones++;
        //cout << endl << now_color << " " << ones << endl;
        if(ans_color < now_color) continue;
        if(ans_color > now_color) {
            ans_color = now_color;
            ans_leaf = ones;
        }
        if(ans_color == now_color) {
            ans_leaf = min(ans_leaf, ones);
        }
    }
    for(int i = 1; i < N; i++) {
        now_color = 0;
        for(int j = 1; j <= N; j++) visited[j] = false;
        now.clear();
        now.push_back(a[i]);
        now.push_back(b[i]);
        ones = 0;
        //cout << i << endl;
        solve();
        //if(pathes[a[i]].size() == 1) ones++;
        //if(pathes[b[i]].size() == 1) ones++;
        //cout << endl << now_color << " " << ones << endl;
        if(ans_color < now_color) continue;
        if(ans_color > now_color) {
            ans_color = now_color;
            ans_leaf = ones;
        }
        if(ans_color == now_color) {
            ans_leaf = min(ans_leaf, ones);
        }
    }
    cout << ans_color << " "<< ans_leaf << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int N=2e5+10;

typedef long long ll;

ll a[N],b[N];

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    a[n+1]=1e9+10;
    for(int i=1;i<=m;i++)
        cin>>b[i];
    b[m+1]=1e9+10;
    for(int i=1;i<=n;i++)
        a[i]+=a[i-1];
    for(int i=1;i<=m;i++)
        b[i]+=b[i-1];

    int l=0,r=n;
    while(l<r)
    {
        int mid = (l+r+1)>>1;
        if(a[mid]<=k) l=mid;else r=mid - 1;
    }

    int j=0;
    int ans=l;
    for(int i=l;i>=0;i--)
    {
        while(a[i]+b[j]<=k)
        {
            ans=max(ans,i+j);
            j++;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 6632
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] arr = new char[n];
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			switch (a / 400) {
				case 0 :
				arr[i] = 'a';
				break;
				case 1 :
				arr[i] = 'b';
				break;
				case 2 :
				arr[i] = 'c';
				break;
				case 3 :
				arr[i] = 'd';
				break;
				case 4 :
				arr[i] = 'e';
				break;
				case 5 :
				arr[i] = 'f';
				break;
				case 6 :
				arr[i] = 'g';
				break;
				case 7 :
				arr[i] = 'h';
				break;
				default :
				arr[i] = 'x';
				break;
			}
		}
		Arrays.sort(arr);
		int cCount = 0;
		int xCount = 0;
		for (int i = 0; i < n; i++) {
			if (arr[i] == 'x') {
				xCount++;
			} else {
				if (i == 0) {
					cCount++;
				} else if (arr[i - 1] != arr[i]) {
					cCount++;
				}
			}
		}
		int min = cCount;
		if (min == 0) {
			min = 1;
		}
		int max = cCount + xCount;
		System.out.println(min + " " + max);
	}
}


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

int main() {
  int N, M;
  cin >> N >> M;
  long long A[N];
  pair<int, long long> BC[M];
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < M; i++) cin >> BC[i].first >> BC[i].second;

  sort(A, A + N);
  sort(BC, BC + M,
       [](pair<int, long long> bc1, pair<int, long long> bc2) -> int {
         return bc1.second > bc2.second;
       });

  int ai = 0;
  for (int i = 0; i < M; i++) {
    if (A[ai] >= BC[i].second) break;

    for (int j = 0; j < BC[i].first; j++) {
      if (A[ai] >= BC[i].second) break;

      A[ai] = BC[i].second;
      ai++;
    }
  }

  long long ans = 0;
  for (int i = 0; i < N; i++) {
    ans += A[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
/* HARE KRSNA HARE KRSNA KRSNA KRSNA HARE HARE
    HARE RAMA HARE RAMA RAMA RAMA HARE HARE  */

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

#define nl "\n"
#define ff first
#define ss second
#define pp pop_back
#define pf pop_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define b_s binary_search
#define all(x) x.begin(),x.end()
#define test ll t; cin>>t; while(t--)
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define rloop(i,s,n) for(ll i=s;i>=n;i--)
#define fill(a,value) memset(a,value,sizeof(a))

#define debug2(a)  for(auto x : a)  cout<<x<<" ";  cout<<nl;
#define debug4(a)  for(auto x : a)  cout<<x.ff<<" "<<x.ss<<nl;
#define debug1(a,n) loop(i,0,n)  cout<<a[i]<<" ";  cout<<nl;
#define debug3(a,n,m)  loop(i,0,n){ loop(j,0,m)	cout<<a[i][j]<<" ";	cout<<nl; }

typedef long long ll;
typedef long double ld;

typedef stack<ll> sll;
typedef queue<ll> qll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef pair<ll, pll> ppll;
typedef vector<vector<ll>> vvll;
typedef priority_queue<ll> pqll;

const ll mod = 1000000007;  //998244353;
const ld pi =  acos((ld) - 1);  //3.1415926535;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll num_generator() 	{ return rand() % 1000; }
void array_generator(ll a[], ll n) { loop(i, 0, n)	a[i] = rand() % 100; }

void solve()
{
	ll n, k;		cin >> n >> k;
	ll a[n];	loop(i, 0, n)		cin >> a[i];
	loop(i, k, n)
	{
		if (a[i] > a[i - k])		cout << "Yes";
		else	cout << "No";
		cout << nl;
	}
}

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

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

	// test
	solve();

	return 0;
}

Measured memory_bytes: 5108
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define NL << endl
using namespace std;
using ll = long long;
const int INFINT = 1 << 30;
const ll INFLL = 1LL << 60;
const int MOD = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a%b) : a;}

int main() {

	int n;

	cin >> n;

	vector<int> t(n), a(n);

	REP(i, n) cin >> t[i] >> a[i];

	ll vt = t[0], va = a[0];

	FOR(i, 1, n) {
		ll k;
		ll k2;
		if (vt % t[i] == 0) k = vt / t[i];
		else k = vt / t[i] + 1;
		if (va % a[i] == 0) k2 = va / a[i];
		else k2 = va / a[i] + 1;
		k = max(k, k2);
		vt = t[i] * k, va = a[i] * k;
	}



	printf("%lld\n", vt + va);


	return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<P> ab;
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		ab.push_back(make_pair(a, b));
	}
	sort(ab.begin(), ab.end());

	ll ans = 0;
	rep(i, n) {
		ans += (ll)ab[i].first * min(ab[i].second, m);
		m -= ab[i].second;
		if (m <= 0) break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
    
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i, n) for (int i = 0; i < n; i++)
#define repn(i, a, b) for (int i = a;i<=b;i++)
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define mem(x) memset(x, 0, sizeof(x))
#define ritr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define pai pair < int, int> 
#define pal pair < ll, ll> 
#define vi vector <int> 
#define vl vector < ll > 
#define vpai vector < pii > 

const int mod = 1e9+7;
const int INF = INT_MAX;
const int sze = 3005;

int calc(int n){
    int count=0;
    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            count++;
            if(i*i!=n) count++;
        }
    }
    return count;
}

void solve() {
    int n;
    cin>>n;
    ll ans=0;
    ll dp[n+1];
    mem(dp);
    repn(i,1,n){
        for(int j=1;j*i<=n;j++) dp[i*j]++;
    }

    repn(i,1,n) ans+=i*dp[i];
    cout<<ans<<endl;
}

int main() {
    IOS;

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

  return 0;
}

Measured memory_bytes: 81768
#include<stdio.h>


void trace(int A[],int N){
	int i;
	for(i=0;i<N;i++){
		if(i>0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}


void insertionSort(int A[],int N){
	int j,i,v;
	for(i=1;i<N;i++){
		v=A[i];
		j=i-1;
		while(j>=0&&A[j]>v){
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=v;
		trace(A,N);
	}
}

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

Measured memory_bytes: 600
# coding: utf-8
n = int(input())
lst = list(map(int, input().split()))
cnt = 0
data = []
for i in range(n - 1):
    if lst[i] >= lst[i + 1]:
        cnt += 1
    else:
        data.append(cnt)
        cnt = 0
data.append(cnt)
print(max(data))


Measured memory_bytes: 63984
n=int(input())
a=list(map(int,input().split()))[::-1]
number=2
if 1 not in a: print(-1);exit()
count=n-len(a[:a.index(1)+1])
a=a[:a.index(1)][::-1]
for i in a:
  if i==number:
    number+=1
  else:
    count+=1
print(count)

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9


int main(){ 
  int N;
  cin >> N;
  vector<int> L(2*N);
  REP(i, 2*N){
    cin >> L[i];
  }
  sort(L.begin(), L.end());
  int ans = 0;
  REP(i, N){
    ans += L[2*i];
  }
  cout << ans << endl;
  return 0;
}



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

int main(){ 
    ll n;
    cin >> n;
    ll ans=0;
    
    for(int a=1;a<=(int)sqrt(n);a++){
        if(!(n%a)) ans = a+n/a-2;
    }
    cout << ans << endl;
    
    return 0;
} 


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	char s[n][m];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++)cin >> s[i][j];
	}
	int flag = 0;
	for (int i = 0; i < n; i++) {
		if (flag == 1)break;
		for (int j = 0; j < m; j++) {
			if (s[i][j] == '#') {
				if (s[i + 1][j] != '#'&&s[i][j + 1] != '#'&&s[i-1][j]!='#'&&s[i][j-1]!='#')flag = 1;
			}
		}
	}
	if (flag == 1)cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

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

int main(void){
    int row,column;
    cin  >> row >> column;

    vector<vector<int>> input_table(row+1,vector<int>(column+1,0));
    for(int i=0;i<row;i++){
        for(int j=0;j<column;j++){
            cin >> input_table[i][j];
            input_table[row][j] += input_table[i][j];
            input_table[i][column] += input_table[i][j];
        }
        input_table[row][column] += input_table[i][column];
    }

    for(int i=0;i<row+1;i++){
        for(int j=0;j<column+1;j++){
            cout << input_table[i][j];
            if(j==column){
                cout << endl;
                break;
            }
            cout << " ";
        }
    }
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

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(){
    int n,m;
    cin >> n >> m;
    int l=0,r=n;
    int a,b;
    for(int i=0;i<m;i++){
        cin >> a >> b;
        l=max(l,a);
        r=min(r,b);
    }
    cout << max(0,r-l+1) << endl;
}

Measured memory_bytes: 256
N = int(input())
S = input()
cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            x = S.find(str(i))
            if x >=0 and x < len(S) - 2:
                y = S[x+1:].find(str(j))
                if y >= 0 and x+y < len(S) -1:
                    z = S[x+y+2:].find(str(k))
                    if z >= 0:
                        cnt += 1
print (cnt)


Measured memory_bytes: 38512