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

using namespace std;

int main(){
  int n;
  string s;
  int wsm[300009], esm[300009];
  memset(wsm, 0, sizeof(wsm));
  memset(esm, 0, sizeof(esm));
  cin >> n;
  cin >> s;
  if(s[0]=='W')wsm[0]++;
  for(int i=1;i<s.length();i++){
    wsm[i]=wsm[i-1];
    if(s[i]=='W')wsm[i]++;
  }
  if(s[s.length()-1]=='E')esm[s.length()-1]++;
  for(int i=s.length()-2;i>=0;i--){
    esm[i] = esm[i+1];
    if(s[i]=='E')esm[i]++;
  }
  int mn = 300000;
  mn = min(mn, esm[1]);
  mn = min(mn, wsm[s.length()-2]);
  for(int i=1;i<s.length()-1;i++){
    mn = min(mn, wsm[i-1]+esm[i+1]);
  }
  cout << mn << endl;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define int long long
using namespace std;

typedef pair<int, int> Pii;

void readint(int N, vector<int> &a);
void readdouble(int N, vector<double> &a);
void readindex(int N, vector<int> &a);



signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    readint(n, a);

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

    int N = a[n - 1];
    int min = a[n - 1] + 1;
    int M = -1;
    REP(i, n){
        if(min > llabs(N - 2 * a[i])){
            min = llabs(N - 2 * a[i]);
            M = a[i];
        }
    }

    cout << N << " " << M;
    
    return 0;
}








void readint(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readdouble(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
void readindex(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str()) - 1;
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str()) - 1;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
using namespace std;

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

  int flag1 = 0;
  int flag2 = 0;
  int flag = 0;
  int count = 0;

  for(int i = 0; i < n-1;) {
    if(s[i] != s[i+1]){
      count++;
      i+=2;
      flag = 1;
    }
    else {
      i++;
      flag = 0;
    }
  }


  cout << count << endl;
  /*
  for(int i = 0; i < n; i++) {
    if(s[i] == 'O' && flag1 == 0 && flag != 1) {
      flag1 = 1;
      flag = 1;
      cout << "1: " ;
    }
    else if(s[i] == 'X' && flag2 == 0 && flag != 1) {
      flag2 = 1;
      flag = 1;
      cout << "2: " ;
    }
    else if(s[i] == 'O' && flag2 == 1) {
      count++;
      flag2 = 0;
      flag1 = 0;
      flag = 0;
      cout << "3: " ;
    }
    else if(s[i] == 'X' && flag1 == 1) {
      count++;
      flag1 = 0;
      flag2 = 0;
      flag = 0;
      cout << "4: " ;
    }
    else {

      flag1 = 0;
      flag2 = 0;
      flag = 0;

      cout << "5: " ;

    }
  //  if(i % 2 == 0) cout << count << endl;


    cout <<"i:"<< i << " " << s[i] << " " << flag1 << " " << flag2 <<" " << count << endl;

  }

  if(flag1 == 1 && flag2 == 1) {
    count++;
  }
  */

}



Measured memory_bytes: 3336
from itertools import combinations as comb
N = int(input())
L = list(map(int,input().split()))
count = 0
for a, b, c in comb(L, 3):
  if a != b and b != c and c != a and a + b > c and b + c > a and c + a > b:
    count += 1
print(count)

Measured memory_bytes: 9048
#include <iostream>
#include <string.h>

