akhauriyash/Code-Regression huggingface dataset:
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from itertools import product
from collections import defaultdict
import sys
MOD = 10**9 + 7
def main(N):
    dp = [defaultdict(int) for _ in range(N + 1)]
    dp[0]['TTT'] = 1
    for i in range(N):
        for j in product('AGCT', repeat=3):
            jj = ''.join(j)
            if jj not in dp[i]: continue
            for k in 'AGCT':
                last4 = jj + k
                last3 = last4[1:]
                if last3 == 'AGC': continue
                if last3 == 'GAC': continue
                if last3 == 'ACG': continue
                if last4[0] == 'A' and last4[3] == 'C' and (last4[1] == 'G' or last4[2] == 'G'): continue
                dp[i + 1][last3] += dp[i][jj]
                dp[i + 1][last3] %= MOD
    ans = 0
    for j in product('AGCT', repeat=3):
        jj = ''.join(j)
        ans += dp[N][jj]
        ans %= MOD
    print(ans)

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    main(N)


Measured memory_bytes: 74524
#include<bits/stdc++.h>
using namespace std ;
typedef  long long int ll ;
#define inf 9e18
#define mod 1000000007
#define mod1 998244353
long long int power(long long int a,long long int n,long long int m) ;
 long long int power(long long int a,long long int n,long long int m)
{  if(n==0)
   return 1 ;
   long long int x=power(a,n/2,m) ;
   if(n%2!=0)
    return (((a*x)%m)*(x)%m)%m ;
    else return (x*x)%m ;
}


int main()
{ ll n,i,j,x,y,m,k,t,sum,count,cnt,b,c,d,j1,z,a,o;
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cin>>x>>y>>z ;
   z=min(z,y-1) ;
   cout<<(z*x)/y<<"\n" ;
   return 0; }


Measured memory_bytes: 3608
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]  # 自身が親だとして初期化
        self.rank = [0 for _ in range(n)]  # 自身が根なので根の深さ0として初期化

    def find(self, x):
        """xの属する根を求める"""
        if self.par[x] == x:  # 親が自分自身なら自分が根
            return x
        else:
            self.par[x] = self.find(self.par[x])  # さらに深く探索する
            return self.par[x]

    def unite(self, x, y):
        """x,yの属する集合のマージ"""
        x = self.find(x)  # xの根
        y = self.find(y)  # yの根
        if x == y:  # 同じ根を持つなら何もしない
            return
        if self.rank[x] < self.rank[y]:  # yの根のほうが深いとき
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # def same(self, x, y):
    #     """xとyが同じ集合に属するかを判定"""
    #     return self.find(x) == self.find(y)


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

parent = [-1] * N
unionfind = UnionFind(N)
for i in range(M):
    xi, yi, zi = map(int, input().split())
    xi -= 1
    yi -= 1
    unionfind.unite(xi, yi)
    parent[yi] = xi

# print(parent)
# print(unionfind.par)
ans_set = set()
for i in range(N):
    ans_set.add(unionfind.find(i))
ans = len(ans_set)

# print(ans_set)
print(ans)


Measured memory_bytes: 17576
vec = []

loop do
  h, w = gets.split.map(&:to_i)
  break if h.zero? && w.zero?

  vec << [h, w]
end

vec.each do |v|
  h = v[0]
  w = v[1]

  h.times do
    puts '#' * w
  end

  puts ''
end



Measured memory_bytes: 8904
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

ll n,a,b;

int main(){
	n=read(),a=read(),b=read();
	if (a>b) swap(a,b);
	if (b-a&1) printf("%lld\n",min(a-1+(b-a+1)/2,(n-b)+(b-a+1)/2));
		else printf("%lld\n",(b-a)/2);
}

Measured memory_bytes: 3756
//https://www.acmicpc.net/problem/11797 
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;
const int MAXN = 200005;

int dp[MAXN], nxt[MAXN];
int tra[MAXN], chr[MAXN];
int a[MAXN], n, m;
int elem[MAXN];
char str[MAXN];

int main(){
	scanf("%s", str);
	n = strlen(str);
	m = 26;
	for(int i=1; i<=n; i++){
		a[i] = str[i-1] - 'a' + 1;
	}
	for(int j=0; j<m; j++) nxt[j] = n+1;
	for(int i=n; i>=0; i--){
		int w = min_element(elem + 1, elem + m + 1) - elem;
		dp[i] = elem[w] + 1;
		tra[i] = nxt[w];
		chr[i] = w;
		nxt[a[i]] = i;
		elem[a[i]] = dp[i];
	}
	int pos = 0;
	for(int i=0; i<dp[0]; i++){
		printf("%c", chr[pos] + 'a' - 1);
		pos = tra[pos];
	}
}


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

