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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;

/**
 * Library
 * --------------------------------------------------------
 */
struct edge {
    int from, to;
    ll cost;
};

class BellmanFord {
    int V;
    int E;
    vector<edge> edges;
    vector<ll> dist;
    vector<bool> negative;

public:
    BellmanFord(int v, int e) : V(v), E(e), negative(v) {
        dist.resize(V, INF);
    }

    void add_edge(int from, int to, ll cost) {
        edges.push_back({from, to, cost});
    }

    ll get_total_cost(int v) {
        return dist[v];
    }

    // v に到達するまでに負ループがあるかを検出する
    bool is_negative(int v) {
        return negative[v];
    }

    // ベルマンフォード法の実行・全辺の負閉路を検出 trueを返す時に負閉路を含む
    bool exec() {
        bool updated = false;
        dist[0] = 0;
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < E; ++j) {
                edge edge = edges[j];
                if (dist[edge.from] != INF && dist[edge.to] > dist[edge.from] + edge.cost) {
                    dist[edge.to] = dist[edge.from] + edge.cost;
                    if (i == V - 1) updated = true;
                }
            }
        }

        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < E; ++j) {
                edge edge = edges[j];
                if (dist[edge.from] != INF && dist[edge.to] > dist[edge.from] + edge.cost) {
                    negative[edge.to] = true;
                }
                if (negative[edge.from]) {
                    negative[edge.to] = true;
                }
            }
        }
        return updated;
    }
};
/**
 * --------------------------------------------------------
 */

/**
 *  ABC061 D - Score Attack
 *  https://atcoder.jp/contests/abc061/submissions/7662112
 */
void Main() {
    int N, M;
    cin >> N >> M;
    BellmanFord bellmanFord(N, M);
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        bellmanFord.add_edge(a, b, -c);
    }
    bellmanFord.exec();

    if (bellmanFord.is_negative(N - 1)) {
        cout << "inf" << '\n';
    } else {
        cout << -bellmanFord.get_total_cost(N - 1) << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int i = 0;
    while (a > 0 && c > 0) {
        if ((i & 1) == 0) {
            c = c - b;
        } else {
            a = a - d;
        }
        i++;
    }
    if (a <= 0) {
        cout << "No";
    } else {
        cout << "Yes";
    }
}


Measured memory_bytes: 3656
#include<iostream>
using namespace std;
long long f[2010],p=1000000007;
int main()
{
    int i,j,n;
    cin>>n;
    for(i=3;i<=n;i++) f[i]=1;
    for(i=1;i<=n;i++)
     for(j=0;j<=i-3;j++)
      f[i]=(f[i]+f[j])%p;
    cout<<f[n];
    cin>>i;
}
    
    


Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
int main()
{
    char s[11];
    scanf("%s", s);
    int i, n, x;
    n = strlen(s);
    if (s[0] != 'A')
    {
        printf("WA\n");
        return 0;
    }
    if (s[1] >= 'A' && s[1] <= 'Z')
    {
        printf("WA\n");
        return 0;
    }
    x = 0;
    for (i = 2; i < n - 1; i++)
    {
        if (s[i] >= 'a' && s[i] <= 'z')
            continue;
        if (s[i] == 'C')
        {
            x++;
            continue;
        }
        printf("WA\n");
        return 0;
    }
    if (x != 1)
    {
        printf("WA\n");
        return 0;
    }
    if (s[n - 1] >= 'A' && s[n - 1] <= 'Z')
    {
        printf("WA\n");
        return 0;
    }
    printf("AC\n");
    return 0;
}

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

using namespace std;

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


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
//string binary = bitset<32>(n).to_string(); 
int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
   string s;
   cin>>s;
   lli n=s.size();
   bool ans=true;
   for(lli i=0;i<n-1;i++)if(s[i]==s[i+1])ans=false;
   	if(!ans)cout<<"Bad";
   else cout<<"Good";









    return 0;
} 