using namespace std;
int main(void){
        char buf[255];
        scanf("%s", buf);

        const int len = strlen(buf);
        int count = 0;
        int max_count = 0;
        for (int i = 0 ; i < len ; i++) {
                char c = buf[i];
                bool last = false;
                if (i == len - 1) {
                        last = true;
                }

                bool is_cand = c == 'A' || c == 'T' || c == 'G' || c == 'C';
                if (is_cand) {
                        count++;
                }

                if (last || !is_cand) {
                                if (max_count < count) {
                                        max_count = count;
                                }
                                count = 0;
                }
        }

        std::cout << max_count;
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
# list(map(int, input().split()))
mod = 10 ** 9 + 7

N = getN()
splitlist = [1]
splitsix = 6
while splitsix < 100000:
    splitlist.append(splitsix)
    splitsix *= 6
splitnine = 9
while splitnine < 100000:
    splitlist.append(splitnine)
    splitnine *= 9
splitlist.sort()
# これやらないと再帰が無限に実行される
splitlist.reverse()

ans = float('inf')
dp = [float('inf')] * (N + 1)
dp[0] = 0

def spliter(n):
    if dp[n] < 1000000:
        return dp[n]
    res = float('inf')
    for split in splitlist:
        if n >= split:
            res = min(res, spliter(n - split) + 1)
    dp[n] = res
    return res
spliter(N)
print(dp[-1])

Measured memory_bytes: 47308
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//mint型にキャスト
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(ll n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
int main(){
    init();
   ll h,w,a,b;
   cin>>h>>w>>a>>b;
   mint ans=0;
   for(int i=0;i<h-a;i++){
       ans+=COM(i+b-1,i)*COM(h-i+w-b-2,h-i-1);
   }
  cout<<ans<<"\n";

}


Measured memory_bytes: 50508
N, K = map(int, input().split())
V = list(map(int, input().split()))

R = min(N, K)
l = []
ans = 0
for a in range(R + 1):
  for b in range(R + 1 - a):
    l = V[:a] + V[N - b:]
    l.sort()
    for i in range(K - a - b + 1):
      ans = max(ans, sum(l[i:]))
print(max(ans, 0))

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <tuple>
#include <algorithm>
#include <map>
#include <cmath>
#include <tuple>
using namespace std;
long long int MOD = 1000000000 + 7;
using ll = long long;
ll LARGE = 1000000;


int main() {
	ll n;
	cin >> n;
	map<string, int> s;
	ll m = 0;
	for (ll i = 0; i < n; ++i) {
		string k;
		cin >> k;
		if (s.find(k) != s.end()) {
			s[k]++;
		}
		else {
			s[k] = 0;
		}
		if (m < s[k]) {
			m = s[k];
		}
	}

	for (auto it = s.begin(); it != s.end(); ++it) {
		if (it->second == m) {
			cout << it->first << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 25216
var
  a:array[1..100000]of longint;
  b:array[1..2,1..100000]of longint;
  n,m,k,i,p,q,o,f,t:longint;
begin
  readln(n);
  for i:=1 to n do 
  begin
     read(a[i]);
	 inc(b[((i-1)mod 2)+1,a[i]]);
	 if a[i]>k then k:=a[i];
  end;
  for i:=1 to k do
  begin
     if b[1,i]>p then begin p:=b[1,i]; o:=i; end;
     if b[2,i]>q then begin q:=b[2,i]; m:=i; end;
  end;
  if o=m then 
  begin 
    if p>q then
	begin
    for i:=1 to k do
	begin
       if (i<>o)and(b[2,i]>=f) then f:=b[2,i];
    end;
	f:=f+p;
	end else
    if p<q then
	begin
    for i:=1 to k do
	begin
       if (i<>o)and(b[1,i]>=f) then f:=b[1,i];
    end;
	f:=f+q;
	end else
	begin
    for i:=1 to k do
	begin
       if (i<>o)and(b[1,i]>=f) then f:=b[1,i];
       if (i<>o)and(b[2,i]>=t) then t:=b[2,i];
    end;
	if t>f then f:=t+p
	else f:=f+p;
	end;
  end else f:=p+q;
  writeln(n-f);
end.

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

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

int n,m,a[1000005];

int main()
{
	n=read();
	for ( int i=2;i<=n;i++ ) a[read()]++;
	for ( int i=1;i<=n;i++ ) printf("%d\n",a[i]);
}


Measured memory_bytes: 4412
#include<iostream>
#include<vector>
#include<string>
#include<math.h> 
#include<algorithm> 
#include<stdio.h> 
#include<sstream>
#include<fstream>  
using namespace std; 
typedef long long ll; 
typedef long double ld; 

int ceil(int a, int m){
    // division of a and m
    if(a % m == 0){
        return a/m; 
    }
    else{
        return a/m + 1; 
    }
}

char nl = '\n'; 
char bl = ' ';
const int MOD = 1e9 + 7; 

int main(){

ios_base::sync_with_stdio(false);
cin.tie(NULL); 
int x; 
cin >> x;
cout << (x == 1 ? 0: 1);


}



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

static const int NMAX = 1000000;

typedef struct process 
{
    char name[11];
    int time;
} Process;

typedef struct queue {
    int n = NMAX;
    Process buf[NMAX];
    Process *buf_end = buf + n - 1;
    Process *start = buf;
    Process *end = buf;
    int size = 0;

    void init(void) {
        size = 0;
        start = buf;
        end = buf;
    }
    bool isEmpty() {
        return size == 0;
    }
    bool isFull() {
        return size == n-1;
    }
    void put(Process *a) {
        if (isFull()) {
            printf("Error!! queue is full!!\n");
        }
        *(end++) = *a;
        size++;
        if (end > buf_end) end = buf;
    }
    Process* get() {
        if (isEmpty()) {
            printf("Error!! queue is empty!!\n");
        }
        size--;
        return start++;
    }
} Queue;

int run (Queue *queue, const int q) {
    int time = 0;
    int rest_time;

    while (queue->size > 0) {
        Process *p = queue->get();
        if (p->time > q) {
            p->time -= q;
            queue->put(p);
            time += q;
        }
        else {
            time += p->time;
            printf("%s %d\n", p->name, time);
        }
    }
}


int main (void) {

    Queue queue; 
    char c[16];
    int n, q;
    char op;
    int ret;
    Process p;

    queue.init();

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

    for (int i = 0; i < n; i++) {
        scanf("%s %d", p.name, &p.time);
        queue.put(&p);
    }

    int t = run(&queue, q);

}



Measured memory_bytes: 5652
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    vector<int> a(3);
    int ans=0;
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(),a.end());

    ans = (a[1]-a[0])+(a[2]-a[1]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
function*stdinIter(){const t=require("fs").readFileSync("/dev/stdin","utf-8").trim().split(/\n|\s/);yield*t}function readMany(t,e){const i=e||this.iter||(this.iter=stdinIter()),n=[];for(let e=0;e<t;e+=1)n.push(i.next().value);return n};

(() => {
    const [ a, b, c ] = readMany(3).map(it => parseInt(it))

    // n * B + C が A の倍数になる整数 n があればよい。
    for (let n = 1; n <= 200; n += 1) {
        if ((n * b + c) % a == 0) return console.log('YES')
    }
    console.log('NO')
})()


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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, m;
  cin >> n >> m;
  vector< vector< tuple< int, ul > > > path(n);
  for (int i=0; i<m; ++i) {
    int l, r;
    ul c;
    cin >> l >> r >> c;
    l--; r--;
    path[l].push_back(make_tuple(r, c));
  }
  for (int i=1; i<n; ++i) {
    path[i].push_back(make_tuple(i-1, 0));
  }
  priority_queue< tuple< ul, int >, vector< tuple< ul, int > >, greater< tuple< ul, int > > > q;
  q.push(make_tuple(0, 0));
  vector< bool > v(n, false);
  while (!q.empty()) {
    auto t = q.top();
    q.pop();
    ul cur_cost = get<0>(t);
    int cur_idx = get<1>(t);
    if (v[cur_idx]) continue;
    v[cur_idx] = true;
    if (cur_idx == n-1) {
      cout << cur_cost << endl;
      return 0;
    }
    for (auto child : path[cur_idx]) {
      int next_idx = get<0>(child);
      ul path_cost = get<1>(child);
      if (v[next_idx]) continue;
      q.push(make_tuple(cur_cost + path_cost, next_idx));
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 9332
#include <iostream>

using namespace std;

int main() {
	int N;
	cin >> N ;
	
	int length = to_string(N).length();

	
	for(int i = 0 ; i < length ; i++) {
		N %= 10;
	}
	if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
		cout << "hon" << "\n";
	}
	else if ( N == 0 || N == 1 || N == 6 || N == 8 ) {
		cout << "pon" << "\n";
	}
	else {
		cout << "bon" << "\n";
	}
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

lint a, b, c, d;

lint ct(lint n, lint d) {
    return n/d;
}

int main() {
    cin >> a >> b >> c >> d;

    lint res = 0;
    lint l = lcm(c, d);

    res = b - ct(b, c) - ct(b, d) + ct(b, l);
    res -= (a-1) - ct(a-1, c) - ct(a-1, d) + ct(a-1, l);

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
//quming
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=2005,L=2000;
int c[N],a[N],n,res;
inline void chg(R int x,R int y){for(;x<=L;x+=x&-x)c[x]+=y;}
inline int query(R int x){R int res=0;for(;x>0;x-=x&-x)res+=c[x];return res;}
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%d",&a[i]);
	fp(i,1,n){
		res+=query(a[i]);
		fp(j,1,i-1){
			R int r=a[i]+a[j],l=abs(a[i]-a[j]);
			chg(l+1,1),chg(r,-1);
		}
	}
	printf("%d\n",res);
	return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C){
    if (A + B >= C) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }

}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


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

using namespace std;
int main()
{
  string a,b;
  cin >> a >> b;
  int diff = 0;
  for(int i=0; i<(int)a.size(); i++){
    if(a[i] != b[i]){
      diff++;
    }
  }
  cout << diff << endl;
  
}

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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    string S;
    int K;
    cin >> S >> K;
    int N = S.size();

    string ans = "";

    rep(i,N) {
        if (i==N-1) {
            int idx = S[i] - 'a';
            idx += K;
            idx %= 26;
            ans += idx + 'a';
        }
        else if (S[i]=='a') {
            ans += 'a';
        }
        else {
            int idx = S[i] - 'a' + 1;
            if (K>=27-idx) {
                ans += 'a';
                K -= 27-idx;
            }
            else {
                ans += S[i];
            }
        }
    }
    cout << ans << endl;
}


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

/*                          
---------------------------------------------------------------
Aditya Kumar mishra
---------------------------------------------------------------
*/

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define len(s) s.length()
#define forp(i, a, b) for (int i = a; i <= b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define ren(i, n) for (int i = n - 1; i >= 0; i--)
#define forn(i, a, b) for (int i = a; i >= b; i--)
#define on cout << endl
#define o2(a, b) cout << a << " " << b
#define os cout << " "
#define all(v) v.begin(), v.end()
#define mem(n, m) memset(n, m, sizeof(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define sii set<int>
#define us unordered_set<int>
#define um unordered_map<int, int>
#define sll set<long long>
#define vii vector<int>
#define vll vector<long long>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ret return 0
#define present(s, x) (s.find(x) != s.end())
#define cpresent(s, x) (find(all(s), x) != s.end())
#define ford(container, it) for (__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fors(container, it, a, b) for (__typeof(container.begin()) it = a; it != b; it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100001
#define SIZ 1000001
#define SIZE 200001

typedef long long ll;
typedef long double ldo;
typedef double db;
using namespace std;
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

void c_p_c()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int main()
{
    c_p_c();
    ll k;
    cin >> k;
    int val = 7%k;
    for (int i = 1; i < 1e7; i++)
    {
        if (val == 0)
        {
            cout << i;
            ret;
        }
        val = (val * 10 + 7) % k;
    }

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

Measured memory_bytes: 3624
d, n = map(int, input().split())
if d == 0:
    if n == 100:
        print(101)
    else:    
        print(n)
elif d == 1:
    if n == 100:
        print(10100)
    else:
        print(100*n)
elif d == 2:
    if n == 100:
        print(1010000)
    else:
        print(10000*n)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
double ans=0;
struct pos{
	double pi,qi;
	bool operator <(const pos &b)const{
		return pi/(pi+qi)>b.pi/(b.pi+b.qi);
	}
}v[8];
int pp[10],qq[10];
int main(){
	int n=0;
	for(int i=1;i<=6;i++) scanf("%d",&pp[i]);
	for(int i=1;i<=6;i++) scanf("%d",&qq[i]);
	for(int i=1,p,q;i<=6;i++){
		p=pp[i],q=qq[i];
		if(p+q==0) continue;n++;
		v[n].pi=0.01*p,v[n].qi=0.01*q;
	}
	double tot=1,ans=0;
	sort(v+1,v+n+1);
	for(int i=1;i<=n;i++)
		ans+=v[i].pi*min(v[i].pi+v[i].qi,tot)/(v[i].pi+v[i].qi),
		tot-=min(v[i].pi+v[i].qi,tot);
	printf("%.10lf",(double)ans);
	return 0;
}

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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,ans; string str;

int solve(){
    cin>>n;
    int t=sqrt(n);
    rep1(i,t,1){
        if(n%i==0){
            cout<<i+n/i-2;
            return 0;
        }
    }
    cout<<n-1;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

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

import math

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

if N==0:
    p = []
else:
    p = list(map(int, input().split()))

p = sorted(p)

for i in range(100):
    if X-i not in p:
        print(X-i)
        quit()

    if X+i not in p:
        print(X+i)
        quit()


Measured memory_bytes: 9160
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int x; cin >> x;
	cout << (x < 1200?"ABC":"ARC") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    int A, P;
    cin >> A >> P;

    int piece = A * 3 + P;

    cout << piece / 2;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int main() {

	int no[5];

	for (int i = 0; i < 5; i++)
		cin >> no[i];

	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 4; j++) {
			if (no[j] < no[j + 1])
				swap(no[j], no[j + 1]);
		}
	}

	for (int i = 0; i < 5; i++) {
		if (i != 0) putchar(' ');
		cout << no[i];
	}
	putchar('\n');

	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;
import java.util.List;
import java.util.Arrays;
import java.util.stream.Collectors;

public class Main {
    
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        
        String[] numbers = scanner.nextLine().split(" ");
        List<Integer> result = Arrays.asList(numbers)
            .stream()
            .map(i -> Integer.parseInt(i))
            .sorted()
            .collect(Collectors.toList());
        
        System.out.println(result.get(0) + " " + result.get(1) + " " + result.get(2));
    } 
}


Measured memory_bytes: 31916
N=int(input())
A=list(map(int,input().split()))
A.insert(0,0)
A.append(0)
value=sum([round(abs(A[i+1]-A[i])) for i in range(len(A)-1)])
for i in range(1,N+1):
    if A[i-1]<=A[i]<=A[i+1] or A[i-1]>=A[i]>=A[i+1]:
        print(value)
    else:
        print(value-2*round(min(abs(A[i]-A[i-1]),abs(A[i+1]-A[i]))))


Measured memory_bytes: 65516
x1, y1, x2, y2 = map(int, input().split())
x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x3 - (y3 - y2)
y4 = y3 + (x3 - x2)
print("{} {} {} {}".format(x3, y3, x4, y4))

Measured memory_bytes: 3060
def print_num(a, b):

    if a < b:
        first  = a
        second = b
    else:
        first  = b
        second = a

    print(str(first) + " " + str(second))

if __name__ == "__main__":

    while(1):
        param = input()
        param = param.split(" ")

        a = int(param[0])
        b = int(param[1])

        if a == 0 and b == 0:
            break
        else:
            print_num(a, b)


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

vector <pair <int, int>> v;
int ans[500 * 500 + 10];
int n;

bool emplace()
{
    queue <int> util, ramas;
    for (auto i : v) {
        for (int j(1); j < i.second; j++)
            util.push(i.second);
        for (int j(i.second + 1); j <= n; j++)
            ramas.push(i.second);
    }
    vector <int> nrpus(n + 1);
    for (int i(1); i <= n * n; i++) {
        if (ans[i]) {
            if (nrpus[ans[i]] != ans[i] - 1)
                return false;
            continue;
        }
        if (!util.empty()) {
            nrpus[util.front()]++;
            ans[i] = util.front();
            util.pop();
        }
        else {
            nrpus[ramas.front()]++;
            ans[i] = ramas.front();
            ramas.pop();
        }
    }
    return true;
}

int main()
{
    cin >> n;
    v.resize(n);
    for (int i(1); i <= n; i++) {
        cin >> v[i - 1].first;
        v[i - 1].second = i;
        ans[v[i - 1].first] = i;
    }

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

    if (!emplace()) {
        cout << "No";
        return 0;
    }

    cout << "Yes\n";

    for (int i(1); i <= n * n; i++)
        cout << ans[i] << ' ';
    return 0;
}


Measured memory_bytes: 2304
use std::str::FromStr;
use std::io::stdin;

fn read<T: FromStr>() -> T{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
                    .map(|e| e.parse().ok().unwrap())
                    .collect()
}

fn main() {
    let n = read::<i32>();
    let k = read::<i32>();

    let mut res = 1;
    for i in 0..n {
        if res+k < res*2 {
            res += k;
        } else {
            res *= 2;
        }
    }
    println!("{}",res);
}

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

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
inline void Fail(){
	printf("0");
	exit(0);
}

const int maxn=805;
int n,m,k,mn=INF,sx,sy;
char grid[maxn][maxn];
int dis[maxn][maxn];
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};

int Dist(int x,int y){
	return min(x,min(y,min(n-x-1,m-y-1)));
}

bool onboard(int x,int y){
	return x>=0&&x<n&&y>=0&&y<m;
} 

void bfs(){
	memset(dis,-1,sizeof(dis));
	dis[sx][sy]=0;
	queue<pii>q;
	q.push(mp(sx,sy));
	while(!q.empty()){
		int x=q.front().first,y=q.front().second;
		q.pop();
		if(dis[x][y]<=k)mn=min(mn,Dist(x,y));
		rep(i,4){
			int nx=x+dx[i],ny=y+dy[i];
			if(onboard(nx,ny)&&dis[nx][ny]==-1&&grid[nx][ny]=='.'){
				dis[nx][ny]=dis[x][y]+1;
				q.push(mp(nx,ny));
			}
		}
	}
}

int main(){
	scanf("%d%d%d",&n,&m,&k);
	rep(i,n){
		scanf("%s",grid[i]);
		rep(j,m)if(grid[i][j]=='S')sx=i,sy=j;
	}
	bfs();
	printf("%d",1+(mn+k-1)/k);
	return 0;
}

/*
Input:
7 7 1
#######
#######
##...##
#######
##.S.##
###.###
###.###
-----------------
Output:
*/

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
using namespace std;
const int N=2102;
vector<int> g[N*N];
int n,m,q,par[N*N];
char s[N][N];
int sd[N][N],su[N][N],sl[N][N],sr[N][N],sum[N][N];
int dx[4]={-1,1,0,0};
int dy[4]={0,0,1,-1};
int vis[N*N];
int id(int x,int y) {
    return x*m+y;
}
void dfs(int x,int y){
    vis[id(x,y)]=1;
    for(int i=0;i<4;i++){
        int nx=x+dx[i];
        int ny=y+dy[i];
        if(vis[id(nx,ny)]==0 && s[nx][ny]=='1'){
            par[id(nx,ny)]=id(x,y);     
            dfs(nx,ny);
        }
    }
}
int main() {
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=n;i++){
        scanf("%s",s[i]+1);
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i][j]=='1' && vis[id(i,j)]==0) {
                dfs(i, j); 
                sum[i][j]=1; 
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            sum[i][j]=sum[i][j]+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i][j]=='1' && s[i][j-1]=='1' && par[id(i,j)] == id(i,j-1)) {
                sl[i][j]=1;
            }
            if(s[i][j]=='1' && s[i][j+1]=='1' && par[id(i,j)] == id(i,j+1)) {
                sr[i][j]=1;
            }
            if(s[i][j]=='1' && s[i-1][j]=='1' && par[id(i,j)] == id(i-1,j)) {
                su[i][j]=1;
            }
            if(s[i][j]=='1' && s[i+1][j]=='1' && par[id(i,j)] == id(i+1,j)) {
                sd[i][j]=1;
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            sl[i][j]+=sl[i-1][j];
            sr[i][j]+=sr[i-1][j];
            su[i][j]+=su[i][j-1];
            sd[i][j]+=sd[i][j-1];
        }
    }
    while(q--) {
        int x1,y1,x2,y2;
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        int ans=sum[x2][y2]-sum[x2][y1-1]-sum[x1-1][y2]+sum[x1-1][y1-1];
        ans=ans+sr[x2][y2]-sr[x1-1][y2];
        ans=ans+sl[x2][y1]-sl[x1-1][y1];
        ans=ans+su[x1][y2]-su[x1][y1-1];
        ans=ans+sd[x2][y2]-sd[x2][y1-1];
        printf("%d\n", ans);
    }
}   






