akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const int N = 102;
char s[N];

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    scanf("%s", s);
    int n = strlen(s);
    for (int i = 0; i < n; i++) {
        printf("x");
    }
    return 0;
}


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

using namespace std;
using ll = long long;


int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  map <ll, ll> ma;
  bool flag = true;
  for(int i=0; i<n; i++){
    int a; cin >> a;
    ma[a]++;
    if(ma[a]==2) flag=false;
  }
  
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;


  return 0;
}

Measured memory_bytes: 17072
#include<iostream>
using namespace std;
int main()
{
    int N;
    int W;
    cin>>N>>W;
    int v[N];
    int w[N];
    for (int i = 0; i < N; i++)   
        cin>>v[i]>>w[i];
        
    int DP[N+1][W+1];

    for (int j = 0; j <= W; j++)
        DP[N][j]=0;
    
    for (int i =N-1; i>=0; i--)
        for (int j = 0; j <=W; j++)
            if(j<w[i])
                DP[i][j]=DP[i+1][j];
            else
            {
                if(DP[i+1][j]>DP[i+1][j-w[i]]+v[i])
                    DP[i][j]=DP[i+1][j];
                else
                    DP[i][j]=DP[i+1][j-w[i]]+v[i];
                
            }
    cout<<DP[0][W]<<endl;
    return 0;
        
        
    
    
    
}


Measured memory_bytes: 7024
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pci pair<char, int>
#define pic pair<int, char>
#define plvl pair<long long, vector<long long> >
#define pcvc pair<char, vector<char> >


using namespace std;

const int mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	if(b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

template <typename T>
void show1(vector<T> dp) {
	for(auto d : dp) {
		cout << d << " ";
	}
	cout << endl;
}

template <typename T>
void show2(vector<vector<T> > dp) {
	for(auto d : dp) {
		for(auto dd : d) {
			cout << dd << " ";
		}
		cout << endl;
	}
}

void executeCode() {
	ll x, y;
	cin >> x >> y;
	for(int i = 0 ; i <= x ; i++) {
		if(2 * i + 4 * (x - i) == y) {
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
	return;
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int tt = 1;
	// cin >> tt;
	while(tt--) {
		executeCode();	
	}
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	long long N, x;
	cin >> N >> x;

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

		b[i] = (a[i] > x) ? x : a[i];
	}
	
	vector<long long> sum(N-1);
	for(int i=0; i<N-1; i++)
	{
		long long s = b[i] + b[i+1];
		if(s > x)
			b[i+1] -= s - x;
	}

	long long ret = 0;
	for(int i=0; i<N; i++)
		ret += a[i] - b[i];

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define sz(x) ((int)(x).size())
#define pii pair<int, int>
#define trav(a,x) for (auto& a : x)
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 5005;

void solve()
{
    int n; cin >> n;
    set<int> s;
    FOR(i, 0, n)
    {
        int a; cin >> a;
        if (s.find(a) != s.end())
        {
            cout << "NO\n";
            return;
        }
        s.insert(a);
    }
    cout << "YES\n";
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    /*int tc;  cin >> tc;
    while (tc--)*/
        solve();
    return 0;
}







Measured memory_bytes: 12900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  ll cur=100;
  ll x;
  cin>>x;
  int i=0;
  while(cur<x){
    cur=(ll)(cur*1.01);
    i++;
  }
  cout<<i<<endl;
}

Measured memory_bytes: 3632
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

k = int(readline())
q = [(i + 1) for i in range(9)]
if k < 10:
    print(k)
    exit()
cnt = 9
while q:
    x = q.pop(0)
    y = int(str(x)[-1])
    if y != 0:
        cnt += 1
        if cnt == k:
            print(10 * x + y - 1)
            exit()
        q.append(10 * x + y - 1)
    cnt += 1
    if cnt == k:
        print(10 * x + y)
        exit()
    q.append(10 * x + y)
    if y != 9:
        cnt += 1
        if cnt == k:
            print(10 * x + y + 1)
            exit()
        q.append(10 * x + y + 1)


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

typedef long long ll;
const ll LL_MAX (1LL<<60);

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

using namespace std;

int main()
{
    string w;
    cin >> w;

    vector<ll> hash(26, 0);

    rep(i, 0, static_cast<ll>(w.size())) 
        hash[w[i]-97]++;

    bool is_b_num (true);
    rep(i, 0, 26) 
        if (hash[i] % 2 != 0)
            is_b_num = false;

    if (is_b_num)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;

int main(){
   rep(i,1,10) rep(j,1,10) {
printf("%dx%d=%d\n",i,j,i*j);
}
    return 0;
}

Measured memory_bytes: 1096
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
#define PP 1000000007
using namespace std;

ll N, K;
vector<ll> fac{1};
vector<ll> ifac{1};
vector<ll> inv{1};

ll F(ll N, ll a, ll p){
 
  if(a == 0)return 1;
 
  if(a%2 == 0 && a != 0)return (F(N, a/2, p)*F(N, a/2, p))%p;
 
  if(a%2 == 1)return N*F(N, a - 1, p)%p;
 
}

void C(){

  ll f = 1;

rep(i, 1, N + 1){

  f *= i;f %= PP;

  fac.push_back(f);

}

rep(i, 1, N + 1){

  inv.push_back(F(i, PP - 2, PP));

}

f = 1;

rep(i, 1, N + 1){

  f *= inv[i];f %= PP;
  ifac.push_back(f);

}
}

ll Com(ll n, ll k, ll p){
  
  if(n - k < 0)return 0;

  else return (((fac[n]*ifac[k])%p)*ifac[n - k])%p;

}

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

rep(i, 1, K + 1){

  cout << Com(N - K + 1, i, PP)*Com(K - 1, i - 1, PP)%PP << endl;
  
}

}




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

int main() {
  int H, W;
  cin >> H >> W;

  vector<char> A;
  for (int cnt_h=0; cnt_h < H; ++cnt_h) {
    for (int cnt_w=0; cnt_w < W; ++cnt_w) {
      char tmp;
      cin >> tmp;
      A.push_back(tmp);
    }
  }

  for (int cnt_h=-1; cnt_h < H+1; ++cnt_h) {
    for (int cnt_w=-1; cnt_w < W+1; ++cnt_w) {
      if ( (0<=cnt_h) && (cnt_h<H) && (0<=cnt_w) && (cnt_w<W)) {
        cout << A.at(cnt_h * W + cnt_w);
      } else {
        cout << '#';
      }
    }
    cout << endl;
  }

  return 0;
}

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

using namespace std;

typedef unsigned int ui;

int main() 
{
    int n, m, x, y;
    scanf("%d", &n);
    
    bitset<64> B(0);
    vector<bitset<64> > Bitmask(n, B);
    
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &m);
        
        for(int j = 0; j < m; j++)
        {
            scanf("%d", &x);
            Bitmask[i].set(x);
        }
    }
    
    scanf("%d", &m);
    
    for(int i = 0; i < m; i++)
    {
        scanf("%d %d", &x, &y);
        
        switch(x)
        {
            case 0:
                printf("%d\n", B.test(y));
                break;
            case 1:
                B |= Bitmask[y];
                break;
            case 2:
                B &= ~Bitmask[y];
                break;
            case 3:
                B ^= Bitmask[y];
                break;
            case 4:
                printf("%d\n", (B & Bitmask[y]).count() == Bitmask[y].count());
                break;
            case 5:
                printf("%d\n", (B & Bitmask[y]).count() != 0);
                break;
            case 6:
                printf("%d\n", (B & Bitmask[y]).count() == 0);
                break;
            case 7:
                printf("%d\n", (ui)(B & Bitmask[y]).count());
                break;
            case 8:
                printf("%lu\n", (B & Bitmask[y]).to_ulong());
                break;
        }
    }
    
    return 0;
}


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

