akhauriyash/Code-Regression huggingface dataset:
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    long long k,n,m;
    cin>>k>>n>>m;
    long long flag=1;
    for(long long i=n;i<=m;i++)
    {
        if(i%k==0)
        {
            flag=0;
            break;
        }
    }
    if(flag==1)
    cout<<"NG";
    else
    cout<<"OK";

    return 0;
}


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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)          \
  sort(x.begin(), x.end()); \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

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

  ll n;
  cin >> n;
  vector<ll> v(n);
  rep(i, n) { cin >> v[i]; }

  sort(all(v));

  cout << v[n - 1] - v[0] << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 10:42-

            int mod = 1_000_000_007;
            int n = sc.nextInt();
            int m = sc.nextInt();
            int[] as = new int[m];

            Set<Integer> broken = new HashSet<>();
            for (int i = 0; i < as.length; i++) broken.add(sc.nextInt());

            int[] dp = new int[n + 1];
            dp[0] = 1;

            for (int i = 1; i <= n; i++) if (!broken.contains(i)) {
                dp[i] += dp[i - 1];
                dp[i] %= mod;
                if (i - 2 >= 0) dp[i] += dp[i - 2];
                dp[i] %= mod;
            }

            out.println(dp[n]);
        }
    }
}


Measured memory_bytes: 64984
// 全探索
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>

using namespace std;

int n, A[50];

// 入力値の m から選んだ要素を引いていく再帰関数
// i : 配列の要素No.
// m : 和を求めるべき値の残り
bool solve(int i, int m)
{
    if( m == 0 )
    {
        // 和の組み合わせが見つかった
        return true;
    }

    if( i >= n )
    {
        // 選択できる要素数をオーバーした
        return false;
    }

    bool ret_1, ret_2;

    // i番目の要素を選択しない
    ret_1 = solve(i + 1, m);
    // i番目の要素を選択する
    ret_2 = solve(i + 1, m - A[i]);

    return ret_1 || ret_2;
}

int main(void)
{
    int q, Q;

    scanf("%d", &n);

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

    scanf("%d", &q);

    for(int i = 0; i < q; i++)
    {
        scanf("%d", &Q);

        // 判定処理の実施
        if( solve(0, Q) )
        {
            printf("yes\n");
        }
        else
        {
            printf("no\n");
        }
    }

    return 0;
}



Measured memory_bytes: 3140
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
int main(){
  double a,b,c,d,e,f;
  cin >> a >> b>> c >> d>> e>> f;
  double howa = e*100/(e+100);
  double ans = 0;
  double A,B ; //あとの要素を入れ子にしていくというてく
  for(int i = 0; i <=f; i+= 100*a){
    for(int j = 0; i+j <= f; j+= 100*b){
      for(int k = 0; i+j+k <= f; k+= c){
        for(int l = 0; i+j+k+l<=f; l+=d){
          double eki = i+j+k+l;
          double sato = k+l;
          if(eki != 0){
           double intensity = sato*100/eki;
              if(intensity <= howa  && ans <= intensity){
              ans = max(ans,intensity) ;
              A = eki;
              B = sato;
            }
             }
            }
          }
        }
      }
cout << A << " "<< B << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll cursol_num = 10e10;

int main() {
  string S;
  cin >> S;
  ll N = S.length();
  vector<ll> result(N, 0);
  ll r_cnt = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'L') {
      result[i] = 1;
      if (r_cnt % 2 == 0) {
        result[i] += r_cnt / 2;
        result[i - 1] += r_cnt / 2;
      } else {
        result[i] += r_cnt / 2;
        result[i - 1] += r_cnt / 2 + 1;
      }
      ll n = i + 1;
      while (S[n] == 'L') {
        if ((n - i) % 2 == 0) {
          result[i] += 1;
        } else {
          result[i - 1] += 1;
        }
        n++;
      }
      i = n - 1;
      r_cnt = 0;
    } else {
      r_cnt++;
    }
  }
  for (int i = 0; i < N; i++) {
    cout << result[i] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

void solve(){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];
	string s;
	cin >> s;

	Vec b;
	repr(i, n){
		ll v = a[i];
		for (ll j : b) chmin(v, v ^ j);
		if(v){
			if(s[i] == '1'){
				co(1);
				return;
			}
			b.pb(v);
		}
	}
	co(0);
}