Measured memory_bytes: 230656
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>

template <size_t Size> struct Activity {
  Activity() = default;
  size_t max() const { return *std::max_element(values.begin(), values.end()); }

  size_t best(const Activity<Size> &other, const size_t index) const {
    size_t best{0};
    for (size_t i = 0; i < Size; ++i) {
      if (i != index) {
        best = std::max(best, other.values[i]);
      }
    }

    return values[index] + best;
  }

  static Activity<Size> create_next(const Activity<Size> &curr,
                                    const Activity<Size> &prev) {
    Activity<Size> result{};
    for (size_t i = 0; i < Size; ++i) {
      result.values[i] = curr.best(prev, i);
    }
    return result;
  }

  std::array<size_t, Size> values;
};

using Activity3 = Activity<3>;

template <size_t Size>
size_t bigger_gain(const std::vector<Activity<Size>> &activities) {
  if (activities.empty()) {
    return 0u;
  }
  if (activities.size() == 1u) {
    return activities.front().max();
  }

  Activity<Size> prev = activities.front();

  for (size_t i = 1u; i < activities.size(); ++i) {
    prev = Activity<Size>::create_next(activities[i], prev);
  }

  return prev.max();
}

int main() {
  size_t count{0};
  std::cin >> count;

  std::vector<Activity3> activities;
  activities.reserve(count);

  for (size_t i = 0; i < count; ++i) {
    Activity3 activity{};
    std::cin >> activity.values[0] >> activity.values[1] >> activity.values[2];
    activities.push_back(activity);
  }

  std::cout << bigger_gain(activities) << std::endl;
  return 0;
}

