akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std; 
typedef long long ll;

ll isWinning(ll x, ll k){

	if(x<k)return 0;

    ll curr=x;

    ll toRem;
    ll cm;

    while(curr%k!=0){
        if(curr<k)break;

        cm=curr%k;

        toRem=(curr/k)+1;

        if((cm)%toRem == 0){
            return curr/k;
        }
        else{
            curr-=((cm/toRem)+1)*toRem;
        }

    }

    return curr/k;
}

int main() 
{ 

	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
    	freopen("error", "w", stderr);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // for(int i=1;i<40;i++){
    //     cerr<<i<<" "<<isWinning(i,3)<<endl;
    // }

    ll n;
    cin>>n;
    ll arr[n][2];
    ll winC=0;
    ll lossC=0;
    ll curr=0;
    for(int i=0;i<n;i++){
    	cin>>arr[i][0]>>arr[i][1];
    	curr^=(isWinning(arr[i][0],arr[i][1]));
    }

    if(curr){
        cout<<"Takahashi"<<endl;
    }
    else{
        cout<<"Aoki"<<endl;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define PI 3.14159265358979323846264338327
#define NUM 1000000007
#define ss second
#define ff first
using namespace std;

int color[100001];
int n, u, v;
long long  w;
vector <pair <int, long long> > adj[100001];
void go(int x, long long  dist, int p){
	dist % 2 == 0 ? color[x] = 1 : color[x] = 0;
	for (int i = 0; i < (int) adj[x].size(); i++)
		if (adj[x][i].ff != p)
			go(adj[x][i].ff, dist + adj[x][i].ss, x);
}

int main(){
	ios::sync_with_stdio(0);	
	cin >> n;
	for (int i = 0; i < n - 1; i++){
		cin >> u >> v >> w;
		adj[u].push_back({v,w});
		adj[v].push_back({u,w});
	}
	go(1, 0, -1);
	for (int i = 1; i <= n; i++){
		cout << color[i] <<"\n";
	}
	//cout << s << "\n";
	return 0;
}

Measured memory_bytes: 11392
#![allow(dead_code)]
#![allow(unused_must_use)]

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(&src);

    let mut a : usize = sc.read();
    let mut b : usize = sc.read();

    let mut ans = 0;
    let mut not_prime = vec![false; 1__000_001];
    for i in 2..1_000_001 {
        if not_prime[i] { continue }
        let mut n = i;
        while n <= 1_000_000 {
            not_prime[n] = true;
            n += i;
        }
        if a % i == 0 && b % i == 0 {
            ans += 1;
        }
        while a % i == 0 {
            a /= i;
        }
        while b % i == 0 {
            b /= i;
        }
    }

    if a == b && a != 1 {
        ans += 1;
    }

    format!("{}", ans + 1)
}

#[test]
fn test() {
    assert_eq!(solve(r"12 18"),r"3");
    assert_eq!(solve(r"420 660"),r"4");
    assert_eq!(solve(r"1 2019"),r"1");
    assert_eq!(solve(r"2000000014 2000000014"), r"3");
}

fn main() {
    let mut buf = String::new();
    use std::io::Read;
    std::io::stdin().read_to_string(&mut buf);
    use std::io::Write;
    std::io::stdout().write_all(solve(&buf).as_bytes());
}

struct Scanner<I>{
    src: I
}

impl<'a> Scanner<std::str::SplitWhitespace<'a>> {
    fn from_str(src: &'a str) -> Self {
        Scanner { src: src.split_whitespace() }
    }
}

impl<'a, I> Scanner<I> where I: std::iter::Iterator<Item = &'a str>{
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.src.next().unwrap().parse().ok().expect("Parse error")
    }
    fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    fn chars(&mut self) -> Vec<char> {
        self.src.next().unwrap().chars().collect()
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
     ios_base::sync_with_stdio(false);
      cin.tie(NULL);
        int n,k;cin>>n>>k;
        vector<int> dp(n+1),h(n+1);
        for(int i=1;i<=n;i++) cin>>h[i];
        dp[1]=0;dp[2]=abs(h[2]-h[1]);
        for(int i=3;i<=n;i++){
            int ans=INT_MAX;
           for(int j=k;j>=1;j--){
               if(i-j>=1)ans=min(ans,abs(h[i]-h[i-j]) + dp[i-j] );
           }
           dp[i]=ans;
        }
        cout<<dp[n]<<endl;
    
    return 0;
}


Measured memory_bytes: 3976
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;
}

Measured memory_bytes: 3660
import scala.math

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  def divisors(n: Int): List[Int] =
    for (i <- (1 to n).toList if n % i == 0) yield i

  var n = sc.nextInt()
  var d = Array.fill(n)(sc.nextInt()).sorted
  println(if(d(n-1) < d.sum-d(n-1)) "Yes" else "No")
}