int main() {
  int N;
  int count=0;
  cin >> N;
  map<string, int> mp;
  
  for(int i=0; i<N;i++){
    string s;
    cin >> s;
    mp[s]++;
  }
  
  for(auto &it :mp){
    if(it.second>=1)
      count++;
  }
  
  cout << count << endl;
}


Measured memory_bytes: 19208
from math import gcd
def main():
    k = int(input())
    r = 0
    for ia in range(1, k + 1):
        for ib in range(1, k + 1):
            for ic in range(1, k + 1):
                t1 = gcd(ib, ic)
                r += gcd(t1,ia)
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9216
n,k = map(int,input().split())
s = input()

a = [0]
i = 0
p = "1"
for t in s:
  if t == p:
    a[i] += 1
  else:
    p = t
    i += 1
    a += [1]
a += [0]
# print(a)

if len(a) <= 2*k+1:
  print(sum(a))
  quit()

x = sum(a[:2*k+1])
m = x 
for i in range(2*k+1,len(a)):
  # print(i, a[i] , a[i-(2*k+1)])
  x = x + a[i] - a[i-(2*k+1)]
  if i%2 == 0:
    m = max(m,x)
print(m)

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

int main () {
  string a,b,c;
  cin >> a >> b >> c;

  if (a[a.size()-1]==b[0] && b[b.size()-1]==c[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>

using namespace std;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,1,-1,0};
const int B = 5;
const int W = 8;
const int BW = 13;
int flagB = 0;
int flagW = 0;
queue<pair<int,int> > que;
void dfs(vector<vector<int> > &map,int x,int y){
  map[x][y] = -1;
  que.push(pair<int,int>(x,y));
  for(int i = 0;i < 4;i++){
    if(x+dx[i] >= 0 && x+dx[i] < map.size() && y+dy[i] >= 0 && y+dy[i] < map[0].size()){
      if(map[x+dx[i]][y+dy[i]] == 1)flagB = B;
      else if(map[x+dx[i]][y+dy[i]] == 2)flagW = W;
      else if(map[x+dx[i]][y+dy[i]] == -1){}
      else dfs(map,x+dx[i],y+dy[i]);
      
    }
  }
  
  return ;
}
void solve(vector<vector<int> > &map){
  while(!que.empty()){

    pair<int,int> tmp = que.front();que.pop();
    map[tmp.first][tmp.second] = flagB+flagW;
  }
  flagB = 0;
  flagW = 0;
  return ;
}
int main(){

  while(1){
    int w,h;
    cin >> w >> h;
    if(w == 0 && h == 0)break;
    vector<vector<int> > map(w,vector<int>(h,0));
    for(int i = 0;i < h;i++){
      for(int j = 0;j < w;j++){
	char a;
	cin >> a;
	if(a == 'B')map[j][i] = 1;///B
	else if(a == 'W')map[j][i] = 2;///W
      }
    }
    for(int i = 0;i < h;i++){
      for(int j = 0;j < w;j++){
	if(map[j][i] == 0){
	  dfs(map,j,i);
	  //	  cout << flagW << "dddddddddddddd" << flagB << endl;
	  solve(map);
	}
      }
    }
    int cnt_W = 0;
    int cnt_B = 0;
    for(int i = 0;i < h;i++){
      for(int j = 0;j < w;j++){
	//cout << map[i][j] << " ";
	if(map[j][i] == B)cnt_B++;
	else if(map[j][i] == W)cnt_W++;
	
      }
      //      cout << endl;
    }
    cout << cnt_B << " " << cnt_W << endl;
  }
  return 0;

}

Measured memory_bytes: 1368
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <time.h>

#define loop(i, num)  for (int i = 0; i < num; i++)

using namespace std;

int main() {
    
    int n;
    
    cin >> n;
    
    cout << 48 - n << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  Int p=-1;
  for(Int i=0;i<n;i++){
    Int x;
    cin>>x;
    if(x==1) p=i;
  }
  if(k==n){
    cout<<1<<endl;
    return 0;
  }
  //cout<<p<<endl;
  Int a=p,b=n-(p+1);
  Int ans=(a/(k-1))+(b/(k-1));
  //cout<<ans<<endl;
  Int x=a%(k-1),y=b%(k-1);
  if(x==0&&y==0);
  else if(x+1+y<=k) ans++;
  else ans+=2;
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  ll n;
  cin >> n;
  if (n%2==0) cout << n << endl;
  else cout << n*2 << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
import math
N = int(input())
can_moves = []
can_moves.append(int(input()))
can_moves.append(int(input()))
can_moves.append(int(input()))
can_moves.append(int(input()))
can_moves.append(int(input()))
min_can_moves = min(can_moves)
time = math.ceil(N / min_can_moves) + len(can_moves) - 1
  
# 出力
print(time)

Measured memory_bytes: 3060
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    int N,M;cin >> N >> M;
    vector<P> retu(N);
    for(int i = 0;i<N;i++) cin >> retu.at(i).first >> retu.at(i).second;
    sort(retu.begin(),retu.end());
    vector<int> days(100005);
    vector<int> indexrui(100005);
    int now = retu.at(0).first;
    int ren = 1;
    for(int i = 1;i<N;i++){
        if(retu.at(i).first != now){
            days.at(now) = ren;
            now = retu.at(i).first;
            ren = 1;
        }
        else ren++;
        if(i == N-1){
            days.at(now) = ren;
        }
    }
    //何日目がどのindexから始まるかの累積和（ダルすぎ）
    for(int i = 1;i<=M;i++){
        indexrui.at(i) = indexrui.at(i-1)+days.at(i);
    }
    int ans = 0;
    priority_queue<int> Q;
    //🐄ろから見る
    for(int i = 1;i<=M;i++){
        for(int j = indexrui.at(i-1);j<indexrui.at(i);j++){
            Q.push(retu.at(j).second);
        }
        if(Q.empty()) continue;
        ans += Q.top();
        Q.pop();
    }
    cout << ans << endl;
}


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

vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	while(a > 0){
		c -= b;
		if(c <= 0){
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
	}
	cout << "No" << endl;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 400400;

PII A[MAX];

VI v;
int get(int x)
{
	return lower_bound(ALL(v), x) - v.begin();
}

struct Fen
{
	int A[MAX];
	int n;

	void init(int n)
	{
		this->n = n;
		FOR (i, 0, n)
		{
			A[i] = -INF;
		}
	}

	void add(int x, int val)
	{
		for (; x < n; x = x | (x+1))
		{
			A[x] = max(A[x], val);
		}
	}

	int get(int x)
	{
		int res = -INF;
		for (; x >= 0; x = (x & (x + 1)) - 1)
		{
			res = max(res, A[x]);
		}
		return res;
	}
} F;

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int x1, y1, x2, y2;
	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
	int n;
	scanf("%d", &n);

	FOR (i, 0, n)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		A[i] = MP(x, y);
	}

	if (x2 > x1)
	{
		FOR (i, 0, n)
		{
			A[i].first *= -1;
		}
		x1 *= -1;
		x2 *= -1;
	}

	if (y2 > y1)
	{
		FOR (i, 0, n)
		{
			A[i].second *= -1;
		}
		y1 *= -1;
		y2 *= -1;
	}

	int dx = abs(x1 - x2);
	int dy = abs(y1 - y2);

	double res = (dx + dy) * 100.;

	v.PB(x1);
	v.PB(y1);
	v.PB(x2);
	v.PB(y2);
	FOR (i, 0, n)
	{
		v.PB(A[i].first);
		v.PB(A[i].second);
	}

	sort(ALL(v));
	v.erase(unique(ALL(v)), v.end());

	x1 = get(x1);
	y1 = get(y1);
	x2 = get(x2);
	y2 = get(y2);
	FOR (i, 0, n)
	{
		A[i].first = get(A[i].first);
		A[i].second = get(A[i].second);
	}

	sort(A, A+n);

	F.init(SZ(v));

	F.add(y2, 0);

	FOR (i, 0, n)
	{
		if (A[i].first < x2) continue;
		if (A[i].first > x1) break;
		int v = F.get(A[i].second) + 1;
		F.add(A[i].second, v);
	}

	int cnt = F.get(y1);

	int a, b;

	//double sub = (20 - PI * 10 / 2) * cnt;
	//res -= sub;
	a = cnt;
	b = 0;

	if (cnt == min(dx, dy) + 1)
	{
		a--;
		b++;
	}

	res -= a * (20 - PI * 5);
	res += b * (PI*10 - 20);

	printf("%.15f\n", res);

}


Measured memory_bytes: 6000
def resolve():
    S = input()
    Q = int(input())
    reverse = False
    import collections
    left = collections.deque([])
    right = collections.deque([])
    for i in range(Q):
        query = input().split()
        if query[0] == "1":
            reverse = (not reverse)
            continue
        if query[1] == "1":
            if reverse:
                right.append(query[2])
            else:
                left.appendleft(query[2])
        elif query[1] == "2":
            if reverse:
                left.appendleft(query[2])
            else:
                right.append(query[2])
    if reverse:
        ans = "{}{}{}".format("".join(reversed(right)), "".join(reversed(S)), "".join(reversed(left)))
    else:
        ans = "{}{}{}".format("".join(left), S, "".join(right))
    print(ans)


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 93608
#include <bits/stdc++.h>
#include <vector> 
#include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;


signed main(){
    int n;
    cin>>n;
    map<int,int> mp;
    int a[n];
    int ans=0;
    rep(i,n) {
        cin >> a[i];
        mp[a[i]]++;
        ans += a[i];
    }
    int q;
    cin >> q;

    rep(i,q) {
        int b,c;
        cin >> b >> c;
        ans -= mp[b]*b;
        ans += mp[b]*c;
        
        mp[c]+=mp[b];
        mp[b]=0;

        cout << ans << endl;

    }

    

    return 0;
}


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

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

const ll mod =  1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976


#define N_MAX 200005
ll f[N_MAX],rf[N_MAX];

ll pow(ll x,ll n){  // xのn乗 (mod m)
    ll res = 1;
    if(n > 0){
        res = pow(x,n / 2);
        if(n % 2 == 0){
            res = (res * res) % mod;
        }else{
            res = (((res * res) % mod) * x) % mod;
        }
    }
    return res;
}

void init(){
    f[0] = 1;
    for(int i = 1; i < N_MAX; i++){
        f[i] = (i * f[i-1]) % mod;
    }
    for(int i = 0; i < N_MAX; i++){
        rf[i] = pow(f[i],mod-2);
    }
}

ll com(ll n, ll k){
    
    ll a = f[n];
    ll b = rf[k];
    ll c = rf[n-k];

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}

int main()
{
    init();
    ll n,k; cin >> n >> k;
    ll a[n];
    rep(i,n) cin >> a[i];
    ll ans = 0;
    sort(a,a+n);
    rep(i,n-k+1){
        ans -= (a[i] * com(n-1-i,k-1) % mod);
        ans %= mod;
    }
    rep(i,n-k+1){
        ans += (a[n-1-i] * com(n-1-i,k-1));
        ans %= mod;
    }
    cout << (ans+mod*2)%mod << endl;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef pair<int,int> pii;

int main(){
  int n,m;
  cin >> n >> m;
  vector< vector<pii> > g(n);
  vector<int> deg(n,0);

  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    g[a].push_back(pii(c,b));
    deg[b]++;
  }

  vector<int> order;
  queue<int> q;
  rep(i,n){
    if(deg[i]==0)q.push(i);
  }

  while(q.size()){
    int v = q.front(); q.pop();
    order.push_back(v);

    for(auto e : g[v]){
      int u = e.second;
      deg[u]--;
      if(deg[u]==0)q.push(u);
    }
  }

  vector<int> ans(n,0);
  rep(i,n){
    int v = order[i];
    for(auto e : g[v]){
      int u = e.second;
      ans[u] = max(ans[u], ans[v] + e.first);
    }
  }

  cout << ans[n-1] << endl;
}

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

int main()
{
	int n,ac=0,wa=0,tle=0,re=0;
	cin>>n;
	string s;
	while(n--)
	{
	
		cin>>s;
		if(s=="AC")
		{
			ac++;
		}
		if(s=="WA")
		{
			wa++;
		}
		if(s=="TLE")
		{
			tle++;
		}
		if(s=="RE")
		{
			re++;
		}
	}
	cout<<"AC"<<" "<<"x"<<" "<<ac<<endl<<"WA"<<" "<<"x"<<" "<<wa<<endl<<"TLE"<<" "<<"x"<<" "<<tle<<endl<<"RE"<<" "<<"x"<<" "<<re<<endl;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

#ifdef LOCAL  //デバッグ出力
#define dout cout
#define debug() if (true)
#else
#define dout \
  if (false) cout
#define debug() if (false)
#endif

using namespace std;
int main() {
  int a=0;
  double b = 0;
  double c = 0;
  double d;
  cin >> a;
  for (int i = 0; i < a; i++) {
    b++;
    if (i % 2 == 0) {
      c++;
    }
  }
  d=c/b;
  cout <<d;
  return 0;
}

Measured memory_bytes: 256
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a = sorted(a, reverse=True)
b = sorted(b, reverse=True)
c = sorted(c, reverse=True)

q = [(a[0]+b[0]+c[0], 0, 0, 0)]
t = []
next_a = (0,0,0,0)
next_b = (0,0,0,0)
next_c = (0,0,0,0)
for i in range(min(x*y*z, k)):
  m = q.pop(q.index(max(q, key=lambda x: x[0])))
  print(m[0])
  if m[1] < x-1:
    next_a = (a[m[1]+1]+b[m[2]]+c[m[3]], m[1]+1, m[2], m[3])
  if m[2] < y-1:
    next_b = (a[m[1]]+b[m[2]+1]+c[m[3]], m[1], m[2]+1, m[3])
  if m[3] < z-1:
    next_c = (a[m[1]]+b[m[2]]+c[m[3]+1], m[1], m[2], m[3]+1)
  if next_a not in t:
    q.append(next_a)
    t.append(next_a)
  if next_b not in t:
    q.append(next_b)
    t.append(next_b)
  if next_c not in t:
    q.append(next_c)
    t.append(next_c)


Measured memory_bytes: 4340
#include<iostream>
#include<list>
#include <iterator>
using namespace std;

int main(void){
  list<int> ls;
  list<int>::iterator itr=ls.begin();
  int loop,operate,num;
  cin>>loop;
  for(int i=0;i<loop;i++){
    cin>>operate;
    if(operate==0){
      cin>>num;
      itr=ls.insert(itr,num);
    }
    else if(operate==1){
      cin>>num;
      advance(itr,num);
    }
    else if(operate==2){
      itr=ls.erase(itr);
    }
  }
  for(list<int>::iterator it = ls.begin(); it != ls.end(); ++it){
    cout<<*it<<endl;
  }
  return 0;
}



Measured memory_bytes: 18548
#include<stdio.h>

int main(){
  int N,M,i,A[10000],sum=0;
  
  scanf("%d%d",&N,&M);
  
  for(i=0;i<M;i++){
    scanf("%d",&A[i]);
    sum +=A[i];
  }
  if((N-sum)<0)
    printf("-1");
  else
    printf("%d",N-sum);
  
  return 0;
}

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

int arr[ (int) 1e5 + 99 ];

int main() {
	
//	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int n, m;
	while ( cin >> n >> m ) {
		memset( arr, 0, sizeof (arr) );
		int take[ n+5 ];
		
		for (int i = 0; i < n; ++i) cin >> take[i];
		
		for (int i = 1; i < (int) 1e5 + 5; ++i) {
			for (int j = 0; j < n; ++j) {
				if ( i-take[j] >= 0 and arr[ i-take[j] ] == 0 ) {
					arr[i] = 1;
				}
			}
		}
		
//		for (int i = 0; i < 100; ++i) cout << arr[i]; cout << '\n';
		
		if ( arr[m] == 1 ) cout << "First\n";
		else if ( arr[m] == 0 ) cout << "Second\n";
	}
	return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
s = input()
k = int(input())
ans = ""
n = len(s)
for p, i in enumerate(s):
    if p == n - 1:
        ans += chr((ord(i) - 97 + k) % 26 + 97)
        break
    if (cost := (123 - ord(i)) % 26) <= k:
        ans += "a"
        k -= cost
    else:
        ans += i
print(ans)


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

int main(){
    string s,t;
    cin>>s>>t;
    if(s[0]==t[2]&&s[1]==t[1]&&s[2]==t[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

typedef complex<double> P;
typedef vector<P> G;

namespace std
{
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}

template<class iter>
tuple<double, P, P> closest_pair(iter left, iter right) {
	int n = distance(left, right);

	if (n <= 1) {
		return make_tuple(numeric_limits<double>::max(), *left, *left);
	}

	if (n == 2) {
		if (left[0].imag() > left[1].imag()) swap(left[0], left[1]);
		return make_tuple(norm(left[0] - left[1]), left[0], left[1]);
	}

	iter middle = next(left, n / 2);
	auto d = min(closest_pair(left, middle), closest_pair(middle, right));
	inplace_merge(left, middle, right, [](const P &a, const P &b) {
		return a.imag() < b.imag();
	});

	vector<iter> around;
	for (iter i = left; i != right; ++i) {
		double dx = fabs(i->real() - middle->real());
		double &opt = get<0>(d);
		if (dx*dx >= opt) continue;
		for (auto j = around.rbegin(); j != around.rend(); ++j) {
			double dx = i->real() - (**j).real();
			double dy = i->imag() - (**j).imag();
			if (dy*dy >= opt) break;
			double norm = dx*dx + dy*dy;
			if (get<0>(d) > norm) {
				d = make_tuple(norm, *i, **j);
			}
		}
		around.push_back(i);
	}
	return d;
};
vector<P> points;

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

	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		double x, y;
		cin >> x >> y;
		points.push_back(P(x, y));
	}

	sort(points.begin(), points.end());
	auto ans = closest_pair(all(points));

	printf("%d\n", (int)get<0>(ans));

	return 0;
}


Measured memory_bytes: 22584
n, m = map(int, input().split())
ac = set()
wa = 0
wa_stock = [0] * n
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC' and not p in ac:
        ac.add(p)
        wa += wa_stock[p]
    elif not p in ac:
        wa_stock[p] += 1
print(len(ac), wa)

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

int main() {
  int N;
  cin >> N;
  int master = 0;
  set<int> rates;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    a = a/400;
    if (a >= 8) {
      master++;
      continue;
    }
    if (!rates.count(a)) {
      rates.insert(a);
    }
  }
  int r = rates.size();
  if (master <= r) {
    cout << r << " " << r + master << endl;
  }
  else if (master > r) {
    cout << max(r, 1) << " " << r + master << endl;
  }
}


Measured memory_bytes: 256
S = input().strip()
C = {chr(i):0 for i in range(97,123)}
for i in range(len(S)):
    C[S[i]] += 1
flag = 0
a = 0
for i in range(97,123):
    if C[chr(i)]==0:
        a = chr(i)
        flag = 1
        break
if flag==1:
    print(a)
else:
    print("None")

Measured memory_bytes: 67168
import scala.io.StdIn._

object Main  {
  def main(args: Array[String]): Unit = {
    val balls = readLine.split(" ")
    val counts = readLine.split(" ").map(_.toInt)
    val thrown = readLine

    if (balls(0) == thrown) {
      println(s"${counts(0) - 1} ${counts(1)}")
    } else {
      println(s"${counts(0)} ${counts(1) - 1}")
    }

  }
}

Measured memory_bytes: 25416
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

ll a, b, c, d;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b >> c >> d;
	ll res = max(max(a * c, a * d), max(b * d, c * b));
	if ((a <= 0 && 0 <= b) || (c <= 0 && 0 <= d))
		res = max(res, 0LL);
	cout << res;
}

Measured memory_bytes: 3668
class Test:
    def __init__(self):
        pass

class CustomUtils:
    def __init__(self):
        pass
    def to_int(self, inputs, sp=' '):
        if sp == '':
            return [int(d) for d in list(inputs)]
        else:
            return [int(d) for d in inputs.split(sp)]
    def debug_print(self, inputs, debug=False):
        if debug:
            print(inputs)

# 引用　python する man,「Pythonでの再帰関数とメモ化」, PSM, ２０１７、７/４
# http://muromura.hatenablog.com/entry/2017/07/04/204908#%E3%83%A1%E3%83%A2%E5%8C%96
def memorize(f):
    table = {}
    def func(*args):
        if not args in table:
            table[args] = f(*args)
        return table[args]
    return func
debug = False



iarray = ['A', 'C', 'G', 'T']
oarray = ['T', 'G', 'C', 'A']
idx = iarray.index(input())

print("{}".format(oarray[idx]))

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int tt; cin >> tt; for(int cs = 1; cs <= tt; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 200000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cout << "The value of " << #val << " is = " << val << endl;
#define testing cout << "--------------------------\n";

int main() {
	IOS
	int n;
	cin>>n;
	ll d,res=0;
	cin>>d;
	for(int i = 0; i < n; i++) {
		ll x,y;
		cin>>x>>y;
		if(x*x+y*y<=d*d) res++;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 3652
/* vim:set foldmethod=marker: */
#include <bits/stdc++.h>
using namespace std;

//{{{
#define all(x) (x).begin(),(x).end()
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i,a,b) for(int i=(int)(a); i>=b; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;

#define dump(x) (cerr << #x << "=" << x << endl)
template<class T> ostream& osContainer(ostream& os,T c) { os<<'[';for(decltype(c.begin()) it=c.begin();it!=c.end();it++)os<<*it<<',';os<<']';return os; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { return osContainer(os,v); }
template<class T> ostream& operator<<(ostream& os,const set<T>& s) { return osContainer(os,s); }
template<class T> ostream& operator<<(ostream& os,const multiset<T>& s) { return osContainer(os,s); }
template<class T,class S> ostream& operator<<(ostream& os,const map<T,S>& m) { return osContainer(os,m); }
template<class T,class S> ostream& operator<<(ostream& os,const multimap<T,S>& m) { return osContainer(os,m); }
template<class T1,class T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){ os << '(' << p.first << ',' << p.second << ')'; return os; }

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

char check[20][20];
char field[21][21];

void solve()
{
    int w, h;
    while (cin >> w >> h, w || h) {
        memset(check, 0, sizeof(check));

        int sx, sy;

        rep(i, h) {
            rep(j, w){
                char c;
                cin >> c;
                field[i][j] = c;
                if (c == '@') {
                    sy = i, sx = j;
                    check[sy][sx] = 1;
                }
            }
            cin.ignore();
        }

        queue<pair<int, int>> q;
        q.push(mp(sy, sx));

        int s = 1;

        while(!q.empty()) {
            auto p = q.front();q.pop();
            int y = p.first, x = p.second;

            rep(i, 4) {
                int ddy = y + dy[i], ddx = x + dx[i];

                if (0 <= ddy && ddy < h && 0 <= ddx & ddx < w && field[ddy][ddx] == '.' && !check[ddy][ddx]) {
                    s++;
                    check[ddy][ddx] = 1;
                    q.push(mp(ddy, ddx));
                }
            }
        }

        cout << s << endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(12);
    solve();
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
 
  if (A > B && A > C){
    cout << (10 * A) + B + C << endl;
  }
  else if (B > A && B > C){
    cout << (10 * B) + A + C << endl;
  }
  else if (C > A && C > B){
    cout << (10 * C) + A + B << endl;
  }
  else {
    cout << (10 * A) + B + C << endl;
  }
}
  
 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)
#define debug(var) cout << "[" << #var << "] " << var << endl

const int INF = 1<<29;
const double EPS=1e-9;
const int MOD=998244353;

signed main() {
    string S;
    cin >> S;
    cout << S.substr(0, 3);
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	
	int ary[5];

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

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

	for (int i = 0; i < 5; i++){
		cout << ary[i];
		if (i != 4)
			cout << ' ';
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 1160
using System;
using System.Linq;
class program{
  static void Main(){
    byte[] xn = Array.ConvertAll(Console.ReadLine().Split(' '),byte.Parse);
    if(xn[1] == 0){
      Console.Write(xn[0]);
      Environment.Exit(0);
    }
    byte[] p = Array.ConvertAll(Console.ReadLine().Split(' '),byte.Parse);
    bool[] table = new bool[201];
    for(byte i = 0;i<xn[1];i++){
      table[p[i]] = true;
    }
    if(!table[xn[0]]){
      Console.Write(xn[0]);
      Environment.Exit(0);
    }
    for(byte i = 1;i < 200;i++){
      if(xn[0] >= i){
      	if(!table[xn[0]-i]){
          Console.Write(xn[0]-i);
          break;
        }
      }
      if(!table[xn[0]+i]){
        Console.Write(xn[0]+i);
        break;
      }
    }
  }
}

Measured memory_bytes: 27572
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> VL;
typedef set<ll> SL;
typedef pair<ll, ll> p2;
const ll M = 1000000007;
const ll M2= 998244353;
ll vis[1000005];
void solve()
{
	ll a, b;cin>>a>>b; cout<<a*b;
}
 
int main()
{
    IOS
    int _=1;
    //cin>>_;
    while(_--)
    {
	    solve();
    }
    
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define io freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define lli long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fi(i,a,n) for(int i=a; i<=n; i++)
const int M=1000000007;
using namespace std;

int main(){
	
	fast
	string s;
	cin>>s;
	int count=0;
	if(s=="SSS")count=0;
	if(s=="RRR")count=3;
	if(s=="RSR")count=1;
	if(s=="RRS")count=2;
	if(s=="SRR")count=2;
	if(s=="SRS")count=1;
	if(s=="SSR")count=1;
	if(s=="RSS")count=1;
	cout<<count<<endl;

	
}


Measured memory_bytes: 3640
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
from fractions import gcd

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


def inp(): return int(sys.stdin.readline())


def inp_list(): return list(map(int, sys.stdin.readline().split()))


def lcm(x, y): return (x * y) // gcd(x, y)

N, K = inp_list()
h = inp_list()

dp = [INF] * N
dp[0] = 0 # initial condition
# 計算量: O(NK)
for i in range(N - 1):
    for j in range(i + 1, i + K + 1):
        if j > N - 1: break
        dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j])) # recurrence formula
    
print(dp[N - 1])


Measured memory_bytes: 79812
//
// Created by Hideaki Imamura on 2019-04-24.
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll m = min(a, min(b, min(c, min(d, e))));
    cout << 4 + (n / m) + (n % m > 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
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! {
        A: i32,
        B: i32,
        C: i32,
    }
    use std::collections::{VecDeque, HashSet};
    let mut queue = VecDeque::new();
    let mut visited = HashSet::new();
    queue.push_back((A, B, C, 0));

    while let Some((a, b, c, cnt)) = queue.pop_front() {
        if a == b && b == c {
            println!("{}", cnt);
            return;
        }

        if visited.contains(&(a, b, c)) {
            continue;
        }
        visited.insert((a, b, c));
        let nc = cnt + 1;
        queue.push_back((a + 1, b + 1, c, nc));
        queue.push_back((a + 1, b, c + 1, nc));
        queue.push_back((a, b + 1, c + 1, nc));
        queue.push_back((a + 2, b, c, nc));
        queue.push_back((a, b + 2, c, nc));
        queue.push_back((a, b, c + 2, nc));
    }
    unreachable!();
}


Measured memory_bytes: 12540
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void) {

  char s[100001];
  scanf("%s", s);
  long length = strlen(s);
  long mod = pow(10,9)+7;
  long num;
  long unit = 1;
  long dp[length][13];
  for (long i = 0; i < length; i++) {
    for (long j = 0; j < 13; j++) {
      dp[i][j] = 0;
    }
  }
  if (s[length-1] == '?') {
    for (int i = 0; i <= 9; i++) {
      dp[0][i] = 1;
    }
  } else {
    num = s[length-1]-'0';
    dp[0][num]++;
  }
  for (long i = length-2; i >= 0; i--) {
    unit = (unit*10)%13;
    if (s[i] == '?') {
      for (num = 0; num <= 9; num++) {
        for (long j = 0; j < 13; j++) {
          dp[length-i-1][(unit*num+j)%13] += dp[length-i-2][j];
          dp[length-i-1][(unit*num+j)%13] %= mod;
        }
      }
    } else {
      num = s[i]-'0';
      for (long j = 0; j < 13; j++) {
        dp[length-i-1][(unit*num+j)%13] += dp[length-i-2][j];
        dp[length-i-1][(unit*num+j)%13] %= mod;
      }
    }
  }
  printf("%ld\n", dp[length-1][5]);

  return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	IOS;
	int a, b, k;
	cin>>a>>b>>k;
	for(int i=100;i>=1;i--)
	{
		if(a%i==0 && b%i==0)
		{
			k--;
			if(k==0)
			{
				cout<<i;
				return 0;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 256
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end


x,y,z = inp
puts "#{z} #{x} #{y}"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> ii;
typedef vector <int> vi;
typedef double ld;
#define X first
#define Y second
#define mk make_pair
#define pb push_back
#define Rep(i, n) for(int i = 0; i < int(n); i ++)
#define Rep1(i, n) for(int i = 1; i <= int(n); i ++)
#define all(x) (x).begin(), (x).end()
const int MOD = (int) 1e9 + 7;
const ll base =  31;
void MAIN();
int main(){
    //freopen("input.txt", "r", stdin);
    ios:: sync_with_stdio(false); cin.tie(0);
    MAIN();
    return 0;
}
////////////////////////////////////////////////////////////////////////

const int N = (int) 1e5 + 32;

int w, h, n, x[N], y[N];
vector <pair <int, ll> > P, Q;


void cal(int* a, vector <pair <int, ll> > &V){
    sort(a, a+n);
    ll sum = 0;
    Rep(i, n) sum += a[i] - a[0];
    Rep(i, n){
        if(abs(i - (n-1)/2) <= 1) V.pb(mk(a[i], sum*2));
        if(i + 1 < n){
            sum += 1LL*(a[i+1] - a[i]) * (i + 1);
            sum -= 1LL*(a[i+1] - a[i]) * (n - i - 1);
        }
    }
}

ii a[N];

void MAIN(){
    cin >> w >> h >> n;
    Rep(i, n) cin >> x[i] >> y[i];
    Rep(i, n) a[i] = ii(x[i], y[i]);
    cal(x, P); cal(y, Q);
    ll ans = 1LL << 60;
    int ax, ay;

    Rep(i, n){
        Rep(u, P.size()) Rep(v, Q.size()){
            //cout << P[u].X << " " << Q[v].X << endl;
            ll sum = P[u].Y + Q[v].Y;
            sum -= abs(P[u].X - a[i].X) + abs(Q[v].X - a[i].Y);
            if(sum < ans){
                ans = sum;
                ax = P[u].X;
                ay = Q[v].X;
            } else if(sum == ans && ii(ax, ay) > ii(P[u].X, Q[v].X)){
                ax = P[u].X;
                ay = Q[v].X;
            }
        }
    }
    cout << ans << endl << ax << " " << ay << endl;
}

Measured memory_bytes: 2788
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
using namespace std;
#define mod int(1e9+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,a,b) for(int i=a;i<=b;i++)
#define repn(i,a,b) for(int i=b-1;i>=a;i--)
#define F first
#define S second
#define pb push_back
#define mk make_pair
typedef long long int ll;

int main()
{ ios_base::sync_with_stdio(false); cin.tie(0);
  ll n,k; cin>>n>>k;
  ll ans=k;
 reps(i,1,n-1) ans*=(k-1);
 cout<<ans<<endl;
  return 0;
}


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

using namespace std;

vector<string> v;
int N;

void sub(int m, string s) {
	if(s.length() == N) {
		v.push_back(s);
	} else {
		for(int i = 0; i <= m; ++i) {
			if(i == m) {
				sub(m + 1, s + static_cast<char>('a' + i));
			} else {
				sub(m, s + static_cast<char>('a' + i));
			}
		}
	}
}

int main(void) {
	cin >> N;
	sub(0, "");
	for(int i = 0; i < v.size(); ++i) {
		cout << v[i] << '\n';
	}
	return 0;
}



Measured memory_bytes: 7796