Measured memory_bytes: 2560
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

map<int,int> f;
const int N = 300005;
int cnt[N];
int ps[N];
int ss[N];

void solve(){  
	int n;
	cin>>n;
	rep(i,0,n){
		int x;
		cin>>x;
		f[x]++;
	}  
	for(auto i:f){
		cnt[i.S]++;
	}
	rep(i,1,n+1){
		ps[i]=ps[i-1]+i*cnt[i];
	}
	repd(i,n,1){
		ss[i]=ss[i+1]+cnt[i];
	}
	rep(i,1,n+1){	
		int lo=0;
		int hi=n+1;
		while(hi-lo>1){
			int mid=(hi+lo)/2;
			int tot=(ss[mid+1]*mid)+ps[mid];
			if(tot>=i*mid){
				lo=mid;
			}
			else hi=mid;
		}
		cout<<lo<<endl;
	}
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 25088
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func newGraph(nNodes int) *Graph {
	g := Graph{}
	g.nodes = make([]*GraphNode, nNodes)
	for iNode := 0; iNode < len(g.nodes); iNode++ {
		g.nodes[iNode] = &GraphNode{}
		g.nodes[iNode].key = GraphNodeKey(iNode)
	}
	return &g
}

var infty = 1000000000

type GraphNodeKey int

// GraphNode is a node for undirected graph
type GraphNode struct {
	key       GraphNodeKey
	adjacents []*GraphNode
	visited   bool
	d, f      int
	parent    *GraphNode
	cc        int
}

func (g *Graph) setAdjacent(l, r GraphNodeKey) {
	g.nodes[l].adjacents = append(g.nodes[l].adjacents, g.nodes[r])
}

// Graph is a undirected graph
type Graph struct {
	nodes []*GraphNode
}

func (g *Graph) initialize() {
	for iNode := 0; iNode < len(g.nodes); iNode++ {
		g.nodes[iNode].visited = false
		g.nodes[iNode].d = infty
		g.nodes[iNode].f = infty
		g.nodes[iNode].parent = nil
		g.nodes[iNode].cc = -1 // 22.3-12
	}
}

type QueueEntry struct {
	node *GraphNode
	next *QueueEntry
}

type Queue struct {
	head, tail *QueueEntry
}

func (q *Queue) enqueue(node *GraphNode) {
	entry := QueueEntry{}
	entry.node = node

	if q.tail == nil {
		q.head = &entry
		q.tail = &entry
		return
	}

	q.tail.next = &entry
	q.tail = q.tail.next
}

func (q *Queue) dequeue() *QueueEntry {
	if q.head == nil {
		return nil
	}
	poped := q.head
	q.head = q.head.next
	if q.head == nil {
		q.tail = nil
	}
	return poped
}

func (q *Queue) isEmpty() bool {
	return q.head == nil
}

var time = 0

func dfsVisit(g *Graph, u *GraphNode, cc int) {
	time++
	u.d = time
	u.cc = cc

	u.visited = true
	for _, v := range u.adjacents {
		if !v.visited {
			v.parent = u
			dfsVisit(g, v, cc)
		}
	}
	time++
	u.f = time
}

func stronglyConnectedComponentsDecomposition(g *Graph) *Graph {
	g.initialize()
	time = 0

	for _, u := range g.nodes {
		if !u.visited {
			dfsVisit(g, u, 0)
		}
	}

	gT := newGraph(len(g.nodes))
	for _, left := range g.nodes {
		for _, right := range left.adjacents {
			gT.setAdjacent(right.key, left.key)
		}
	}
	sort.Slice(g.nodes, func(i, j int) bool { return g.nodes[i].f > g.nodes[j].f })

	cc := 0
	for _, node := range g.nodes {
		u := gT.nodes[node.key]
		if !u.visited {
			dfsVisit(gT, u, cc)
			cc++
		}
	}

	return gT
}

func main() {
	scanner.Split(bufio.ScanWords)

	nNodes := nextInt()
	nEdges := nextInt()
	graph := newGraph(nNodes)
	for iEdge := 0; iEdge < nEdges; iEdge++ {
		l := GraphNodeKey(nextInt())
		r := GraphNodeKey(nextInt())
		graph.setAdjacent(l, r)
	}

	graphTransposed := stronglyConnectedComponentsDecomposition(graph)

	nQueries := nextInt()
	for iQuery := 0; iQuery < nQueries; iQuery++ {
		l := GraphNodeKey(nextInt())
		r := GraphNodeKey(nextInt())

		if graphTransposed.nodes[l].cc == graphTransposed.nodes[r].cc {
			fmt.Println("1")
		} else {
			fmt.Println("0")
		}
	}
}



Measured memory_bytes: 4764
#include<stdio.h>
typedef long long ll;
ll dp[311][311][311];
int main()
{
	int num, gen;
	ll mod;
	scanf("%d%d%lld", &num, &gen, &mod);
	dp[0][0][0] = 1;
	for (int i = 0; i < gen; i++)
	{
		for (int j = 0; j <= num; j++)dp[i + 1][j][j] = dp[i][j][0];
		for (int j = 0; j <= num; j++)for (int k = j - 1; k >= 0; k--)dp[i + 1][j][k] = (dp[i + 1][j][k + 1] + dp[i + 1][j - 1][k] * (k + 1)) % mod;
	}
	printf("%lld\n", dp[gen][num][0]);
}


Measured memory_bytes: 228736
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
    int N;
    cin >> N;
  
    int A[N];
    for(int i=0; i<N; i++){cin >> A[i];}

    sort(A,A+N);

    int enemy_min  = A[0];
    int enemy_next = A[1];
    int i = 0;

    while(1){
        A[i+1] = A[i+1] % A[i];

        if(A[i+1]<A[i]){ 
            int tmp;
            tmp = A[i];
            A[i] = A[i+1];
            A[i+1] = tmp;
        }

        if(A[i]<1){i++;}

        if(A[N-2]==0){break;}
    }

    cout << A[N-1] << endl;

    return 0;

}




Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
 