int main(void){
	ll t;
	cin >> t;
	rep(i, t) solve();

	return 0;
}


Measured memory_bytes: 3480
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    ll N;
    string S;
    cin >> N >> S;

    ll R = 0, G = 0, B = 0;
    for (auto e : S) {
        if (e == 'R') ++R;
        else if (e == 'G')
            ++G;
        else if (e == 'B')
            ++B;
    }

    ll ans = R * G * B;
    for (int i = 0; i < N - 2; ++i) {
        for (int j = 1; i + j + j < N; ++j) {
            if (S[i] != S[i + j] && S[i + j] != S[i + j + j]
                && S[i] != S[i + j + j])
                --ans;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <string.h>
#define N 1000


int max(int a,int b)
{
  if(a>=b) return a;
  else return b;
}


int LCS(char x[N+1],char y[N+1])
{
  int m,n,i,j,c[N+1][N+1];
  int maxlen = 0;

  m = strlen(x);
  n = strlen(y);

  for(i=0;i<=m;i++) c[i][0] = 0;
  for(j=1;j<=n;j++) c[0][j] = 0;

  for(i=1; i<=m;i++){
    for(j=1;j<=n;j++){
      if(x[i-1]==y[j-1]) c[i][j]=c[i-1][j-1]+1;
      else c[i][j] = max(c[i-1][j],c[i][j-1]);

      maxlen = max(maxlen,c[i][j]);
    }
  }
  return maxlen;
}


int main()
{
  int n,i;
  char str1[N+1],str2[N+1];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s%s",str1,str2);
    printf("%d\n",LCS(str1,str2));
  }

  return 0;
}



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

int main() {
  int N, M;
  cin >> N >> M;
  vector<long> H(N);
  for(int i = 0; i < N; ++i){
    cin >> H.at(i);
  }

  vector<int> A(M);
  vector<int> B(M);
  for(int i = 0; i < M; ++i){
    int a, b;
    cin >> a >> b;

    A.at(i) = a;
    B.at(i) = b;
  }

  vector<int> goodTower(N, 1);
  for(int i = 0; i < M; ++i){
    long a = H.at(A.at(i)-1);
    long b = H.at(B.at(i)-1);

    if(a <= b) goodTower.at(A.at(i)-1) = 0;
    if(a >= b) goodTower.at(B.at(i)-1) = 0;
  }
  
  int cnt = 0;
  for(int i = 0; i < N; ++i){
    if(goodTower.at(i) == 1) ++cnt;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 5372
import numpy as np
import fractions
import decimal
from collections import deque

s=str(input())
a=s[:(len(s)-1)//2]
# print(a)
if(s!=s[::-1]):
    print("No")
    exit(0)
if(a!=a[::-1]):
    print("No")
    exit(0)
b=s[(len(s)+3)//2-1:]
# print(b)
if(b!=b[::-1]):
    print("No")
    exit(0)

print("Yes")

Measured memory_bytes: 19964
#include<bits/stdc++.h>
using namespace std;
int a[300005];
signed main(){
	int n;scanf("%d",&n);
	for(register int i=1;i<=3*n;++i){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+3*n+1);
	long long ans=0;
	for(register int i=3*n-1;i>=n+1;i-=2){
		ans+=a[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4844
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	
	int n;
	cin >> n;

	vll a(n);
	rep(i,n)cin >> a[i];

	int all = 1;
	rep(i,n)all *= 3;
	int o = 1;
	rep(i,n){
		if(a[i]%2)o *= 1;
		else o *= 2;
	}
	cout << all - o << endl;



	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://code-festival-2017-qualc.contest.atcoder.jp/tasks/code_festival_2017_qualc_b

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i,s=0;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	for(i=0;i<n;i++)
		if(a[i]!=a[i-1])
			s++;
	cout<<s<<endl;
	return 0;
}

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

#define swap(a,b) {int t; t = a; a = b; b = t;}

int main(int argc, char *argv[])
{
    int n;
    int a[100000];
    int a_min, a_min_ptr;
    int a_min_next, a_min_next_ptr;
    int i;

    scanf("%d", &n);

    a_min = INT_MAX;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        if (a[i] < a_min) {
            a_min = a[i];
            swap(a[0], a[i]);
        }
    }

    while(n > 1) {
        for (i = 1; i < n; i++) {
            a[i] %= a_min;
            if (a[i] == 0) {
                //swap
                a[i] = a[n - 1];
                n--;
                i--; continue;
            } else {
                if (a[i] < a[0]) {
                    swap(a[i], a[0]);
                }
            }
        }
        a_min = a[0];
    }

    printf("%d\n", a_min);

    return 0;
}


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

int main(){
  long long x,a,b,c,d,e;
  cin>>x>>a>>b>>c>>d>>e;
  vector<long long>y{a,b,c,d,e};
  sort(y.begin(),y.end());
  long long z=x/(y[0])+4;
  if(x%y[0]!=0){
  z++;
  }
  cout<<z<<endl;
}

Measured memory_bytes: 256
import collections

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

N = int(input())
ans, temp = 1, [0] * (N+1)
for i in range(2, N+1):
    c = prime_factorize(i)
    divs, exps = list(c.keys()), list(c.values())
    for j in range(len(divs)):
        temp[divs[j]] += exps[j]

for i in range(N+1):
    ans *= (temp[i] + 1)
print(ans % (10**9 + 7))

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

int main(){
    int n,m;
    cin >> n >> m;
    int ans=0;
    vector <int> s(n),p(m);
    vector <vector <int>> s2(m);
    int k,s3;
    rep(i,m){
        cin >> k;
        rep(j,k){
            cin >> s3;
            s2[i].push_back(s3-1);
        }
    }

    rep(i,m){
        cin >> p[i];
    }

    int k2;

    rep(i,pow(2,n)){
        rep(j,n){
            s[j]=(i>>j)&1;
        }

        rep(j,m){
            k2=0;
            rep(l,s2[j].size()){
                if(s[s2[j][l]]==1){
                    ++k2;
                }
            }
            if(k2%2!=p[j]){
                break;
            }
            if(j==m-1){
                ++ans;
            }
        }


    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// 入力
int N;
long long W, weight[110], value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に
// DPテーブル
long long dp[110][100100] = {0};
int main()
{
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

        // DPループ
        for (int i = 0; i < N; ++i) {
            for (int sum_w = 0; sum_w <= W; ++sum_w) {

                // i 番目の品物を選ぶ場合
                if (sum_w - weight[i] >= 0) {
                    dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w - weight[i]] + value[i]);
                }

                // i 番目の品物を選ばない場合
                dp[i+1][sum_w]=max(dp[i+1][sum_w], dp[i][sum_w]);
            }
        }

        // 最適値の出力
        cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 79360
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

using namespace std;
int x;
int main(){
	cin >> x;
	if(x==0) cout << 1 << endl;
	else if(x==1) cout << 2 << endl;
	else if(x==2) cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3116
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 1000000007
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
vector<complex<double>>  DFT(vector<complex<double>> a) {
	int n = a.size();
	if (n == 1) return a;
	vector<complex<double>> a0(n / 2), a1(n / 2);
	REP(i, n) {
		if (i % 2 == 0) {
			a0[i / 2] = a[i];
		}
		else {
			a1[i / 2] = a[i];
		}
	}
	vector<complex<double>> inversed_a0 = DFT(a0), inversed_a1 = DFT(a1);
	vector<complex<double>> inversed_a(n);
	for (int i = 0; i < n; ++i) {
		complex<double> zeta = complex<double>(cos(2 * Ma_PI * i / n), sin(2 * Ma_PI * i / n));
		inversed_a[i] = inversed_a0[i % (n / 2)] + zeta * inversed_a1[i % (n / 2)];
	}
	return inversed_a;
}
vector<complex<double>> IDFT(vector<complex<double>> inversed_a) {
	int n = inversed_a.size();
	vector<complex<double>> now = DFT(inversed_a);
	reverse(now.begin(), now.end());
	for (int q = now.size() - 1; q >= 1; --q) {
		swap(now[q], now[q - 1]);
	}
	REP(i, n) {
		now[i] /= complex<double>(n, 0);
	}
	return now;
}
vector<complex<double>> conv(vector<complex<double>> a, vector<complex<double>> b) {
	int deg = a.size() + b.size() - 1;
	int n = 1;
	while (n < deg) n <<= 1;
	a.resize(n);
	b.resize(n);
	vector<complex<double>> inversed_a = DFT(a), inversed_b = DFT(b);
	vector<complex<double>> inversed_c(n);
	REP(i, n) {
		inversed_c[i] = inversed_a[i] * inversed_b[i];
	}
	return IDFT(inversed_c);
}
long long powing(long long now, long long hoge) {
	long long ans = 1;
	while (hoge != 0) {
		if (hoge % 2 == 1) {
			ans *= now;
			ans %= MOD;
		}
		hoge /= 2;
		now *= now;
		now %= MOD;
	}
	return ans;
}
long long inv(long long now) {
	return powing(now, MAX_MOD - 2LL);
}
unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x^(x << 11));
	x = y; y = z; z = w;
	return (w = (w^(w >> 19))^(t^(t >> 8)));
}
int main() {
	long long a, b;
	cin >> a >> b;
	long long geko = a + b;
	geko /= 2LL;
	if (llabs(a - geko) == llabs(b - geko)) {
		cout << geko << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
}

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;
int main(){
  int64_t n, k;
  cin >> n >> k;
  cout << min(abs(n%k),abs(k-n%k)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXNUM 1000000007
using namespace std;
int main(){
	int n;
	long long int a[200005];
	cin>>n;
	long long int sum=0;
	
	for(int i=0;i<n;i++){
		cin>>a[i];	
	}
	long long int front=0;
	long long int last=0;
	for(int i=1;i<n;i++){
		front=a[i];
		last+=a[i-1];
		last=last%1000000007;
		sum+=(front*last);
		sum=sum%1000000007;
	}
//	long long int cnt=1;
	cout<<sum;

}

Measured memory_bytes: 5180
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
char S[1005];
int W;
int main(){
  scanf("%s",S);
  cin>>W;
  int n=strlen(S);
  string res;
  for(int i=0;i<n;i+=W) res+=S[i];
  cout<<res<<endl;
  return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int h, w, sum;
int c[10][10];
int M[200][200];

int main() {
    cin >> h >> w;
    rep(i, 10) rep(j, 10) cin >> c[i][j];
    rep(i, h) rep(j, w) cin >> M[i][j];
    rep(k, 10) rep(i, 10) rep(j, 10) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    rep(i, h) rep(j, w) if (M[i][j] != -1) sum += c[M[i][j]][1];
    cout << sum << endl;
    return 0;
}

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


#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <functional>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

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

	int ans = 1;
	rep(i, n) {
		if (ans < k) {
			ans = ans * 2;
		}
		else {
			ans += k;
		}
	}
	cout << ans << endl;
	
	return 0;
}




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

int H,W;
int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1}, dy[8] = {0, 1, 0, -1, -1, -1, 1, 1};
char maze[50][50];

int count(int x, int y) {
	if(maze[x][y] == '#') return -1;
	int num=0;
	for(int i=0; i<8; i++){
		int nx, ny;
		nx = x + dx[i];
		ny = y + dy[i];
		if(nx>=0 && nx<W && ny>=0 && ny<H && maze[nx][ny] == '#') num++;
	}
	return num;
}


int main() {
	cin >> H >> W;
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			cin >> maze[j][i];
		}
	}
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			int output = count(j, i);
            if(output<0){
				cout << '#';
            }else{
				cout << output;
            }
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && a!=c) cout<<c<<endl;
    else if(a==c && a!=b) cout<<b<<endl;
    else if(b==c && b!=a) cout<<a<<endl;
    return 0;
}



Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

s = list(input())
K = INT()

for i in range(len(s)):
	tmp = 26 - ascii_lowercase.index(s[i])
	if tmp <= K and tmp < 26:
		K -= tmp
		s[i] = "a"

idx = ascii_lowercase.index(s[-1])
s[-1] = ascii_lowercase[(idx+K)%26]

print(*s, sep="")

Measured memory_bytes: 9048
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x;
  long long y;
  /*bool operator < (const P &a )const{
    //if(y!=a.y)
    return y<a.y;
  };*/
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[412111];
int l[1];
int j[1];

long long x,y,z,mod=1000000007;
//string r;
char r[3];

P u[1];
queue<P> q;
stack<int> s;
//set<int> s;
map<int,int> p[201010];

vector<int> v;


bool as(P a,P b)
{
  //if(a.x!=b.x)
  //return a.x<b.x;
  return a.y>b.y;
}

int f(int n)
{
  if(o[n]==n) return n;
  return o[n]=f(o[n]);
}

int main()
{
  scanf("%d %d %d",&a,&b,&c);
  iota(o+1,o+a*2+1,1);
  for(int t=1;t<=b;t++)
  {
    scanf("%d %d",&n,&m);
    o[f(n)]=f(m);
  }
  for(int t=1;t<=c;t++)
  {
    scanf("%d %d",&n,&m);
    n+=a,m+=a;
    o[f(n)]=f(m);
  }
  for(int t=1;t<=a;t++)
    p[f(t)][f(t+a)]++;
  for(int t=1;t<=a;t++)
  printf("%d ",p[f(t)][f(t+a)]);
}
//0
//11




Measured memory_bytes: 20096
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <cmath>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define INF 0x3f3f3f3f
#define rep(i,x,y) for(int i = x;i <= y;++i)
#define fori(i,x,y) for(int i = x;i >= y; -- i)
#define bug puts("--------------")
#define out(x) cout<<x<<'\n';
inline char gc(){char op[2];scanf("%s",op);return op[0];}
const int N = 1e5+10;
const double eps = 0.00000001;
const ll mod = 1e9 + 7 ;
using namespace std;
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
char s[N];
bool f(int l,int r){
    while(l<=r){
        if(s[l]!=s[r]) return 0;
        l ++;r --;
    }
    return 1;
}
int main(){
    double l ;
    cin >> l;
    l /= 3;
    printf("%.12lf",l*l*l);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    string s;
    cin>>s;
    ll n=s.length();
    ll ans=0;
    for(int x=0;x<n/2;x++)
    {
        if(s[x]!=s[n-x-1])
            ++ans;
    }
    cout<<ans;
}


Measured memory_bytes: 256
s_init = input()
s_list = list(reversed(s_init))
s = ''.join(s_list)
t = ""
words = ["maerd", "remaerd", 'esare', 'resare']
s_list = list(s)
t_list = list(t)
while s != t:
    t_fixed = t
    if len(s_list) < len(t_list):
        break
    elif t == 'gameover':
        break
    else:
        for word in words:
            if s.startswith(t + word):
                t = t + word
                break
        if t == t_fixed:
            t = 'gameover'
if s == t:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 4724
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    string S;
    cin >> S;
    
    vector<int> cnt(3, 0);
    rep(i, S.size()) cnt[S[i] - 'a']++;//それぞれの文字をカウント、(0,1,2)が(a,b,c)に対応している
    string ans = "YES";
    rep(i, 3) rep(j, 3) {
        if (abs(cnt[i] - cnt[j]) > 1) ans = "NO";//文字の個数の差が2以上あったら回文が作れちゃう
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,T,c,t,ans=10000;
  cin >> N >> T;
  for(int i=0 ; i<N ; i++){
    cin >> c >> t;
    if(t<=T)
      ans=min(c,ans);
  }
  if(ans==10000)
    cout << "TLE" << endl;
  else
    cout << ans << endl;
}

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

typedef long long lglg;

int main() {
    ios::sync_with_stdio(0);//, cin.tie(0), cout.tie(0);

	int N,K,Q; cin >> N >> K >> Q;
	int correct[N+1] = {};

	for (int i=0; i<Q; ++i) {
		int a; cin >> a;
		++correct[a];
	}
	for (int i=1; i<=N; ++i) {
		if (correct[i] > Q-K) cout << "Yes\n";
		else cout << "No\n";
	}
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include<string>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);

int n, W;
vector<int> w;
vector<ll> v;
vector<vector<ll>> dp;

int main(void) {
	cin >> n >> W;
	w = vector<int>(W + 1, 0);
	v = vector<ll>(n + 1, 0);
	for (int i = 1; i < n + 1; i++)
		cin >> w[i] >> v[i];
	dp = vector<vector<ll>>(n + 1, vector <ll>(W + 1, 0));
	for (int i = 1; i < n + 1; i++) {
		for (int j = 1; j < W + 1; j++) {
			if (j >= w[i])
				dp[i][j] = max(dp[i - 1][j], dp[i-1][j - w[i]] + v[i]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
	cout << dp[n][W] << endl;
	return 0;
}

Measured memory_bytes: 83428
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	set<int>s;
	rep(i, 3) {
		int num;
		cin >> num;
		s.insert(num);
	}
	if (s.size() == 1)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B;
    scanf("%d %d",&A,&B);
    if((A==1&&B==2)||(A==2&&B==1))
    printf("3\n");
    else if((A==1&&B==3)||(A==3&&B==1))
    printf("2\n");
    else if((A==2&&B==3)||(A==3&&B==2))
    printf("1\n");
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int N;
  scanf("%d",&N);
  int A[N];
  int i;

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

  int count=0,j,temp;

  for(i=0;i<N;i++){
    for(j=N-1;j>i;j--){
      if(A[j-1]>A[j]){
	temp=A[j-1];
	A[j-1]=A[j];
	A[j]=temp;
	count++;
      }
    }
  }
  for(i=0;i<N;i++){
    if(i != N - 1)printf("%d ",A[i]);
	else printf("%d", A[i]);  
}
  printf("\n");
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2124
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int a[3];
	fori(3)cin>>a[i];
	sort(a,a+3,greater<int>());
	cout<<abs(a[1]-a[0])+abs(a[2]-a[1]);
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, X) = listOfLong()
    val N = n.toInt()
    val a = LongArray(N + 1); a[0] = 1
    val p = LongArray(N + 1); p[0] = 1
    for (n in 1 .. N) {
        a[n] = a[n - 1] * 2 + 3
        p[n] = p[n - 1] * 2 + 1
    }
    fun f(n: Int, x: Long): Long {
        if (n == 0) {
            return  if (x <= 0L) 0 else 1
        } else if (x <= 1 + a[n - 1]) {
            return f(n - 1, x - 1)
        } else {
            return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1])
        }
    }
    val ans = f(N, X)
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map(String::toLong)


Measured memory_bytes: 37860
#include <bits/stdc++.h>
using namespace std;
//4/
typedef unsigned long long ull;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i < (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fill_2(a,b)  memset(a, 0, sizeof (a));memset(b, 0, sizeof (b));
#define fill_n(a) memset(a,-1,sizeof(a))
#define fst first
#define snd second
#define mpr make_pair
#define pb push_back
#define mod 1000000007
#define endl "\n"
//#define int long long
 
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll, pii> pip;
typedef pair<pii, ll> ppi;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<ll,ll> mpl;
 
inline ll exp(ll x,ll n){ll r=1;x=x%mod;while(n){if(n%2)r=(r*x)%mod;x=(x*x)%mod;n=n/2;}return r;}
inline ll mmi(ll a){return exp(a,mod-2)%mod;}
inline ll fact(ll n){ll res=1;repA(i,1,n+1){res=(res*i)%mod;}return res;}
inline ll inv_fact(ll n){ll par=fact(n);ll res=mmi(par);return res;}

struct triplet{ll a,b,c;};
bool operator < (const triplet &t1,const triplet &t2){
	if(t1.a<t2.a)return true;
	if(t1.a==t2.a && t1.b <t2.b)return true;
	if(t1.a==t2.a && t1.b ==t2.b && t1.c<t2.c)
		return true;return false;}
 

pair<ll,pii > ex_gcd(ll a,ll b)
{   if(b==0){return mpr(a,mpr(1,0));}
    pip p=ex_gcd(b,a%b);
	ll gcd=p.fst;ll x1=p.snd.fst;ll y1=p.snd.snd;
    ll x=y1;ll y=x1-(a/b)*y1;
	return mpr(gcd,mpr(x,y));
} 


int main()
{
	ll n;
	cin>>n;
	ll f=(n)/500;
	f=1000*f;
	n=n%500;
	ll s=(n/5)*5;
	cout<<f+s<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
typedef long long ll;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
 
using namespace std;

int main(){
    int N;  cin >> N;
    vector<int> v(N);
    for(int i=0; i<N; i++)  cin >> v[i];
    sort(all(v));
    int ans[N-1][2];
    int tmp;
    if(v[0] >= 0 && v[N-1] >= 0){
        tmp = v[0];
        for(int i=0; i<N-2; i++){
            ans[i][0] = tmp;
            ans[i][1] = v[i+1];
            tmp -= v[i+1];
        }
        ans[N-2][0] = v[N-1];
        ans[N-2][1] = tmp;
        tmp = v[N-1] - tmp;
    }else if(v[0] <= 0 && v[N-1] >= 0){
        for(int i=0; i<N; i++){
            if(v[i] >= 0){
                for(int j=i; j<N-1; j++){
                    ans[j-i][0] = v[0];
                    ans[j-i][1] = v[j];
                    v[0] -= v[j];
                }
                for(int j=0; j<i; j++){
                    ans[N-1-i+j][0] = v[N-1];
                    ans[N-1-i+j][1] = v[j];
                    v[N-1] -= v[j];
                }
                tmp = v[N-1];
                break;
            }
        }
    }else{
        for(int i=N-1; i>0; i--){
            ans[N-1-i][0] = v[N-1];
            ans[N-1-i][1] = v[i-1];
            v[N-1] -= v[i-1];
        }
        tmp = v[N-1];
    }
    print(tmp);
    for(int i=0; i<N-1; i++)    cout << ans[i][0] << " " << ans[i][1] << endl;
}

Measured memory_bytes: 4580
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int a[1005];
int main()
{
	int sum = 0,m,n,i,k;
	scanf("%d%d",&n,&m);
	for (i = 0;i < n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	k = n - m;
	for (i = k;i < n;i++)
		sum = sum + a[i];
		printf("%d",sum);
	return 0;
}



Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

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



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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N; cin >> N;
	vi A(N);
	for(auto &x : A)cin >> x;
	//if(N == 2){
		//cout << A[1] << ' ' << A[0] << '\n';
		//return 0;
	//}
	ll ac = A[0];
	forn(i,1,N)ac ^= A[i];
	forn(i,0,N){
		ac ^= A[i];
		cout << ac << ' ';
		ac ^= A[i];
	}
	cout << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    ll n, c, k;
    cin >> n >> c >> k;
    vector<ll> t(n, 0);
    rep1(i, n) cin >> t[i];
    sort(t.begin(), t.end());
    ll ans = 1, lim = 1e10, cnt = 0;
    rep1(i, n){
        if (cnt<c){
            if (t[i]<=lim){
                cnt++;
                lim = min(lim, t[i]+k);
            } else{
                ans++;
                cnt = 1;
                lim = t[i] + k;
            }
        } else{
            ans++;
            cnt = 1;
            lim = t[i] + k;
        }
    }
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int n;
    cin>>n;
    deque<int> que;
    rep(i,n){
        int tmp;cin>>tmp;
        if(i%2)que.push_back(tmp);
        else que.push_front(tmp);
    }
    rep(i,n){
        if(n%2){
            cout << que.front();
            que.pop_front();
        }else{
            cout << que.back();
            que.pop_back();
        }
        if(i==n-1)cout << endl;
        else cout << " ";
    }
    return 0;
}


Measured memory_bytes: 2944
a = list(map(int, input().split()))
cnt_five = 0
cnt_seven = 0

for i in range(3):
    if (a[i] == 5):
        cnt_five += 1
    if (a[i] == 7):
        cnt_seven += 1

if(cnt_five == 2 and cnt_seven == 1):
    print('YES')
else:
    print('NO')


    

Measured memory_bytes: 9116
#dpで素直にやるとO(N^2)だから、累積和で高速化しO(KN)にする

n, k = map(int,input().split())
mod = 998244353

s = []
for i in range(k):
  s.append(list(map(int,input().split())))

cnt = [0]*n
cnt[0] = 1
sum = [0]*n
sum[0] = 1
for i in range(1,n):
  for j in range(k):
    if i > s[j][1]:
      cnt[i] += sum[i-s[j][0]] - sum[i-s[j][1]-1]
    elif i >= s[j][0]:
      cnt[i] += sum[i-s[j][0]]
    cnt[i] %= mod
    sum[i] = (sum[i-1] + cnt[i]) % mod

print(cnt[-1])

Measured memory_bytes: 77184
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        p: [usize; 5]
    }
    let m = p.iter().min().unwrap();
    let k = if n % m > 0 {
        n / m + 1
    } else {
        n / m
    };
    println!("{}", k + 4);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
using namespace std;
int a,b,c,x,y;
int main()
{
    while(~scanf("%d %d %d %d %d",&a,&b,&c,&x,&y))
    {
        if(a+b<2*c)
            printf("%d\n",a*x+b*y);
        else
        {
            int sum=0;
            if(x>=y)
            {
                sum+=2*c*y;
                x-=y;
                y=0;
                if(a<=2*c)
                {
                    sum+=a*x;
                }
                else
                    sum+=2*c*x;
                printf("%d\n",sum);
            }
            else
            {
                sum+=2*c*x;
                y-=x;
                x=0;
                if(b<=2*c)
                    sum+=b*y;
                else
                    sum+=2*c*y;
                printf("%d\n",sum);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	int a,b;
	cin>>a>>b;
	cout<<(a+b)%24<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    string ans = "AGC";
    if (n<1200) ans = "ABC";
    else if (n<2800) ans = "ARC";
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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; cin >> N;
  vvi A(2,vi(N)); REP(i,2) REP(j,N) cin >> A[i][j];

  int ans = 0;
  REP(down,N) {
    int s1 = accumulate(A[0].begin(),A[0].begin()+down+1,0);
    int s2 = accumulate(A[1].begin()+down,A[1].end(),0);
    ans = max(ans, s1+s2);
  }

  cout << ans << endl;
}

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

typedef long long int ll;
ll powk(ll a, ll n = 2){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> h(n);
    vector<pair<ll,ll>> ab(m);
    for(ll i = 0;i < n;i++){
        cin >> h[i];
    }
    for(ll i = 0;i < m;i++){
        cin >> ab[i].first >> ab[i].second;
    }
    vector<ll> ans(n);

    for(ll i = 0;i < m;i++){
        if(h[ab[i].first - 1] < h[ab[i].second - 1]){
            ans[ab[i].first - 1] = -1;
        }
        else if(h[ab[i].first - 1] == h[ab[i].second - 1]){
            ans[ab[i].first - 1] = ans[ab[i].second - 1] = -1;
        }
        else{
            ans[ab[i].second - 1] = -1;
        }
    }

    ll cnt = 0;
    for(ll i = 0;i < n;i++){
        if(ans[i] != -1){
            cnt++;
        }
    }

    cout << cnt;

    return 0;
}

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

using namespace std;
#define ll long long
#define f first
#define s second
int main() {
    //freopen("sample-8.in", "r", stdin);
    //freopen("output8.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b;
    cin>>a>>b;
    if(a>=13){
        cout<<b<<endl;
    }
    else if(a<=5){
        cout<<0<<endl;
    }
    else{
        cout<<b/2<<endl;
    }
    return 0;
}

Measured memory_bytes: 256