Measured memory_bytes: 55364
# -*- coding: utf-8 -*-
"""
Basic Modifications - Reverse
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_A&lang=jp

"""
_ = input()
A = [int(a) for a in input().split()]
for _ in range(int(input())):
    b, e = map(int, input().split())
    A = A[0:b] + A[b:e][::-1] + A[e:]
print(*A)



Measured memory_bytes: 5824
N = input()
l = len(N)

ans = 0
for i in range(1 << l-1):
    n = N
    for j in range(l-1)[::-1]:
        if (i >> j) & 1 == 1:
            n = n[:j+1] + "+" + n[j+1:]
    ans += sum(list(map(int, n.split("+"))))

print(ans)
            

Measured memory_bytes: 3064
n=gets.chomp.chars.reverse
l=n.length
b=0
a=2**(l-1)
c=0
l.times do |i|
  g=a
  i.times do |j|
    c+=g/2*10**j*n[i].to_i
    g/=2
  end
  c+=g*10**i*n[i].to_i
end
p c

Measured memory_bytes: 1916
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 1;
        for(int i = 1; i <= n; i++) {
            ans *= i;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 26176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (ll r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
int main()
{
	int n, k, q;
	cin>>n>>k>>q;
	vector<int>A(n+1, 0);
	rep(i,0,q)
	{
		int a;
		cin>>a;
		A[a]++;
	}
	rep(i,1,n+1)
	{
		if(q-A[i]>=k)
		{
			cout<<"No"<<endl;
		}
		else
		{
			cout<<"Yes"<<endl;
		}
	}
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int n,A,B,C,D,E,F,G;
    while(1){
        cin >> n;
        if(n==0)break;
        A=1000-n;
        B=(A/500);
        C=((A%500)/100);
        D=(((A%500)%100)/50);
        E=((((A%500)%100)%50)/10);
        F=(((((A%500)%100)%50)%10)/5);
        G=(((((A%500)%100)%50)%10)%5);
        cout << B+C+D+E+F+G << endl;
    }
}



Measured memory_bytes: 3056
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
	long long n;
	cin>>n;
	long long k;
	cin>>k;
	vector<long long> A;
	vector<long long> B;
	for(int i =0;i<n;i++)
	{
		long long a; long long b;
		cin>>a>>b;
		A.push_back(a);
		B.push_back(b);
	}
	
	long long dp[n+1][k+1];
	for(long long i =0;i<=n;i++)
	{
		for(long long j =0;j<=k;j++)
		{
			if(i==0 or j==0) dp[i][j] = 0;
			else if(j<A[i-1])dp[i][j] = dp[i-1][j];
			else dp[i][j] = max(B[i-1]+dp[i-1][j-A[i-1]], dp[i-1][j]);
		}
	}
	cout<<dp[n][k];
	 return 0;
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, a, s[101];
  ll result = 0;
  rep(i, 101) s[i] = 0;
  cin >> n;
  rep(i, n) {
    cin >> a;
    FOR(j, 1, a + 1) s[j]++;
  }
  FOR(i, 1, 101) {
    if(s[i] >= i) result = i;
  }
  cout << result << endl;
	return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

vector<pii> g[100005];
int d[100005];
bool b[100005];

void dfs(int x) {
    for (pii i : g[x]) {
        if (!b[i.first]) {
            b[i.first] = 1;
            d[i.first] = d[x] + i.second;
            dfs(i.first);
        } else {
            if (d[i.first] != d[x] + i.second) {
                cout << "No";
                exit(0);
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    int n, m, u, v, w;
    cin >> n >> m;
    fr(m) cin >> u >> v >> w, g[u].push_back({v, w}), g[v].push_back({u, -w});
    fr1(n) if (!b[i]) b[i] = 1, dfs(i);
    cout << "Yes";
}


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

int N, ans = 1;

int foo(int S[], int k){
  for(int i = 1; i <= k; i++)
    for(int j = i; j <= N; j+=k)
      if(S[i] != S[j]) return 0;
  
  ans = N/k;
  return 1;
}

int main(){
  int S[200100] ,temp;

  cin>>N;

  for(int i = 1; i <= N; i++)cin>>S[i];
  for(int i = 1; i * i <= N; i++){
     if(N%i == 0){if(foo(S, i))break; foo(S, N/i);}
  }
  cout<<ans<<endl;
  
  return 0;
}



Measured memory_bytes: 3872
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
using namespace std;

int H, W, D, sx[100009], sy[100009]; vector<int>F[100009];

int dist(int p1, int p2, int p3, int p4) {
	return abs(p1 - p3) + abs(p2 - p4);
}

int main() {
	cin >> H >> W >> D;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			int G; cin >> G; G--;
			sx[G] = i; sy[G] = j;
		}
	}
	for (int i = 0; i < D; i++) F[i].push_back(0);
	for (int i = 0; i < H*W - D; i++) {
		F[i%D].push_back(dist(sx[i], sy[i], sx[i + D], sy[i + D]));
	}
	for (int i = 0; i < D; i++) {
		for (int j = 1; j < F[i].size(); j++) F[i][j] += F[i][j - 1];
	}
	int Q; cin >> Q;
	for (int i = 0; i < Q; i++) {
		int l, r; cin >> l >> r; l--; r--;
		cout << F[l%D][r / D] - F[l%D][l / D] << endl;
	}
	return 0;
}

Measured memory_bytes: 6272
def main():
    from collections import defaultdict
    n = int(input())
    s = list(input())

    L = s[:n]
    R = s[n:]
    R.reverse()

    br_l = defaultdict(int)
    br_r = defaultdict(int)

    L_map = dict()

    for i in range(2**n):
        al,bl,ar,br = '','','',''
        for j in range(n):
            if (i>>j)%2:
                al += L[j]
                ar += R[j]
            else:
                bl += L[j]
                br += R[j]
        br_l[(al,bl)] += 1
        br_r[(ar,br)] += 1

    ans = 0
    for k in br_l.keys():
        ans+= br_r[k] * br_l[k]
    print(ans)

main()

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



signed main() {
	int n;
	cin >> n;
	int val[n];
	for(int i=0;i<n;i++){
		cin >> val[i];
	}
	int dp[n][n],sum[n][n];
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			sum[i][j]=0;
			for(int k=i;k<=j;k++){
				sum[i][j]+=val[k];
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n-i;j++){
			if(i==0){
				dp[j][i+j]=0;
			}
			else if(i==1){
				dp[j][j+1]=sum[j][j+1];
			}
			else{
				dp[j][i+j]=(dp[j][j]+dp[j+1][i+j]+sum[j][i+j]);
				for(int k=0;k<i;k++){
					dp[j][i+j]=min((dp[j][j+k]+dp[j+k+1][i+j]+sum[j][i+j]),dp[j][i+j]);
				}
			}
		}
	}
	cout << dp[0][n-1];
	// your code goes here
	return 0;
}

Measured memory_bytes: 2688
object Main {
  def main(args: Array[String]): Unit = {
    val nums = io.StdIn.readLine().split(" ").map{_.toInt}
    val count_of_listen = nums(1)/nums(0)
    if(nums(2) < count_of_listen) {
      println(nums(2))
    }
    else {
      println(count_of_listen)
    }
  }
}

Measured memory_bytes: 27204
N, A, B, C = map(int,input().split())
ls = [int(input()) for i in range(N)]
def func(pos, a, b, c):return abs(a - A) + abs(b - B) + abs(c - C) - 30 + 9999 * max(0, 1 - a * b * c) if pos == N else min(func(pos + 1, a + ls[pos] * (i == 0), b + ls[pos] * (i == 1), c + ls[pos] * (i == 2)) + 10 * (i < 3) for i in range(4))
print(func(0, 0, 0, 0))

Measured memory_bytes: 3064
'use strict'

const read = () => {
  function* iterInput() {
    const input = require('fs').readFileSync('/dev/stdin', 'utf8');
    for (const token of input.trim().split(/\s+/)) {
      yield token;
    }
  }
  const it = iterInput()
  return () => {
    return it.next().value
  }
}

const main = (next) => {
  const abc = Array.from({length: 3}).map(() => +next())
  abc.sort();
  console.log(abc[2] * 10 + abc[0] + abc[1]);
}


main(read());


Measured memory_bytes: 7372
#include<stdio.h>
int main(void) {
	int d, m;
	unsigned long long int p = 1;
	scanf("%d%d", &d, &m);
	switch (d - m)
	{
	case 0:
		for (int i = 1; i <= d; i++) {
			p = p*i;
			p = p % 1000000007;
		}
		p = p*p;
		p = p % 1000000007;
		p = p * 2;
		break;
	case -1:
		for (int i = 1; i <= d; i++){
			p = p*i;
			p = p % 1000000007;
		}
		p = p*p;
		p = p % 1000000007;
		p = p*m;
		break;
	case 1:
		for (int i = 1; i <= m; i++) {
			p = p*i;
			p = p % 1000000007;
		}
		p = p*p;
		p = p % 1000000007;
		p = p*d;
		break;
	default:
		p = 0;
		break;
	}
	p = p % 1000000007;
	printf("%llu", p);
	return 0;
}

Measured memory_bytes: 128
import sys

str = input()

if str[0] != 'A' :
    print("WA")
    sys.exit()

str = str.replace('A', 'a', 1)

flag = False

for i in range(2, len(str) - 1) :
    if str[i] == 'C':
        str = str.replace('C' , 'c', 1)
        flag = True
        break
        
if not flag :
    print("WA")
    sys.exit()

if str.islower():
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
pair<int,int> f(string s){
    int l=((s[0]-'0')*10+s[1]-'0')*60+(s[3]-'0')*10+s[4]-'0';
    int r=((s[6]-'0')*10+s[7]-'0')*60+(s[9]-'0')*10+s[10]-'0';
    return {l,r};
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;cin >> k;
    vector<pair<int,int>> c(k);
    rep(i,k){
        string s;cin >> s;
        c[i]=f(s);
    }
    int n;cin >> n;
    vector<vector<pair<int,int>>> t(n);
    rep(i,n){
        int p;cin >> p;
        rep(j,p){
            string s;cin >> s;
            t[i].push_back(f(s));
        }
    }
    int m;cin >> m;
    vector<vector<pair<int,int>>> u(m);
    rep(i,m){
        int p;cin >> p;
        rep(j,p){
            string s;cin >> s;
            u[i].push_back(f(s));
        }
    }
    int ans=0;
    rep(i,k){
        int a=0,b=0;
        rep(j,n){
            for(auto x:t[j]){
                if(x.first<=c[i].first&&c[i].second<=x.second){
                    a++;
                }
            }
        }
        rep(j,m){
            for(auto x:u[j]){
                if(x.first<=c[i].first&&c[i].second<=x.second){
                    b++;
                }
            }
        }
        ans+=min(a,b);
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
string t;
/******* define variable end *******/
int solve() {
	cin >> t;
	REP(i, t.size()){
		if(t.substr(i, 1) == "?"){
			cout << "D";
		}else{
			cout << t.substr(i, 1);
		}
	}
	cout << endl;
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


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

using namespace std;

using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define delete

const static int MOD = 1000000007;
const static int INF = 1<<30;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int flag = 0;
    vector<int> A(n), B(n);
    rep(i ,n) cin >> A[i] >> B[i];

    rep(i, n - 2) {
        if (A[i] == B[i] && A[i + 1] == B[i + 1] && A[i + 2] == B[i + 2]) flag = 1;
    }

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

    return 0;
}

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

int main(){
  ll N, x;  cin >> N >> x;
  ll ans = 0;
  ll prv = 0;
  for(int i = 0; i < N; i++){
    ll a; cin >> a;
    if(prv + a > x){
      ans += prv + a - x;
      prv = x - prv;
    }else prv = a;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace WelcomeAtcordet
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int K = int.Parse(input[0]);
            int S = int.Parse(input[1]);
            int ans = 0;

            for (int x = 0; x <= K; x++)
            {
                for (int y = 0; y <= K; y++)
                {
                    int z = S - x - y;
                    if (z < 0)
                    {
                        break;
                    }
                    if (z > K)
                    {
                        continue;
                    }

                    ans++;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
int64_t N,T;
cin >> N >> T;
vector<int64_t> t(N);
for (int i=0; i < N; i++)
{
    cin >> t.at(i);
}
int64_t ans=t.at(N-1)+T;
int64_t hosei=0;
for(int i=0; i<N-1; i++)
{
    if(t.at(i+1)>t.at(i)+T)
    {
        hosei+=t.at(i+1)-(t.at(i)+T);
    }
}

cout << ans-hosei << endl; 

}

Measured memory_bytes: 4836
#include <stdio.h>
#include <string.h>
int main() {
	char s[16];
	int cnt = 0;
	scanf("%s", s);
	int k = strlen(s);
	for (int i = 0; i < k; i++) {
		if (s[i] == 'x') {
			cnt++;
		}
	}
	if (cnt <= 7) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
const ll LINF = 1e18 + 100;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

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

	int n,k;

	cin >> n;

	
	
	cout << (n/2)*(n-n/2) << endl;
}
	

Measured memory_bytes: 256
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();

function main(){
  var read = 0;
  var resultCase = 1;
  while(true){
    var maxWeight = +input[read++];
    if(!maxWeight){
      break;
    }
    
    var treasures = +input[read++];
    var pdp = new Int32Array(maxWeight + 1);
    for(var i = treasures; i--;){
      var c = input[read++].split(",");
      var tv = +c[0];
      var tw = +c[1];

      var dp = new Int32Array(maxWeight + 1);
      for(var w = 1; w <= maxWeight; w++){
        if(w - tw < 0){
          dp[w] = pdp[w];
        }else{
          dp[w] = max(pdp[w-tw] + tv, pdp[w]);
        }
      }
      pdp = dp;
    }

    var resultWeight = 1001;
    var resultCost = 0;
    for(var i = 0; i <= maxWeight; i++){
      if(pdp[i] > resultCost){
        resultCost = pdp[i];
        resultWeight = i;
      }
    }
    
    console.log("Case " + resultCase++ + ":\n" + resultCost + "\n" + resultWeight);
  }
}

function max(a, b) {
  var t = a - b;
  return a - (t & (t >> 31));
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    int dummy[n];
    rep(i,n){
        cin >> a[i];
        dummy[i] = a[i];
    }

    sort(dummy, dummy+n, greater<int>());
    int max_val = dummy[0];
    int second_max_val = dummy[1];
    int ans;    
    rep(i,n){
        if(a[i]==max_val){
            cout << second_max_val << endl;
        }
        else{
            cout << max_val << endl;
        }
    }

    return 0;
}

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

using namespace std;

#define ll long long 
#define Fastest ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"

int main()
{
	string ch, bh;
	
	cin >> ch >> bh;
	
	int coun = 0;
	
	if(ch[0] == bh[0]) coun++;
	if(ch[1] == bh[1]) coun++;
	if(ch[2] == bh[2]) coun++;
	
	cout <<  coun << endl;
	return 0;
}


Measured memory_bytes: 256
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


def main():
    n, x, y = LI()
    x, y = x - 1, y - 1
    d = [[INF] * n for _ in range(n)]
    ans = [0] * n
    for i in range(n - 1):
        for j in range(i + 1, n):
            d[i][j] = min([j - i,
                           abs(x - i) + 1 + abs(j - y),
                           abs(y - i) + 1 + abs(j - x)])
            ans[int(d[i][j])] += 1
    print(*ans[1:], sep='\n')


main()


Measured memory_bytes: 88692
#include <bits/stdc++.h>
#define rep(i,from,to) for(int i=from;i<(int)to;++i)
#define REP(i,from,to) for(int i=from;i<=(int)to;++i)
#define ll long long
using namespace std;
const int MAX = 10100;
int n, q, T;
int S[MAX];
void solve() {
	int ans = 0;
	cin >> n;
	rep(i,0,n)
	{
		cin >> S[i];

	}

	cin >> q;
	rep(i,0,q)
	{
		cin >> T;
		S[n] = T;

		int j = 0;

		while (S[j] != T) {

			j++;
		}
		if(j!=n)ans++;

	}
	cout << ans << endl;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

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


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>

using namespace std;

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

    vector<int> A(N);

    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    if ((N - 1) % (K - 1) == 0) {
        cout << (N - 1) / (K - 1) << endl;
        return 0;
    }
    cout << (N - 1) / (K - 1) + 1 << endl;
}

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

int main(void) {
  ios::sync_with_stdio(false);
  int N, L;
  cin >> N >> L;
  vector<int> A(N);
  rep(i, N) { cin >> A[i]; }
  rep(i, N) {
    if (i == 0) {
      if ((A[0] + A[1]) < L) continue;
      cout << "Possible" << endl;
      for (int j = N - 1; j > 0; --j) {
        cout << j << endl;
      }
      return 0;
    } else if (i == N - 1) {
      if ((A[N - 1] + A[N - 2]) < L) continue;
      cout << "Possible" << endl;
      for (int j = 1; j < N; ++j) {
        cout << j << endl;
      }
      return 0;
    }

    vector<int> answer;
    if ((A[i] + A[i - 1]) >= L) {
      answer.emplace_back(i);
      for (int j = i - 1; j > 0; --j) answer.emplace_back(j);
      for (int j = i + 1; j < N; ++j) answer.emplace_back(j);
    } else if ((A[i] + A[i + 1]) >= L) {
      answer.emplace_back(i + 1);
      for (int j = i + 2; j < N; ++j) answer.emplace_back(j);
      for (int j = i; j > 0; --j) answer.emplace_back(j);
    } else {
      continue;
    }
    cout << "Possible" << endl;
    for (int j = N - 2; j >= 0; --j) {
      cout << answer[j] << endl;
    }
    return 0;
  }
  cout << "Impossible" << endl;
  return 0;
}


Measured memory_bytes: 4328
k,n=map(int,input().split())
a=list(map(int,input().split()))
aa=0
for i in range(n-1):
  if a[i+1]-a[i]>aa:
    aa=a[i+1]-a[i]
if k-a[n-1]+a[0]>aa:
  print(int(a[n-1]-a[0]))
else:
  print(int(k-aa))


Measured memory_bytes: 25840
import math

a,b,x = map(int,input().split())
if x <= a*a*b/2:
    l = x/a/b*2
    print(math.degrees(math.atan(b/l)))
else:
    l = (a*b - x/a)/a*2
    print(math.degrees(math.atan(l/a)))

Measured memory_bytes: 38384
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;

#define INF (1e9)

int N, M;

int main() {
    cin >> N;

    if (N == 7 or N == 5 or N == 3) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )

using namespace std;

typedef complex<double> P;

// OÏ (cross product) : a~b = |a||b|sin¦
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

// àÏ (dot product) : aEb = |a||b|cos¦
double dot(P a, P b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}

// a1,a2ð[_Æ·éüªÆb1,b2ð[_Æ·éüªÌð·»è
bool is_intersected_ls(P a1, P a2, P b1, P b2) {
  return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
         ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}

int main(){
  double xa,ya,xb,yb,xc,yc,xd,yd;
  P a,b,c,d;
  while(cin>>xa>>ya>>xb>>yb>>xc>>yc>>xd>>yd){
  a = P(xa,ya);
  b = P(xb,yb);
  c = P(xc,yc);
  d = P(xd,yd);
  if (is_intersected_ls&&abs(dot(b-a,d-c))<EPS)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
IN = input().split()
N = int(IN[0])
X = int(IN[1])
m = [input() for i in range(N)]
m = [ int(x) for x in m]

Goukei = sum(m)
Nokori = X - Goukei
saishou = min(m)
kosuu = Nokori // saishou
ANS = 0
if saishou > Nokori:
    print(N)
else:
    ANS =  N + kosuu    
    print(ANS)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
int N,M;
vector<vector <ll> > gyouretu1(vector<vector <ll> > a,vector<vector<ll> > b){
  vector< vector<ll> > ans(N,vector<ll>(N));
  for(int i = 0;i < N;i++){
    for(int j = 0;j < N;j++){
      for(int k = 0;k < N;k++){
	ans[i][j] = (ans[i][j] + a[k][j]*b[i][k]);
      }
      ans[i][j] = ans[i][j] % M;
    }
  }
  return ans;
}

int main(){
  while(true){
    int A,B,C,T;
    cin >> N;
    cin >> M;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> T;
    vector<ll> s  = vector<ll>(N);
    if(N == 0 && M == 0 && A == 0 && B == 0 && C == 0 && T == 0)break;
    for(int i = 0;i < N;i++){
      cin >> s[i];
    }
    vector< vector<ll> > x(N,vector<ll>(N));
    int a,b,c;
    a = -1;b = 0;c = 1; 
    
    for(int i = 0;i < N;i++){
      for(int j = 0;j < N;j++){
	if(j == a){
	  x[i][j] = A;  
	}else if(j == b){
	  x[i][j] = B;
	}else if(j == c){
	  x[i][j] = C;
	}else x[i][j] = 0;
      }
      a++;
      b++;
      c++;
    }
    vector< vector<ll> > ans(N,vector<ll>(N));
    for(int i = 0;i < N;i++){
      for(int j = 0;j < N;j++){
	if(j == i)ans[i][j] = 1;
	else ans[i][j] = 0;
      }
    }
    
    while(T > 0){
      if(T & 1){
	ans = gyouretu1(ans,x);
      }
      x = gyouretu1(x,x);
      T = T >> 1;
    }
    ll anser = 0;
    //cout << s[N-2] << "aaaaaaaa" << endl;
    
    for(int i = 0;i < N;i++){
      for(int j = 0;j < N;j++){
	anser = anser + ans[i][j]*s[j];
      }
      if(i == 0)
	cout << anser%M;
      else cout << " " << anser%M;
      anser = 0;
    }
    cout << endl;
    
  }
    
    
    

  
  return 0;
}

Measured memory_bytes: 1336
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
XY = [tuple(map(int, input().split())) for _ in range(M)]

ans = [0] * N
for i, (a, b) in enumerate(AB):
    d = abs(XY[0][0] - a) + abs(XY[0][1] - b)
    for j, (x, y) in enumerate(XY):
        e = abs(a - x) + abs(b - y)
        if d > e:
            ans[i] = j
            d = e

print(*[a + 1 for a in ans], sep='\n')


Measured memory_bytes: 3064
#include <cstdio>

using namespace std;

int main() {
    int i, j;
    long long n;
    
    scanf("%lld", &n);
    
    for (i = 1; i <= 3500; i++) {
        for (j = 1; j <= 3500; j++) {
            long long x = n * i * j;
            long long y = 4 * i * j - n * i - n * j;
            
            if (y > 0 && x % y == 0) {
                printf("%d %d %d\n", i, j, x / y);
                
                return 0;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 128
import sys
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

N = int(input())
d = list(map(int, input().split()))

ans = 0
for i in range(N):
	for j in range(i+1, N):
		ans += d[i] * d[j]

print(ans)

Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  long long int N;
  int zero = 0;
  long long prod = 1;
  cin>>N;
  long long arr[N];
  for(int i = 0;i < N;i++){
    cin>>arr[i];
  }
  for(int i = 0;i < N;i++){
    if(arr[i] == 0){
      zero += 1;
    }
    if(zero >= 1){
      cout<<0<<'\n';
      return 0;
    }
  }
  for(int i = 0;i < N;i++){
    if(arr[i] <= 1000000000000000000 / prod){
      prod *= arr[i];
    }else{
      cout<<-1<<'\n';
      return 0;
    }
  }
  cout<<prod<<'\n';
}

Measured memory_bytes: 4420
#ABC110B
n,m,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

l = max(x)
r = min(y)
flag = False
for z in range(X+1,Y+1):
    if l<z and z<=r:
        flag = True
        break
print('No War' if flag else 'War')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int r = sc.nextInt();
			if (n==0&&r==0) {
				break; 
			}
			int[] a=new int[n];
			for(int i=0;i<n;i++){
				a[i]=i+1;
			}
			for(int j=0;j<r;j++){
				int p=sc.nextInt();
				int c=sc.nextInt();
				int[] buffer=new int[n];
				for(int i=0;i<c;i++){
					buffer[i]=a[n-p-i];
				}
				for(int i=1;i<p;i++){
					a[n-p-c+i]=a[n-p+i];
				}
				for(int i=0;i<c;i++){
					a[n-i-1]=buffer[i];
				}
			}
			System.out.println(a[n-1]);
		}
	}
}

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

int main() {
  int64_t n;
  cin >> n;
  int total = 0; //ｚの合計
  int64_t i = 2;
  while (n > 1) {
    if (i > 1000000) {
      total++;
      break;
    }
    
    int count = 1; //各素因数におけるeのパターン数    
    for (int j = 1; n % i == 0; j++) {
      if (j == count * (count + 1) / 2) {
        total++;
        count++;
      }
      n /= i;
    }
    if (i == 2)
      i++;
    else
      i += 2;
  }
  
  cout << total << endl;
}


Measured memory_bytes: 3640
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int maxn = 1e5+5;

LL w[maxn],v[maxn],dp[maxn];

int main(){
	LL n,m;
	scanf("%lld %lld",&n,&m);
	memset(dp,0x3f,sizeof dp);
	LL tol = 0; dp[0] = 0;
	for(LL i = 1; i <= n; i++){
		scanf("%lld %lld", &w[i],&v[i]);
		tol += v[i];
	}
	for(LL i = 1; i <= n; i++){
		for(LL j = tol; j >= 0; j--){
			if(j >= v[i]) dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
		}
	}
	for(LL i = tol; i >= 0; i--){
		if(dp[i] <= m){
			printf("%lld", i);
			break;
		}
	}
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long) (1e9+7);
	static long cf = 998244353;
    static final long MAX = (long) 1e15;
   // public static List<Integer>[] edges;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
	         int n = sc.nextInt();
	        long k = sc.nextLong();
	        long[] a = new long[n];
	        long[] f = new long[n];
	 
	        for (int i=0; i<n; i++) a[i] = sc.nextInt();
	        for (int i=0; i<n; i++) f[i] = sc.nextInt();
	 
	        Arrays.sort(a);
	        Arrays.sort(f);
	 
	        long max = 0;
	        for (int i=0; i<n; i++){
	            max = Math.max(max, a[i]*f[n-1-i]);
	        }
	 
	        long l = 0;
	        long r = max;
	 
	        while (l<r){
	            long mid = (l+r)/2;
	            long cnt = 0;
	            for (int i=0; i<n; i++){
	                if (a[i]*f[n-1-i]>mid){
	                    cnt += a[i] - mid/f[n-1-i];
	                }
	            }
	            if (cnt<=k){
	                r = mid;
	            }else {
	                l = mid+1;
	            }
	        }
	       out.println(r);
		out.close();
	}
	
	static class Pair{
		int a;
		int b;
		Pair(int a,int b){
			this.a = a;
			this.b = b;
		}
	}
}


Measured memory_bytes: 55884
function is_dark(A){
  var darks = [];
  for(var i=0;i<A.length;i++){
    line_set = new Set(A[i])
    if(line_set.size==1 && A[i][0]=='#'){continue;}
    if(line_set.size==2 || line_set.size==1 && A[i][0]=='.'){return false;}
  }
  return true;
}

function main(input){
  const lines = input.split('\n');
  const H = lines[0].split(' ').map(x => parseInt(x))[0];
  const W = lines[0].split(' ').map(x => parseInt(x))[1];
  var A=[];
  for(var i=0;i<H;i++){
    var line = lines[1+i].split('');
    A.push(line);
  }

//  console.log([H,W,A]);

  var result = 0;

  // get black
  var blacks = [];
  for(var i=0;i<A.length;i++){
    for(var j=0;j<A[0].length;j++){
      if(A[i][j]=='#'){blacks.push([i,j])}
    }
  }

  while(true){

    var darken_blacks=[]
    for(var i=0;i<blacks.length;i++){
      var c_black = blacks[i];
      x = c_black[1];
      y = c_black[0];

      if((y>0 && A[y-1][x]=='#')&&(x>0 && A[y][x-1]=='#')&&(x<A[0].length-1 && A[y][x+1]=='#')&&(y<A.length-1 && A[y+1][x]=='#')){continue;}

      if(y>0                            && A[y-1][x]=='.'){
        darken_blacks.push([y-1, x]);
        A[y-1][x]='#';
      }
      if(x>0                            && A[y][x-1]=='.'){
        darken_blacks.push([y, x-1]);
        A[y][x-1]='#';
      }
      if(x<A[0].length-1 && A[y][x+1]=='.'){
        darken_blacks.push([y, x+1]);
        A[y][x+1]='#';
      }
      if(y<A.length-1       && A[y+1][x]=='.'){
        darken_blacks.push([y+1, x]);
        A[y+1][x]='#';
      }
    }
    blacks = darken_blacks;

    if(blacks.length==0){break;}
//    console.log('==');
//    console.log(blacks);
//    console.log(blacks.length);
//    console.log(A);
    result++;
  }

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 140508
//============================================================================
// Name        : SoundHoundProgrammingContest2018.cpp
// Author      : sep
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cmath>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>

using namespace std;

inline void mainA() {

	long int a, b;

	cin >> a >> b;

	if (a + b == 15) {
		cout << "+";
	} else if (a * b == 15) {
		cout << "*";
	} else {
		cout << "x";
	}

}

inline void mainB() {

	string s;
	int w;
	int i;

	cin >> s >> w;

	for (i = 0; i < s.length(); i += w) {
		cout << s[i];
	}

}

int main() {

#ifdef TEST
	struct timespec startTime, endTime;
	while (1) {
		clock_gettime(CLOCK_REALTIME, &startTime);
#endif

		mainB();

#ifdef TEST
		cout << flush;
		cerr << flush;
		cerr << endl << "Elapsed Time:";
		clock_gettime(CLOCK_REALTIME, &endTime);
		if (endTime.tv_nsec < startTime.tv_nsec) {
			cerr << endTime.tv_sec - startTime.tv_sec - 1 << "."
					<< endTime.tv_nsec + 1000000000 - startTime.tv_nsec << "s"
					<< endl;
		} else {
			cerr << endTime.tv_sec - startTime.tv_sec << "."
					<< endTime.tv_nsec - startTime.tv_nsec << "s" << endl;
		}

		cerr << endl;
	}
#endif

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;

const int maxn = 1234;

int main(int argc, char const *argv[])
{
    // freopen("input.txt", "r", stdin);
    string a, b;
    cin>>a>>b;
    cout<<b+a<<endl;
    // sort(a.begin(), a.end());
    // sort(b.begin(), b.end());
    
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize (3)
#include<bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ff(v,a,b) for(int v=a;v<=b;v++)
#define fr(v,a,b) for(int v=a;v>=b;v--)
#define clr(a,v) memset(a,v,sizeof(a))
#define rep(v,a,b) for(int v=(a);(v)<(b);v++)
#define ll long long
using namespace std;
void rd(int &v) {
	char ch;
	for(ch='*'; ch<'0'||ch>'9'; ch=getchar());
	for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
}
int n,maxx,max2,a[200005];
int main() {
	cin>>n;
	ff(i,1,n) {
		rd(a[i]);
		if(a[i]>=a[maxx]) max2=maxx,maxx=i;
		else if(a[i]>a[max2]) max2=i;
	}
	ff(i,1,n) {
		if(maxx==i) printf("%d\n",a[max2]);
		else printf("%d\n",a[maxx]);
	}
}

Measured memory_bytes: 2432
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n,w = LI()
        if n == 0:
            break
        a = [I() for _ in range(n)]
        ma = max(a)
        l = (ma // w + 1)
        b = [0] * l
        for c in a:
            b[c//w] += 1
        h = max(b)
        r = 0.01
        for i in range(l):
            bi = b[i]
            d = (l-i-1) / (l-1)
            r += d * bi / h
        rr.append(r)

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9032
#include <stdio.h>

int main(void) {
	int N, K;
	int i, answer;
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%d", &K) != 1) return 1;
	answer = 1;
	for (i = 0; i < N; i++) {
		answer += answer < K ? answer : K;
	}
	printf("%d\n", answer);
	return 0;
}

/*
操作でのdeltaが少ない方を常に選べば良い (不利ならその次でも不利なので)
*/


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

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

int main(){
    int w,h,x,y;
    in(w,h,x,y);
    int ans2=0;
    if(2*y==h&&2*x==w){
        ans2=1;
    }
    out((double)h*w/2,ans2);
}

Measured memory_bytes: 3780
#include<iostream>
#include<stdio.h>
#define INF 0x3f3f3f3f
using namespace std;

int main()
{
    int n;
    cin>>n;
    int maxx=-1,minn=INF;
    for(int i=0;i<n;i++)
    {
        int a;cin>>a;
        maxx=max(maxx,a);
        minn=min(minn,a);
    }
    cout<<maxx-minn<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
#define MOD (ll)(1e9+7)
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

signed main(){
    ll n,k;
    string s;
    cin >> n >> k >> s;

    ll cnt = 1;
    rep(i,0,n-1){
        if(s[i] != s[i+1]) cnt++;
    }
    cout << (ll)min(n - max((cnt-2*k),0LL),n-1LL) << endl;
    return 0;
}


Measured memory_bytes: 512
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True
#for i in range(n):

ans=0

def f(n):
    if n<2:
        return 1
    return n*f(n-2)

n=I()
if n%2==1:
    ans=0
    print(ans)
    exit()


def g(n,k):
    
    '''
    k=-1
    for i in range(30):
        if 5**i<=n:
            k=i
    '''
    return n//(5**(k))-n//(5**(k+1))

n=n//2

for i in range(1,30):
    #show((n,i),g(n,i))
    ans+=g(n,i)*i

print(ans)



Measured memory_bytes: 38764