public class Main {	
	
	
	public static void main(String[] args) throws Exception {
		
		//int N = scan.nextInt();
		//long L = scan.nextLong();
		//double D = scan.nextDouble();
		//char[] A = scan.next().toCharArray();
		
		int N = scan.nextInt();
		int tmp = 1000-N%1000;
		out.println((tmp == 1000)? 0 : tmp);
		
		
		out.flush();
	}


	static FastScanner scan = new FastScanner();
	static PrintWriter out = new PrintWriter(System.out);			 
	static long MOD = 1_000_000_007;

	static int[] dx = {1,-1,0,0};
	static int[] dy = {0,0,1,-1};
	static int[] dx8 = {1,-1,0,0,1,1,-1,-1};
	static int[] dy8 = {0,0,1,-1,1,-1,1,-1};

	//GCD最大公約数を返す
	static long gcd(long a, long b){
		if(b == 0) return a;
		return gcd(b, a%b);
	}

	//aとbの最小公倍数を返す
	static long lcm (long a, long b) {
		return ((a/gcd(a,b))*b);
	}
	
	//入力
	//https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
	static class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        if (!hasNext()) throw new NoSuchElementException();
	        long n = 0;
	        boolean minus = false;
	        int b = readByte();
	        if (b == '-') {
	            minus = true;
	            b = readByte();
	        }
	        if (b < '0' || '9' < b) {
	            throw new NumberFormatException();
	        }
	        while(true){
	            if ('0' <= b && b <= '9') {
	                n *= 10;
	                n += b - '0';
	            }else if(b == -1 || !isPrintableChar(b)){
	                return minus ? -n : n;
	            }else{
	                throw new NumberFormatException();
	            }
	            b = readByte();
	        }
	    }
	    public int nextInt() {
	        long nl = nextLong();
	        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
	        return (int) nl;
	    }
	    public double nextDouble() { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 32576
import java.util.*;
import java.lang.*;
 
public class Main
{  
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 21588
#include <algorithm>
#include <iostream>
#include <limits>
#include <map>
#include <set>
#include <vector>

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

    std::vector<int> h(n);
    for(int i = 0; i < n; ++i) {
        std::cin >> h[i];
    }

    std::vector<int> dp(n);
    for(int i = 1; i < n; ++i) {
        int min_cost = std::numeric_limits<int>::max();
        for(int t = 1; t <= k; ++t) {
            if(i - t >= 0) {
                min_cost =
                    std::min(min_cost, dp[i - t] + std::abs(h[i] - h[i - t]));
            }
        }
        dp[i] = min_cost;
    }

    std::cout << dp[n - 1] << "\n";
}

Measured memory_bytes: 1024
//
//  main.swift
//  AtCoderSwift
//
//  Created by burita083 on 2020/08/25.
//  Copyright © 2020 burita083. All rights reserved.
//

import Foundation
func readInt() -> Int {
    return Int(readLine()!)!
}
 
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
 
func readTwoInts() -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: " ").map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

