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

using namespace std;

bool x_dp[4010][16100] = {};
bool y_dp[4010][16100] = {};
int ori = 8050;

int main(){
    string s;
    int x, y;
    cin >> s >> x >> y;
    vector<int> h, v;
    int cnt = 0;
    bool m = true;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'F') cnt++;
        else{
            if(m){
                if(cnt != 0) h.emplace_back(cnt);
                m = false; cnt = 0;
            }else{
                if(cnt != 0) v.emplace_back(cnt);
                m = true; cnt = 0;
            }
        }
    }
    if(m){
        if(cnt > 0) h.emplace_back(cnt);
    }else{
        if(cnt > 0) v.emplace_back(cnt);
    }
    if(s[0] == 'F'){
        x_dp[1][ori + h[0]] = true;
    }else{
        if(h.size() > 0){
            x_dp[1][ori + h[0]] = true;
            x_dp[1][ori - h[0]] = true;
        }else{
            x_dp[0][ori] = true;
        }
    }
    y_dp[0][ori] = true;
    for(int i = 1; i < h.size(); i++){
        for(int j = ori - s.size(); j <= ori + s.size(); j++){
            if(x_dp[i][j]){
                x_dp[i + 1][j - h[i]] = true;
                x_dp[i + 1][j + h[i]] = true;
            }
        }
    }
    for(int i = 0; i < v.size(); i++){
        for(int j = ori - s.size(); j <= ori + s.size(); j++){
            if(y_dp[i][j]){
                y_dp[i + 1][j - v[i]] = true;
                y_dp[i + 1][j + v[i]] = true;
            }
        }
    }
    if(x_dp[h.size()][ori + x] && y_dp[v.size()][ori + y]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 66304
#include<iostream>
#include<cstdio>
const int N=1e5+5;
int n,dp[1<<16],tot[20]={},a[N]={};bool vis[1<<16]={};
int len(int x) {
    int res=0;for(int i=1;i<16;i++) if(x>>i&1) res++;return res;
}
int dfs(int x) {
    if(x<=1) return 0;
    if(len(x)==1) return N;
    if(vis[x]) return dp[x];
    int res=N;vis[x]=true;
    for(int i=1;i<16;i++) {
        if(~x>>i&1) continue;
        for(int j=1;j<16;j++) {
            if(i==j||(~x>>j&1)) continue;
            int nxt=x^(1<<i)^(1<<j)^(1<<(i^j));
            if(len(nxt)>=len(x)) continue;
            res=std::min(res,dfs(nxt)+1+(~nxt>>(i^j)&1));
        }
    }
    return dp[x]=res;
}
int main() {
    scanf("%d",&n);int x,y,z;
    for(int i=1;i<n;i++) scanf("%d%d%d",&x,&y,&z),a[x]^=z,a[y]^=z;
    for(int i=0;i<n;i++) tot[a[i]]++;
    int ans=0,sta=0;
    for(int i=1;i<16;i++) ans+=(tot[i]>>1),sta|=(tot[i]&1)<<i;
    printf("%d\n",ans+dfs(sta));
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    //--<for debugging>
    #define whatis(x) cout << #x << " is " << x<<" ";
    #define whatisl(x) cout << #x << " is " << x<<"\n";
    #define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
    #define lline cout<<"\n";
    #define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
    #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
        
    void err(istream_iterator<string> it) {}
    template<typename T, typename... Args>
    void err(istream_iterator<string> it, T a, Args... args) {
        cout << *it << " = " << a <<" , ";
        err(++it, args...);
    }
    //--</for debugging> 
    #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
    #define testcase ll tt; cin >> tt; while(tt--)
    #define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
    #define pb push_back 
    #define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
    #define vll vector<ll>
    #define pll pair<ll,ll>
    #define sll set<ll>
    #define pint pair<int,int>
    const ll INF=1e9+7;
    const ll MOD=1e9+7;
    int main()
    {
        boost vars
        cin>>a>>b>>x>>y;
        p=x-a;
        q=y-b;
        for(i=0;i<q;i++)cout<<"U";
        for(i=0;i<p;i++)cout<<"R";
        for(i=0;i<q;i++)cout<<"D";
        for(i=0;i<=p;i++)cout<<"L";
        for(i=0;i<=q;i++)cout<<"U";
        for(i=0;i<=p;i++)cout<<"R";cout<<"DR";
        for(i=0;i<=q;i++)cout<<"D";
        for(i=0;i<=p;i++)cout<<"L";cout<<"U";
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main() {
    fastio
	ll n,t,i,j,x,k;
    ll a,b,c,d;
    
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d});
    
	return 0;
}

Measured memory_bytes: 3652
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

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

	N := getInt()
	a := make([]int, N)
	sum := 0
	for i := 0; i < N; i++ {
		a[i] = getInt()
		sum += a[i]
	}

	//	x := sum / N
	//	y := sum % N
	//	if y > N/2 {
	//		x++
	//	}

	x := 0
	if sum > 0 {
		x = int(float64(sum)/float64(N) + 0.5)
	} else {
		x = int(float64(sum)/float64(N) - 0.5)
	}

	ans := 0
	for i := 0; i < N; i++ {
		ans += (a[i] - x) * (a[i] - x)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
A, B, C, K = map(int, input().split())

ans = 0

if A - K < 0:
    ans += A
    K -= A
    if B - K < 0:
        K -= B
        if C - K < 0:
            print(ans - C)
        else:
            print(ans - K)
    else:
        print(ans)
else:
    print(K)

Measured memory_bytes: 9184
#include <iostream>
using namespace std;
int main(void){
  string s;
  cin >> s;
  for(int i = 0; i < s.size()-1; i++){
    if(s[i] == 'A' && s[i+1] == 'C'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i = 0;
	int ans = 1, N;
	int count = 0;
	int D;
	if(scanf("%d %d", &D, &N) == 2)

	for(i = 0; i < D; i++){
		ans *= 100;
	}

	if(N == 100){
		printf("%d\n", ans * (N + 1));
	}else{
		printf("%d\n", ans * N);
	}
	return 0;
}

Measured memory_bytes: 128
fun main(array: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    var list = Array(m){0}.toMutableList()
        repeat(n) {
            val arr = readLine()!!.split(" ").map { it.toInt() }
            for(i in 1..m) {
                for(j in 1 until arr.size) {
                    if(i == arr[j]) {
                        list[i-1] += 1
                    }
                }
            }
        }

    var cnt = 0
    repeat(m) {
        if(list[it] == n) cnt++
    }
    print(cnt)
}

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


int main(){
	int N,answer=0;
	int input_1,input_2;
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> input_1 >> input_2;
		answer+=(input_2-input_1)+1;
	}
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string n;
    cin >> n;
    bool nine = true;
    for(int i = 1; i < n.size(); i++){
        if(n[i] != '9'){
            nine = false;
        }
    }
    if(n.size() == 1){
        cout << n << endl;
    }else if(nine == true){
        cout << n[0] - '0' + 9 * (n.size() - 1) << endl;
    }else{
        cout << n[0] - '0' - 1 + 9 * (n.size() - 1) << endl;
    }
    return 0;
}

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

int N, Q;
string s;
vector<char> t, d;

int C(int x, const bool dir_flag){
    for(int i = 0; i < Q; ++i){
        if(x < 0 || x >= N) break;

        if(s[x] == t[i] && d[i] == 'R') ++x;
        else if(s[x] == t[i] && d[i] == 'L') --x;
    }
    
    if(x < 0) return dir_flag;
    else if(x >= N) return !dir_flag;
    else return false;
}

int main(){
    cin >> N >> Q;
    cin >> s;

    t.resize(Q);
    d.resize(Q);
    for(int i = 0; i < Q; ++i) cin >> t[i] >> d[i];

    int ans = N;

    int lb = -1, ub = N+1, mid;
    while(ub - lb > 1){
        mid = (lb+ub)/2;
        if(C(mid, true)) lb = mid;
        else ub = mid;
    }

    ans -= ub;

    lb = -1;
    ub = N+1;
    while(ub - lb > 1){
        mid = (lb+ub)/2;
        if(C(mid, false)) ub = mid;
        else lb = mid;
    }
    ans -= N-ub;

    cout << ans << endl;
}

Measured memory_bytes: 900
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
//ll longinf=1ll<<60;
int inf=1<<29;
ll longinf=(1ll<<60);

int main(){
      cin.tie(0);
      ios::sync_with_stdio(false);
      int a,b;
      cin>>a>>b;
      if(b%a) cout<<b-a<<endl;
      else cout<<a+b<<endl;
      return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	wset := make(map[string]struct{})
	var ws string
	r := "Yes"
	for i := 0; i < N; i++ {
		in := ""
		fmt.Scan(&in)
		if ws != "" && ws[len(ws)-1:] != in[:1] {
			r = "No"
			break
		}
		if _, ok := wset[in]; ws != "" && ok {
			r = "No"
			break
		}
		ws = in
		wset[in] = struct{}{}
	}
	fmt.Println(r)
}

Measured memory_bytes: 512
def sgn(n):
    if n>0:
        return 1
    elif n==0:
        return 0
    else:
        return -1
    
class SegmentTree:
    # 初期化処理
    # f : SegmentTreeにのせるモノイド
    # default : fに対する単位元
    def __init__(self, size, f=lambda x,y : x+y, default=0):
        self.size = 2**(size-1).bit_length() # 簡単のため要素数Nを2冪にする
        self.default = default
        self.dat = [default]*(self.size*2-1) # 要素を単位元で初期化
        self.f = f

    def update(self, i, x):
        i += self.size-1
        self.dat[i] = x
        while i > 0:
            i = (i-1) >> 1
            self.dat[i] = self.f(self.dat[i*2+1], self.dat[i*2+2])

    def query(self, l, r, k=0, L=0, R=None):
        if R is None:
            R = self.size
        if R <= l or r <= L:
            return self.default
        if l <= L and R <= r:
            return self.dat[k]
        else:
            lres = self.query(l, r, k*2+1, L, (L+R) >> 1)
            rres = self.query(l, r, k*2+2, (L+R) >> 1, R)
            return self.f(lres, rres)
        
n=int(input())
b=[int(i) for i in input().split()]
l = SegmentTree(size=n)
p0=0
for i in range(n):
    l.update(i,b[i])
for i in range(n):
    sg=(-1)**(i)
    v=l.query(0,i+1)
    #print(v,p0)
    if sgn(v) != sg:
        tmp= abs(v)+1
        #print(f'{b[i]}---{tmp}--->{sg}')
        p0 += tmp
        l.update(i,b[i]+tmp*sg)
        
l = SegmentTree(size=n)
for i in range(n):
    l.update(i,b[i])
p1=0
#print()
for i in range(n):
    sg=(-1)**(i+1)
    v=l.query(0,i+1)
    #print(v,p1)
    if sgn(v) != sg:
        tmp= abs(v)+1
        #print(f'{b[i]}---{tmp}--->{sg}')
        p1 += tmp
        l.update(i,b[i]+tmp*sg)
    #print(l.query(0,i+1),p1)
print(min(p0,p1))

Measured memory_bytes: 85204
//Solution by Zhusupov Nurlan
#include <bits/stdc++.h>

using namespace std;

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

#define endl '\n'
#define pb(x) push_back(x)
#define sqr(x) ((x) * (x))
#define F first
#define S second
#define SZ(t) ((int) t.size())
#define len(t) ((int) t.length())
#define base LL(1e9 + 7)
#define fname ""
#define sz 1000 * 1000
#define EPS (1e-8)
#define INF ((int)1e9 + 9)
#define mp make_pair

int n, a[sz];

int main()
{
//    freopen(fname"in", "r", stdin);
//    freopen(fname"out", "w", stdout);

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  int p = 1, ans = 0;
  while (p <= n) {
    ans++;
    while (p < n && a[p] == a[p + 1]) p++;
    if (p < n) {
      if (a[p] < a[p + 1])
      while (p < n && a[p] <= a[p + 1]) {
        p++;
      } else {
        while (p < n && a[p] >= a[p + 1]) p++;
      }
    }
    p++;
  }

  cout << ans;

}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	  for(auto &e:u) fill_v<T>(e,v...);
}

vector<PLL> G[310];

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

  int64 N, M, L;
  cin >> N >> M >> L;
  REP(i, M) {
    int64 a, b, c;
    cin >> a >> b >> c; a--; b--;
    G[a].emplace_back(c, b);
    G[b].emplace_back(c, a);
  }
  int64 Q;
  cin >> Q;
  vector<int64> res(Q, -1);
  map<int64, vector<PLL>> q;
  REP(_, Q) {
    int64 s, t;
    cin >> s >> t;
    q[s-1].emplace_back(t-1, _);
  }
  REP(i, N) {
    auto d = make_v<PLL>(N + 1);
    fill_v<PLL>(d, PLL(INF, 0));
    d[i] = PLL(0, -L);
    using T = tuple<int64, int64, int64>;
    priority_queue<T, vector<T>, greater<T>> pq;
    pq.emplace(0, -L, i);
    while (pq.size()) {
      int64 vv, dd, rr;
      tie(dd, rr, vv) = pq.top();
      pq.pop();
      if (d[vv].fs < dd || (d[vv].fs == dd && -d[vv].sc > -rr)) continue;

      REP(i, G[vv].size()) {
        int64 uu, cc;
        tie(cc, uu) = G[vv][i];
        if (-rr < cc && L >= cc && d[uu] > PLL(dd+1, -L+cc)) {
          d[uu] = PLL(dd+1, -L + cc);
          pq.emplace(dd+1, -L + cc, uu);
        } else if (-rr >= cc && d[uu] > PLL(dd, rr + cc)) {
          d[uu] = PLL(dd, rr + cc);
          pq.emplace(dd, rr + cc, uu);
        }
      }
    }
    for (auto &t: q[i]) {
      if (d[t.fs].fs != INF) res[t.sc] = d[t.fs].fs;
    }
  }
  REP(i, Q) {
    cout << res[i] << endl;
  }
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;
vector<int> G[MAX];
int dis1[MAX],dis2[MAX];
int D[MAX];
int nou=-1,nov=-1;

void DFS(int u,int p,int k){
    for(int to:G[u]){
        if(to==p) continue;
        if(k==1){
            dis1[to]=dis1[u]+1;
        }else{
            dis2[to]=dis2[u]+1;
        }
        DFS(to,u,k);
    }
}

void solve(int u,int p){
    for(int to:G[u]){
        if(to==p) continue;
        if(u==nou&&to==nov) continue;
        if(to==nou&&u==nov) continue;
        
        D[to]=D[u]+1;
        solve(to,u);
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    int u,v;cin>>u>>v;
    u--;v--;
    
    for(int i=0;i<N-1;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    DFS(u,-1,1);
    DFS(v,-1,2);
    
    int M=dis1[v];
    
    if(M%2==0){
        for(int i=0;i<N;i++){
            if(dis1[i]==M/2-1&&dis2[i]==M/2+1) nou=i;
            if(dis1[i]==M/2&&dis2[i]==M/2) nov=i;
        }
        solve(nou,-1);
        
        int maxi=0;
        
        for(int i=0;i<N;i++){
            maxi=max(maxi,D[i]);
        }
        
        cout<<dis1[nou]+maxi+1<<endl;
    }else{
        for(int i=0;i<N;i++){
            if(dis1[i]==M/2&&dis2[i]==M/2+1) nou=i;
            if(dis1[i]==M/2+1&&dis2[i]==M/2) nov=i;
        }
        solve(nou,-1);
        
        int maxi=0;
        
        for(int i=0;i<N;i++){
            maxi=max(maxi,D[i]);
        }
        
        cout<<dis1[nou]+maxi<<endl;
    }
}


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

int n,k;
string s;
queue <int> Q;
int sum=0,now=0,ans=0,sum0=0;

int main(){
	cin>>n>>k;
	cin>>s; 
	for(int i=0;i<n;i++){
		if((s[i]=='0'&&s[i-1]=='1')||(s[i]=='0'&&i==0)){
			sum0++;
			if(sum0>k){
				sum0--;
				sum-=Q.front();
				Q.pop();
			}
		}
		else if(s[i]=='1'&&s[i-1]=='0'&&i!=0){
			Q.push(now);
			now=0;
		}
		sum++;
		now++;
		ans=max(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
package main

import (
    "fmt"
    "math"
)

func main() {

    var n int
    fmt.Scan(&n)

    t := map[int]int{0: 0}
    x := map[int]int{0: 0}
    y := map[int]int{0: 0}
    for i := 1; i <= n; i++ {
        var xi, yi, ti int
        fmt.Scan(&ti, &xi, &yi)
        t[i] = ti
        x[i] = xi
        y[i] = yi
    }

    res := true
    for i := 1; i <= n; i++ {
        dx := int(math.Abs(float64(x[i] - x[i-1])))
        dy := int(math.Abs(float64(y[i] - y[i-1])))
        dt := int(math.Abs(float64(t[i] - t[i-1])))
        if dx+dy > dt || (dx+dy)%2 != dt%2 {
            res = false
        }
    }

    if res {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
}

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

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

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

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

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

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

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

  ll n;
  cin >> n;

  ll ans = n * (n - 1) / 2;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
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()
{   
    int k,n; cin >> k >> n;
    cout << (k*500>=n?"Yes":"No") << endl;
}
    

Measured memory_bytes: 256
# シカのAtCoDeerくんとTopCoDeerくんが「正直者か嘘つきか」ゲームをしています。
# このゲームでは、正直者は常にほんとうのことを言い、嘘つきは常に嘘を言います。
# 文字 a と b が入力として与えられます。
# これらはそれぞれ H か D のどちらかです。
# a=H のとき、AtCoDeerくんは正直者です。
# a=D のとき、AtCoDeerくんは嘘つきです。
# b=H のとき、AtCoDeerくんは「TopCoDeerくんは正直者だ」と発言しています。
# b=D のとき、AtCoDeerくんは「TopCoDeerくんは嘘つきだ」と発言しています。
#
# これらから判断して、TopCoDeerくんが正直者かどうか判定してください。

# 制約
# a='H' または 'D'
# b='H' または 'D'


# 標準入力から文字列 a と b を取得する
input_a, input_b = map(str,input().split())

reslut = "ret"

# TopCoDeerくんが正直者かどうか判定し、結果を出力する。
# ※ 正直者=="H"、嘘つき=="D"
if input_a == "H":  # AtCoDeerくんが正直者の場合
    if input_b == "H":
        result = "H"
    elif input_b == "D":
        result = "D"
elif input_a == "D":    # AtCoDeerくんが嘘つき者の場合（条件増えた時ようにelifにした）
    if input_b == "H":
        result = "D"
    elif input_b == "D":
        result = "H"
else:
    reslut = "I don't Know."

print(result)




Measured memory_bytes: 8880
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
typedef long long ll;
const ll MOD = 1e+9+7;

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> a(M);
    ll ans=-1;
    rep(i,M){
        cin >> a[i];
        if(i>0&&a[i]==a[i-1]+1){
            ans=0;
        }
    }

    //フィボナッチ
    vector<ll> f(N+1);
    f[0]=1;
    f[1]=1;
    rep(i,N-1){
        f[i+2]=f[i+1]+f[i];
        f[i+2]%=MOD;
    }


    if(ans==0){
        cout << ans <<endl;
    }else if(M>0){
        ans=1;
        ans*=f[a[0]-1];
        rep(i,M-1){
            ans*=f[a[i+1]-a[i]-2];
            ans%=MOD;
            
        }
        ans*=f[N-a[M-1]-1];
        ans%=MOD;
        cout << ans << endl;
    }else{
        ans = f[N];
        cout << ans << endl;
    }
}

Measured memory_bytes: 1408
X,K,D=map(int,input().split())
X=abs(X)
n1=max((K-X/D)//2,0)
n2=min(n1+1,K//2)
n3=max(n1-1,0)
d1=abs(X-D*(K-2*n1))
d2=abs(X-D*(K-2*n2))
d3=abs(X-D*(K-2*n3))
print(int(min(d1,d2,d3)))

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t x;
  cin >> x;
  int kofuku;
  while(x >= 500){
    x-=500;
    kofuku+=1000;
  }
  while(x >= 5){
    x-=5;
    kofuku+=5;
  }
  cout << kofuku << endl;
  return 0;
}

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

#define for_(i,a,b) for (int i=(a);i<(b);++i)

int n, k, w[100010];

bool able(int P) {
	int t = 1, p = P;

	for_(i,0,n) {
		if (p >= w[i]) {
			p -= w[i];
		} else {
			p = P - w[i];
			++t;
		}
	}
	
	return t <= k;
}

void solve() {	
	int lb = *max_element(w, w + n) - 1, ub = accumulate(w, w + n, 0) + 10;
	
	while (ub - lb > 1) {
		int mid = (lb + ub) / 2;
		
		if (able(mid)) ub = mid;
		else lb = mid;
	}
	
	cout << ub << endl;
}

int main() {
	cin >> n >> k;
	for_(i,0,n) cin >> w[i];
	solve();
}

Measured memory_bytes: 1548
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;
const double eps = 1e-8;

set<lint> ablest;

lint T, N, A;
vector<lint> arr;
string s;

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> T;
	REP(i, T) {
		arr.clear();
		ablest.clear();
		ablest.insert(0);
		cin >> N;
		REP(j, N) {
			cin >> A;
			arr.push_back(A);
		}
		cin >> s;
		bool flag = true;
		lint prev = 0;
		vector<lint> basis;
		IREP(j, N) {
			for (auto base : basis) {
				chmin(arr[j], arr[j] ^ base);
			}
			if (arr[j]) {
				if (s[j] == '0') {
					basis.push_back(arr[j]);
				}
				else {
					flag = false;
				}
			}
		}
		if (flag) cout << 0 << endl;
		else cout << 1 << endl;
	}
}


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

int main() {
	string s;
	int k;

	cin >> s;
	cin >> k;
	
	int temp;
	for (int i = 0; i < 100; i++)
		if (s[i] != '1') {
	 		temp = i - 1;
			break;
		}
	
	if (k <= temp + 1) cout << 1 << endl;
	else cout << s[temp+1] << endl;
}


Measured memory_bytes: 256
//To compile : type "$     g++ test.cpp -std=c++14 -I .    "
#include <atcoder/string>
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
using namespace atcoder;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

int main() {
	cin>>S;
	auto suf = suffix_array(S), ans = lcp_array(S, suf);
	N = S.size();
	cout<<N * (N + 1) / 2 - accumulate(ALL(ans), 0LL)<<endl;
}


Measured memory_bytes: 15548
#include <stdio.h>

#define WIDTH 12
#define HEIGHT 12

void delIsland( int, int );

char field[ WIDTH ][ HEIGHT ];
const int dx[ 4 ] = { -1, 0, 1, 0 }, dy[ 4 ] = { 0, -1, 0, 1 };

int main( void ) {
	int x, y, island;

	while ( ungetc( getchar(), stdin ) != EOF ) {
		for ( y = 0; y < HEIGHT; y++ )
			for ( x = 0; x < WIDTH; x++ )
				scanf( "%c ", field[ x ] + y );

		island = 0;
		for ( x = 0; x < WIDTH; x++ )
			for ( y = 0; y < HEIGHT; y++ )
				if ( field[ x ][ y ] == '1' ) {
					delIsland( x, y );
					island++;
				}

		printf( "%d\n", island );
	}

	return 0;
}

void delIsland( int x, int y ) {
	int i;

	field[ x ][ y ] = '0';

	for ( i = 0; i < 4; i++ ) {
		int nx = x + dx[ i ], ny = y + dy[ i ];

		if ( nx >= 0 && nx < WIDTH && ny >= 0 && ny < HEIGHT && field[ nx ][ ny ] == '1' )
			delIsland( nx, ny );
	}
}

Measured memory_bytes: 548
#include <stdio.h>

#define MAX 1000

int main(void) {
  int A[MAX][MAX];
  int B[MAX][MAX];
  unsigned long C[MAX][MAX];

  int i, j, k;
  int n, m, l;
  scanf("%d %d %d", &n, &m, &l);

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

  for(i=0; i<m; ++i) {
    for(j=0; j<l; ++j) {
      scanf("%d", &B[i][j]);
    }
  }

  for(i=0; i<n; ++i) {
    for(j=0; j<l; ++j) {
      for(k=0; k<m; ++k) {
        C[i][j] += A[i][k] * B[k][j];
      }
      if(j != l-1) printf("%lu ", C[i][j]);
      else printf("%lu", C[i][j]);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2944
import sys


class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1


def main():
    n, m = map(int, sys.stdin.buffer.readline().split())
    uf = UnionFind(n)
    ans = [n*(n-1)//2]
    for x in reversed(sys.stdin.buffer.readlines()):
        a, b = map(int, x.split())
        a -= 1
        b -= 1
        if uf.find(a, b):
            ans.append(ans[-1])
            continue
        ba, bb = uf.table[uf._root(a)], uf.table[uf._root(b)]
        ans.append(ans[-1] - ba*bb)
        uf.union(a, b)
    ans.reverse()
    print("\n".join(map(str, ans[1:])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 24040
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int N, X, T;;
  cin >> N >> X >> T;
  int ans = N / X;
  if (N % X != 0) {
    ans++;
  }
  cout << T * ans << endl;

}
  
  

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define yes cout<<"Yes"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define mod 1000000007
#define f first
#define sec second
#define gcd(x,y) __gcd(x, y)
using namespace std;
int main()
{
	ll a,b;
	cin>>a>>b;
	if(b==1)
	{
		cout<<0<<endl;
		return 0;
	}
	ll x=0,y=1;
	while(y<b)
	{
		y+=a-1;
		x++;
	}
	
	cout<<x<<endl;
}

Measured memory_bytes: 3612
io = STDIN
n,k=io.gets.split.map(&:to_i)
a=io.gets.split.map(&:to_i)
#example size:6 parts size:3
# * * * * * *
# * * *
#     * * *
#         * * .
# (6-1)/(3-1)
def cnt(size,part_size)
  part_cnt=(size == part_size) ? 1 : (((size+1)-1)/(part_size-1).to_f).ceil
  [part_cnt,part_cnt*(part_size-1)+1]
end
ix= a.index(1)
left_cnt,left_size=cnt(ix+1,k)
right_cnt=cnt(n-left_size,k)[0]

  puts left_cnt+right_cnt


Measured memory_bytes: 8068
INF = 1e5
n, m = list(map(int, input().split()))
C = list(map(int, input().split()))
dp = [[INF] * (n + 1) for _ in range(m)] 
for i in range(m):
    dp[i][0] = 0
for j in range(1 + n):
    dp[0][j] = j
from itertools import product
for i, j in product(range(1, m), range(1, n + 1)):
    dp[i][j] = min(dp[i][j], dp[i - 1][j])
    if 0 <= j - C[i]:
        dp[i][j] = min(dp[i][j], dp[i][j - C[i]] + 1)

print(dp[i][j])


Measured memory_bytes: 45356
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const LL N=100005;
LL n;
struct qq
{
	LL a,b,c;
}a[N];
bool cmp (qq x,qq y)	{return x.c>y.c;}
int main()
{
	scanf("%lld",&n);
	for (LL u=1;u<=n;u++)
	{
		scanf("%lld%lld",&a[u].a,&a[u].b);
		a[u].c=a[u].a+a[u].b;
	}
	sort(a+1,a+1+n,cmp);
	LL ans=0;
	for (LL u=1;u<=n;u++)
	{
		if (u&1) ans=ans+a[u].a;
		else ans=ans-a[u].b;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {                        
	int K;
	cin >> K;
                                                                            

	queue<int> qu;

	if (K <= 9) {
	 	cout << K;
		return 0;
	}

	for (int i = 1; i <= 9; i++) qu.push(i);

	for (int i = 0; i < K - 1; i++) {
	 	int cur = qu.front();
		qu.pop();
	
		int prev = (cur % 10 - 1 + 10) % 10;
		int next = (cur % 10 + 1) % 10;

		if (abs(prev - cur % 10) <= 1) {
		 	int want = cur * 10 + prev;
			qu.push(want);
		}
		qu.push(cur * 10 + cur % 10);
		if (abs(next - cur % 10) <= 1) {
		 	int want = cur * 10 + next;
			qu.push(want);
		}
	}	

	cout << qu.front() << '\n';
	     
	
}


Measured memory_bytes: 1792
import math
N = int(input())
def get_integers(n):
    '''
    Reads in one line of input that contains n integers.
    Returns a list of n integers
    '''
    s = input()
    numbers = s.split(' ')
    r = []
    for x in numbers:
        r.append(int(x))
    return  r

w = get_integers(N)

q = []
for t in range(1,N):

    b = 0
    l = 0
    
    for f in range (0, t):
        b += w[f]
    for p in range (t, N):
        l += w[p]

    if b>l:
        q.append(b-l)
    else:
        q.append(l-b)

print(min(q))

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

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

int n, m, a[200000], b[200000];

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

	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
	}

	map<int, int> mp;
	for (int i = 0; i < m; i++) {
		if(a[i] == 1) mp[b[i]]++;
		if(b[i] == n) mp[a[i]]++;
	}

	for(auto itr : mp){
		if(itr.second > 1){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;

int n;
ll a,b,c,d,l,r;

int main(){
	int i;
	scanf("%d%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	for (i=1;i<=n;i++)
		if (a-b>=1ll*(i-1)*c-1ll*(n-i)*d&&a-b<=1ll*(i-1)*d-1ll*(n-i)*c){
			printf("YES\n");
			return 0;
		}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
import heapq

n , m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
if n >= m:
    print(0)
    exit()

zentai = x[m-1] - x[0]
kyori = []

for i in range(m-1):
    kyori.append(x[i] - x[i+1])
heapq.heapify(kyori)
tobasi = 0

for i in range(n-1):
    tobasi += heapq.heappop(kyori)
    
print(zentai + tobasi)

Measured memory_bytes: 14084
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<map>
#include<iostream>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
#define d read()
ll n,m,ans;
bool b[110];
int main(){
	n=d,m=d;
	f(i,1,m){
		ll x=d;
		f(j,1,x){
			ll y=d;
			b[y]=1;
		}
	}
	f(i,1,n)ans+=!b[i];
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#define N 100

void swap(int*, int*);
void pr(int*, int);

int main(){
  int n, i, j, k;
  int t=0; // times
  int mini;
  int a[N];

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &a[i]);

  for( i = 0 ; i < n ; i++){
    mini = i;
    for(j = i ; j < n ; j++){
      if( a[j] < a[mini] ){
	mini = j;
      }
    }
    if( i != mini){
      swap(&a[i] ,&a[mini]);
      t++;
    }
  }

  pr(a,n);
  printf("%d\n" ,t);
  return 0;
}

void swap(int *a_p, int *b_p){
  int k;
  k    = *a_p;
  *a_p = *b_p;
  *b_p = k;
}

void pr(int *a_p, int n){
  int i;
  for( i = 0 ; i < n-1 ; i++ ){
    printf("%d " ,a_p[i]);
  }
  printf("%d" , a_p[n-1]);
  printf("\n");
}

Measured memory_bytes: 1036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    string s;cin>>s;
    if(s[(ll)s.size()-1]=='s'){
        cout<<s<<"es"<<endl;
    }else{
        cout<<s<<'s'<<endl;
    }
    return 0;
}





Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <limits>

using namespace std;
struct Edge{
    int a;
    int b;
    double c;
};
int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<double>> dista(n, vector<double>(n, numeric_limits<double>::infinity()));
    vector<Edge> edge(m);
    int a, b;
    double c;
    for(int i=0;i<m;++i){
        cin >> a >> b >> c;
        --a; --b;
        edge[i].a = a;
        edge[i].b = b;
        edge[i].c = c;
        dista[a][b] = c;
        dista[b][a] = c;
    }
    for(int i=0;i<n;++i){
        dista[i][i]=0;
    }
    double d;
    for(int k=0;k<n;++k){
        for(int i=0;i<n;++i){
            for(int j=0;j<n;++j){
                if(dista[i][j]>(d=dista[i][k]+dista[k][j])){
                    dista[i][j]=d;
                }
            }
        }
    }
    int  count=m;
    for(int k=0;k<m;++k){
        bool flag=false;
        for(int i=0;i<n;++i){
            if(dista[i][edge[k].a]+edge[k].c==dista[i][edge[k].b])
                flag=true;
        }
        if(flag)
            --count;
    }
    cout <<  count;
    return 0;
}

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

using namespace std;

using int64 = long long;

const int INF = 1 << 30;

int main() {
  int N;
  string S;

  cin >> N;
  cin >> S;

  int l = 0;
  for(int i = 0; i < N; i++) {
    l += S[i] == 'E';
  }
  int best = INF;
  for(int i = 0; i < N; i++) {
    l -= S[i] == 'E';
    if(i) l += S[i - 1] == 'W';
    best = min(best, l);
  }
  cout << best << endl;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a[10000000],b,c,cmp,cmpp,m,h,w,x,y,k,t,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

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

       cin >> k >> t;
       rep(i,t)cin>>a[i];
       sort(a,a+t);
       reverse(a,a+t);
       pos=a[0];
       rep(i,t){
           if(i!=0){
               pos-=a[i];
           }
       }
       if(pos>0){
           Cout(pos-1);
       }
       else{
           Cout(0);
       }
       
return 0;
}


Measured memory_bytes: 256
def examB():
    S = SI()
    w = I()
    ans = ""
    i=0
    while(i<len(S)):
        ans +=S[i]
        i +=w

    print(ans)



import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 3444
import bisect

def main():
    a, b = input().split()
    l_a = a*int(b)
    l_b = b*int(a)
    l_sort = [l_a, l_b]
    l_sort = sorted(l_sort)
    print(l_sort[0])

    return 0

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
/*
    And I know I may end up failing too
*/




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

typedef long long ll;
typedef pair<ll,ll> pll;
#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7
#define pb           push_back
#define pf           push_front
#define pi           acos(-1)
#define all(x)       x.begin(),x.end()
#define fast         ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF          0x3f3f3f3f
struct hash_pair
{
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1> {}(p.first);
        auto hash2 = hash<T2> {}(p.second);
        return hash1 ^ hash2;
    }
};




ll t;
ll m=N;
ll arr[100005][4];

int main()
{
    ll a,b,c,d,e,f,g,i,j;
    ll n,k,x;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }
    for(i=1;i<n;i++)
    {
        arr[i][0]=arr[i][0]+max(arr[i-1][1],arr[i-1][2]);
        arr[i][1]=arr[i][1]+max(arr[i-1][0],arr[i-1][2]);
        arr[i][2]=arr[i][2]+max(arr[i-1][0],arr[i-1][1]);
    }
    f=max(arr[n-1][0],arr[n-1][1]);
    f=max(f,arr[n-1][2]);
    cout<<f<<endl;
}


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

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

    int n;
    cin >> n;

    map<int, int> a;
    REP(i, n) {
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }

    int ans = 0;
    for (auto i : a) {
        if (i.second % 2)
            ans++;
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 4992
// 2018/12/19 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int A, B, C, D, E;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;
	cin >> E;

	if(A<0){
		cout << -A*C+D+B*E << endl;
	}
	else{
		cout << (B-A)*E << endl;
	}

	return 0;
}



Measured memory_bytes: 3104
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define EQ(a,b) (abs((a)-(b))<EPS)
char map[110][110];
int main()
{
	while(1)
	{
		int w,h;
		cin >> w >> h;
		if(w==0&&h==0)break;
		for(int i=0;i<w;i++)
		{
			for(int j=0;j<h;j++)
			{
				cin >> map[i][j];
			}
		}
		int x=0,y=0;
		int count=0;
		bool flag=false;
		while(1)
		{
			if(map[x][y]=='>')
			{
				y++;
			}
			if(map[x][y]=='<')
			{
				y--;
			}
			if(map[x][y]=='v')
			{
				x++;
			}
			if(map[x][y]=='^')
			{
				x--;
			}
			if(map[x][y]=='.')
			{
				break;
			}
			count++;
			if(count>11000)
			{
				flag=true;
				break;
			}

		}
		if(flag)
		{
			cout << "LOOP" << endl;
		}
		else
		{
			cout << y << ' ' << x << endl;
		}
	}
	return 0;
}

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

int main() {
  long long int p=2, n=1, f, i_max;
  cin >> i_max;
  for (long long int i=2;i<=i_max;i++) {
    f = p + n;
    p = n;
    n = f;
  }
  cout << n;
}

Measured memory_bytes: 256
//BY: YASH JAIN, CF: yashjain0333
#include <bits/stdc++.h>
using namespace std;
#define May_the_fork_be_with_you ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define INF 1e18
#define ll long long
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define int long long
#define N 200005

void solve(){
    int n; cin>>n;
    if(n==1) cout<<0;
    else cout<<1;
}

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

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

int main() {
	 int N;
	 cin >> N;
	 int A[N];
	 int dp[N];
	 for(int i = 0 ; i < N ; i++) cin >> A[i];
	 dp[0] = 0;
	 dp[1] = abs(A[1] - A[0]);
	 for(int i = 2 ; i < N ; ++i) {
	 	  dp[i] = min(dp[i-1] + abs(A[i] - A[i-1]), dp[i-2] + abs(A[i] - A[i-2]));
	 }
	 cout<<dp[N-1]<<endl;
	 return 0;
}

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

int score(int n) {
    if(n==1) return 300000;
    if(n==2) return 200000;
    if(n==3) return 100000;
    return 0;
}

int main(void){
    int A, B;
    cin >> A >> B;
    int sum = 0;
    sum += score(A);
    sum += score(B);
    if(sum == 600000) sum = 1000000;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        }
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int main(void) {
    int n;
    cin >> n;
    VI a(n), b(n), c(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    REP(i, n) cin >> c[i];

    sort(ALL(a));
    sort(ALL(b));
    sort(ALL(c));

    LL ans = 0;
    REP(i, n) {
        auto ia = lower_bound(ALL(a), b[i]);
        auto ic = upper_bound(ALL(c), b[i]);
        ans += (ia - a.begin()) * (c.end() - ic);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1536