Measured memory_bytes: 256
using System;
class Atcoder_ABC137B
{
    static void Main(string[] args)
    {
        string[] input_string = Console.ReadLine().Split(' ');
        int K_int = int.Parse(input_string[0]);
        int X_int = int.Parse(input_string[1]);

        int MinPos = X_int - (K_int - 1);
        int MaxPos = X_int + (K_int - 1);
        int BlackPos = MinPos;

        string result = MinPos.ToString();
        for (int i = 0; i < MaxPos - MinPos; i++)
        {
            BlackPos += 1;
            result += ' ' + BlackPos.ToString();
        }

        //出力
        Console.WriteLine(result);
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int numTimes = in.nextInt();
		int[] values = new int[numTimes];
		for (int i = 0; i < numTimes; i++) {
			values[i] = in.nextInt();
		}
		//finished importing values, now maxing
		System.out.println(MP_DP(numTimes, values));
	}
	static int MP(int n, int[] values) {
		int maxp = -2000000000; //taken from yye
		// n = time points, values = array
		for (int i = 0; i < n-1; i++) {
			for (int j = i + 1; j<n; j++) {
				if (values[j] - values[i] > maxp) {
					maxp = values[j] - values[i];
				}
			}
		}
		return maxp;
	}
	static int MP_DP(int n, int[] values) {
		int maxp = values[1] - values[0];
		int minv = Math.min(values[1], values[0]);
		for (int i = 2; i < n; i++) {
			//Sell on day i
			maxp = Math.max(maxp,  values[i] - minv);
			// Sell vs not sell; which is max?
			minv = Math.min(minv, values[i]);
			// new lowest price to buy
		}
		return maxp;
	}
	
	
}