func abc080_b() {
    let N = readLine()!
    let sum = N.map { Int(String($0))! }.reduce(0, +)
    print(Int(N)! % sum == 0 ? "Yes" : "No")
}

//abc080_b()

func abc078_b() {
    let input = readInts()
    var X = input[0]
    let Y = input[1]
    let Z = input[2]
    var ans = 0
    X -= Y+Z*2
    ans += 1
    ans += X/(Y+Z)
    
    print(ans)
}

func abc085_b() {
    let N = readInt()
    var l: [Int] = []
    for _ in 0..<N {
        let d = readInt()
        l.append(d)
    }
    print(l.reduce([], { $0.contains($1) ? $0 : $0 + [$1] }).count)
}

func isSquare(n: Double) -> Bool {
    let sqrt = floor(n.squareRoot())
    return sqrt * sqrt == n
}

func abc077_b() {
    let N = readInt()
    for n in (1...N).reversed() {
        if isSquare(n: Double(n)) {
            print(n)
            return
        }
    }
}

func abc020_b () {
    let inputs = readInts()
    print(Int(String(inputs[0]) + String(inputs[1]))! * 2)
}

func abc073_b () {
    var ans = 0
    let N = readInt()
    for _ in 0..<N {
        let inputs = readInts()
        ans += inputs[1] - inputs[0] + 1
    }
    print(ans)
}