using namespace std;
int main(){
int N;
cin>>N;
  int h[N];
    for(int i = 0;i<N;i++){
cin>>h[i];
    }
  int ans = 1;
    for(int x = 1;x<N;x++){
      int cnt = 0;
      for(int y = 0;y<x;y++){
        if(h[y]<=h[x]){
          cnt++;
        }
      }
      if(cnt == x){
          ans++;
        }
    }
  cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int t;
string s;
int main(){
	cin >> s;
	rep(i,s.size()) if((~i&1 && s[i] == 'L') || (i&1 && s[i] == 'R')) t = 1;
	cout << (t ? "No" : "Yes") << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N,M,V,P;
    cin >> N >> M >> V >> P;
    vector<ll> A(N);
    vector<ll> B(N + 1);
    B[0] = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    sort(A.begin(),A.end(),greater<ll>());
    for(int i = 0; i < N; i++){
        B[i + 1] = B[i] + A[i];
        //cout << A[i] << "," << B[i + 1] << endl;
    }
    ll count = 0;
    ll thr = A[P - 1];
    for (int i = 0; i < N; ++i) {
        if(i < P){
            count++;
            continue;
        }
        if(A[P - 1] > A[i] + M){
            continue;
        }
        ll votable = 0;
        votable += (P - 1) * M;
        votable += (N - i) * M;
        votable += (i - P + 1) * (A[i] + M) - (B[i]-B[P - 1]);
        if(votable >= M * V){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(s[i] != s[n-1-i]){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i = 0; i < (n-1)/2; i++){
        if(s[i] != s[(n-1)/2-1-i] || s[(n+3)/2-1+i] != s[n-1-i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
def GCD(a,b):
  if a == 0 or b == 0: return max(a,b)
  else:
    gcd = 1
    while 1:
      if a%b == 0:
        gcd = b
        break
      else:
        r = a%b
        a = b
        b = r
    return gcd

def main():
  n,x = map(int,input().split())
  pos = list(map(int,input().split()))
  res = 1
  if n == 1:
    res = abs(pos[0] - x)
  else:
    gcd = GCD(abs(pos[0] - x), abs(pos[1] - x))
    for i in range(2,n): gcd = GCD(gcd, abs(pos[i] - x))
    res = gcd
  
  print(res)

if __name__ == "__main__":
  main()

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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;


int main() {

	ll n, k;
	cin >> n >> k;
	VI p(n);
	REP(i, n)cin >> p[i];

	ll sum = 0;

	ll ans = 0;

	REP(i, k)sum += p[i];
	
	ans = sum;
	FOR(i, k, n) {
		sum += p[i];
		sum -= p[i - k];
		ans = max(ans, sum);
	}

	double ansa = (double)ans;
	ansa += k;
	ansa /= 2.0;

	cout << fixed << setprecision(15) << ansa << endl;
	
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define foreach(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define len(a) ((int) (a).size())

#ifdef CUTEBMAING
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

using namespace std;

typedef long long int64;
typedef long double ld;
typedef unsigned long long lint;

const int inf = (1 << 30) - 1;
const int64 linf = (1ll << 62) - 1;

int main() {
#ifdef XCODE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m; cin >> n >> m;
    vector<vector<string>> a(n, vector<string>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            static char buf[100500];
            scanf("%s", buf);
            a[i][j] = string(buf);
            if (a[i][j] == "snuke") {
                printf("%c%d\n", (char) (j + 'A'), i + 1);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
const int Maxn=200005;
int n,m;
LL A[Maxn],B[Maxn];
LL dp[Maxn][2],S[Maxn];
vector<int> G[Maxn],nG[Maxn];
int par[Maxn],ord[Maxn];
bool O[Maxn];
int findset(int x){
	return par[x]=(par[x]==x)?x:findset(par[x]);
}
bool cmp(int x,int y){
	return A[x]-B[x]<A[y]-B[y];
}
void dfs(int x){
	S[x]=B[x];
	for (int i=0;i<nG[x].size();i++){
		dfs(nG[x][i]);
		S[x]+=S[nG[x][i]];
	}
}
void dfs2(int x){
	dp[x][0]=S[x]-B[x]+max(A[x],B[x]);
	for (int i=0;i<nG[x].size();i++){
		dfs2(nG[x][i]);
	}
	dp[x][1]=dp[x][0];
	LL totS=S[x]-B[x];
	for (int i=0;i<nG[x].size();i++){
		int v=nG[x][i];
		dp[x][1]=min(dp[x][1],max(totS-S[v]+max(A[x],B[x]),totS-S[v]+B[x]+dp[v][1]));
	}
}
int main(){
	n=read();m=read();
	for (int i=1;i<=n;i++){
		A[i]=read();B[i]=read();
	}
	for (int i=0;i<m;i++){
		int u,v;u=read();v=read();
		G[u].pb(v);G[v].pb(u);
	}
	for (int i=1;i<=n;i++) ord[i]=i;
	for (int i=1;i<=n;i++) par[i]=i;
	sort(ord+1,ord+1+n,cmp);
	for (int i=1;i<=n;i++){
		int v=ord[i];
		vector<int> tmp;
		for (int j=0;j<G[v].size();j++){
			if (O[G[v][j]])tmp.pb(findset(G[v][j]));
		}
		sort(tmp.begin(),tmp.end());
		tmp.resize(unique(tmp.begin(),tmp.end())-tmp.begin());
		for (int j=0;j<tmp.size();j++){
			nG[v].pb(tmp[j]);
			//cout<<"Add"<<' '<<v<<' '<<tmp[j]<<endl;
			par[tmp[j]]=v;
		}
		O[v]=1;
	}
	int rt=ord[n];
	dfs(rt);
	dfs2(rt);
	printf("%lld\n",dp[rt][1]);
	return 0;
} 

Measured memory_bytes: 26876
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	++n;
	vector<int> a(n);
	for(int i = 1; i < n; ++i){ cin >> a[i]; }
	ll sum = 0;
	for(int i = 0; i < n; ++i){
		sum += abs(a[i] - a[(i + 1) % n]);
	}
	for(int i = 1; i < n; ++i){
		const int prev = (i - 1 + n) % n;
		const int next = (i + 1) % n;
		const ll answer =
			sum - abs(a[prev] - a[i]) - abs(a[next] - a[i]) + abs(a[prev] - a[next]);
		cout << answer << endl;
	}
	return 0;
}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    string s, t;
    cin >> s >> t;

    int ans;
    ans = 0;
    rep(i, 3) if (s[i] == t[i]) ans++;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<iterator>
#include<cmath>
#include<string>
#include<algorithm>
#include<sstream>
#include<queue>
#include<list>
#include<deque>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<chrono>


/*  auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
auto duration = duration_cast<milliseconds>(stop - start);
pr(duration.count());    */


#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define siz         100009
#define mp          make_pair
#define ll          long long int
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define pi          acos(-1.0)
#define all(x)      x.begin(),x.end()
#define ull		    unsigned long long int
#define m(a)	    memset(a,0,sizeof(a))
#define f(i,n)	    for(ll i=0;i<n;i++)
#define sc(a)	    scanf("%lld",&a)
#define pr(a)	    printf("%lld\n",a)
const ll inf = 1000000000000000;
ll in = 1000000000000000000;
using namespace std;
int main()
{
	FastIO;
	ll t, a, i, j, k, n, q;
	cin >> n;
	if ((10 * n) % 55)
		a = (10 * n) / 55 + 1;
	else
		a = (10 * n) / 55;
	if((10*(n+5)) %55==0)
		a--;
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 256
/**
 * 	author: krayr
 * 	created: 21.05.2019
**/

#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define mp make_pair
#define forn(i, s, n) for(int i = s; i < int(n); i++)

typedef long long ll;
//~ const double pi = 2*acos(0.0);
//~ const long long mod = 1e9+7;
//~ const int MAX_N = 1e6+5;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
       
    #ifdef _DEBUG
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    
    int date; cin >> date;
    
    int left = date / 100;
    int right = date % 100;
    
    if(left >= 1 && left <= 12){
		if(right >= 1 && right <= 12)
			cout << "AMBIGUOUS\n";
		else
			cout << "MMYY\n";
	}else{
		if(right >= 1 && right <= 12)
			cout << "YYMM\n";
		else
			cout << "NA\n";
	}
    

    return 0;
}


Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)
	// defer wr.Flush()

	n := scanInt()
	a := scanInts(n)

	cnt := make([]int, 13)
	cnt[0]++
	for _, e := range a {
		cnt[e]++
	}

	for i := 0; i < 13; i++ {
		if cnt[i] > 2 || (cnt[i] > 1 && (i == 0 || i == 12)) {
			fmt.Fprintln(wr, 0)
			wr.Flush()
			return
		}
	}

	s := 0
	bitExhaustiveSearch(13, func(b []bool) {
		arr := []int{}
		for i := 0; i < 13; i++ {
			if cnt[i] == 0 {
				continue
			}
			if cnt[i] == 1 {
				if !b[i] {
					arr = append(arr, i)
				} else {
					arr = append(arr, (24-i)%24)
				}
			} else {
				arr = append(arr, i, (24-i)%24)
			}
		}

		mi := 24
		for i := 0; i < len(arr); i++ {
			for j := i+1; j < len(arr); j++ {
				d := abs(arr[i]-arr[j])
				mi = min(mi, min(24-d,d))
			}
		}
		s = max(s, mi)
	})

	fmt.Fprintln(wr, s)
	wr.Flush()
}

func bitExhaustiveSearch(n int, fn func(a []bool)) {
	all := 1 << uint(n)
	a := make([]bool, n)
	for i := 0; i < all; i++ {
		for j := 0; j < n; j++ {
			if i >> uint(j) & 1 == 1 { a[j] = true } else { a[j] = false }
		}
		fn(a)
	}
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    int c=INF,f=-INF;
    rep(i,0,n){
        if(s[i]=='C'){
            c=i;
            break;
        }
    }
    rep(i,0,n){
        if(s[i]=='F') f=i;
    }
    cout<<(c<f?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;

int Ctoi(char c){
    return c-'0';
}

LL ans;

LL calc(int k,string t){
    while(!t.empty()&&t[0]=='0'){t=t.substr(1,t.size()-1);}
    int n=t.size();
    if(k==0){return 1;}
    else{
        if(n>=k){
            LL x=calc(k-1,t.substr(1,t.size()-1));
            LL y;
            LL z;
            LL y1,y2,y3;
            y1=(n-1)*9;
            y2=(n-1)*(n-2)*81/2;
            y3=(n-1)*(n-2)*(n-3)*729/6;
            if(k==1){y=y1;z=(Ctoi(t[0])-1)*1;}
            if(k==2){y=y2;z=(Ctoi(t[0])-1)*y1;}
            if(k==3){y=y3;z=(Ctoi(t[0])-1)*y2;}
            return x+y+z;
        }
        else{return 0;}
    }
}

int main()
{ 
    string s;
    cin>>s;
    int k;
    cin>>k;
    LL ans=0;
    ans=calc(k,s);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		String string = input.nextLine();
		char first = ' ';
		int counter = 0;
		for(char b : string.toCharArray()){
			if(first == ' '){
				first = b;
			}  else{
				if(b == first){
					
				} else {
					first = b;
					counter++;
				}
			}
		}
		System.out.println(counter);
	}

}

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

int t[10][7]={
  {1,1,1,1,1,1,0},
  {0,1,1,0,0,0,0},
  {1,1,0,1,1,0,1},
  {1,1,1,1,0,0,1},
  {0,1,1,0,0,1,1},
  {1,0,1,1,0,1,1},
  {1,0,1,1,1,1,1},
  {1,1,1,0,0,1,0},
  {1,1,1,1,1,1,1},
  {1,1,1,1,0,1,1}
};
int n,a,b;
int main(){

  while(1){
    cin>>n;
    if(n==-1)break;
    cin>>a;
    for(int i=6;i>=0;i--)cout<<t[a][i];
    cout<<endl;
    for(int j=1;j<n;j++){
      b=a;
      cin>>a;
      for(int i=6;i>=0;i--){
	cout<<(t[a][i]!=t[b][i]?'1':'0');
      }
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;
 
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;
 
 
const int mod=1000000007;
//const int mod=998244353;

 ll pow(ll a, ll b, ll m) {
     a %= m;
     ll res = 1;
     while (b > 0) {
         if (b & 1)
             res = res * a % m;
         a = a * a % m;
         b >>= 1;
     }
     return res;
 }
 
vector<long long int> fact,fact_inverse;
template<typename type>
void tabulate(type n){
    fact.resize(n+1);
    fact_inverse.resize(n+1);
    fact[0]=1;
    fact_inverse[0]=pow(1, mod-2, mod);
    for (int i=1; i<n+1; i++) {
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
        fact_inverse[i]=pow(fact[i], mod-2, mod);
    }
}
template<typename type>
long long int nCk(type n,type k){
    return fact[n]*fact_inverse[n-k]%mod*fact_inverse[k]%mod;
}
template<typename type>
long long int nPk(type n,type k){
    return fact[n]*fact_inverse[n-k]%mod;
}
 



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r,p;
    cin >> k;
    string s;
    cin >> s;
    n=k+s.length();
    tabulate(n);
    a=0;
    for(int i=0; i<s.length(); i++){
        a+=nCk((int)n,i)*pow(25,n-i,mod);
        a%=mod;
    }
    a=pow(26,n,mod)-a;
    cout << (a+mod)%mod << el;
    return 0;
}


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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int g[15][15];
    int n; cin >> n;
    rep(i,n)rep(j,n) g[i][j] = -1;
    rep(i,n){
        int a; cin >> a;
        rep(j,a){
            int x, y; cin >> x >> y; x--;
            g[i][x] = y;
        }
    }
    int ans = 0;
    rep(i,1<<n){
        vector<int> d(n);
        rep(j,n){
            if(i>>j & 1) d[j] = 1;
        }
        bool ok = true;
        rep(j,n){
            if (d[j]){
                rep(k,n){
                    if(g[j][k] == -1) continue;
                    if(g[j][k] != d[k]) ok = false;
                }
            }
        }
        if (ok) ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def calc(a, b, c)
  a,b = b,a if a > b
  (c-(b-a)+1)/2 + b
end

n, m, k = gets.split.map(&:to_i)
l1 = Array.new(n){ Array.new(n, 1<<31) }
l2 = n.times.map{[]}
l3 = []
n.times{ |i| l1[i][i] = -1 }
m.times do
  a, b, c = gets.split.map(&:to_i)
  a -= 1; b -= 1
  l1[a][b] = l1[b][a] = c
  l2[a] << b; l2[b] << a
  l3 << [a,b,c]
end

visited = n.times.map{ false }
arr = []
dist = n.times.map{ 1<<31 }
k.times do
  visited[i = gets.to_i - 1] = true
  arr << i
  dist[i] = 0
end

until arr.empty?
  s = arr.min{ |a,b| dist[a] <=> dist[b] }
  arr.delete s
  l2[s].each do |t|
    d = dist[s] + l1[s][t]
    if (old = dist[t]) > d
      dist[t] = d
      arr << t if old == 1 << 31
    end
  end
end
ret = 0
m.times{ |i| ret = [ret, calc(dist[l3[i][0]], dist[l3[i][1]], l3[i][2])].max }
p ret

Measured memory_bytes: 88560
#include<bits/stdc++.h>
using namespace std;
int a,b,c; 
int main(){
	cin>>a>>b>>c;
	if((a==b&&b!=c)||(a==c&&c!=b)||(c==b&&a!=b)){
		cout<<"Yes";
	}
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


/**
 * Lesson8A 与えられた文字列の小文字と大文字を入れ替えるプログラム
 *
 * @author Internship
 *
 */
public class Main{

	/**
	 * プログラムのエントリポイント
	 *
	 * @param args
	 */
	public static void main(String[] args) {

		//1行読み込む
		try {
			BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

			String strLine = insBR.readLine();

			//char型に分解
			char[] chaAryLine = strLine.toCharArray();

			//各charが大文字なら小文字、小文字なら大文字へ
			for(int i = 0; i < chaAryLine.length; i++) {
				if(Character.isUpperCase(chaAryLine[i])) {
					chaAryLine[i] = Character.toLowerCase(chaAryLine[i]);
				}else if(Character.isLowerCase(chaAryLine[i])) {
					chaAryLine[i] = Character.toUpperCase(chaAryLine[i]);
				}

				//出力
				System.out.print(chaAryLine[i]);
			}
			System.out.println("");

		} catch (IOException e) {
			System.out.println(e);
		}

	}
}

Measured memory_bytes: 17156
s = input()
t = input()
mx = 0
mxp = [-1, -1]
dp = [[0 for i in range(len(t) + 1)] for j in range(len(s) + 1)]
for i in range(len(s)):
	for j in range(len(t)):
		if s[i] == t[j]:
			dp[i + 1][j + 1] = 1 + dp[i][j]
		else:
			dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])
		if dp[i + 1][j + 1] > mx:
			mx = dp[i + 1][j + 1]
			mxp = [i + 1, j + 1]
if mx == 0:
	print()
else:
	ans = ''
	x = mxp[0]
	y = mxp[1]
	while dp[x][y]:
		if s[x - 1] == t[y - 1]:
			ans += s[x - 1]
			x -= 1
			y -= 1
		else:
			if dp[x - 1][y] > dp[x][y - 1]:
				x -= 1
			else:
				y -= 1
	print(ans[::-1])


Measured memory_bytes: 153384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<pair<T, T> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

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

	sort(sides.begin(), sides.end());
	int sum = 0;
	for (int i = 0; i < n - 1; ++i) {
		sum += sides[i];
	}

	if (sides[n - 1] < sum) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int n, m, x, ans = INF;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  REP(i, n) {
    cin >> c.at(i);
    REP(j, m) { cin >> a.at(i).at(j); }
  }

  for (int bit = 0; bit < (1 << n); bit++) {
    int val = 0;
    vector<int> u(m, 0);
    bool f = true;
    REP(i, n) {
      if (bit & (1 << i)) {
        val += c.at(i);
        REP(j, m) { u.at(j) += a.at(i).at(j); }
      }
    }
    REP(j, m) {
      if (u.at(j) < x) f = false;
    }
    
    if (f) ans = min(ans, val);
  }
  if (ans == INF)
    cout << -1 << "\n";
  else
    cout << ans << "\n";
  return 0;
}


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


void input(); template<typename First,typename... Rest> void input(First&,Rest&...);
void inputVector(); template<typename First,typename... Rest>  void inputVector(std::vector<First>&,Rest&...);
#define loop(n) for(int i = 0;i < (int)(n);++i)
#define rep(i,n) for(int i = 0;i < (int)(n);++i)


void calculate(){

}

int main(int,char**){
    std::string str;
    input(str);
    int res = 700;
    rep(i,3)
        if(str[i] == 'o') res += 100;
    std::cout << res << '\n';
}



void input(){return;}
template<typename First,typename... Rest>
void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}

void inputVector(){return;}
template<typename First,typename... Rest> 
void inputVector(std::vector<First> &first,Rest&... rest){
    int N = first.size();
    for(int i = 0;i < N;i++){
        std::cin >> first[i];
    }
    inputVector(rest...);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef int32_t i32;

#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>=b;i--)
#define FILL(a,b,c) for(ll i=0;i<c;i++) a[i]=b;

#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()

#define endl "\n"
#define setpri(x) setprecision(x)
#define vp(x) cout<<#x<<" : "<< (x)<<" | "
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define forf(i,a,b) for(int i=a;i<b;i++)

#define INF 1e17+4
#define MINF 
#define MAX_INT 100000
#define MOD 1000000007
ll mod(ll n) { n %= MOD; if (n < 0) return n + MOD; else return n;}
// vector<int> adj[1000002];
// int vis[1000002],dep[1000002],siz[1000002];

// void dfs(ll cur,ll par)
// {
//     vis[cur]=1;siz[cur]=1;
//     for(auto x:adj[cur])
//     {
//         if(vis[x]!=1)
//         {
//             dep[x]=dep[cur]+1;
//             dfs(x,cur);
//             siz[cur]+=siz[x];
//         }    
//     }
// }

// bool sortfunc(const pair<int,int> &a, const pair<int,int> &b) 
// { 
//     return ;


void solve()
{
    int n,k;
    cin>>n>>k;
    vector<int> v(n+1);
    forf(i,1,n+1)
        cin>>v[i];
    vector<int> r(n+1),data(n+1);
    int c=1,cnt=1;
    k++;
    while(c<=n && r[c]==0)
    {
        r[c]=cnt;
        data[cnt]=c;
        cnt++;
        k--;
        if(k==0)    
        {
            cout<<c<<endl;
            return;
        }
        c=v[c];
    }
    data[cnt]=c;
    // cout<<c<<" "<<cnt<<" "<<v[c]<<endl;
    // for(int i=1;i<=n;i++)
    //     cout<<i<<" "<<r[i]<<endl;
    // cout<<endl;
    
    int x=cnt-r[c];
    // cout<<"x  "<<x<<endl<<endl;
    k=k%x;
    // cout<<"k  "<<k<<endl<<endl;
    if(k==0)
        k+=x;
    // // cout<<k<<" "<<x<<" "<<cnt<<endl;
    cout<<data[k+r[c]-1]<<endl;
    // cout<<c<<" "<<cnt;
    
    
}


signed main()
{
    FAST;
    
    // ll t;cin>>t;while(t--)
        solve();
 
    return 0;
}

Measured memory_bytes: 7900
/*

*/
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((ll)(x).size())
#define cin1(x) cin >> x
#define cin2(x, y) cin >> x >> y
#define cin3(x, y, z) cin >> x >> y >> z
#define cin4(x, y, z, _) cin >> x >> y >> z >> _
#define cin5(x, y, z, p, q) cin >> x >> y >> z >> p >> q
#define cou(x) cout << x
#define cous(x) cout << x << " "
#define coul(x) cout << x << "\n"
#define ret(x) return x
#define MAX 5000001
#define start int main() {   fastio
#define finish ret(0); }
#define Test ll _t cin1(_t); rep(i, 0, _t)

struct point{    int x, y, ind;   char ch;  };
typedef long long ll;
typedef vector<ll> VI;
typedef pair<ll,ll> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod=1000000007;
//ll rnd(ll x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}ret(res);}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[13];
void factorial() {   fact[0]=1;  rep(i, 1, 12) fact[i]=(fact[i-1]*i);  }
vector <ll> sie; //for sieve function
ll spf[MAX+7];  //for sieve function
void sieve() {    rep(i, 2, MAX)  {  if (spf[i] == 0) {  spf[i] = i;   sie.pb(i);  }    for (ll j=0; j<SZ(sie) && i*sie[j] <= MAX && sie[j] <= spf[i]; j++)   spf[i * sie[j]] = sie[j]; }   }
bool cmp(point A, point B){   if(A.x != B.x) ret(A.x < B.x);  ret(A.y < B.y);   }
// head collected

ll q, _, __, re;
string str, s;
char ara_a[55][55];
char ara_b[55][55];

start;

    cin2(_, __);

    rep(i, 9, 1251) {
        q = (8*i)/100;
        re = i/10;
        if (  _ == q && __ == re){
            coul(i);
            ret(0);
        }
    }

    coul("-1");

finish


/*
rtry
15
1
2 2 s
2 1 d
1
2 1 h
2 2 j
2 2 u
1
2 1 n
1
2 2 b
2 1 b
1
2 2 n
2 1 n

*/









Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		sc.close();
		System.out.println((a*b)%2==1?"Odd":"Even");
	}
}


Measured memory_bytes: 21588
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int 
int main() {
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll k=s.length();
    if(k<=n){
        cout<<s;
    }
    else{
        string d=s.substr(0,n);
        d+="...";
        cout<<d;
    }
    
    
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
    int n;
    cin >> n;
    vector<long long> l = vector<long long>(n);
    rep (i, n) cin >> l[i];

    long long cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            for (int k = j+1; k < n; k++) {
                if (l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i]
                    && l[i]+l[j]>l[k] && l[j]+l[k]>l[i] && l[k]+l[i]>l[j]) cnt++;
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3624
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47464
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> X(N), Y(N);
    REP(i, N) {
        cin >> X[i];
        Y[i] = X[i];
    }
    SORT(Y);
    int m1 = Y[N / 2 - 1], m2 = Y[N / 2];
    REP(i, N) {
        if (X[i] <= m1) {
            cout << m2 << endl;
        } else {
            cout << m1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3840
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <vector>
#include <string>
#include <set>
using namespace std;
typedef long long ll;

int ck[128];

bool cl(string s){
    set<char> st;
    for(auto i : s) st.insert(i);
    return st.size()==1;
}

int f(string a, char c){
    int cnt = 0;
    while(!cl(a)){
        string tmp = "";
        for(int i = 0 ; i < a.size()-1 ; i++){
            if(a[i]==c||a[i+1]==c) tmp += c;
            else tmp += a[i];
        }
        cnt++;
        a = tmp;
    }
    return cnt;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
    int ans = 105;
    string s; cin >> s;
    for(auto i : s) ck[i] = 1;
    for(char i = 'a' ; i <= 'z' ; i++){
        if(ck[i]) ans = min(ans, f(s,i));
    }
    cout << ans;
}



Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k == x:
        ans += 1
print(ans)

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

using namespace std;

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

  cout << s[0];

  int count = 0;
  for(int i = 0; i < s.length(); i++) {
    if(count < w) {
      count++;
    }
    else if(count == w) {
      cout << s[i];
      count = 1;
    }
  }

  cout << endl;
}

Measured memory_bytes: 256
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    n,x,y=map(int,input().split())
    d2=[[INFI for i in range(n+1)] for j in range(n+1)]
    total=[0]*(n+1)
    d2[x][y]=1
    d2[y][x]=1
    for i in range(1,n+1):
        for j in range(1,n+1):
            d2[i][j]=min(d2[i][j],abs(i-j),d2[i][x]+d2[y][j]+1,abs(d2[i][y]+d2[x][j]+1))
    for i in range(1,n+1):
        for j in range(1,n+1):
            d2[i][j]=min(d2[i][j],abs(i-j),d2[i][x]+d2[y][j]+1,abs(d2[i][y]+d2[x][j]+1))

    for i in range(1,n+1):
        for j in range(1,n+1):
            total[d2[i][j]]+=1

    for i in range(1,n):
        print(total[i]//2)




if __name__ == "__main__":

    main()

Measured memory_bytes: 80732
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

int main(){
    string s;
    cin >> s;
    int len = s.length();

    int s_cnt = 0;
    int cnt = 0;
    rep(i,len){
        if(s[i] == 'S'){
            s_cnt++;
        }else{
            if(s_cnt>0){
                cnt += 2;
                s_cnt--;
            }
        }
    }

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


Measured memory_bytes: 3660
s = input()
fo = int(s[0] + s[1])
la = int(s[2] + s[3])
fism = 00 < fo and fo < 13
lism = 00 < la and la < 13
if fism and lism:
    ans = "AMBIGUOUS"
if fism and not lism:
    ans = "MMYY"
if not fism and lism:
    ans = "YYMM"
if not fism and not lism:
    ans = "NA"
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

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

int main(void){
    ll X,Y; cin >> X >> Y;
    
    ll ans = X;
    ll len = 0;
    while(ans <= Y){
        ans *= 2;
        len++;
    }
    
    cout << len << endl;
}


Measured memory_bytes: 384
n, X = map(int, input().split())

is_false = True
for i in range(n+1):
  for j in range(n+1):
    if i+j > n:
      pass
    else:
      k = n-i-j
      otoshi = 10000*i + 5000*j + 1000*k
      if otoshi == X:
        print(i, j, k)
        is_false = False
        break
  else:
    continue
  break

if is_false:
  print('-1 -1 -1')

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[][] c = new char[3][3];
			for (int i = 0; i < 3; i++) {
				c[i] = in.nextString().toCharArray();
			}
			StringBuffer sb = new StringBuffer();
			sb.append(c[0][0]).append(c[1][1]).append(c[2][2]);
			System.out.println(sb.toString());

		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21460
#include <iostream>
#include <math.h>

int main()
{
    int N, D;
    std::cin >> N >> D;
    int X[N], Y[N];
    for(int i=0; i<N; i++){
        std::cin >> X[i] >> Y[i];
    }
    int ans = 0;
    long long D2 = static_cast<long long>(std::round(pow(D, 2)));

    for(int i=0; i<N; i++){
        //std::cout << "i" << i << std::endl;
        //std::cout << "X" << static_cast<int>(pow(X[i], 2)) << std::endl;
        //std::cout << "Y" << static_cast<int>(pow(Y[i], 2)) << std::endl;
        //std::cout << "sol" << static_cast<int>(std::round(std::round(pow(X[i], 2)) + std::round(pow(Y[i], 2)))) << std::endl;
        if(static_cast<long long>(std::round(std::round(pow(X[i], 2)) + std::round(pow(Y[i], 2)))) <= D2){
            ans++;
        }
    }

    std::cout << ans << std::endl;
    //int end;
    //std::cin >> end;
    return 0;
}

Measured memory_bytes: 5228
#include <stdio.h>

int main(void) {
int a, b, c;
int flag = 0;

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

if (a < b) {
if (b < c) {
printf("Yes\n");
flag = 1;
}
}

if (flag == 0) printf("No\n");

return 0;
}


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



int main() {
    using vi = vector<int>;
    
    int n,m;
    cin >> n >> m;
    if(m>=n){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
}

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

string S;
int t[1 << 18], cnt[1 << 18];

int main() {
	cin >> S; int v = -1;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'R') v = -1;
		else {
			if (v == -1) v = i;
			t[i] = v;
		}
	}
	v = -1;
	for (int i = S.size() - 1; i >= 0; i--) {
		if (S[i] == 'L') v = -1;
		else {
			if (v == -1) v = i;
			t[i] = v;
		}
	}

	for (int i = 0; i < S.size(); i++) {
		int r = abs(t[i] - i);
		if (S[i] == 'L') { if (r % 2 == 0) cnt[t[i]]++; else cnt[t[i] - 1]++; }
		if (S[i] == 'R') { if (r % 2 == 0) cnt[t[i]]++; else cnt[t[i] + 1]++; }
	}
	for (int i = 0; i < S.size(); i++) { if (i) cout << " "; cout << cnt[i]; } cout << endl;
	return 0;
}

Measured memory_bytes: 1408
while True:
   H, W = [int(i) for i in input().split()]
   if H == W == 0:
      break
   
   for h  in range(H):
      for w in range(W):
         if h == 0  or h == H - 1 or w == 0 or w == W -1:
           print('#', end='')
         else:
           print('.', end='')
 
      print()
    
   print()

Measured memory_bytes: 9036
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    total = sum(A)
    ans = 0
    for a in A:
        if a >= (total / (4 * M)):
            ans += 1

    if ans >= M:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060