Measured memory_bytes: 101048
#include <string>
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
	int i, j,  S[100] = { 0 }, T[100] = { 0 };
	string s, t, alp = { "abcdefghijklmnopqrstuvwxyz" };
	cin >> s; cin >> t;
	int k = 0, f=t.size()-1,l = 0;

	for (j = 0; j < alp.size(); j++) {
		for (i = 0; i < s.size(); i++) {
			if (s[i] == alp[j]) {
				S[k]=j;
				char temp;
				temp = s[k];
				s[k] = s[i];
				s[i] = temp;
				k++;
			}
		}

		for (i = 0; i < t.size(); i++) {
			if (t[i] == alp[j]) {
				T[f]=j;
				char temp;
				temp = t[l];
				t[l] = t[i];
				t[i] = temp;
				l++;	f--;
			}
		}
	}

	for (i = 0; i < s.size(); i++) {
		if (S[i] < T[i]) {
			cout << "Yes" << endl;
			return 0;
		}
		else if (S[i] > T[i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	if (k==l)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
ss = list(set([s[0], s[1], s[2], s[3]]))
flag = True
if len(ss) != 2:
    flag = False
else:
    for i in range(len(ss)):
        if s.count(ss[i]) == 2:
            continue
        else:
            flag = False
            break

if flag:
    print('Yes')
else:
    print('No')


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

int main() {
  int N, X, L;
  cin >> N >> X;

  int i = 1, D = 0;
  for (; i <= N; i++) {
    cin >> L;
    D = D + L;
    if (D > X) break;
  }
  cout << i << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import Counter
from functools import reduce
import fractions
import math
import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # greatest common divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # least common multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))


n, a, b, c, d, e, = II(), II(), II(), II(), II(), II()
print(math.ceil(n / min(a, b, c, d, e))+4) 



Measured memory_bytes: 5384
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-02 11:44:10
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

int64 dp[202020][3];

constexpr int64 inf = 1e18;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  vector<int64> a(n); cin >> a;

  fill(dp[0], dp[202020], -inf);

  if (n & 1) {
    dp[0][0] = a[0], dp[1][1] = a[1], dp[2][2] = a[2];
    dp[2][0] = a[0] + a[2], dp[3][1] = max(a[0], a[1]) + a[3];

    for (int i = 4; i < n; ++i) {
      dp[i][0] = dp[i - 2][0] + a[i];
      dp[i][1] = max(dp[i - 2][1], dp[i - 3][0]) + a[i];
      dp[i][2] = max({dp[i - 2][2], dp[i - 3][1], dp[i - 4][0]}) + a[i];
    }

    cout << max({dp[n - 1][2], dp[n - 2][1], dp[n - 3][0]}) << endl;
  } else {
    dp[0][0] = a[0], dp[1][1] = a[1], dp[2][0] = a[0] + a[2];
    for (int i = 3; i < n; ++i) {
      dp[i][0] = dp[i - 2][0] + a[i];
      dp[i][1] = max(dp[i - 2][1], dp[i - 3][0]) + a[i];
    }
    cout << max(dp[n - 1][1], dp[n - 2][0]) << endl;
  }

  return 0;
}

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

using namespace std;

int main() {
  int tot = 0, n, k; cin >> n >> k;
  int a[n];
  for(int i = 0; i<n; i++) {
    cin >> a[i];
  }
  sort(a, a+n);
  for(int i = 0; i<k; i++) {
    tot += a[i];
  }
  cout << tot << "\n";
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> a(N);
    ll maxa= 0;
    rep(i, N)
    {
        cin >> a[i];
        chmax(maxa, a[i]);
    }
    ll l = 0, r = maxa;
    ll y = 0;
    while(r-l > 1)
    {
        ll x = (r+l)/2;
        auto f = [&](int x)->bool
        {
            ll cnt = 0;
            rep(i, N)
            {
                cnt += ((a[i]-1)/x);
                //if((a[i])%x > 0) ++cnt;
            }
            return cnt <= K;
        };
        

        if(f(x)) r = x;
        else     l = x;
       // cout << x << r << l << endl;
        ++y;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 4852
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 999;// 1e25;
static const ll MAX_N = 100001;

ll a[100001];
ll b[100001];
ll c[100001];
int main() {
	ll n; cin >> n;
	rep(i, 0, n)cin >> a[i];
	rep(i, 0, n)cin >> b[i];
	rep(i, 0, n)c[i] = a[i] - b[i];

	ll ans = 0;
	ll sum_nega = 0;
	ll sum = 0;
	rep(i, 0, n) {
		if (c[i] < 0) {
			sum_nega += c[i];
			ans++;
		}
		sum += c[i];
	}
	if (sum_nega >= 0) {
		cout << 0 << endl;
		return 0;
	}
	if (sum < 0) {
		cout << -1 << endl;
		return 0;
	}

	sort(c, c + n);
	reverse(c, c + n);

	rep(i, 0, n) {
		sum_nega += c[i];
		ans++;
		if (sum_nega >= 0) {
			cout << ans << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
#define cu cout<<
#define en endl
#define sp " "
#define RE(i,n) for(int i=0,_n=(n);i<_n;++i)
#define RI(i,n) for(int i=1,_n=(n);i<=_n;++i)
#include<cstdio>
#include<cstring>
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                pe[j] = false;
        }
    }
}*/
/*bool isprime(ll n)
{
    if(n<2) return 0;
    if(n==2) return 1;
    else
    {
        for(int i=2; i*i<=n; i++)
            if(n%i==0) return 0;
    }
    return 1;
}*/
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}

int main()
{
    fast ;
    ll  a;
  cin >> a;
  cout <<(a+(a*a)+(a*a*a))<<endl;

}


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

const int INF = 200000000;
const int MOD = 1e9 + 7;

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

    int N;
    cin >> N;
    vector<int> A(N);
    vector<vector<int>> x(N, vector<int>(0)), y(N, vector<int>(0));
    REP(i, N) {
        cin >> A.at(i);
        REP(j, A[i]) {
            int p, q;
            cin >> p >> q;
            p--;
            x[i].push_back(p);
            y[i].push_back(q);
        }
    }

    int ans = 0;
    REP(bits, (1 << N)) {
        vector<bool> honest(N, false);
        int count = 0;
        REP(j, N) {
            int mask = 1 << j;
            if (bits & mask) {
                honest[j] = true;
                count++;
            }
        }
        bool flag = false;
        REP(j, N) {
            if (honest[j]) {
                REP(k, A[j]) {
                    if ((y[j][k] == 0 && honest[x[j][k]]) || (y[j][k] == 1 && !honest[x[j][k]])) {
                        flag = true;
                        break;
                    }
                }
            }
            if (flag)
                break;
        }
        if (!flag) {
            ans = max(ans, count);
        }

    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    long long n, k;
    cin >> n >> k;

    vector<long double> p(n);

    for(long long i = 0; i < n; i++){
        cin >> p[i];
        p[i] = (1.0+p[i])/2;
    }

    long long right = 0;
    long double sum = 0;
    long double maxv = 0;

    for(long long left = 0; left < n; left++){
        while(right < n and right - left < k){
            sum += p[right];
            right++;
        }
        maxv = max(maxv, sum);

        if(right == left) right++;
        else sum -= p[left];
    }
    printf("%.10Lf\n", maxv);
    return 0;
}

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

int main(void){
    char s[1001];
    int w;
    scanf("%s",s);
    scanf("%d",&w);
    
    int i = 0;
    while(i<strlen(s)){
        printf("%c",s[i]);
        i += w;
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
bool chmin(ll& a, ll& b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll& b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> n >> c;
    vl A, B,C,D;
    rep(i, n) {
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
        C.push_back(c - a);
        D.push_back(b);
    }
    reverse(all(C));
    reverse(all(D));


    a = 0;
    vl X, Y, Z, W;
    rep(i, n) {
        a += B[i];
        X.push_back(a - A[i]);
        Y.push_back(a - A[i] * 2);
    }

    a = 0;

    rep(i, n) {
        a += D[i];
        Z.push_back(a - C[i]);
        W.push_back(a - C[i] * 2);
    }

    rep(i, n-1) {
        X[i + 1] = max(X[i + 1], X[i]);
        Y[i + 1] = max(Y[i + 1], Y[i]);
        Z[i + 1] = max(Z[i + 1], Z[i]);
        W[i + 1] = max(W[i + 1], W[i]);
    }

    rep(i, n) {
        ans = max(ans, X[i]);
        ans = max(ans, Z[i]);
    }

    rep(i, n-1) {
        ans = max(X[i] + W[n - 2 - i],ans);
        ans = max(Y[i] + Z[n - 2 - i], ans);
    }

    cout << ans << endl;

}

Measured memory_bytes: 7292
N=int(input())
A=list(map(int,input().split()))
from collections import defaultdict

p=defaultdict(int)
q=defaultdict(int)

for i, a in enumerate(A):
    p[i+a]+=1
    q[i-a]+=1

ans=0
for k,v in p.items():
    x=q[k]
    ans+=x*v
print(ans)

Measured memory_bytes: 73040
#include<stdio.h>
#include<iostream>
using namespace std;

bool include3(int x){
  for(int i=x;i;i/=10){
    if(i % 10 == 3){
      return true;
    }
  }
  return false;
}

void call(int n){
  for(int i=1;i<=n;i++){
    if ( i % 3 == 0 || include3(i)){
      cout << " " << i;
    }
  }
  cout << endl;
}

int main(){
  int n=0;
  scanf("%d",&n);
  call(n);
  return 0;
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    int t = 0,a = 0;
    t = dup(C,B);
    a = dup(A,D);
    if(t<=a){
        cout << "Yes" << endl;
    }else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>

int main(){
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	printf("%d %d %.10lf\n",d,r,f);
	return 0;
}

Measured memory_bytes: 1068
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int h = scanner.nextInt(), w = scanner.nextInt();
        for (int i = 1; i <= h; i++) {
            for (int j = 0; j < w; j++) {
                if (scanner.next().equals("snuke")) {
                    System.out.println((char)('A' + j) + "" + i);
                }
            }
        }
    }
}

Measured memory_bytes: 21972
#include <stdio.h>

int main(void)
{
	int price[4] = {6000, 4000, 3000, 2000};
	int i, t, n;
	
	for (i = 0; i < 4; i++){
		scanf("%d %d", &t, &n);
		
		printf("%d\n", price[t-1] * n);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 50 + 5;
 
int main(){
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
		cout << 'x';
	cout << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 10 ** 10

    for y in range(min(a), max(a) + 1):
        total = 0
        for x in a:
            total += (x - y) ** 2
        ans = min(ans, total)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rr(x,y) read(x);read(y)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
#define pb(x) push_back(x)
#define sss(str) scanf("%s",str+1)
#define ssf(x) scanf("%lf",&x)
#define aLL(x) x.begin(),x.end()
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef double dd;
typedef pair<int,int> pt;
const int N=2e5+5;
const int M=2e3+50;
const int INF=0x7fffffff;
const int mod=1e9+7;
const int sz=18;
const double eps=1e-10;
const double pi=acos(-1);
//***********************
int n,m;
char str[M];
int f[N];
//***********************
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    rr(n,m);
    int ans=-1;
    FOR(i,m*10,m*10+9){
        int tmp=floor(i*0.08);
        if(n==tmp){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int N = int.Parse(s[0]);
        int A = int.Parse(s[1]) - 1;
        int B = int.Parse(s[2]) - 1;
        int C = int.Parse(s[3]) - 1;
        int D = int.Parse(s[4]) - 1;
        string S = Console.ReadLine();
        if (C < D)
        {
            string roadA = S.Substring(A, C - A + 1);
            string roadB = S.Substring(B, D - B + 1);
            if (!roadA.Contains("##") && !roadB.Contains("##"))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
        else
        {
            string roadAToD = S.Substring(A, D - A);
            string roadA = roadAToD + "#" + S.Substring(D + 1, C - D);
            string roadB = S.Substring(B, D - B + 1);
            string roadBtoD = S.Substring(B - 1, D - B + 2);
            if ((!roadA.Contains("##") || roadBtoD.Contains("...")) && !roadB.Contains("##"))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }

    }
}

Measured memory_bytes: 12640
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	string s1;
	string s2;
	string s3;

	cin >> s1;
	cin >> s2;
	cin >> s3;

	cout << s1.substr(0, 1) << s2.substr(1, 1) << s3.substr(2, 1);


	return 0;
}

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

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

  vector<long long int> V(N);
  vector<long long int> A(N);
  vector<long long int> B(N);

  for(int i = 0;i < N;i++)cin >> V[i];

  A[0] = V[0];
  B[N-1] = V[N-1];

  for(int i = 1;i < N;i++){
    A[i] = __gcd(A[i-1],V[i]);
    B[N-1-i] = __gcd(B[N-i],V[N-1-i]);
  }

  long long int ans = max(A[N-2],B[1]);

  for(int i = 1;i < N-1;i++){
    ans = max(ans,__gcd(A[i-1],B[i+1]));
  }

  cout << ans << endl;


  return 0;


}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
using namespace std;
int field[102][102] = {0};
int d[4][2] = {{0,1},{1,0},{-1,0},{0,-1}};
void dfs(int x, int y, int n);
int main(){
  int h,w;
  while(cin >>h>>w,h||w){
    int ans = 0;
    string s;
    for(int i=0; i<102; i++){for(int j=0; j<102; j++){field[i][j] = 0;}}
    for(int i=0; i<h; i++){
      cin >>s;
      for(int j=0; j<w; j++){
	if(s[j] == '#'){field[i+1][j+1] = 1;}
	if(s[j] == '*'){field[i+1][j+1] = 2;}
	if(s[j] == '@'){field[i+1][j+1] = 3;}
      }
    }
    for(int i=0; i<h+2; i++){
      for(int j=0; j<w+2; j++){
	if(field[i][j]!=0){
	  dfs(i,j,field[i][j]);
	  ans++;
	}
      }
    }
    cout <<ans<<endl;
  }
  return 0;
}
void dfs(int x, int y, int n){
  field[x][y] = 0;
  for(int i=0; i<4; i++){
    if(field[x+d[i][0]][y+d[i][1]] == n){dfs(x+d[i][0],y+d[i][1],n);}
  }
}

Measured memory_bytes: 1716
import java.util.*;
public class Main {
	public static void main(String args[]){
    	Scanner s = new Scanner(System.in);
    	int N = s.nextInt();
      	int W = s.nextInt();
      	int wt[] = new int[N];
      	int ct[] = new int[N];
      	for(int i=0;i<N;i++){
        	wt[i] = s.nextInt();
          	ct[i] = s.nextInt();
        }
      	long ans = ans(wt,ct,W,N);
      	System.out.println(ans);
    }
  	public static long ans(int[] wt, int[] ct, int W, int N){
      	if(N<=0)
          	return 0;
      	long dp[][] = new long[N+1][W+1];
      	for(int w=1;w<=W;w++){
        	for(int i=1;i<=N;i++){
              	dp[i][w] = dp[i-1][w];
            	if(w-wt[i-1]>=0){
                	dp[i][w] = Math.max(dp[i-1][w-wt[i-1]]+ct[i-1], dp[i][w]);
                }
            }
        }
        return dp[N][W];
    }
}

Measured memory_bytes: 127572
#include<bits/stdc++.h>
using namespace std;
int n,k;
int dfs(int sum,int now){
    if(now==n) return sum;
    return min(dfs(sum*2,now+1),dfs(sum+k,now+1));
}
int main(){
    scanf("%d%d",&n,&k);
    printf("%d\n",dfs(1,0));
    return 0;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
using namespace std;
int main(){
    string n;
    cin >> n;
    if(n[0]=='7' || n[1]=='7' || n[2]=='7') cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
package main

import (
	"fmt"
)

func main() {
	var n, k, height int
	fmt.Scan(&n, &k)

	count := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&height)
		if height >= k {
			count++
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()

void solve(){
  int n; cin >> n;ld ans=0;
  FOR(i,0,n){ ld a; cin >> a; ans += (1/a);}
  std::cout << std::fixed << std::setprecision(20);
  cout << 1/ans << endl;
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 256
def z(s,l):
	for i in range(n-1):
		r=l+a[i+1]
		if r*l>=0:
			if l<=0:
				s+=1-r
				r=1
			else:
				s+=1+r
				r=-1
		l=r
	return s
n=int(input())
a=list(map(int,input().split()))
s1=0
l1=a[0]
if a[0]<=0:
	s1=1-a[0]
	l1=1
s2=0
l2=a[0]
if a[0]>=0:
	s2=a[0]+1
	l2=-1
print(min(z(s1,l1),z(s2,l2)))

Measured memory_bytes: 14468
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

// const int MOD = 1e9 + 7;
const int MOD = 998244353;

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

    vector<int> l(k), r(k);

    for(int i = 0; i < k; i++) {
        cin >> l[i] >> r[i];
    }

    vector<ll> dp(n, 0);
    vector<ll> cum(n, 0); // 累積和
    dp[0] = 1;
    cum[0] = 1;

    for(int i = 1; i < n; i++) {
        for(int j = 0; j < k; j++) {
            int R = i - l[j];
            int L = i - r[j];
            if(R >= 0) dp[i] = (dp[i] + cum[R]) % MOD;
            if(L >= 1) dp[i] = (dp[i] - cum[L - 1] + MOD) % MOD;
        }
        cum[i] = (dp[i] + cum[i - 1]) % MOD;
    }

    cout << dp[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 6336
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	p = 10^9+7
	h,w = readline() |> split |> parseMap
	a = String["" for i in 1:h]
	for i in 1:h
		a[i] = readline() |> chomp
	end
	dp = zeros(Int,h,w)
	dp[1,1] = 1
	for i in 1:h
		for j in 1:w
			if a[i][j]=='.'
				if i>1
					dp[i,j]=(dp[i,j]+dp[i-1,j])%p
				end
				if j>1
					dp[i,j]=(dp[i,j]+dp[i,j-1])%p
				end
			end
		end
	end
	println(dp[h,w])
end

main()

Measured memory_bytes: 121852
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

bool dp[2][20000];

bool check(int pos, vector<int> vec){
    memset(dp, 0, sizeof(dp));
    dp[0][10000] = true;//原点
    for(int i = 0; i < vec.size(); ++i){
        for(int j = 0; j < 20000; ++j){
            if(dp[i%2][j] == 0) continue;
            if(j - vec[i] >= 0)     dp[(i+1)%2][j - vec[i]] |= dp[i%2][j];
            if(j + vec[i] < 20000)  dp[(i+1)%2][j + vec[i]] |= dp[i%2][j];
        }
        for(int j = 0; j < 20000; j++){
            dp[i%2][j] = false;
        }
    }
    return dp[vec.size() % 2][pos + 10000];
}

int main(){
    string s; cin >> s;
    int x, y; cin >> x >> y;
    /*
    {
        //一回もTがないとき->のみ
        int cntT = 0;
        int cntF = 0;
        for(auto c : s) {
            if(c == 'T') cntT++;
            else cntF++;
        }
        if(cntT == 0){
            if(x == cntF && y == 0) cout << "Yes" << endl;
            else cout << "No" << endl;
            return 0;
        }
    }
    */
    vector<int> vecx, vecy;
    int id = 0;
    int cnt = 0;
    s += 'T';
    bool goright = true;
    int offset = 0;
    for(auto c : s){
        if(c == 'F') cnt++;
        else {
            if(id%2==0){
                if(goright){
                    goright = false;
                    offset = cnt;
                    id++;
                    cnt = 0;
                    vecx.push_back(0);
                }else{
                    vecx.push_back(cnt);
                    id++;
                    cnt = 0;
                }
            }else{
                vecy.push_back(cnt);
                id++;
                cnt = 0;
            }
        }
    }
    /*
    for(auto elem : vecx) cout << elem;
    cout << endl;
    for(auto elem : vecy) cout << elem;
    cout << endl;
    cout << vecx.size() << endl;
    cout << vecy.size() << endl;
    */
    if(check(x-offset,vecx) && check(y, vecy)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n=ni()
a=sorted(nl())[::-1]
 
ans=0

cur=0
now=1
for i in range(n-1):
  ans+=a[cur]
  if now==1:
    now=0
    cur+=1
  elif now==0:
    now=1


print(ans)


Measured memory_bytes: 105324
N = int(input())
A = list(map(int, input().split()))

d = [1] * (N+1)
d[0] -= A[0]
for i in range(N):
    d[i+1] = d[i] * 2 - A[i+1]

if d[-1] < 0:
    print(-1)
    exit()
else:
    d[-1] = A[-1]
for i in range(N, 0, -1):
    x = d[i]
    x += A[i-1]
    if d[i-1] * 2 < x:
        y = x - A[i-1]
        if (y+1) // 2 + A[i-1] <= d[i-1] * 2:
            x = d[i-1] * 2
    d[i-1] = min(x, d[i-1]+A[i-1])
print(sum(d))


Measured memory_bytes: 668704
n,*a = map(int,open(0).read().split())
pm = sum(a)
e = 1
te = 1
for i in a:
  pm -= i
  e = min((e-i)*2,pm)
  te += e
  if e < 0:
    break
if e < 0:
  print(-1)
else:
  print(te)



Measured memory_bytes: 20004
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n-1); i >= 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main(){
	int n; cin >> n;
	int ans=0;
	rep(i,n) {
		int l,r; cin >> l >> r;
		ans+=abs(r-l+1);
	}
	cout << ans << endl;
}

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

void solve() {
  int N;
  cin >> N;
  vector<int> vx(N), vy(N), vh(N);
  rep(i, 0, N) cin >> vx[i] >> vy[i] >> vh[i];
  int Max = 101;

  rep(y, 0, Max) {
    rep(x, 0, Max) {
      int h = -1;

      rep(i, 0, N) {
        if (vh[i] > 0) {

          int tmp = vh[i] + abs(y - vy[i]) + abs(x - vx[i]);
          if (h == -1) {
            h = tmp;
          } else {
            if (h != tmp) {
              h = -2;
              break;
            }
          }
        }
      }
      if (h == -2) continue;
      
      rep(i, 0, N) {
        if (vh[i] == 0) {
          int tmp = abs(y - vy[i]) + abs(x - vx[i]);
          if (h > tmp) {
            h = -2;
            break;
          }
        }
      }
      if (h == -2) continue;
      cout << x << " " << y << " " << h << endl;
      return;
    }
  }
}

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

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<vector>
using namespace std;



int main(){
    int n, key;
    cin >> n;
    int d[n];
    for(int i = 0; i < n; i++){
         cin >> d[i];
    }   
    sort(d, d+n);
    key = n / 2;
    cout << d[key] - d[key-1] << endl;
}

Measured memory_bytes: 888
N,K = (int(i) for i in input().split())
a = [int(x) for x in input().split()]

b= a.index(1)+1

if b/(K-1) == 0:
    answer = -(-(N-1)//(K-1)) +1

else:
    answer = -(-(N-1)//(K-1))

print(answer)

Measured memory_bytes: 13812
import sys
x = int(input())
y = 0
m = 1
if 360 % x == 0:
    m = int(360 / x)
else:
    for i in range(1, 1000):
        y = x * i
        if y > 360:
            if y % 360 == 0:
                m = i
                break
                
print(m)

Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

long long gcd(long long a, long long b){return (b == 0)? a : gcd(b, a % b);}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll k; cin >> k;
	ll ans = 0;
	rep(i, 1, k){
		rep(j, 1, k){
			rep(l, 1, k){
				ans += gcd(i, gcd(j, l));	
			}
		}
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int MAXN=100010;
int stones[MAXN];
int mins[MAXN]= {-1};
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; ++i)
    {
        cin>>stones[i];
    }
    for(int i=n-2; i>=0; --i)
    {
        if(i==n-2)
        {
            mins[n-2]=abs(stones[i]-stones[i+1]);
        }
        else if(i==n-3)
        {
            int one=abs(stones[i]-stones[i+1])+mins[i+1];
            int two=abs(stones[i]-stones[i+2]);
            mins[i]=min(one,two);
        }
        else
        {
            int one=abs(stones[i]-stones[i+1])+mins[i+1];
            int two=abs(stones[i]-stones[i+2])+mins[i+2];
            mins[i]=min(one,two);
        }
    }
    printf("%d\n",mins[0]);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rpd(i,a,b) for(int i=a;i>=b;--i)
#define ll long long
#define pb push_back
using namespace std;
const int N=2e5+5;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
string s;
int n;
int main(){
	getline(cin,s);n=read();
	for(int i=0;s[i];++i)if(i%n==0)cout<<s[i];
	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)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,h;
  cin >> a >> b >> h;
  cout << (a+b) * h / 2 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stack>
#include <iostream>
using namespace std;

int main (){

while (1){

int a,b,s,k,s2,i[18][18]={0},count=0;

stack <pair<int,int> > que;

pair <int,int> p,g;

p.first=1;
p.second=1;

que.push(p);

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

if (a==0&&b==0) break;

for (s=0;s<=a+1;s++){
     for (s2=0;s2<=b+1;s2++){
	  if (s==a+1||s==0){
		i[s][s2]=1;
		}
	  if (s2==b+1||s2==0){
		i[s][s2]=1;
                }
	}
}

g.first=a;
g.second=b;

scanf ("%d",&k);

for (s=0;s<k;s++){

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

i[a][b]=1;

}

while (!que.empty()){
	p=que.top();
	que.pop();
	if (i[p.first+1][p.second]==0){
		p.first=p.first+1;
		que.push(p);
		p.first=p.first-1;
	}

	if (i[p.first][p.second+1]==0){
		p.second=p.second+1;
		que.push(p);
		p.second=p.second-1;
	}

		if (p==g){
		count++;
	}

}

printf ("%d\n",count);

}

return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    mp[a] = i + 1;
  }
  for (auto &it : mp) cout << it.second << " ";
  cout << endl;

  return 0;
}


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

ll q,h,s,d,n;

int main(void){
	scanf("%lld%lld%lld%lld",&q,&h,&s,&d);
	scanf("%lld",&n);
	ll best=q;
	best=min(best*2LL,h);
	best=min(best*2LL,s);
	if(best*2LL<=d){
		printf("%lld\n",best*n);
	}else{
		ll res=0;
		res+=d*(n/2LL);
		res+=best*(n%2LL);
		printf("%lld\n",res);
	}
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N;
 int Y = 0;
 string C;
 cin >> N;
 for(int i; i<N; i++){
   cin >> C;
   if(C == "Y"){
     Y++;
     break;
   }
 }
  if(Y == 1){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
   
}

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

long long dp[120][2][4];
// [iまでの桁][未満フラグ][0ではない値何個あるか]

int main(){
	for(int i=0;i<120;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<4;k++){
				dp[i][j][k]=0;
			}
		}
	}

	string n;	cin>>n;
	int k;	cin>>k;
	dp[0][0][0]=1;
	for(int i=0;i<n.length();i++){
		int D=n[i]-'0';
		for(int j=0;j<2;j++){
			for(int k=0;k<4;k++){
				for(int d=0; d<=((j==true)? 9:D); d++){
					// d: 最下位の数字として可能なもの
					if(k+(d!=0)>3)continue;
					dp[i+1][j||(d<D)][k+(d!=0)]+=dp[i][j][k];
				}
			}
		}
	}
	cout<<dp[n.length()][0][k]+dp[n.length()][1][k]<<endl;


	return 0;
}


Measured memory_bytes: 256
def main():
    X = int(input())
    if X <= 3:
        print(1)
        return
    
    ans = 0
    for n in range(2, X):
        p = 2
        while pow(n, p) <= X:
            if ans < pow(n, p):
                ans = pow(n, p)
            p += 1
    print(ans)
    
main()  

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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;
typedef pair<ll,string>Pc;


const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int n;
long double p[3010],dp[3010][3010],ans;

void input(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>p[i];
	}
	return;
}

void solve(){
	dp[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			dp[i+1][j]+=dp[i][j]*(1.0-p[i]);
			dp[i+1][j+1]+=dp[i][j]*p[i];
		}
	}
	for(int i=0;i<=n;i++){
		if(i>n-i)ans+=dp[n][i];
	}
	cout<<setprecision(14)<<ans<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  while(true){
    int n;
    cin>>n;
    if(n==0)return 0;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int Min=INT_MAX;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(i==j)continue;
        if(Min>abs(a[i]-a[j])){
          Min=abs(a[i]-a[j]);
        }
      }
    }
    cout<<Min<<endl;
  }
  return 0;
}



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

//int mod = 1000000007;
char in[120];
pair<pair<string,int>,int> p[110];

int main(){
  int a; cin >> a;

  for(int i=0;i<a;i++){
    int t; cin >> in >> t;
    string tmp=in;
    p[i]=make_pair(make_pair(in,-t),i);
  }

  std::sort(p,p+a);

  for(int i=0;i<a;i++) cout << p[i].second+1 << endl;
}

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

int main(){
  ll n, m;
  cin >> n >> m;

  vector<pair<ll,ll>> w(m + 100100);
for(ll i = m; i < m+100100; i++){
    w[i].second = 0;
}

  for(ll i = 0; i < n; i++){
      ll a;
      cin >> a;
      w[m + i].first = a;
      w[m + i].second++;
  }
    
  for(ll i = 0; i < m; i++){
          cin >> w[i].second >> w[i].first;
  }

  sort(w.begin(), w.end());
    ll i = w.size()-1;
    ll cnt = 0;
    ll sum = 0;
    bool f = false;
  while(true){
      while(w[i].second > 0){
          sum += w[i].first;
          cnt ++;
          if(cnt == n){f = true; break;}
          w[i].second--;
      }
      if(f){break;}
      i--;

  }
  



  cout << sum << endl;

}

Measured memory_bytes: 3328