func abc026_b () {
    var evens: [Int] = []
    var odds: [Int] = []
    var all: [Int] = []
    let N = readInt()
    for _ in 0..<N {
        let R = readInt()
        all.append(R)
    }

    for (i, e) in all.sorted(by: >).enumerated() {
        if i % 2 == 0 {
            evens.append(e)
        } else {
            odds.append(e)
        }
    }
    let ans = evens.map { $0 * $0 }.reduce(0, +) - odds.map { $0 * $0 }.reduce(0, +)
    print(Double(ans) * Double.pi)
}

extension StringProtocol {
    var firstUppercased: String {
        return prefix(1).uppercased()  + self.lowercased().dropFirst()
    }
}

func abc012_b () {
    print(readLine()!.firstUppercased)

}

func abc007_b () {
    print(readLine()! == "a" ? -1 : "a")
}

func abc028_b () {
    let S = readLine()!
    let A = String(S.filter { $0 == "A" }.count)
    let B = String(S.filter { $0 == "B" }.count)
    let C = String(S.filter { $0 == "C" }.count)
    let D = String(S.filter { $0 == "D" }.count)
    let E = String(S.filter { $0 == "E" }.count)
    let F = String(S.filter { $0 == "F" }.count)
    print(A + " " + B + " " + C + " " + D + " " + E + " " + F)
}

func abc097_b () {
    let x = Double(Int(readLine()!)!)
    var ans: Double = 1
    for b in 2..<32 {
        var p: Double = 2
        while pow(Double(b), p) <= x {
            ans = max(ans, pow(Double(b), p))
            p += 1
        }
    }
    print(Int(ans))
}


abc097_b()



Measured memory_bytes: 13440
N=int(input())
listA=[]
for i in range(N):
    lis=input().split()
    listA.append([lis[0],int(lis[1]),i])
sort=sorted(listA,key=lambda x:(x[0],-x[1]))
for i in range(N):
    sort[i].append(i+1)
for disp in sort:
    print(disp[2]+1)

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>

#define ZERO '0'
#define ITI  '1'

int main(void){
  char s[100000];
  int i, n, count = 0;
  
  scanf("%s", s);
  n = strlen(s);
  
  for(i = 1;i < n;i++){
    if(s[i] == s[i - 1]){
      if(s[i] == ZERO){
        s[i] = ITI;
      }else{
        s[i] = ZERO;
      }
      count++;
    }
  }
  printf("%d\n", count);
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  int n=s.length();
  int bnum=0,wnum=0;
  
  for (int i =0;i< n; i++){
    if (i % 2 == 1){
      if (s[i] == '0'){
	bnum++;
      }else{
	wnum++;
      }
    }else{
      if (s[i] == '0'){
	wnum++;
      }else{
	bnum++;
      }
    }
  }
  
  cout << min(wnum,bnum);
}




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

int main() {
	ll n,ans=0;
	cin>>n;
	if(n%11>6){
		ans=2;
	}
	else if(n%11>=1){
		ans=1;
	}
	else{
		ans =0;
	}
	cout << n/11*2+ans;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }

    long long ans = (h / 2LL) * (w / 2LL) * 2LL;
    if(h % 2 != 0)
        ans += w / 2;
    if(w % 2 != 0)
        ans += h / 2;
    if(h % 2 != 0 && w % 2 != 0)
        ++ ans;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
s = input()

def remove_word_from_string(string, word):
  return ''.join(string.split(word))

ls = ["eraser", "erase", "dreamer", "dream"]

for word in ls:
  s = remove_word_from_string(s, word)
  
ans = "YES" if s == '' else "NO"

print(ans)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 string ans="";
	 ll n;
	 cin>>n;
	 while(n>0)
	 {
		 int r=n%26;
		 if(r==0)
		 {
			ans+='z';
			n=n/26-1;
		 }
		 else
		 {
			 ans+=(r-1+'a');
			 n=n/26;
		 }
	 }
	 reverse(ans.begin(),ans.end());
	 cout<<ans<<'\n';
}


Measured memory_bytes: 3652